Merge
authoraph
Tue, 18 Oct 2016 17:14:09 +0000
changeset 41730 09cbc65e88db
parent 41729 d852f04fa9df (current diff)
parent 41726 e0747416c678 (diff)
child 41731 721bb4b955a8
Merge
hotspot/make/Dist.gmk
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EmptyEventProvider.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EventProvider.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotJVMCICompilerFactory.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/services/JVMCICompilerFactory.java
hotspot/test/compiler/floatingpoint/Test15FloatJNIArgs.java
hotspot/test/compiler/floatingpoint/libTest15FloatJNIArgs.c
hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener
hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.JVMCICompiler
hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.services.JVMCICompilerFactory
jdk/make/Import.gmk
jdk/src/java.base/aix/native/libnio/ch/AixNativeThread.c
jdk/src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelDeviceEventListener.java
jdk/src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java
jdk/test/java/awt/image/multiresolution/MultiResolutionTrayIconTest/MultiResolutionTrayIconTest.html
jdk/test/java/beans/XMLEncoder/EnumPrivate.java
jdk/test/java/beans/XMLEncoder/EnumPublic.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedCollection.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedList.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedMap.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedRandomAccessList.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedSet.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedSortedMap.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedSortedSet.java
jdk/test/java/beans/XMLEncoder/java_util_EnumMap.java
jdk/test/java/beans/XMLEncoder/java_util_JumboEnumSet.java
jdk/test/java/beans/XMLEncoder/java_util_RegularEnumSet.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ModuleNameReader.java
make/StripBinaries.gmk
--- a/.hgtags	Wed Oct 12 12:24:41 2016 +0000
+++ b/.hgtags	Tue Oct 18 17:14:09 2016 +0000
@@ -380,3 +380,5 @@
 e384420383a5b79fa0012ebcb25d8f83cff7f777 jdk-9+135
 1b4b5d01aa11edf24b6fadbe3d2f3e411e3b02cd jdk-9+136
 9cb87c88ed851c0575b8ead753ea238ed5b544e9 jdk-9+137
+d273dfe9a126d3bffe92072547fef2cd1361b0eb jdk-9+138
+65477538bec32963dc41153d89c4417eb46c45fc jdk-9+139
--- a/.hgtags-top-repo	Wed Oct 12 12:24:41 2016 +0000
+++ b/.hgtags-top-repo	Tue Oct 18 17:14:09 2016 +0000
@@ -380,3 +380,5 @@
 82b94cb5f342319d2cda77f9fa59703ad7fde576 jdk-9+135
 3ec350f5f32af249b59620d7e37b54bdcd77b233 jdk-9+136
 d7f519b004254b19e384131d9f0d0e40e31a0fd3 jdk-9+137
+67c4388142bdf58aec8fefa4475faaa8a5d7380c jdk-9+138
+7dcf453eacae79ee86a6bcc75fd0b546fc99b48a jdk-9+139
--- a/ASSEMBLY_EXCEPTION	Wed Oct 12 12:24:41 2016 +0000
+++ b/ASSEMBLY_EXCEPTION	Tue Oct 18 17:14:09 2016 +0000
@@ -1,27 +1,27 @@
 
 OPENJDK ASSEMBLY EXCEPTION
 
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
 only ("GPL2"), with the following clarification and special exception.
 
     Linking this OpenJDK Code statically or dynamically with other code
     is making a combined work based on this library.  Thus, the terms
     and conditions of GPL2 cover the whole combination.
 
-    As a special exception, Sun gives you permission to link this
-    OpenJDK Code with certain code licensed by Sun as indicated at
+    As a special exception, Oracle gives you permission to link this
+    OpenJDK Code with certain code licensed by Oracle as indicated at
     http://openjdk.java.net/legal/exception-modules-2007-05-08.html
     ("Designated Exception Modules") to produce an executable,
     regardless of the license terms of the Designated Exception Modules,
     and to copy and distribute the resulting executable under GPL2,
     provided that the Designated Exception Modules continue to be
-    governed by the licenses under which they were offered by Sun.
+    governed by the licenses under which they were offered by Oracle.
 
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception).  If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception).  If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/common/autoconf/buildjdk-spec.gmk.in	Wed Oct 12 12:24:41 2016 +0000
+++ b/common/autoconf/buildjdk-spec.gmk.in	Tue Oct 18 17:14:09 2016 +0000
@@ -33,6 +33,7 @@
 CC := @BUILD_CC@
 CXX := @BUILD_CXX@
 LD := @BUILD_LD@
+LDCXX := @BUILD_LDCXX@
 AS := @BUILD_AS@
 NM := @BUILD_NM@
 AR := @BUILD_AR@
--- a/common/autoconf/generated-configure.sh	Wed Oct 12 12:24:41 2016 +0000
+++ b/common/autoconf/generated-configure.sh	Tue Oct 18 17:14:09 2016 +0000
@@ -687,7 +687,6 @@
 MSVCP_DLL
 MSVCR_DLL
 LIBCXX
-STATIC_CXX_SETTING
 FIXPATH_DETACH_FLAG
 FIXPATH
 BUILD_GTEST
@@ -5092,7 +5091,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1474894604
+DATE_WHEN_GENERATED=1475218974
 
 ###############################################################################
 #
@@ -53087,49 +53086,10 @@
 
 
   if test "x$OPENJDK_TARGET_OS" = xlinux; then
-    # Test if -lstdc++ works.
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if dynamic link of stdc++ is possible" >&5
-$as_echo_n "checking if dynamic link of stdc++ is possible... " >&6; }
-    ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-    OLD_CXXFLAGS="$CXXFLAGS"
-    CXXFLAGS="$CXXFLAGS -lstdc++"
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-  has_dynamic_libstdcxx=yes
-else
-  has_dynamic_libstdcxx=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-    CXXFLAGS="$OLD_CXXFLAGS"
-    ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_dynamic_libstdcxx" >&5
-$as_echo "$has_dynamic_libstdcxx" >&6; }
-
     # Test if stdc++ can be linked statically.
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking if static link of stdc++ is possible" >&5
 $as_echo_n "checking if static link of stdc++ is possible... " >&6; }
-    STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
+    STATIC_STDCXX_FLAGS="-static-libstdc++ -static-libgcc"
     ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -53137,9 +53097,7 @@
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
     OLD_LIBS="$LIBS"
-    OLD_CXX="$CXX"
     LIBS="$STATIC_STDCXX_FLAGS"
-    CXX="$CC"
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -53159,7 +53117,6 @@
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
     LIBS="$OLD_LIBS"
-    CXX="$OLD_CXX"
     ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -53169,59 +53126,34 @@
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_static_libstdcxx" >&5
 $as_echo "$has_static_libstdcxx" >&6; }
 
-    if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
-      as_fn_error $? "Cannot link to stdc++, neither dynamically nor statically!" "$LINENO" 5
-    fi
-
     if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
       as_fn_error $? "Static linking of libstdc++ was not possible!" "$LINENO" 5
     fi
 
-    if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
-      as_fn_error $? "Dynamic linking of libstdc++ was not possible!" "$LINENO" 5
-    fi
-
     # If dynamic was requested, it's available since it would fail above otherwise.
     # If dynamic wasn't requested, go with static unless it isn't available.
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libstdc++" >&5
 $as_echo_n "checking how to link with libstdc++... " >&6; }
-    if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno ||   [[ " $JVM_VARIANTS " =~ " zeroshark " ]]  ; then
-      LIBCXX="$LIBCXX -lstdc++"
-      # To help comparisons with old build, put stdc++ first in JVM_LIBS
-      JVM_LIBS="-lstdc++ $JVM_LIBS"
-      # Ideally, we should test stdc++ for the BUILD toolchain separately. For now
-      # just use the same setting as for the TARGET toolchain.
-      OPENJDK_BUILD_JVM_LIBS="-lstdc++ $OPENJDK_BUILD_JVM_LIBS"
-      LDCXX="$CXX"
-      STATIC_CXX_SETTING="STATIC_CXX=false"
+    if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno \
+        ||   [[ " $JVM_VARIANTS " =~ " zeroshark " ]]  ; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: dynamic" >&5
 $as_echo "dynamic" >&6; }
     else
       LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
-      JVM_LDFLAGS="$JVM_LDFLAGS -static-libgcc"
-      # To help comparisons with old build, put stdc++ first in JVM_LIBS
-      JVM_LIBS="-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic $JVM_LIBS"
+      JVM_LDFLAGS="$JVM_LDFLAGS $STATIC_STDCXX_FLAGS"
       # Ideally, we should test stdc++ for the BUILD toolchain separately. For now
       # just use the same setting as for the TARGET toolchain.
-      OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -static-libgcc"
-      OPENJDK_BUILD_JVM_LIBS="-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic $OPENJDK_BUILD_JVM_LIBS"
-      LDCXX="$CC"
-      STATIC_CXX_SETTING="STATIC_CXX=true"
+      OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS $STATIC_STDCXX_FLAGS"
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: static" >&5
 $as_echo "static" >&6; }
     fi
   fi
 
-
   # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
   if test "x$TOOLCHAIN_TYPE" = xsolstudio && test "x$LIBCXX" = x; then
     LIBCXX="${SYSROOT}/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
   fi
 
-  # TODO better (platform agnostic) test
-  if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$TOOLCHAIN_TYPE" = xgcc; then
-    LIBCXX="-lstdc++"
-  fi
 
 
   # Setup Windows runtime dlls
--- a/common/autoconf/lib-std.m4	Wed Oct 12 12:24:41 2016 +0000
+++ b/common/autoconf/lib-std.m4	Tue Oct 18 17:14:09 2016 +0000
@@ -45,84 +45,44 @@
   )
 
   if test "x$OPENJDK_TARGET_OS" = xlinux; then
-    # Test if -lstdc++ works.
-    AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
-    AC_LANG_PUSH(C++)
-    OLD_CXXFLAGS="$CXXFLAGS"
-    CXXFLAGS="$CXXFLAGS -lstdc++"
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
-        [has_dynamic_libstdcxx=yes],
-        [has_dynamic_libstdcxx=no])
-    CXXFLAGS="$OLD_CXXFLAGS"
-    AC_LANG_POP(C++)
-    AC_MSG_RESULT([$has_dynamic_libstdcxx])
-
     # Test if stdc++ can be linked statically.
     AC_MSG_CHECKING([if static link of stdc++ is possible])
-    STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
+    STATIC_STDCXX_FLAGS="-static-libstdc++ -static-libgcc"
     AC_LANG_PUSH(C++)
     OLD_LIBS="$LIBS"
-    OLD_CXX="$CXX"
     LIBS="$STATIC_STDCXX_FLAGS"
-    CXX="$CC"
     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
         [has_static_libstdcxx=yes],
         [has_static_libstdcxx=no])
     LIBS="$OLD_LIBS"
-    CXX="$OLD_CXX"
     AC_LANG_POP(C++)
     AC_MSG_RESULT([$has_static_libstdcxx])
 
-    if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
-      AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
-    fi
-
     if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
       AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
     fi
 
-    if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
-      AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
-    fi
-
     # If dynamic was requested, it's available since it would fail above otherwise.
     # If dynamic wasn't requested, go with static unless it isn't available.
     AC_MSG_CHECKING([how to link with libstdc++])
-    if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
-      LIBCXX="$LIBCXX -lstdc++"
-      # To help comparisons with old build, put stdc++ first in JVM_LIBS
-      JVM_LIBS="-lstdc++ $JVM_LIBS"
-      # Ideally, we should test stdc++ for the BUILD toolchain separately. For now
-      # just use the same setting as for the TARGET toolchain.
-      OPENJDK_BUILD_JVM_LIBS="-lstdc++ $OPENJDK_BUILD_JVM_LIBS"
-      LDCXX="$CXX"
-      STATIC_CXX_SETTING="STATIC_CXX=false"
+    if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno \
+        || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
       AC_MSG_RESULT([dynamic])
     else
       LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
-      JVM_LDFLAGS="$JVM_LDFLAGS -static-libgcc"
-      # To help comparisons with old build, put stdc++ first in JVM_LIBS
-      JVM_LIBS="-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic $JVM_LIBS"
+      JVM_LDFLAGS="$JVM_LDFLAGS $STATIC_STDCXX_FLAGS"
       # Ideally, we should test stdc++ for the BUILD toolchain separately. For now
       # just use the same setting as for the TARGET toolchain.
-      OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -static-libgcc"
-      OPENJDK_BUILD_JVM_LIBS="-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic $OPENJDK_BUILD_JVM_LIBS"
-      LDCXX="$CC"
-      STATIC_CXX_SETTING="STATIC_CXX=true"
+      OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS $STATIC_STDCXX_FLAGS"
       AC_MSG_RESULT([static])
     fi
   fi
-  AC_SUBST(STATIC_CXX_SETTING)
 
   # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
   if test "x$TOOLCHAIN_TYPE" = xsolstudio && test "x$LIBCXX" = x; then
     LIBCXX="${SYSROOT}/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
   fi
 
-  # TODO better (platform agnostic) test
-  if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$TOOLCHAIN_TYPE" = xgcc; then
-    LIBCXX="-lstdc++"
-  fi
   AC_SUBST(LIBCXX)
 
   # Setup Windows runtime dlls
--- a/common/bin/compare.sh	Wed Oct 12 12:24:41 2016 +0000
+++ b/common/bin/compare.sh	Tue Oct 18 17:14:09 2016 +0000
@@ -654,10 +654,10 @@
             OTHER_DIZ_FILE="$OTHER/support/native/java.base/java_objs/java.diz"
         elif [ "$NAME" = "jimage.exe" ] \
                && [ -f "$OTHER/support/native/jdk.jlink/jimage_objs/jimage.diz" ]; then
-            OTHER_DIZ_FILE="$OTHER/support/native/jdk.jlink/jimage_objs/jimage.diz"
+            OTHER_DIZ_FILE="$OTHER/support/modules_cmds/jdk.jlink/jimage.diz"
         elif [ "$NAME" = "javacpl.exe" ] \
                && [ -f "$OTHER/support/native/jdk.plugin/javacpl/javacpl.diz" ]; then
-            OTHER_DIZ_FILE="$OTHER/support/native/jdk.plugin/javacpl/javacpl.diz"
+            OTHER_DIZ_FILE="$OTHER/support/modules_cmds/jdk.deploy.controlpanel/javacpl.diz"
         elif [ -f "${OTHER_FILE_BASE}.diz" ]; then
             OTHER_DIZ_FILE=${OTHER_FILE_BASE}.diz
         else
@@ -686,10 +686,10 @@
             THIS_DIZ_FILE="$THIS/support/native/java.base/java_objs/java.diz"
         elif [ "$NAME" = "jimage.exe" ] \
                && [ -f "$THIS/support/native/jdk.jlink/jimage_objs/jimage.diz" ]; then
-            THIS_DIZ_FILE="$THIS/support/native/jdk.jlink/jimage_objs/jimage.diz"
+            THIS_DIZ_FILE="$THIS/support/modules_cmds/jdk.jlink/jimage.diz"
         elif [ "$NAME" = "javacpl.exe" ] \
                && [ -f "$THIS/support/native/jdk.plugin/javacpl/javacpl.diz" ]; then
-            THIS_DIZ_FILE="$THIS/support/native/jdk.plugin/javacpl/javacpl.diz"
+            THIS_DIZ_FILE="$THIS/support/modules_cmds/jdk.deploy.controlpanel/javacpl.diz"
         elif [ -f "${THIS_FILE_BASE}.diz" ]; then
             THIS_DIZ_FILE=${THIS_FILE/.dll/}.diz
         else
--- a/corba/.hgtags	Wed Oct 12 12:24:41 2016 +0000
+++ b/corba/.hgtags	Tue Oct 18 17:14:09 2016 +0000
@@ -380,3 +380,5 @@
 094d0db606db976045f594dba47d4593b715cc81 jdk-9+135
 aa053a3faf266c12b4fd5272da431a3e08e4a3e3 jdk-9+136
 258cf18fa7fc59359b874f8743b7168dc48baf73 jdk-9+137
+27bb44be32076861a0951bcefb07a1d92509a4b6 jdk-9+138
+8c9da7fc5b07c606afd571c7012441b77dda83b2 jdk-9+139
--- a/corba/ASSEMBLY_EXCEPTION	Wed Oct 12 12:24:41 2016 +0000
+++ b/corba/ASSEMBLY_EXCEPTION	Tue Oct 18 17:14:09 2016 +0000
@@ -1,27 +1,27 @@
 
 OPENJDK ASSEMBLY EXCEPTION
 
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
 only ("GPL2"), with the following clarification and special exception.
 
     Linking this OpenJDK Code statically or dynamically with other code
     is making a combined work based on this library.  Thus, the terms
     and conditions of GPL2 cover the whole combination.
 
-    As a special exception, Sun gives you permission to link this
-    OpenJDK Code with certain code licensed by Sun as indicated at
+    As a special exception, Oracle gives you permission to link this
+    OpenJDK Code with certain code licensed by Oracle as indicated at
     http://openjdk.java.net/legal/exception-modules-2007-05-08.html
     ("Designated Exception Modules") to produce an executable,
     regardless of the license terms of the Designated Exception Modules,
     and to copy and distribute the resulting executable under GPL2,
     provided that the Designated Exception Modules continue to be
-    governed by the licenses under which they were offered by Sun.
+    governed by the licenses under which they were offered by Oracle.
 
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception).  If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception).  If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/corba/make/gensrc/Gensrc-java.corba.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/corba/make/gensrc/Gensrc-java.corba.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -38,7 +38,7 @@
     SRC := $(CORBA_TOPDIR)/make/src/classes, \
     BIN := $(BUILDTOOLS_OUTPUTDIR)/corba_tools_classes))
 
-TOOL_LOGUTIL_CMD := $(JAVA) -cp $(BUILDTOOLS_OUTPUTDIR)/corba_tools_classes \
+TOOL_LOGUTIL_CMD := $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/corba_tools_classes \
     build.tools.logutil.MC
 
 $(eval $(call SetupJavaCompilation,BUILD_IDLJ, \
@@ -50,7 +50,7 @@
     EXCLUDE_FILES := ResourceBundleUtil.java module-info.java))
 
 # Force the language to english for predictable source code generation.
-TOOL_IDLJ_CMD := $(JAVA) -cp $(BUILDTOOLS_OUTPUTDIR)/idlj_classes \
+TOOL_IDLJ_CMD := $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/idlj_classes \
     -Duser.language=en com.sun.tools.corba.se.idl.toJavaPortable.Compile
 
 ################################################################################
--- a/hotspot/.hgtags	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/.hgtags	Tue Oct 18 17:14:09 2016 +0000
@@ -541,3 +541,4 @@
 a20da289f646ee44440695b81abc0548330e4ca7 jdk-9+136
 dfcbf839e299e7e2bba1da69bdb347617ea4c7e8 jdk-9+137
 fc0956308c7a586267c5dd35dff74f773aa9c3eb jdk-9+138
+08492e67bf3226784dab3bf9ae967382ddbc1af5 jdk-9+139
--- a/hotspot/ASSEMBLY_EXCEPTION	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/ASSEMBLY_EXCEPTION	Tue Oct 18 17:14:09 2016 +0000
@@ -1,9 +1,9 @@
 
 OPENJDK ASSEMBLY EXCEPTION
 
-The OpenJDK source code made available by Oracle at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
 only ("GPL2"), with the following clarification and special exception.
 
     Linking this OpenJDK Code statically or dynamically with other code
@@ -19,9 +19,9 @@
     provided that the Designated Exception Modules continue to be
     governed by the licenses under which they were offered by Oracle.
 
-As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Oracle
-could not provide under GPL2 (or that Oracle has provided under GPL2 with the
-Classpath exception).  If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception).  If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/hotspot/make/BuildHotspot.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/make/BuildHotspot.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2015, 2016 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
@@ -45,10 +45,7 @@
 jsig:
 	+$(MAKE) -f lib/CompileLibjsig.gmk
 
-dist: $(VARIANT_TARGETS) jsig
-	+$(MAKE) -f Dist.gmk
-
-all: dist
+all: $(VARIANT_TARGETS) jsig
 
 .PHONY: $(VARIANT_TARGETS) $(VARIANT_GENSRC_TARGETS) $(VARIANT_LIBS_TARGETS) \
-    jsig dist all
+    jsig all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/CopyToExplodedJdk.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,55 @@
+#
+# 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.
+#
+
+# Copy all built libraries into exploded jdk
+LIB_TARGETS := $(filter $(LIB_OUTPUTDIR)/%, $(TARGETS))
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  $(eval $(call SetupCopyFiles, COPY_LIBS_BIN, \
+      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
+      DEST := $(JDK_OUTPUTDIR)/bin, \
+      FILES := $(filter-out %.lib, $(LIB_TARGETS)), \
+  ))
+
+  $(eval $(call SetupCopyFiles, COPY_LIBS_LIB, \
+      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
+      DEST := $(JDK_OUTPUTDIR)/lib, \
+      FILES := $(filter %.lib, $(LIB_TARGETS))))
+
+  TARGETS += $(COPY_LIBS_BIN) $(COPY_LIBS_LIB)
+else
+  $(eval $(call SetupCopyFiles, COPY_LIBS, \
+      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
+      DEST := $(JDK_OUTPUTDIR)/lib, \
+      FILES := $(filter %$(SHARED_LIBRARY_SUFFIX), $(LIB_TARGETS)), \
+  ))
+  $(eval $(call SetupCopyFiles, LINK_LIBS, \
+      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
+      DEST := $(JDK_OUTPUTDIR)/lib, \
+      FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), $(LIB_TARGETS)), \
+      MACRO := link-file-relative, \
+  ))
+
+  TARGETS += $(COPY_LIBS) $(LINK_LIBS)
+endif
--- a/hotspot/make/Dist.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,223 +0,0 @@
-#
-# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  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.
-#
-
-################################################################################
-# Copy the generated output into well-defined places in the dist directory.
-
-# This must be the first rule
-default: all
-
-include $(SPEC)
-include MakeBase.gmk
-
-$(eval $(call IncludeCustomExtension, hotspot, Dist.gmk))
-
-DIST_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR)/dist
-
-# Unfortunately, all platforms have different target subdirs.
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  LIB_SUBDIR := bin
-else ifeq ($(OPENJDK_TARGET_OS), macosx)
-  LIB_SUBDIR := lib
-else
-  LIB_SUBDIR := lib$(OPENJDK_TARGET_CPU_LIBDIR)
-endif
-
-################################################################################
-# Setup make rules to copy a native library and associated data.
-#
-# Parameter 1 is the name of the rule. This name is used as variable prefix,
-# and the targets generated are listed in a variable by that name.
-#
-# Remaining parameters are named arguments. These include:
-#   NAME -- The base name of the native library (e.g. 'jvm')
-#   VARIANT -- The variant to copy from
-#   VARIANT_TARGET_DIR -- The variant target sub dir, with trailing slash, optional
-SetupDistLibFile = $(NamedParamsMacroTemplate)
-define SetupDistLibFileBody
-  ifneq ($$($1_VARIANT), )
-    $1_SRC_DIR := $$(HOTSPOT_OUTPUTDIR)/variant-$$($1_VARIANT)/lib$$($1_NAME)
-  else
-    $1_SRC_DIR := $$(HOTSPOT_OUTPUTDIR)/lib$$($1_NAME)
-  endif
-  $1_LIB_NAME := $(LIBRARY_PREFIX)$$($1_NAME)
-  $1_TARGET_DIR := $$(DIST_OUTPUTDIR)/$$(LIB_SUBDIR)/$$($1_VARIANT_TARGET_DIR)
-
-  # Copy the the native library.
-  $$(eval $$(call SetupCopyFiles, $1_COPY_LIB, \
-      DEST := $$($1_TARGET_DIR), \
-      FILES := $$(wildcard \
-          $$($1_SRC_DIR)/$$($1_LIB_NAME)$(SHARED_LIBRARY_SUFFIX)), \
-  ))
-
-  TARGETS += $$($1_COPY_LIB)
-
-  # Copy related data (debug symbols, static-build symbols file etc)
-  $$(eval $$(call SetupCopyFiles, $1_COPY_FILES, \
-      DEST := $$($1_TARGET_DIR), \
-      FILES := $$(wildcard \
-          $$(addprefix $$($1_SRC_DIR)/$$($1_LIB_NAME), \
-          .diz .debuginfo .pdb .map .symbols)), \
-  ))
-
-  TARGETS += $$($1_COPY_FILES)
-
-  ifeq ($(OPENJDK_TARGET_OS), macosx)
-    # Debug symbols on macosx is a directory, not a single file, per library.
-    $1_DSYM_SRC := $$($1_SRC_DIR)/$$($1_LIB_NAME)$(SHARED_LIBRARY_SUFFIX).dSYM)
-    ifneq ($$(wildcard $$($1_DSYM_SRC)), )
-      $$(eval $$(call SetupCopyFiles, $1_COPY_DSYM_DIR, \
-          DEST := $$($1_TARGET_DIR), \
-          SRC := $$($1_SRC_DIR), \
-          FILES := $$(shell $(FIND) $$($1_DSYM_SRC) -type f), \
-       ))
-       TARGETS += $$($1_COPY_DSYM_DIR)
-    endif
-  endif
-endef
-
-################################################################################
-# Copy common files, which are independent on the jvm variant(s) being built.
-# For files that were generated during the build, we assume all versions of
-# these files are identical, and just pick one arbitrarily to use as source.
-
-ANY_JVM_VARIANT := $(firstword $(JVM_VARIANTS))
-JVM_VARIANT_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR)/variant-$(ANY_JVM_VARIANT)
-
-### Copy platform-independent .h files
-INCLUDE_FILES_SRC_DIR := $(HOTSPOT_TOPDIR)/src/share/vm
-$(eval $(call SetupCopyFiles, COPY_INCLUDE, \
-    SRC := $(INCLUDE_FILES_SRC_DIR), \
-    DEST := $(DIST_OUTPUTDIR)/include, \
-    FLATTEN := true, \
-    FILES := $(INCLUDE_FILES_SRC_DIR)/prims/jni.h \
-        $(INCLUDE_FILES_SRC_DIR)/code/jvmticmlr.h \
-        $(INCLUDE_FILES_SRC_DIR)/services/jmm.h))
-
-TARGETS += $(COPY_INCLUDE)
-
-### Copy jni_md.h
-
-# This might have been defined in a custom extension
-ifeq ($(JNI_MD_H_SRC), )
-  JNI_MD_H_SRC := $(HOTSPOT_TOPDIR)/src/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/vm/jni_$(HOTSPOT_TARGET_CPU_ARCH).h
-endif
-
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-  # NOTE: This should most likely be darwin, but the old hotspot build uses bsd
-  JNI_MD_SUBDIR := bsd
-else ifeq ($(OPENJDK_TARGET_OS), windows)
-  JNI_MD_SUBDIR := win32
-else
-  JNI_MD_SUBDIR := $(OPENJDK_TARGET_OS)
-endif
-
-# SetupCopyFiles is not used here since it's non-trivial to copy a single
-# file with a different target name.
-$(DIST_OUTPUTDIR)/include/$(JNI_MD_SUBDIR)/jni_md.h: $(JNI_MD_H_SRC)
-	$(call LogInfo, Copying hotspot/dist/include/$(JNI_MD_SUBDIR)/jni_md.h)
-	$(install-file)
-
-TARGETS += $(DIST_OUTPUTDIR)/include/$(JNI_MD_SUBDIR)/jni_md.h
-
-$(eval $(call SetupCopyFiles, COPY_JVMTI_H, \
-    DEST := $(DIST_OUTPUTDIR)/include, \
-    FLATTEN := true, \
-    FILES := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles/jvmti.h))
-
-TARGETS += $(COPY_JVMTI_H)
-
-# NOTE: In the old build, this file was not copied on Windows.
-ifneq ($(OPENJDK_TARGET_OS), windows)
-  $(eval $(call SetupCopyFiles, COPY_JVMTI_HTML, \
-      DEST := $(DIST_OUTPUTDIR)/docs/platform/jvmti, \
-      FILES := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles/jvmti.html))
-endif
-
-TARGETS += $(COPY_JVMTI_HTML)
-
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  $(eval $(call SetupCopyFiles, COPY_JVM_LIB, \
-      DEST := $(DIST_OUTPUTDIR)/lib, \
-      FILES :=$(JVM_VARIANT_OUTPUTDIR)/libjvm/objs/jvm.lib))
-
-  TARGETS += $(COPY_JVM_LIB)
-endif
-
-# Copy libjsig, if it exists
-$(eval $(call SetupDistLibFile, DIST_jsig, \
-    NAME := jsig, \
-))
-
-################################################################################
-# Copy variant-specific files
-
-# Setup make rules to copy a single variant to dist.
-# $1: The name of the variant
-define SetupDistForVariant
-  ifneq ($$(filter client minimal, $1), )
-    VARIANT_TARGET_DIR := $1
-  else
-    # Use 'server' as default target directory name for all other variants.
-    VARIANT_TARGET_DIR := server
-  endif
-
-  $$(eval $$(call SetupDistLibFile, DIST_$(strip $1)_jvm, \
-      NAME := jvm, \
-      VARIANT := $1, \
-      VARIANT_TARGET_DIR := $$(VARIANT_TARGET_DIR)/, \
-  ))
-
-  # Copy the dtrace libraries, if they exist
-  $$(eval $$(call SetupDistLibFile, DIST_$(strip $1)_jvm_db, \
-      NAME := jvm_db, \
-      VARIANT := $1, \
-      VARIANT_TARGET_DIR := $$(VARIANT_TARGET_DIR)/, \
-  ))
-
-  $$(eval $$(call SetupDistLibFile, DIST_$(strip $1)_jvm_dtrace, \
-      NAME := jvm_dtrace, \
-      VARIANT := $1, \
-      VARIANT_TARGET_DIR := $$(VARIANT_TARGET_DIR)/, \
-  ))
-
-  # Copy the Xusage.txt file
-  $$(eval $$(call SetupCopyFiles, DIST_$(strip $1)_Xusage, \
-      DEST := $$(DIST_OUTPUTDIR)/$$(LIB_SUBDIR)/$(strip $1), \
-      FILES := $$(HOTSPOT_OUTPUTDIR)/variant-$(strip $1)/support/misc/Xusage.txt, \
-  ))
-
-  TARGETS += $$(DIST_$(strip $1)_Xusage)
-endef
-
-$(foreach variant, $(JVM_VARIANTS), \
-  $(eval $(call SetupDistForVariant, $(variant))) \
-)
-
-################################################################################
-
-all: $(TARGETS)
-
-.PHONY: all
--- a/hotspot/make/HotspotCommon.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/make/HotspotCommon.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -33,6 +33,15 @@
 
 DTRACE_SUPPORT_DIR := $(JVM_SUPPORT_DIR)/dtrace
 
+LIB_OUTPUTDIR := $(call FindLibDirForModule, java.base)
+ifneq ($(filter client minimal, $(JVM_VARIANT)), )
+  JVM_VARIANT_SUBDIR := $(JVM_VARIANT)
+else
+  # Use 'server' as default target directory name for all other variants.
+  JVM_VARIANT_SUBDIR := server
+endif
+JVM_LIB_OUTPUTDIR := $(LIB_OUTPUTDIR)/$(JVM_VARIANT_SUBDIR)
+
 ################################################################################
 
 # Test if a feature is available in the present build of JVM_VARIANT. Will return
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/copy/Copy-java.base.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -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.  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.
+#
+
+# These include files are currently being copied from the jdk repository for
+# historical reasons. Disable copying from here until this has been cleaned up.
+# The files in hotspot differ slightly from the corresponding files in jdk.
+# See JDK-8167078.
+
+INCLUDE_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_include/$(MODULE)
+
+################################################################################
+# Copy platform-independent .h files
+$(eval $(call SetupCopyFiles, COPY_INCLUDE_FILES, \
+    SRC := $(HOTSPOT_TOPDIR)/src/share/vm, \
+    DEST := $(INCLUDE_DST_DIR), \
+    FLATTEN := true, \
+    FILES := prims/jni.h code/jvmticmlr.h \
+))
+
+#TARGETS += $(COPY_INCLUDE_FILES)
+
+################################################################################
+# Copy jni_md.h
+
+# This might have been defined in a custom extension
+JNI_MD_H_SRC ?= $(HOTSPOT_TOPDIR)/src/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/vm/jni_$(HOTSPOT_TARGET_CPU_ARCH).h
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+  # NOTE: This should most likely be darwin, but the old hotspot build uses bsd
+  JNI_MD_SUBDIR := bsd
+else ifeq ($(OPENJDK_TARGET_OS), windows)
+  JNI_MD_SUBDIR := win32
+else
+  JNI_MD_SUBDIR := $(OPENJDK_TARGET_OS)
+endif
+
+# SetupCopyFiles is not used here since it's non-trivial to copy a single
+# file with a different target name.
+$(INCLUDE_DST_DIR)/$(JNI_MD_SUBDIR)/jni_md.h: $(JNI_MD_H_SRC)
+	$(call LogInfo, Copying hotspot/dist/include/$(JNI_MD_SUBDIR)/jni_md.h)
+	$(install-file)
+
+#TARGETS += $(INCLUDE_DST_DIR)/$(JNI_MD_SUBDIR)/jni_md.h
+
+################################################################################
--- a/hotspot/make/gensrc/GenerateSources.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/make/gensrc/GenerateSources.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -47,7 +47,7 @@
 # The Xusage.txt file needs to have platform specific path separator
 $(eval $(call SetupTextFileProcessing, CREATE_XUSAGE, \
     SOURCE_FILES := $(HOTSPOT_TOPDIR)/src/share/vm/Xusage.txt, \
-    OUTPUT_FILE := $(JVM_SUPPORT_DIR)/misc/Xusage.txt, \
+    OUTPUT_FILE := $(JVM_LIB_OUTPUTDIR)/Xusage.txt, \
     REPLACEMENTS := separated by ;> => separated by $(PATH_SEP)> ; , \
 ))
 
--- a/hotspot/make/gensrc/GensrcJvmti.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/make/gensrc/GensrcJvmti.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -130,6 +130,21 @@
 TARGETS += $(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp
 
 ################################################################################
+# Disable copy of jvmti.h from hotspot until this has been cleared up. The file
+# is currently being copied from the jdk repository. See JDK-8167078.
+# Copy jvmti.h to include dir
+
+# The file is the same regardless of jvm variant. Only let one do the copy.
+#ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
+#  $(eval $(call SetupCopyFiles, COPY_JVMTI_H, \
+#      DEST := $(SUPPORT_OUTPUTDIR)/modules_include/java.base, \
+#      FILES := $(JVMTI_OUTPUTDIR)/jvmti.h, \
+#  ))
+
+#  TARGETS += $(COPY_JVMTI_H)
+#endif
+
+################################################################################
 # Create trace files in gensrc/tracefiles
 
 TRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/tracefiles
--- a/hotspot/make/lib/CompileDtracePostJvm.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/make/lib/CompileDtracePostJvm.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -180,7 +180,7 @@
 
     $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DTRACE, \
         LIBRARY := jvm_dtrace, \
-        OUTPUT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR), \
+        OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
         SRC := $(HOTSPOT_TOPDIR)/src/os/solaris/dtrace, \
         INCLUDE_FILES := jvm_dtrace.c, \
         CFLAGS := -m64 -G -mt -KPIC, \
@@ -197,7 +197,7 @@
     # the old build.
     $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DB, \
         LIBRARY := jvm_db, \
-        OUTPUT_DIR := $(LIBJVM_DB_OUTPUTDIR), \
+        OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
         SRC := $(HOTSPOT_TOPDIR)/src/os/solaris/dtrace, \
         INCLUDE_FILES := libjvm_db.c, \
         CFLAGS := -I$(JVM_VARIANT_OUTPUTDIR)/gensrc -I$(DTRACE_SUPPORT_DIR) \
--- a/hotspot/make/lib/CompileGtest.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/make/lib/CompileGtest.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -55,7 +55,7 @@
 # Disabling switch warning for clang because of test source.
 
 $(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \
-    TOOLCHAIN := $(JVM_TOOLCHAIN), \
+    TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
     LIBRARY := jvm, \
     OUTPUT_DIR := $(JVM_OUTPUTDIR)/gtest, \
     OBJECT_DIR := $(JVM_OUTPUTDIR)/gtest/objs, \
@@ -69,7 +69,7 @@
     CFLAGS := $(JVM_CFLAGS) -I$(GTEST_FRAMEWORK_SRC) \
         -I$(GTEST_FRAMEWORK_SRC)/include \
         $(addprefix -I,$(GTEST_TEST_SRC)), \
-    CFLAGS_windows := /EHsc, \
+    CFLAGS_windows := -EHsc, \
     CFLAGS_solaris := -DGTEST_HAS_EXCEPTIONS=0 -library=stlport4, \
     CFLAGS_macosx := -DGTEST_OS_MAC=1, \
     CFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
@@ -95,7 +95,7 @@
 ################################################################################
 
 $(eval $(call SetupNativeCompilation, BUILD_GTEST_LAUNCHER, \
-    TOOLCHAIN := $(JVM_TOOLCHAIN), \
+    TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
     PROGRAM := gtestLauncher, \
     OUTPUT_DIR := $(JVM_OUTPUTDIR)/gtest, \
     EXTRA_FILES := $(GTEST_LAUNCHER_SRC), \
--- a/hotspot/make/lib/CompileJvm.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/make/lib/CompileJvm.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -143,13 +143,6 @@
   JVM_PRECOMPILED_HEADER := $(HOTSPOT_TOPDIR)/src/share/vm/precompiled/precompiled.hpp
 endif
 
-ifneq ($(filter $(OPENJDK_TARGET_OS), macosx aix solaris), )
-  # On macosx, aix and solaris we have to link with the C++ compiler
-  JVM_TOOLCHAIN := TOOLCHAIN_LINK_CXX
-else
-  JVM_TOOLCHAIN := TOOLCHAIN_DEFAULT
-endif
-
 ifeq ($(OPENJDK_TARGET_CPU), x86)
   JVM_EXCLUDE_PATTERNS += x86_64
 else ifeq ($(OPENJDK_TARGET_CPU), x86_64)
@@ -181,13 +174,6 @@
   JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM"
 endif
 
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-  # NOTE: The old build did not strip binaries on macosx.
-  JVM_STRIP_SYMBOLS := false
-else
-  JVM_STRIP_SYMBOLS := true
-endif
-
 JVM_OPTIMIZATION ?= HIGHEST_JVM
 
 # Need to set JVM_STRIPFLAGS to the default value from SPEC since the STRIPFLAGS
@@ -199,9 +185,9 @@
 # Now set up the actual compilation of the main hotspot native library
 
 $(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
-    TOOLCHAIN := $(JVM_TOOLCHAIN), \
+    TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
     LIBRARY := jvm, \
-    OUTPUT_DIR := $(JVM_OUTPUTDIR), \
+    OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
     SRC := $(JVM_SRC_DIRS), \
     EXCLUDES := $(JVM_EXCLUDES), \
     EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \
@@ -223,7 +209,6 @@
     OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \
     MAPFILE := $(JVM_MAPFILE), \
     USE_MAPFILE_FOR_SYMBOLS := true, \
-    STRIP_SYMBOLS := $(JVM_STRIP_SYMBOLS), \
     STRIPFLAGS := $(JVM_STRIPFLAGS), \
     EMBED_MANIFEST := true, \
     RC_FLAGS := $(JVM_RCFLAGS), \
@@ -232,6 +217,18 @@
     PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
 ))
 
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  # It doesn't matter which jvm.lib file gets exported, but we need
+  # to pick just one.
+  ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
+    $(eval $(call SetupCopyFiles, COPY_JVM_LIB, \
+        DEST := $(LIB_OUTPUTDIR), \
+        FILES :=$(JVM_VARIANT_OUTPUTDIR)/libjvm/objs/jvm.lib, \
+    ))
+    TARGETS += $(COPY_JVM_LIB)
+  endif
+endif
+
 # AIX warning explanation:
 # 1500-010  : (W) WARNING in ...: Infinite loop.  Program may not stop.
 #             There are several infinite loops in the vm, so better suppress.
--- a/hotspot/make/lib/CompileLibjsig.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/make/lib/CompileLibjsig.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -34,7 +34,6 @@
 
 ifneq ($(OPENJDK_TARGET_OS), windows)
   ifeq ($(STATIC_BUILD), false)
-    LIBJSIG_STRIP_SYMBOLS := true
     ifeq ($(OPENJDK_TARGET_OS), linux)
       LIBJSIG_CFLAGS := -fPIC -D_GNU_SOURCE -D_REENTRANT $(EXTRA_CFLAGS)
       LIBJSIG_LDFLAGS := $(LDFLAGS_HASH_STYLE) $(EXTRA_CFLAGS)
@@ -72,8 +71,6 @@
     else ifeq ($(OPENJDK_TARGET_OS), macosx)
       LIBJSIG_CFLAGS := -m64 -D_GNU_SOURCE -pthread -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fPIC
       LIBJSIG_LDFLAGS := $(LDFLAGS_HASH_STYLE)
-      # NOTE: This lib is not stripped on macosx in old build. Looks like a mistake.
-      LIBJSIG_STRIP_SYMBOLS := false
     else
       $(error Unknown target OS $(OPENJDK_TARGET_OS) in CompileLibjsig.gmk)
     endif
@@ -84,20 +81,71 @@
 
     LIBJSIG_LDFLAGS += $(SHARED_LIBRARY_FLAGS)
 
+    LIB_OUTPUTDIR := $(call FindLibDirForModule, java.base)
+
     $(eval $(call SetupNativeCompilation, BUILD_LIBJSIG, \
         LIBRARY := jsig, \
         EXTRA_FILES := $(LIBJSIG_SRC_FILE), \
-        OUTPUT_DIR := $(LIBJSIG_OUTPUTDIR), \
+        OUTPUT_DIR := $(LIB_OUTPUTDIR), \
         LANG := C, \
         CFLAGS := $(LIBJSIG_CFLAGS) $(LIBJSIG_CPU_FLAGS), \
         LDFLAGS := $(LIBJSIG_LDFLAGS) $(LIBJSIG_CPU_FLAGS), \
         LIBS := $(LIBJSIG_LIBS), \
         MAPFILE := $(LIBJSIG_MAPFILE), \
         OBJECT_DIR := $(LIBJSIG_OUTPUTDIR)/objs, \
-        STRIP_SYMBOLS := $(LIBJSIG_STRIP_SYMBOLS), \
     ))
 
     TARGETS += $(BUILD_LIBJSIG)
+
+    ############################################################################
+    # Create symlinks in each variant sub dir
+    ifeq ($(OPENJDK_TARGET_OS), macosx)
+      DEBUG_INFO_SUFFIX := $(SHARED_LIBRARY_SUFFIX).dSYM
+    else
+      DEBUG_INFO_SUFFIX := .debuginfo
+    endif
+
+    # $1 variant subdir
+    define CreateSymlinks
+      # Always symlink from libdir/variant/libjsig.so -> ../libjsig.so and
+      # the corresponding debuginfo.
+      $(LIB_OUTPUTDIR)/$1/$(call SHARED_LIBRARY,jsig): \
+          $(LIB_OUTPUTDIR)/$(call SHARED_LIBRARY,jsig)
+		$$(call MakeDir, $$(@D))
+		$(RM) $$@
+		$(LN) -s ../$$(@F) $$@
+
+      TARGETS += $(LIB_OUTPUTDIR)/$1/$(call SHARED_LIBRARY,jsig)
+
+      ifeq ($(COPY_DEBUG_SYMBOLS), true)
+        $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX): \
+            $(LIB_OUTPUTDIR)/$(call SHARED_LIBRARY,jsig)
+		$$(call MakeDir, $$(@D))
+		$(RM) $$@
+		$(LN) -s ../$$(@F) $$@
+
+        TARGETS += $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX)
+
+        ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
+          $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz: \
+              $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX)
+			$(CD) $$(@D) && $(ZIP) -q -y $$@ $$(basename $$(@F))$(DEBUG_INFO_SUFFIX)
+
+          TARGETS += $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz
+        endif
+      endif
+    endef
+
+    # The subdir is the same as the variant for client and minimal, for all
+    # others it's server.
+    VARIANT_SUBDIRS := $(filter client minimal, $(JVM_VARIANTS)) \
+        $(if $(filter-out client minimal, $(JVM_VARIANTS)), server)
+    $(foreach v, $(VARIANT_SUBDIRS), $(eval $(call CreateSymlinks,$v)))
+
+    ############################################################################
+
+    include CopyToExplodedJdk.gmk
+
   endif
 endif
 
--- a/hotspot/make/lib/CompileLibraries.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/make/lib/CompileLibraries.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -41,6 +41,8 @@
   include lib/CompileGtest.gmk
 endif
 
+include CopyToExplodedJdk.gmk
+
 all: $(TARGETS)
 
 .PHONY: all
--- a/hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -130,8 +130,8 @@
   if (_num_fp_args < Argument::n_float_register_parameters_c) {
     __ ldrs(as_FloatRegister(_num_fp_args++), src);
   } else {
-    __ ldrh(r0, src);
-    __ strh(r0, Address(to(), _stack_offset));
+    __ ldrw(r0, src);
+    __ strw(r0, Address(to(), _stack_offset));
     _stack_offset += wordSize;
     _num_fp_args++;
   }
@@ -349,7 +349,7 @@
       _num_fp_args++;
     } else {
       *_to++ = from_obj;
-      _num_int_args++;
+      _num_fp_args++;
     }
   }
 
@@ -364,7 +364,7 @@
       _num_fp_args++;
     } else {
       *_to++ = from_obj;
-      _num_int_args++;
+      _num_fp_args++;
     }
   }
 
--- a/hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -60,12 +60,12 @@
 void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) {
   address pc = _instructions->start() + pc_offset;
   if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
-    narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK);
+    narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK);
     TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
     Unimplemented();
   } else {
     NativeMovConstReg* move = nativeMovConstReg_at(pc);
-    void* reference = record_metadata_reference(constant, CHECK);
+    void* reference = record_metadata_reference(_instructions, pc, constant, CHECK);
     move->set_data((intptr_t) reference);
     TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
   }
--- a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -989,7 +989,16 @@
 
 // A float arg may have to do float reg int reg conversion
 static void float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
-  if (src.first() != dst.first()) {
+  assert(src.first()->is_stack() && dst.first()->is_stack() ||
+         src.first()->is_reg() && dst.first()->is_reg(), "Unexpected error");
+  if (src.first()->is_stack()) {
+    if (dst.first()->is_stack()) {
+      __ ldrw(rscratch1, Address(rfp, reg2offset_in(src.first())));
+      __ strw(rscratch1, Address(sp, reg2offset_out(dst.first())));
+    } else {
+      ShouldNotReachHere();
+    }
+  } else if (src.first() != dst.first()) {
     if (src.is_single_phys_reg() && dst.is_single_phys_reg())
       __ fmovs(dst.first()->as_FloatRegister(), src.first()->as_FloatRegister());
     else
@@ -1023,7 +1032,16 @@
 
 // A double move
 static void double_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
-  if (src.first() != dst.first()) {
+  assert(src.first()->is_stack() && dst.first()->is_stack() ||
+         src.first()->is_reg() && dst.first()->is_reg(), "Unexpected error");
+  if (src.first()->is_stack()) {
+    if (dst.first()->is_stack()) {
+      __ ldr(rscratch1, Address(rfp, reg2offset_in(src.first())));
+      __ str(rscratch1, Address(sp, reg2offset_out(dst.first())));
+    } else {
+      ShouldNotReachHere();
+    }
+  } else if (src.first() != dst.first()) {
     if (src.is_single_phys_reg() && dst.is_single_phys_reg())
       __ fmovd(dst.first()->as_FloatRegister(), src.first()->as_FloatRegister());
     else
--- a/hotspot/src/cpu/ppc/vm/c1_MacroAssembler_ppc.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/c1_MacroAssembler_ppc.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -64,17 +64,16 @@
 
 
 void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
+  // Avoid stack bang as first instruction. It may get overwritten by patch_verified_entry.
+  const Register return_pc = R20;
+  mflr(return_pc);
+
+  // Make sure there is enough stack space for this method's activation.
   assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
-  // Make sure there is enough stack space for this method's activation.
   generate_stack_overflow_check(bang_size_in_bytes);
 
-  // Create the frame.
-  const Register return_pc  = R0;
-
-  mflr(return_pc);
-  // Get callers sp.
-  std(return_pc, _abi(lr), R1_SP);           // SP->lr = return_pc
-  push_frame(frame_size_in_bytes, R0);       // SP -= frame_size_in_bytes
+  std(return_pc, _abi(lr), R1_SP);     // SP->lr = return_pc
+  push_frame(frame_size_in_bytes, R0); // SP -= frame_size_in_bytes
 }
 
 
--- a/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -2550,7 +2550,7 @@
   __ lbzx(R17_tos, Rclass_or_obj, Roffset);
   __ extsb(R17_tos, R17_tos);
   __ push(ztos);
-  if (!is_static) {
+  if (!is_static && rc == may_rewrite) {
     // use btos rewriting, no truncating to t/f bit is needed for getfield.
     patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch);
   }
@@ -2874,7 +2874,9 @@
   if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
   __ andi(R17_tos, R17_tos, 0x1);
   __ stbx(R17_tos, Rclass_or_obj, Roffset);
-  if (!is_static) { patch_bytecode(Bytecodes::_fast_zputfield, Rbc, Rscratch, true, byte_no); }
+  if (!is_static && rc == may_rewrite) {
+    patch_bytecode(Bytecodes::_fast_zputfield, Rbc, Rscratch, true, byte_no);
+  }
   if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
     __ beq(CR_is_vol, Lvolatile); // Volatile?
   }
--- a/hotspot/src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -71,7 +71,7 @@
   if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
 #ifdef _LP64
     NativeMovConstReg32* move = nativeMovConstReg32_at(pc);
-    narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK);
+    narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK);
     move->set_data((intptr_t)narrowOop);
     TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
 #else
@@ -79,7 +79,7 @@
 #endif
   } else {
     NativeMovConstReg* move = nativeMovConstReg_at(pc);
-    void* reference = record_metadata_reference(constant, CHECK);
+    void* reference = record_metadata_reference(_instructions, pc, constant, CHECK);
     move->set_data((intptr_t)reference);
     TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
   }
--- a/hotspot/src/cpu/sparc/vm/vmStructs_sparc.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/cpu/sparc/vm/vmStructs_sparc.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -84,7 +84,6 @@
   declare_constant(VM_Version::sun4v_m)                                   \
   declare_constant(VM_Version::blk_init_instructions_m)                   \
   declare_constant(VM_Version::fmaf_instructions_m)                       \
-  declare_constant(VM_Version::fmau_instructions_m)                       \
   declare_constant(VM_Version::sparc64_family_m)                          \
   declare_constant(VM_Version::M_family_m)                                \
   declare_constant(VM_Version::T_family_m)                                \
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -179,7 +179,7 @@
   assert((OptoLoopAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size");
 
   char buf[512];
-  jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+  jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
                (has_v9() ? ", v9" : (has_v8() ? ", v8" : "")),
                (has_hardware_popc() ? ", popc" : ""),
                (has_vis1() ? ", vis1" : ""),
@@ -193,6 +193,7 @@
                (has_sha512() ? ", sha512" : ""),
                (has_crc32c() ? ", crc32c" : ""),
                (is_ultra3() ? ", ultra3" : ""),
+               (has_sparc5_instr() ? ", sparc5" : ""),
                (is_sun4v() ? ", sun4v" : ""),
                (is_niagara_plus() ? ", niagara_plus" : (is_niagara() ? ", niagara" : "")),
                (is_sparc64() ? ", sparc64" : ""),
@@ -487,16 +488,11 @@
     if (strstr(impl, "SPARC-T1") != NULL) {
       features |= T1_model_m;
     }
+  } else if (strstr(impl, "SUN4V-CPU") != NULL) {
+    // Generic or migration class LDOM
+    features |= T_family_m;
   } else {
-    if (strstr(impl, "SPARC") == NULL) {
-#ifndef PRODUCT
-      // kstat on Solaris 8 virtual machines (branded zones)
-      // returns "(unsupported)" implementation. Solaris 8 is not
-      // supported anymore, but include this check to be on the
-      // safe side.
-      warning("Can't parse CPU implementation = '%s', assume generic SPARC", impl);
-#endif
-    }
+    log_info(os, cpu)("Failed to parse CPU implementation = '%s'", impl);
   }
   os::free((void*)impl);
   return features;
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -34,30 +34,29 @@
 
 protected:
   enum Feature_Flag {
-    v8_instructions      = 0,
-    hardware_mul32       = 1,
-    hardware_div32       = 2,
-    hardware_fsmuld      = 3,
-    hardware_popc        = 4,
-    v9_instructions      = 5,
-    vis1_instructions    = 6,
-    vis2_instructions    = 7,
-    sun4v_instructions   = 8,
+    v8_instructions       = 0,
+    hardware_mul32        = 1,
+    hardware_div32        = 2,
+    hardware_fsmuld       = 3,
+    hardware_popc         = 4,
+    v9_instructions       = 5,
+    vis1_instructions     = 6,
+    vis2_instructions     = 7,
+    sun4v_instructions    = 8,
     blk_init_instructions = 9,
-    fmaf_instructions    = 10,
-    fmau_instructions    = 11,
-    vis3_instructions    = 12,
-    cbcond_instructions  = 13,
-    sparc64_family       = 14,
-    M_family             = 15,
-    T_family             = 16,
-    T1_model             = 17,
-    sparc5_instructions  = 18,
-    aes_instructions     = 19,
-    sha1_instruction     = 20,
-    sha256_instruction   = 21,
-    sha512_instruction   = 22,
-    crc32c_instruction   = 23
+    fmaf_instructions     = 10,
+    vis3_instructions     = 11,
+    cbcond_instructions   = 12,
+    sparc64_family        = 13,
+    M_family              = 14,
+    T_family              = 15,
+    T1_model              = 16,
+    sparc5_instructions   = 17,
+    aes_instructions      = 18,
+    sha1_instruction      = 19,
+    sha256_instruction    = 20,
+    sha512_instruction    = 21,
+    crc32c_instruction    = 22
   };
 
   enum Feature_Flag_Set {
@@ -75,7 +74,6 @@
     sun4v_m                 = 1 << sun4v_instructions,
     blk_init_instructions_m = 1 << blk_init_instructions,
     fmaf_instructions_m     = 1 << fmaf_instructions,
-    fmau_instructions_m     = 1 << fmau_instructions,
     vis3_instructions_m     = 1 << vis3_instructions,
     cbcond_instructions_m   = 1 << cbcond_instructions,
     sparc64_family_m        = 1 << sparc64_family,
--- a/hotspot/src/cpu/x86/vm/jvmciCodeInstaller_x86.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/jvmciCodeInstaller_x86.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -89,14 +89,14 @@
   if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
 #ifdef _LP64
     address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand);
-    *((narrowKlass*) operand) = record_narrow_metadata_reference(constant, CHECK);
+    *((narrowKlass*) operand) = record_narrow_metadata_reference(_instructions, operand, constant, CHECK);
     TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand));
 #else
     JVMCI_ERROR("compressed Klass* on 32bit");
 #endif
   } else {
     address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
-    *((void**) operand) = record_metadata_reference(constant, CHECK);
+    *((void**) operand) = record_metadata_reference(_instructions, operand, constant, CHECK);
     TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand));
   }
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java	Tue Oct 18 17:14:09 2016 +0000
@@ -96,9 +96,6 @@
         if ((config.vmVersionFeatures & config.sparcFmafInstructions) != 0) {
             features.add(CPUFeature.FMAF);
         }
-        if ((config.vmVersionFeatures & config.sparcFmauInstructions) != 0) {
-            features.add(CPUFeature.FMAU);
-        }
         if ((config.vmVersionFeatures & config.sparcSparc64Family) != 0) {
             features.add(CPUFeature.SPARC64_FAMILY);
         }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -55,7 +55,6 @@
     final int sparcSun4v = getConstant("VM_Version::sun4v_m", Integer.class);
     final int sparcBlkInitInstructions = getConstant("VM_Version::blk_init_instructions_m", Integer.class);
     final int sparcFmafInstructions = getConstant("VM_Version::fmaf_instructions_m", Integer.class);
-    final int sparcFmauInstructions = getConstant("VM_Version::fmau_instructions_m", Integer.class);
     final int sparcSparc64Family = getConstant("VM_Version::sparc64_family_m", Integer.class);
     final int sparcMFamily = getConstant("VM_Version::M_family_m", Integer.class);
     final int sparcTFamily = getConstant("VM_Version::T_family_m", Integer.class);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/EmptyEventProvider.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.hotspot;
+
+/**
+ * An empty implementation for {@link EventProvider}. This implementation is used when no logging is
+ * requested.
+ */
+final class EmptyEventProvider implements EventProvider {
+
+    static InternalError shouldNotReachHere() {
+        throw new InternalError("should not reach here");
+    }
+
+    @Override
+    public CompilationEvent newCompilationEvent() {
+        return new EmptyCompilationEvent();
+    }
+
+    static class EmptyCompilationEvent implements CompilationEvent {
+        public void commit() {
+            throw shouldNotReachHere();
+        }
+
+        public boolean shouldWrite() {
+            // Events of this class should never been written.
+            return false;
+        }
+
+        public void begin() {
+        }
+
+        public void end() {
+        }
+
+        public void setMethod(String method) {
+            throw shouldNotReachHere();
+        }
+
+        public void setCompileId(int compileId) {
+            throw shouldNotReachHere();
+        }
+
+        public void setCompileLevel(int compileLevel) {
+            throw shouldNotReachHere();
+        }
+
+        public void setSucceeded(boolean succeeded) {
+            throw shouldNotReachHere();
+        }
+
+        public void setIsOsr(boolean isOsr) {
+            throw shouldNotReachHere();
+        }
+
+        public void setCodeSize(int codeSize) {
+            throw shouldNotReachHere();
+        }
+
+        public void setInlinedBytes(int inlinedBytes) {
+            throw shouldNotReachHere();
+        }
+    }
+
+    @Override
+    public CompilerFailureEvent newCompilerFailureEvent() {
+        return new EmptyCompilerFailureEvent();
+    }
+
+    static class EmptyCompilerFailureEvent implements CompilerFailureEvent {
+        public void commit() {
+            throw shouldNotReachHere();
+        }
+
+        public boolean shouldWrite() {
+            // Events of this class should never been written.
+            return false;
+        }
+
+        public void setCompileId(int compileId) {
+            throw shouldNotReachHere();
+        }
+
+        public void setMessage(String message) {
+            throw shouldNotReachHere();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/EventProvider.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.hotspot;
+
+import jdk.vm.ci.hotspot.EmptyEventProvider.EmptyCompilationEvent;
+import jdk.vm.ci.hotspot.EmptyEventProvider.EmptyCompilerFailureEvent;
+import jdk.vm.ci.services.JVMCIPermission;
+
+/**
+ * Service-provider class for logging compiler related events.
+ */
+public interface EventProvider {
+
+    /**
+     * Creates and returns an empty implementation for {@link EventProvider}. This implementation
+     * can be used when no logging is requested.
+     */
+    static EventProvider createEmptyEventProvider() {
+        return new EmptyEventProvider();
+    }
+
+    /**
+     * Creates and returns an empty implementation for {@link CompilationEvent}.
+     */
+    static CompilationEvent createEmptyCompilationEvent() {
+        return new EmptyCompilationEvent();
+    }
+
+    /**
+     * Creates and returns an empty implementation for {@link CompilationEvent}.
+     */
+    static CompilerFailureEvent createEmptyCompilerFailureEvent() {
+        return new EmptyCompilerFailureEvent();
+    }
+
+    /**
+     * An instant event is an event that is not considered to have taken any time.
+     */
+    public interface InstantEvent {
+        /**
+         * Commits the event.
+         */
+        void commit();
+
+        /**
+         * Determines if this particular event instance would be committed to the data stream right
+         * now if application called {@link #commit()}. This in turn depends on whether the event is
+         * enabled and possible other factors.
+         *
+         * @return if this event would be committed on a call to {@link #commit()}.
+         */
+        boolean shouldWrite();
+    }
+
+    /**
+     * Timed events describe an operation that somehow consumes time.
+     */
+    public interface TimedEvent extends InstantEvent {
+        /**
+         * Starts the timing for this event.
+         */
+        void begin();
+
+        /**
+         * Ends the timing period for this event.
+         */
+        void end();
+    }
+
+    /**
+     * Creates a new {@link CompilationEvent}.
+     *
+     * @return a compilation event
+     */
+    public abstract CompilationEvent newCompilationEvent();
+
+    /**
+     * A compilation event.
+     */
+    public interface CompilationEvent extends TimedEvent {
+        void setMethod(String method);
+
+        void setCompileId(int compileId);
+
+        void setCompileLevel(int compileLevel);
+
+        void setSucceeded(boolean succeeded);
+
+        void setIsOsr(boolean isOsr);
+
+        void setCodeSize(int codeSize);
+
+        void setInlinedBytes(int inlinedBytes);
+    }
+
+    /**
+     * Creates a new {@link CompilerFailureEvent}.
+     *
+     * @return a compiler failure event
+     */
+    public abstract CompilerFailureEvent newCompilerFailureEvent();
+
+    /**
+     * A compiler failure event.
+     */
+    public interface CompilerFailureEvent extends InstantEvent {
+        void setCompileId(int compileId);
+
+        void setMessage(String message);
+    }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,8 +26,10 @@
 import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
 import jdk.vm.ci.runtime.JVMCICompiler;
+import jdk.vm.ci.runtime.JVMCICompilerFactory;
 import jdk.vm.ci.runtime.JVMCIRuntime;
-import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
+import jdk.vm.ci.services.JVMCIServiceLocator;
+import jdk.vm.ci.services.JVMCIPermission;
 import jdk.vm.ci.services.Services;
 
 final class HotSpotJVMCICompilerConfig {
@@ -37,7 +39,7 @@
      * to perform a compilation. This allows the reflective parts of the JVMCI API to be used
      * without requiring a compiler implementation to be available.
      */
-    private static class DummyCompilerFactory extends JVMCICompilerFactory implements JVMCICompiler {
+    private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler {
 
         public HotSpotCompilationRequestResult compileMethod(CompilationRequest request) {
             throw new JVMCIError("no JVMCI compiler selected");
@@ -63,15 +65,16 @@
      * Gets the selected system compiler factory.
      *
      * @return the selected system compiler factory
+     * @throws SecurityException if a security manager is present and it denies
+     *             {@link JVMCIPermission} for any {@link JVMCIServiceLocator} loaded by this method
      */
     static JVMCICompilerFactory getCompilerFactory() {
         if (compilerFactory == null) {
             JVMCICompilerFactory factory = null;
             String compilerName = Option.Compiler.getString();
             if (compilerName != null) {
-                for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) {
+                for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) {
                     if (f.getCompilerName().equals(compilerName)) {
-                        Services.exportJVMCITo(f.getClass());
                         factory = f;
                     }
                 }
@@ -80,8 +83,9 @@
                 }
             } else {
                 // Auto select a single available compiler
-                for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) {
+                for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) {
                     if (factory == null) {
+                        Services.exportJVMCITo(f.getClass());
                         factory = f;
                     } else {
                         // Multiple factories seen - cancel auto selection
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerFactory.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.hotspot;
+
+import jdk.vm.ci.runtime.JVMCICompilerFactory;
+
+/**
+ * HotSpot extensions to {@link JVMCICompilerFactory}.
+ */
+public abstract class HotSpotJVMCICompilerFactory implements JVMCICompilerFactory {
+
+    /**
+     * Gets 0 or more prefixes identifying classes that should by compiled by C1 in simple mode
+     * (i.e., {@code CompLevel_simple}) when HotSpot is running with tiered compilation. The
+     * prefixes should be class or package names using "/" as the separator, e.g. "jdk/vm/ci".
+     *
+     * @return 0 or more Strings identifying packages that should by compiled by the first tier only
+     *         or null if no redirection to C1 should be performed.
+     */
+    public String[] getTrivialPrefixes() {
+        return null;
+    }
+
+    public enum CompilationLevelAdjustment {
+        /**
+         * No adjustment.
+         */
+        None,
+
+        /**
+         * Adjust based on declaring class of method.
+         */
+        ByHolder,
+
+        /**
+         * Adjust based on declaring class, name and signature of method.
+         */
+        ByFullSignature
+    }
+
+    /**
+     * Determines if this object may want to adjust the compilation level for a method that is being
+     * scheduled by the VM for compilation.
+     */
+    public CompilationLevelAdjustment getCompilationLevelAdjustment() {
+        return CompilationLevelAdjustment.None;
+    }
+
+    public enum CompilationLevel {
+        None,
+        Simple,
+        LimitedProfile,
+        FullProfile,
+        FullOptimization
+    }
+
+    /**
+     * Potentially modifies the compilation level currently selected by the VM compilation policy
+     * for a method.
+     *
+     * @param declaringClass the class in which the method is declared
+     * @param name the name of the method or {@code null} depending on the value that was returned
+     *            by {@link #getCompilationLevelAdjustment()}
+     * @param signature the signature of the method or {@code null} depending on the value that was
+     *            returned by {@link #getCompilationLevelAdjustment()}
+     * @param isOsr specifies if the compilation being scheduled in an OSR compilation
+     * @param level the compilation level currently selected by the VM compilation policy
+     * @return the compilation level to use for the compilation being scheduled (must be a valid
+     *         {@code CompLevel} enum value)
+     */
+    public CompilationLevel adjustCompilationLevel(Class<?> declaringClass, String name, String signature, boolean isOsr, CompilationLevel level) {
+        throw new InternalError("Should not reach here");
+    }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Tue Oct 18 17:14:09 2016 +0000
@@ -27,13 +27,11 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintStream;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.ServiceLoader;
 import java.util.TreeMap;
 
 import jdk.internal.misc.VM;
@@ -43,16 +41,15 @@
 import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.common.InitTimer;
 import jdk.vm.ci.common.JVMCIError;
-import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory;
-import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory.CompilationLevel;
-import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory.CompilationLevel;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.JavaType;
 import jdk.vm.ci.meta.ResolvedJavaType;
 import jdk.vm.ci.runtime.JVMCI;
 import jdk.vm.ci.runtime.JVMCIBackend;
 import jdk.vm.ci.runtime.JVMCICompiler;
-import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
+import jdk.vm.ci.runtime.JVMCICompilerFactory;
+import jdk.vm.ci.services.JVMCIServiceLocator;
 import jdk.vm.ci.services.Services;
 
 /**
@@ -246,11 +243,7 @@
         if (vmEventListeners == null) {
             synchronized (this) {
                 if (vmEventListeners == null) {
-                    List<HotSpotVMEventListener> listeners = new ArrayList<>();
-                    for (HotSpotVMEventListener vmEventListener : ServiceLoader.load(HotSpotVMEventListener.class)) {
-                        listeners.add(vmEventListener);
-                    }
-                    vmEventListeners = listeners;
+                    vmEventListeners = JVMCIServiceLocator.getProviders(HotSpotVMEventListener.class);
                 }
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.hotspot;
+
+import jdk.vm.ci.code.CompiledCode;
+import jdk.vm.ci.code.InstalledCode;
+
+/**
+ * Listener for responding to VM events.
+ */
+public interface HotSpotVMEventListener {
+
+    /**
+     * Notifies this client that the VM is shutting down.
+     */
+    default void notifyShutdown() {
+    }
+
+    /**
+     * Notify on successful install into the code cache.
+     *
+     * @param hotSpotCodeCacheProvider the code cache into which the code was installed
+     * @param installedCode the code that was installed
+     * @param compiledCode the compiled code from which {@code installedCode} was produced
+     */
+    default void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
+    }
+
+    /**
+     * Notify on completion of a bootstrap.
+     */
+    default void notifyBootstrapFinished() {
+    }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EmptyEventProvider.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.vm.ci.hotspot.services;
-
-/**
- * An empty implementation for {@link EventProvider}. This implementation is used when no logging is
- * requested.
- */
-final class EmptyEventProvider extends EventProvider {
-
-    EmptyEventProvider() {
-        super(null);
-    }
-
-    static InternalError shouldNotReachHere() {
-        throw new InternalError("should not reach here");
-    }
-
-    @Override
-    public CompilationEvent newCompilationEvent() {
-        return new EmptyCompilationEvent();
-    }
-
-    static class EmptyCompilationEvent implements CompilationEvent {
-        public void commit() {
-            throw shouldNotReachHere();
-        }
-
-        public boolean shouldWrite() {
-            // Events of this class should never been written.
-            return false;
-        }
-
-        public void begin() {
-        }
-
-        public void end() {
-        }
-
-        public void setMethod(String method) {
-            throw shouldNotReachHere();
-        }
-
-        public void setCompileId(int compileId) {
-            throw shouldNotReachHere();
-        }
-
-        public void setCompileLevel(int compileLevel) {
-            throw shouldNotReachHere();
-        }
-
-        public void setSucceeded(boolean succeeded) {
-            throw shouldNotReachHere();
-        }
-
-        public void setIsOsr(boolean isOsr) {
-            throw shouldNotReachHere();
-        }
-
-        public void setCodeSize(int codeSize) {
-            throw shouldNotReachHere();
-        }
-
-        public void setInlinedBytes(int inlinedBytes) {
-            throw shouldNotReachHere();
-        }
-    }
-
-    @Override
-    public CompilerFailureEvent newCompilerFailureEvent() {
-        return new EmptyCompilerFailureEvent();
-    }
-
-    static class EmptyCompilerFailureEvent implements CompilerFailureEvent {
-        public void commit() {
-            throw shouldNotReachHere();
-        }
-
-        public boolean shouldWrite() {
-            // Events of this class should never been written.
-            return false;
-        }
-
-        public void setCompileId(int compileId) {
-            throw shouldNotReachHere();
-        }
-
-        public void setMessage(String message) {
-            throw shouldNotReachHere();
-        }
-    }
-
-}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EventProvider.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.vm.ci.hotspot.services;
-
-import jdk.vm.ci.hotspot.services.EmptyEventProvider.EmptyCompilationEvent;
-import jdk.vm.ci.hotspot.services.EmptyEventProvider.EmptyCompilerFailureEvent;
-import jdk.vm.ci.services.JVMCIPermission;
-
-/**
- * Service-provider class for logging compiler related events.
- */
-public abstract class EventProvider {
-
-    private static Void checkPermission() {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
-            sm.checkPermission(new JVMCIPermission());
-        }
-        return null;
-    }
-
-    @SuppressWarnings("unused")
-    EventProvider(Void ignore) {
-    }
-
-    /**
-     * Initializes a new instance of this class.
-     *
-     * @throws SecurityException if a security manager has been installed and it denies
-     *             {@link JVMCIPermission}
-     */
-    protected EventProvider() {
-        this(checkPermission());
-    }
-
-    /**
-     * Creates and returns an empty implementation for {@link EventProvider}. This implementation
-     * can be used when no logging is requested.
-     */
-    public static EventProvider createEmptyEventProvider() {
-        return new EmptyEventProvider();
-    }
-
-    /**
-     * Creates and returns an empty implementation for {@link CompilationEvent}.
-     */
-    public static CompilationEvent createEmptyCompilationEvent() {
-        return new EmptyCompilationEvent();
-    }
-
-    /**
-     * Creates and returns an empty implementation for {@link CompilationEvent}.
-     */
-    public static CompilerFailureEvent createEmptyCompilerFailureEvent() {
-        return new EmptyCompilerFailureEvent();
-    }
-
-    /**
-     * An instant event is an event that is not considered to have taken any time.
-     */
-    public interface InstantEvent {
-        /**
-         * Commits the event.
-         */
-        void commit();
-
-        /**
-         * Determines if this particular event instance would be committed to the data stream right
-         * now if application called {@link #commit()}. This in turn depends on whether the event is
-         * enabled and possible other factors.
-         *
-         * @return if this event would be committed on a call to {@link #commit()}.
-         */
-        boolean shouldWrite();
-    }
-
-    /**
-     * Timed events describe an operation that somehow consumes time.
-     */
-    public interface TimedEvent extends InstantEvent {
-        /**
-         * Starts the timing for this event.
-         */
-        void begin();
-
-        /**
-         * Ends the timing period for this event.
-         */
-        void end();
-    }
-
-    /**
-     * Creates a new {@link CompilationEvent}.
-     *
-     * @return a compilation event
-     */
-    public abstract CompilationEvent newCompilationEvent();
-
-    /**
-     * A compilation event.
-     */
-    public interface CompilationEvent extends TimedEvent {
-        void setMethod(String method);
-
-        void setCompileId(int compileId);
-
-        void setCompileLevel(int compileLevel);
-
-        void setSucceeded(boolean succeeded);
-
-        void setIsOsr(boolean isOsr);
-
-        void setCodeSize(int codeSize);
-
-        void setInlinedBytes(int inlinedBytes);
-    }
-
-    /**
-     * Creates a new {@link CompilerFailureEvent}.
-     *
-     * @return a compiler failure event
-     */
-    public abstract CompilerFailureEvent newCompilerFailureEvent();
-
-    /**
-     * A compiler failure event.
-     */
-    public interface CompilerFailureEvent extends InstantEvent {
-        void setCompileId(int compileId);
-
-        void setMessage(String message);
-    }
-}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotJVMCICompilerFactory.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +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 jdk.vm.ci.hotspot.services;
-
-import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
-
-/**
- * HotSpot extensions to {@link JVMCICompilerFactory}.
- */
-public abstract class HotSpotJVMCICompilerFactory extends JVMCICompilerFactory {
-
-    /**
-     * Gets 0 or more prefixes identifying classes that should by compiled by C1 in simple mode
-     * (i.e., {@code CompLevel_simple}) when HotSpot is running with tiered compilation. The
-     * prefixes should be class or package names using "/" as the separator, e.g. "jdk/vm/ci".
-     *
-     * @return 0 or more Strings identifying packages that should by compiled by the first tier only
-     *         or null if no redirection to C1 should be performed.
-     */
-    public String[] getTrivialPrefixes() {
-        return null;
-    }
-
-    public enum CompilationLevelAdjustment {
-        /**
-         * No adjustment.
-         */
-        None,
-
-        /**
-         * Adjust based on declaring class of method.
-         */
-        ByHolder,
-
-        /**
-         * Adjust based on declaring class, name and signature of method.
-         */
-        ByFullSignature
-    }
-
-    /**
-     * Determines if this object may want to adjust the compilation level for a method that is being
-     * scheduled by the VM for compilation.
-     */
-    public CompilationLevelAdjustment getCompilationLevelAdjustment() {
-        return CompilationLevelAdjustment.None;
-    }
-
-    public enum CompilationLevel {
-        None,
-        Simple,
-        LimitedProfile,
-        FullProfile,
-        FullOptimization
-    }
-
-    /**
-     * Potentially modifies the compilation level currently selected by the VM compilation policy
-     * for a method.
-     *
-     * @param declaringClass the class in which the method is declared
-     * @param name the name of the method or {@code null} depending on the value that was returned
-     *            by {@link #getCompilationLevelAdjustment()}
-     * @param signature the signature of the method or {@code null} depending on the value that was
-     *            returned by {@link #getCompilationLevelAdjustment()}
-     * @param isOsr specifies if the compilation being scheduled in an OSR compilation
-     * @param level the compilation level currently selected by the VM compilation policy
-     * @return the compilation level to use for the compilation being scheduled (must be a valid
-     *         {@code CompLevel} enum value)
-     */
-    public CompilationLevel adjustCompilationLevel(Class<?> declaringClass, String name, String signature, boolean isOsr, CompilationLevel level) {
-        throw new InternalError("Should not reach here");
-    }
-}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.vm.ci.hotspot.services;
-
-import jdk.vm.ci.code.CompiledCode;
-import jdk.vm.ci.code.InstalledCode;
-import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
-import jdk.vm.ci.services.JVMCIPermission;
-
-/**
- * Service-provider class for responding to VM events.
- */
-public abstract class HotSpotVMEventListener {
-
-    private static Void checkPermission() {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
-            sm.checkPermission(new JVMCIPermission());
-        }
-        return null;
-    }
-
-    @SuppressWarnings("unused")
-    HotSpotVMEventListener(Void ignore) {
-    }
-
-    /**
-     * Initializes a new instance of this class.
-     *
-     * @throws SecurityException if a security manager has been installed and it denies
-     *             {@link JVMCIPermission}
-     */
-    protected HotSpotVMEventListener() {
-        this(checkPermission());
-    }
-
-    /**
-     * Notifies this client that the VM is shutting down.
-     */
-    public void notifyShutdown() {
-    }
-
-    /**
-     * Notify on successful install into the code cache.
-     *
-     * @param hotSpotCodeCacheProvider
-     * @param installedCode
-     * @param compiledCode
-     */
-    public void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
-    }
-
-    /**
-     * Notify on completion of a bootstrap.
-     */
-    public void notifyBootstrapFinished() {
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompilerFactory.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.runtime;
+
+import java.io.PrintStream;
+
+/**
+ * Factory for creating JVMCI compilers.
+ */
+public interface JVMCICompilerFactory {
+
+    /**
+     * Get the name of this compiler. The name is used by JVMCI to determine which factory to use.
+     */
+    String getCompilerName();
+
+    /**
+     * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime)
+     * create} a compiler and it should now perform any heavy weight initialization that it deferred
+     * during construction.
+     */
+    default void onSelection() {
+    }
+
+    /**
+     * Create a new instance of a {@link JVMCICompiler}.
+     */
+    JVMCICompiler createCompiler(JVMCIRuntime runtime);
+
+    /**
+     * Prints a description of the properties used to configure this compiler.
+     *
+     * @param out where to print the message
+     */
+    default void printProperties(PrintStream out) {
+    }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/services/JVMCICompilerFactory.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.vm.ci.runtime.services;
-
-import java.io.PrintStream;
-
-import jdk.vm.ci.runtime.JVMCICompiler;
-import jdk.vm.ci.runtime.JVMCIRuntime;
-import jdk.vm.ci.services.JVMCIPermission;
-
-/**
- * Service-provider class for creating JVMCI compilers.
- */
-public abstract class JVMCICompilerFactory {
-
-    private static Void checkPermission() {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
-            sm.checkPermission(new JVMCIPermission());
-        }
-        return null;
-    }
-
-    @SuppressWarnings("unused")
-    private JVMCICompilerFactory(Void ignore) {
-    }
-
-    /**
-     * Initializes a new instance of this class.
-     *
-     * @throws SecurityException if a security manager has been installed and it denies
-     *             {@link JVMCIPermission}
-     */
-    protected JVMCICompilerFactory() {
-        this(checkPermission());
-    }
-
-    /**
-     * Get the name of this compiler. The name is used by JVMCI to determine which factory to use.
-     */
-    public abstract String getCompilerName();
-
-    /**
-     * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime)
-     * create} a compiler and it should now perform any heavy weight initialization that it deferred
-     * during construction.
-     */
-    public void onSelection() {
-    }
-
-    /**
-     * Create a new instance of a {@link JVMCICompiler}.
-     */
-    public abstract JVMCICompiler createCompiler(JVMCIRuntime runtime);
-
-    /**
-     * Prints a description of the properties used to configure this compiler.
-     *
-     * @param out where to print the message
-     */
-    public void printProperties(PrintStream out) {
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/JVMCIServiceLocator.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.services;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Service-provider class for the runtime to locate providers of JVMCI services where the latter are
+ * not in packages exported by the JVMCI module. As part of instantiating
+ * {@link JVMCIServiceLocator}, all JVMCI packages will be {@linkplain Services#exportJVMCITo(Class)
+ * exported} to the module defining the class of the instantiated object.
+ *
+ * While the {@link #getProvider(Class)} method can be used directly, it's usually easier to use
+ * {@link #getProviders(Class)}.
+ */
+public abstract class JVMCIServiceLocator {
+
+    private static Void checkPermission() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(new JVMCIPermission());
+        }
+        return null;
+    }
+
+    @SuppressWarnings("unused")
+    private JVMCIServiceLocator(Void ignore) {
+    }
+
+    /**
+     * Creates a capability for accessing JVMCI. Once successfully instantiated, JVMCI exports all
+     * its packages to the module defining the type of this object.
+     *
+     * @throws SecurityException if a security manager has been installed and it denies
+     *             {@link JVMCIPermission}
+     */
+    protected JVMCIServiceLocator() {
+        this(checkPermission());
+        Services.exportJVMCITo(getClass());
+    }
+
+    /**
+     * Gets the provider of the service defined by {@code service} or {@code null} if this object
+     * does not have a provider for {@code service}.
+     */
+    public abstract <S> S getProvider(Class<S> service);
+
+    /**
+     * Gets the providers of the service defined by {@code service} by querying the
+     * {@link JVMCIServiceLocator} providers obtained by {@link Services#load(Class)}.
+     */
+    public static <S> List<S> getProviders(Class<S> service) {
+        List<S> providers = new ArrayList<>();
+        for (JVMCIServiceLocator access : Services.load(JVMCIServiceLocator.class)) {
+            S provider = access.getProvider(service);
+            if (provider != null) {
+                providers.add(provider);
+            }
+        }
+        return providers;
+    }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARC.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARC.java	Tue Oct 18 17:14:09 2016 +0000
@@ -349,7 +349,6 @@
         SUN4V,
         BLK_INIT_INSTRUCTIONS,
         FMAF,
-        FMAU,
         SPARC64_FAMILY,
         M_FAMILY,
         T_FAMILY,
--- a/hotspot/src/jdk.vm.ci/share/classes/module-info.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -25,12 +25,9 @@
 
 module jdk.vm.ci {
     exports jdk.vm.ci.services;
-    exports jdk.vm.ci.runtime.services;
-    exports jdk.vm.ci.hotspot.services;
 
-    uses jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+    uses jdk.vm.ci.services.JVMCIServiceLocator;
     uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;
-    uses jdk.vm.ci.runtime.services.JVMCICompilerFactory;
 
     provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with
         jdk.vm.ci.hotspot.aarch64.AArch64HotSpotJVMCIBackendFactory;
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -2563,7 +2563,7 @@
   uint64_t outdata[2];
   uint_t validity = 0;
 
-  if (os::Solaris::meminfo(&addr, 1, info_types, 2, outdata, &validity) < 0) {
+  if (meminfo(&addr, 1, info_types, 2, outdata, &validity) < 0) {
     return false;
   }
 
@@ -2601,7 +2601,7 @@
       addrs_count++;
     }
 
-    if (os::Solaris::meminfo(addrs, addrs_count, info_types, types, outdata, validity) < 0) {
+    if (meminfo(addrs, addrs_count, info_types, types, outdata, validity) < 0) {
       return NULL;
     }
 
@@ -4160,9 +4160,6 @@
 void report_error(const char* file_name, int line_no, const char* title,
                   const char* format, ...);
 
-// (Static) wrapper for getisax(2) call.
-os::Solaris::getisax_func_t os::Solaris::_getisax = 0;
-
 // (Static) wrappers for the liblgrp API
 os::Solaris::lgrp_home_func_t os::Solaris::_lgrp_home;
 os::Solaris::lgrp_init_func_t os::Solaris::_lgrp_init;
@@ -4174,9 +4171,6 @@
 os::Solaris::lgrp_cookie_stale_func_t os::Solaris::_lgrp_cookie_stale;
 os::Solaris::lgrp_cookie_t os::Solaris::_lgrp_cookie = 0;
 
-// (Static) wrapper for meminfo() call.
-os::Solaris::meminfo_func_t os::Solaris::_meminfo = 0;
-
 static address resolve_symbol_lazy(const char* name) {
   address addr = (address) dlsym(RTLD_DEFAULT, name);
   if (addr == NULL) {
@@ -4300,27 +4294,6 @@
   return false;
 }
 
-void os::Solaris::misc_sym_init() {
-  address func;
-
-  // getisax
-  func = resolve_symbol_lazy("getisax");
-  if (func != NULL) {
-    os::Solaris::_getisax = CAST_TO_FN_PTR(getisax_func_t, func);
-  }
-
-  // meminfo
-  func = resolve_symbol_lazy("meminfo");
-  if (func != NULL) {
-    os::Solaris::set_meminfo(CAST_TO_FN_PTR(meminfo_func_t, func));
-  }
-}
-
-uint_t os::Solaris::getisax(uint32_t* array, uint_t n) {
-  assert(_getisax != NULL, "_getisax not set");
-  return _getisax(array, n);
-}
-
 // int pset_getloadavg(psetid_t pset, double loadavg[], int nelem);
 typedef long (*pset_getloadavg_type)(psetid_t pset, double loadavg[], int nelem);
 static pset_getloadavg_type pset_getloadavg_ptr = NULL;
@@ -4351,10 +4324,6 @@
 
   Solaris::initialize_system_info();
 
-  // Initialize misc. symbols as soon as possible, so we can use them
-  // if we need them.
-  Solaris::misc_sym_init();
-
   int fd = ::open("/dev/zero", O_RDWR);
   if (fd < 0) {
     fatal("os::init: cannot open /dev/zero (%s)", os::strerror(errno));
--- a/hotspot/src/os/solaris/vm/os_solaris.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/os/solaris/vm/os_solaris.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -73,8 +73,6 @@
     LGRP_VIEW_OS            // what's available to operating system
   } lgrp_view_t;
 
-  typedef uint_t (*getisax_func_t)(uint32_t* array, uint_t n);
-
   typedef lgrp_id_t (*lgrp_home_func_t)(idtype_t idtype, id_t id);
   typedef lgrp_cookie_t (*lgrp_init_func_t)(lgrp_view_t view);
   typedef int (*lgrp_fini_func_t)(lgrp_cookie_t cookie);
@@ -86,11 +84,6 @@
                                        lgrp_rsrc_t type);
   typedef int (*lgrp_nlgrps_func_t)(lgrp_cookie_t cookie);
   typedef int (*lgrp_cookie_stale_func_t)(lgrp_cookie_t cookie);
-  typedef int (*meminfo_func_t)(const uint64_t inaddr[],   int addr_count,
-                                const uint_t  info_req[],  int info_count,
-                                uint64_t  outdata[], uint_t validity[]);
-
-  static getisax_func_t _getisax;
 
   static lgrp_home_func_t _lgrp_home;
   static lgrp_init_func_t _lgrp_init;
@@ -102,8 +95,6 @@
   static lgrp_cookie_stale_func_t _lgrp_cookie_stale;
   static lgrp_cookie_t _lgrp_cookie;
 
-  static meminfo_func_t _meminfo;
-
   // Large Page Support
   static bool is_valid_page_size(size_t bytes);
   static size_t page_size_for_alignment(size_t alignment);
@@ -191,8 +182,6 @@
   static void libthread_init();
   static void synchronization_init();
   static bool liblgrp_init();
-  // Load miscellaneous symbols.
-  static void misc_sym_init();
   // This boolean allows users to forward their own non-matching signals
   // to JVM_handle_solaris_signal, harmlessly.
   static bool signal_handlers_are_installed;
@@ -272,17 +261,6 @@
   }
   static lgrp_cookie_t lgrp_cookie()                 { return _lgrp_cookie; }
 
-  static bool supports_getisax()                     { return _getisax != NULL; }
-  static uint_t getisax(uint32_t* array, uint_t n);
-
-  static void set_meminfo(meminfo_func_t func)       { _meminfo = func; }
-  static int meminfo (const uint64_t inaddr[],   int addr_count,
-                      const uint_t  info_req[],  int info_count,
-                      uint64_t  outdata[], uint_t validity[]) {
-    return _meminfo != NULL ? _meminfo(inaddr, addr_count, info_req, info_count,
-                                       outdata, validity) : -1;
-  }
-
   static sigset_t* unblocked_signals();
   static sigset_t* vm_signals();
   static sigset_t* allowdebug_blocked_signals();
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -784,7 +784,7 @@
 
   __try {
     RaiseException (MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (const ULONG_PTR*)&info );
-  } __except(EXCEPTION_CONTINUE_EXECUTION) {}
+  } __except(EXCEPTION_EXECUTE_HANDLER) {}
 }
 
 bool os::distribute_processes(uint length, uint* distribution) {
--- a/hotspot/src/os/windows/vm/perfMemory_windows.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/os/windows/vm/perfMemory_windows.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -1404,12 +1404,14 @@
                objectname);      /* name for object */
 
   if (fmh == NULL) {
+    DWORD lasterror = GetLastError();
     if (PrintMiscellaneous && Verbose) {
       warning("OpenFileMapping failed for shared memory object %s:"
-              " lasterror = %d\n", objectname, GetLastError());
+              " lasterror = %d\n", objectname, lasterror);
     }
-    THROW_MSG_(vmSymbols::java_lang_Exception(),
-               "Could not open PerfMemory", INVALID_HANDLE_VALUE);
+    THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+               err_msg("Could not open PerfMemory, error %d", lasterror),
+               INVALID_HANDLE_VALUE);
   }
 
   return fmh;;
--- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -343,8 +343,15 @@
 #define _SC_L2CACHE_LINESZ      527     /* Size of L2 cache line */
 #endif
 
+// Hardware capability bits that appeared after Solaris 11.1
+#ifndef AV_SPARC_FMAF
+#define AV_SPARC_FMAF    0x00000100 /* Fused Multiply-Add */
+#endif
+#ifndef AV2_SPARC_SPARC5
+#define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */
+#endif
+
 int VM_Version::platform_features(int features) {
-  assert(os::Solaris::supports_getisax(), "getisax() must be available");
 
   // Check 32-bit architecture.
   if (Sysinfo(SI_ARCHITECTURE_32).match("sparc")) {
@@ -357,119 +364,75 @@
   }
 
   // Extract valid instruction set extensions.
-  uint_t avs[2];
-  uint_t avn = os::Solaris::getisax(avs, 2);
-  assert(avn <= 2, "should return two or less av's");
-  uint_t av = avs[0];
-
-  log_info(os, cpu)("getisax(2) returned: " PTR32_FORMAT, av);
-  if (avn > 1) {
-    log_info(os, cpu)(" " PTR32_FORMAT, avs[1]);
-  }
+  uint_t avs[AV_HW2_IDX + 1];
+  uint_t avn = getisax(avs, ARRAY_SIZE(avs));
 
-  if (av & AV_SPARC_MUL32)  features |= hardware_mul32_m;
-  if (av & AV_SPARC_DIV32)  features |= hardware_div32_m;
-  if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
-  if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
-  if (av & AV_SPARC_POPC)   features |= hardware_popc_m;
-  if (av & AV_SPARC_VIS)    features |= vis1_instructions_m;
-  if (av & AV_SPARC_VIS2)   features |= vis2_instructions_m;
-  if (avn > 1) {
-    uint_t av2 = avs[1];
-#ifndef AV2_SPARC_SPARC5
-#define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */
-#endif
-    if (av2 & AV2_SPARC_SPARC5)       features |= sparc5_instructions_m;
+  log_info(os, cpu)("getisax(2) returned %d words:", avn);
+  for (int i = 0; i < avn; i++) {
+    log_info(os, cpu)("    word %d: " PTR32_FORMAT, i, avs[i]);
   }
 
-  // We only build on Solaris 10 and up, but some of the values below
-  // are not defined on all versions of Solaris 10, so we define them,
-  // if necessary.
-#ifndef AV_SPARC_ASI_BLK_INIT
-#define AV_SPARC_ASI_BLK_INIT 0x0080  /* ASI_BLK_INIT_xxx ASI */
-#endif
-  if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
-
-#ifndef AV_SPARC_FMAF
-#define AV_SPARC_FMAF 0x0100        /* Fused Multiply-Add */
-#endif
-  if (av & AV_SPARC_FMAF)         features |= fmaf_instructions_m;
-
-#ifndef AV_SPARC_FMAU
-#define AV_SPARC_FMAU    0x0200  /* Unfused Multiply-Add */
-#endif
-  if (av & AV_SPARC_FMAU)         features |= fmau_instructions_m;
-
-#ifndef AV_SPARC_VIS3
-#define AV_SPARC_VIS3    0x0400  /* VIS3 instruction set extensions */
-#endif
-  if (av & AV_SPARC_VIS3)         features |= vis3_instructions_m;
+  uint_t av1 = avs[AV_HW1_IDX];
+  if (av1 & AV_SPARC_MUL32)        features |= hardware_mul32_m;
+  if (av1 & AV_SPARC_DIV32)        features |= hardware_div32_m;
+  if (av1 & AV_SPARC_FSMULD)       features |= hardware_fsmuld_m;
+  if (av1 & AV_SPARC_V8PLUS)       features |= v9_instructions_m;
+  if (av1 & AV_SPARC_POPC)         features |= hardware_popc_m;
+  if (av1 & AV_SPARC_VIS)          features |= vis1_instructions_m;
+  if (av1 & AV_SPARC_VIS2)         features |= vis2_instructions_m;
+  if (av1 & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
+  if (av1 & AV_SPARC_FMAF)         features |= fmaf_instructions_m;
+  if (av1 & AV_SPARC_VIS3)         features |= vis3_instructions_m;
+  if (av1 & AV_SPARC_CBCOND)       features |= cbcond_instructions_m;
+  if (av1 & AV_SPARC_CRC32C)       features |= crc32c_instruction_m;
+  if (av1 & AV_SPARC_AES)          features |= aes_instructions_m;
+  if (av1 & AV_SPARC_SHA1)         features |= sha1_instruction_m;
+  if (av1 & AV_SPARC_SHA256)       features |= sha256_instruction_m;
+  if (av1 & AV_SPARC_SHA512)       features |= sha512_instruction_m;
 
-#ifndef AV_SPARC_CBCOND
-#define AV_SPARC_CBCOND 0x10000000  /* compare and branch instrs supported */
-#endif
-  if (av & AV_SPARC_CBCOND)       features |= cbcond_instructions_m;
-
-#ifndef AV_SPARC_CRC32C
-#define AV_SPARC_CRC32C 0x20000000  /* crc32c instruction supported */
-#endif
-  if (av & AV_SPARC_CRC32C)       features |= crc32c_instruction_m;
-
-#ifndef AV_SPARC_AES
-#define AV_SPARC_AES 0x00020000  /* aes instrs supported */
-#endif
-  if (av & AV_SPARC_AES)       features |= aes_instructions_m;
-
-#ifndef AV_SPARC_SHA1
-#define AV_SPARC_SHA1   0x00400000  /* sha1 instruction supported */
-#endif
-  if (av & AV_SPARC_SHA1)         features |= sha1_instruction_m;
-
-#ifndef AV_SPARC_SHA256
-#define AV_SPARC_SHA256 0x00800000  /* sha256 instruction supported */
-#endif
-  if (av & AV_SPARC_SHA256)       features |= sha256_instruction_m;
-
-#ifndef AV_SPARC_SHA512
-#define AV_SPARC_SHA512 0x01000000  /* sha512 instruction supported */
-#endif
-  if (av & AV_SPARC_SHA512)       features |= sha512_instruction_m;
+  if (avn > AV_HW2_IDX) {
+    uint_t av2 = avs[AV_HW2_IDX];
+    if (av2 & AV2_SPARC_SPARC5)    features |= sparc5_instructions_m;
+  }
 
   // Determine the machine type.
   if (Sysinfo(SI_MACHINE).match("sun4v")) {
     features |= sun4v_m;
   }
 
-  bool use_solaris_12_api = false;
-  Sysinfo impl(SI_CPUBRAND);
-  if (impl.valid()) {
-    // If SI_CPUBRAND works, that means Solaris 12 API to get the cache line sizes
-    // is available to us as well
-    use_solaris_12_api = true;
-    features |= parse_features(impl.value());
+  // If SI_CPUBRAND works, that means Solaris 12 API to get the cache line sizes
+  // is available to us as well
+  Sysinfo cpu_info(SI_CPUBRAND);
+  bool use_solaris_12_api = cpu_info.valid();
+  const char* impl;
+  int impl_m = 0;
+  if (use_solaris_12_api) {
+    impl = cpu_info.value();
+    log_info(os, cpu)("Parsing CPU implementation from %s", impl);
+    impl_m = parse_features(impl);
   } else {
     // Otherwise use kstat to determine the machine type.
     kstat_ctl_t* kc = kstat_open();
-    kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
-    const char* implementation;
-    bool has_implementation = false;
-    if (ksp != NULL) {
-      if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
-        kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
-        for (int i = 0; i < ksp->ks_ndata; i++) {
-          if (strcmp((const char*)&(knm[i].name),"implementation") == 0) {
-            implementation = KSTAT_NAMED_STR_PTR(&knm[i]);
-            has_implementation = true;
-            log_info(os, cpu)("cpu_info.implementation: %s", implementation);
-            features |= parse_features(implementation);
-            break;
+    if (kc != NULL) {
+      kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
+      if (ksp != NULL) {
+        if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
+          kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
+          for (int i = 0; i < ksp->ks_ndata; i++) {
+            if (strcmp((const char*)&(knm[i].name), "implementation") == 0) {
+              impl = KSTAT_NAMED_STR_PTR(&knm[i]);
+              log_info(os, cpu)("Parsing CPU implementation from %s", impl);
+              impl_m = parse_features(impl);
+              break;
+            }
           }
-        } // for(
+        }
       }
+      kstat_close(kc);
     }
-    assert(has_implementation, "unknown cpu info (changed kstat interface?)");
-    kstat_close(kc);
   }
+  assert(impl_m != 0, "Unknown CPU implementation %s", impl);
+  features |= impl_m;
 
   bool is_sun4v = (features & sun4v_m) != 0;
   if (use_solaris_12_api && is_sun4v) {
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -1493,6 +1493,21 @@
   // Check to see whether we are inlining. If so, Return
   // instructions become Gotos to the continuation point.
   if (continuation() != NULL) {
+
+    int invoke_bci = state()->caller_state()->bci();
+
+    if (x != NULL  && !ignore_return) {
+      ciMethod* caller = state()->scope()->caller()->method();
+      Bytecodes::Code invoke_raw_bc = caller->raw_code_at_bci(invoke_bci);
+      if (invoke_raw_bc == Bytecodes::_invokehandle || invoke_raw_bc == Bytecodes::_invokedynamic) {
+        ciType* declared_ret_type = caller->get_declared_signature_at_bci(invoke_bci)->return_type();
+        if (declared_ret_type->is_klass() && x->exact_type() == NULL &&
+            x->declared_type() != declared_ret_type && declared_ret_type != compilation()->env()->Object_klass()) {
+          x = append(new TypeCast(declared_ret_type->as_klass(), x, copy_state_before()));
+        }
+      }
+    }
+
     assert(!method()->is_synchronized() || InlineSynchronizedMethods, "can not inline synchronized methods yet");
 
     if (compilation()->env()->dtrace_method_probes()) {
@@ -1516,7 +1531,6 @@
     // State at end of inlined method is the state of the caller
     // without the method parameters on stack, including the
     // return value, if any, of the inlined method on operand stack.
-    int invoke_bci = state()->caller_state()->bci();
     set_state(state()->caller_state()->copy_for_parsing());
     if (x != NULL) {
       if (!ignore_return) {
--- a/hotspot/src/share/vm/c1/c1_Instruction.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/c1/c1_Instruction.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -360,7 +360,8 @@
 }
 
 ciType* Invoke::declared_type() const {
-  ciType *t = _target->signature()->return_type();
+  ciSignature* declared_signature = state()->scope()->method()->get_declared_signature_at_bci(state()->bci());
+  ciType *t = declared_signature->return_type();
   assert(t->basic_type() != T_VOID, "need return value of void method?");
   return t;
 }
--- a/hotspot/src/share/vm/ci/ciMethod.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/ci/ciMethod.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -256,6 +256,14 @@
     return get_method_at_bci(bci, ignored_will_link, &ignored_declared_signature);
   }
 
+  ciSignature*  get_declared_signature_at_bci(int bci) {
+    bool ignored_will_link;
+    ciSignature* declared_signature;
+    get_method_at_bci(bci, ignored_will_link, &declared_signature);
+    assert(declared_signature != NULL, "cannot be null");
+    return declared_signature;
+  }
+
   // Given a certain calling environment, find the monomorphic target
   // for the call.  Return NULL if the call is not monomorphic in
   // its calling environment.
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -2041,7 +2041,6 @@
                 if (nm != NULL && !m->is_method_handle_intrinsic()) {
                   // Throw out the code so that the code cache doesn't fill up
                   nm->make_not_entrant();
-                  m->clear_code();
                 }
                 CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_full_optimization,
                                               methodHandle(), 0, CompileTask::Reason_CTW, THREAD);
@@ -2060,7 +2059,6 @@
             if (nm != NULL && !m->is_method_handle_intrinsic()) {
               // Throw out the code so that the code cache doesn't fill up
               nm->make_not_entrant();
-              m->clear_code();
             }
           }
         }
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -780,19 +780,26 @@
     // Put the class on the fixup_module_list to patch later when the java.lang.reflect.Module
     // for java.base is known.
     assert(!Universe::is_module_initialized(), "Incorrect java.lang.reflect.Module pre module system initialization");
-    MutexLocker m1(Module_lock, THREAD);
-    // Keep list of classes needing java.base module fixup
-    if (!ModuleEntryTable::javabase_defined()) {
-      if (fixup_module_field_list() == NULL) {
-        GrowableArray<Klass*>* list =
-          new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true);
-        set_fixup_module_field_list(list);
+
+    bool javabase_was_defined = false;
+    {
+      MutexLocker m1(Module_lock, THREAD);
+      // Keep list of classes needing java.base module fixup
+      if (!ModuleEntryTable::javabase_defined()) {
+        if (fixup_module_field_list() == NULL) {
+          GrowableArray<Klass*>* list =
+            new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true);
+          set_fixup_module_field_list(list);
+        }
+        k->class_loader_data()->inc_keep_alive();
+        fixup_module_field_list()->push(k());
+      } else {
+        javabase_was_defined = true;
       }
-      k->class_loader_data()->inc_keep_alive();
-      fixup_module_field_list()->push(k());
-    } else {
-      // java.base was defined at some point between calling create_mirror()
-      // and obtaining the Module_lock, patch this particular class with java.base.
+    }
+
+    // If java.base was already defined then patch this particular class with java.base.
+    if (javabase_was_defined) {
       ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry();
       assert(javabase_entry != NULL && javabase_entry->module() != NULL,
              "Setting class module field, java.base should be defined");
--- a/hotspot/src/share/vm/classfile/moduleEntry.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -368,9 +368,6 @@
 
   // Store pointer to the ModuleEntry for java.base in the java.lang.reflect.Module object.
   java_lang_reflect_Module::set_module_entry(module_handle(), jb_module);
-
-  // Patch any previously loaded classes' module field with java.base's java.lang.reflect.Module.
-  patch_javabase_entries(module_handle);
 }
 
 // Within java.lang.Class instances there is a java.lang.reflect.Module field
@@ -378,7 +375,6 @@
 // definition, classes needing their module field set are added to the fixup_module_list.
 // Their module field is set once java.base's java.lang.reflect.Module is known to the VM.
 void ModuleEntryTable::patch_javabase_entries(Handle module_handle) {
-  assert(Module_lock->owned_by_self(), "should have the Module_lock");
   if (module_handle.is_null()) {
     fatal("Unable to patch the module field of classes loaded prior to java.base's definition, invalid java.lang.reflect.Module");
   }
--- a/hotspot/src/share/vm/classfile/modules.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/classfile/modules.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -244,6 +244,12 @@
               "Module java.base is already defined");
   }
 
+  // Only the thread that actually defined the base module will get here,
+  // so no locking is needed.
+
+  // Patch any previously loaded class's module field with java.base's java.lang.reflect.Module.
+  ModuleEntryTable::patch_javabase_entries(module_handle);
+
   log_debug(modules)("define_javabase_module(): Definition of module: java.base,"
                      " version: %s, location: %s, package #: %d",
                      module_version != NULL ? module_version : "NULL",
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -226,7 +226,7 @@
     WKID_LIMIT,
 
 #if INCLUDE_JVMCI
-    FIRST_JVMCI_WKID = WK_KLASS_ENUM_NAME(HotSpotCompiledCode_klass),
+    FIRST_JVMCI_WKID = WK_KLASS_ENUM_NAME(JVMCI_klass),
     LAST_JVMCI_WKID  = WK_KLASS_ENUM_NAME(Value_klass),
 #endif
 
--- a/hotspot/src/share/vm/code/nmethod.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -1252,7 +1252,7 @@
     if (method() != NULL && (method()->code() == this ||
                              method()->from_compiled_entry() == verified_entry_point())) {
       HandleMark hm;
-      method()->clear_code();
+      method()->clear_code(false /* already owns Patching_lock */);
     }
   } // leave critical region under Patching_lock
 
--- a/hotspot/src/share/vm/gc/shared/gcTraceTime.inline.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/gc/shared/gcTraceTime.inline.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -35,7 +35,6 @@
 #include "prims/jni_md.h"
 #include "utilities/ticks.hpp"
 
-#define LOG_STOP_TIME_FORMAT "(%.3fs, %.3fs) %.3fms"
 #define LOG_STOP_HEAP_FORMAT SIZE_FORMAT "M->" SIZE_FORMAT "M("  SIZE_FORMAT "M)"
 
 inline void GCTraceTimeImpl::log_start(jlong start_counter) {
@@ -46,7 +45,7 @@
     if (_gc_cause != GCCause::_no_gc) {
       out.print(" (%s)", GCCause::to_string(_gc_cause));
     }
-    out.print_cr(" (%.3fs)", TimeHelper::counter_to_seconds(start_counter));
+    out.cr();
   }
 }
 
@@ -71,7 +70,7 @@
     out.print(" " LOG_STOP_HEAP_FORMAT, used_before_m, used_m, capacity_m);
   }
 
-  out.print_cr(" " LOG_STOP_TIME_FORMAT, start_time_in_secs, stop_time_in_secs, duration_in_ms);
+  out.print_cr(" %.3fms", duration_in_ms);
 }
 
 inline void GCTraceTimeImpl::time_stamp(Ticks& ticks) {
@@ -117,7 +116,7 @@
 GCTraceConcTimeImpl<Level, T0, T1, T2, T3, T4, GuardTag>::GCTraceConcTimeImpl(const char* title) :
   _enabled(LogImpl<T0, T1, T2, T3, T4, GuardTag>::is_level(Level)), _start_time(os::elapsed_counter()), _title(title) {
   if (_enabled) {
-    LogImpl<T0, T1, T2, T3, T4>::template write<Level>("%s (%.3fs)", _title, TimeHelper::counter_to_seconds(_start_time));
+    LogImpl<T0, T1, T2, T3, T4>::template write<Level>("%s", _title);
   }
 }
 
@@ -125,11 +124,8 @@
 GCTraceConcTimeImpl<Level, T0, T1, T2, T3, T4, GuardTag>::~GCTraceConcTimeImpl() {
   if (_enabled) {
     jlong stop_time = os::elapsed_counter();
-    LogImpl<T0, T1, T2, T3, T4>::template write<Level>("%s " LOG_STOP_TIME_FORMAT,
-                                                   _title,
-                                                   TimeHelper::counter_to_seconds(_start_time),
-                                                   TimeHelper::counter_to_seconds(stop_time),
-                                                   TimeHelper::counter_to_millis(stop_time - _start_time));
+    LogImpl<T0, T1, T2, T3, T4>::template write<Level>("%s %0.3fms", _title,
+                                                       TimeHelper::counter_to_millis(stop_time - _start_time));
   }
 }
 
--- a/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -172,7 +172,7 @@
   return map;
 }
 
-void* CodeInstaller::record_metadata_reference(Handle constant, TRAPS) {
+void* CodeInstaller::record_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS) {
   /*
    * This method needs to return a raw (untyped) pointer, since the value of a pointer to the base
    * class is in general not equal to the pointer of the subclass. When patching metaspace pointers,
@@ -184,12 +184,14 @@
     Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj));
     assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed klass pointer %s @ " INTPTR_FORMAT, klass->name()->as_C_string(), p2i(klass));
     int index = _oop_recorder->find_index(klass);
+    section->relocate(dest, metadata_Relocation::spec(index));
     TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string());
     return klass;
   } else if (obj->is_a(HotSpotResolvedJavaMethodImpl::klass())) {
     Method* method = (Method*) (address) HotSpotResolvedJavaMethodImpl::metaspaceMethod(obj);
     assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed method pointer %s @ " INTPTR_FORMAT, method->name()->as_C_string(), p2i(method));
     int index = _oop_recorder->find_index(method);
+    section->relocate(dest, metadata_Relocation::spec(index));
     TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string());
     return method;
   } else {
@@ -198,7 +200,7 @@
 }
 
 #ifdef _LP64
-narrowKlass CodeInstaller::record_narrow_metadata_reference(Handle constant, TRAPS) {
+narrowKlass CodeInstaller::record_narrow_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS) {
   oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant);
   assert(HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected uncompressed pointer");
 
@@ -208,6 +210,7 @@
 
   Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj));
   int index = _oop_recorder->find_index(klass);
+  section->relocate(dest, metadata_Relocation::spec(index));
   TRACE_jvmci_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string());
   return Klass::encode_klass(klass);
 }
@@ -701,12 +704,12 @@
     if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) {
       if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
 #ifdef _LP64
-        *((narrowKlass*) dest) = record_narrow_metadata_reference(constant, CHECK_OK);
+        *((narrowKlass*) dest) = record_narrow_metadata_reference(_constants, dest, constant, CHECK_OK);
 #else
         JVMCI_ERROR_OK("unexpected compressed Klass* in 32-bit mode");
 #endif
       } else {
-        *((void**) dest) = record_metadata_reference(constant, CHECK_OK);
+        *((void**) dest) = record_metadata_reference(_constants, dest, constant, CHECK_OK);
       }
     } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) {
       Handle obj = HotSpotObjectConstantImpl::object(constant);
--- a/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -189,9 +189,9 @@
   ScopeValue* get_scope_value(Handle value, BasicType type, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, TRAPS);
   MonitorValue* get_monitor_value(Handle value, GrowableArray<ScopeValue*>* objects, TRAPS);
 
-  void* record_metadata_reference(Handle constant, TRAPS);
+  void* record_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS);
 #ifdef _LP64
-  narrowKlass record_narrow_metadata_reference(Handle constant, TRAPS);
+  narrowKlass record_narrow_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS);
 #endif
 
   // extract the fields of the HotSpotCompiledCode
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -640,8 +640,6 @@
 JVM_END
 
 Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) {
-  guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime");
-
   TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle()));
   KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, CHECK_(Handle()));
   TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle()));
@@ -656,42 +654,37 @@
 }
 
 void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) {
-  if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) {
-    ResourceMark rm;
-#ifdef ASSERT
-    // This should only be called in the context of the JVMCI class being initialized
-    TempNewSymbol name = SymbolTable::new_symbol("jdk/vm/ci/runtime/JVMCI", CHECK);
-    Klass* k = SystemDictionary::resolve_or_null(name, CHECK);
-    instanceKlassHandle klass = InstanceKlass::cast(k);
-    assert(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD),
-           "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");
-#endif
+  guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime");
+  JVMCIRuntime::initialize_well_known_classes(CHECK);
+  // This should only be called in the context of the JVMCI class being initialized
+  instanceKlassHandle klass = InstanceKlass::cast(SystemDictionary::JVMCI_klass());
+  guarantee(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD),
+         "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");
 
-    Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime",
-                               "runtime",
-                               "()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
-    objArrayOop trivial_prefixes = HotSpotJVMCIRuntime::trivialPrefixes(result);
-    if (trivial_prefixes != NULL) {
-      char** prefixes = NEW_C_HEAP_ARRAY(char*, trivial_prefixes->length(), mtCompiler);
-      for (int i = 0; i < trivial_prefixes->length(); i++) {
-        oop str = trivial_prefixes->obj_at(i);
-        if (str == NULL) {
-          THROW(vmSymbols::java_lang_NullPointerException());
-        } else {
-          prefixes[i] = strdup(java_lang_String::as_utf8_string(str));
-        }
+  Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime",
+                             "runtime",
+                             "()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
+  objArrayOop trivial_prefixes = HotSpotJVMCIRuntime::trivialPrefixes(result);
+  if (trivial_prefixes != NULL) {
+    char** prefixes = NEW_C_HEAP_ARRAY(char*, trivial_prefixes->length(), mtCompiler);
+    for (int i = 0; i < trivial_prefixes->length(); i++) {
+      oop str = trivial_prefixes->obj_at(i);
+      if (str == NULL) {
+        THROW(vmSymbols::java_lang_NullPointerException());
+      } else {
+        prefixes[i] = strdup(java_lang_String::as_utf8_string(str));
       }
-      _trivial_prefixes = prefixes;
-      _trivial_prefixes_count = trivial_prefixes->length();
     }
-    int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result);
-    assert(adjustment >= JVMCIRuntime::none &&
-           adjustment <= JVMCIRuntime::by_full_signature,
-           "compilation level adjustment out of bounds");
-    _comp_level_adjustment = (CompLevelAdjustment) adjustment;
-    _HotSpotJVMCIRuntime_initialized = true;
-    _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result());
+    _trivial_prefixes = prefixes;
+    _trivial_prefixes_count = trivial_prefixes->length();
   }
+  int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result);
+  assert(adjustment >= JVMCIRuntime::none &&
+         adjustment <= JVMCIRuntime::by_full_signature,
+         "compilation level adjustment out of bounds");
+  _comp_level_adjustment = (CompLevelAdjustment) adjustment;
+  _HotSpotJVMCIRuntime_initialized = true;
+  _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result());
 }
 
 void JVMCIRuntime::initialize_JVMCI(TRAPS) {
--- a/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -29,6 +29,7 @@
 #else
 #define JVMCI_WK_KLASSES_DO(do_klass)                                                                                           \
   /* JVMCI classes. These are loaded on-demand. */                                                                              \
+  do_klass(JVMCI_klass,                                  jdk_vm_ci_runtime_JVMCI,                               Jvmci) \
   do_klass(HotSpotCompiledCode_klass,                    jdk_vm_ci_hotspot_HotSpotCompiledCode,                 Jvmci) \
   do_klass(HotSpotCompiledCode_Comment_klass,            jdk_vm_ci_hotspot_HotSpotCompiledCode_Comment,         Jvmci) \
   do_klass(HotSpotCompiledNmethod_klass,                 jdk_vm_ci_hotspot_HotSpotCompiledNmethod,              Jvmci) \
--- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -712,7 +712,6 @@
   declare_constant(VM_Version::sun4v_m)                                   \
   declare_constant(VM_Version::blk_init_instructions_m)                   \
   declare_constant(VM_Version::fmaf_instructions_m)                       \
-  declare_constant(VM_Version::fmau_instructions_m)                       \
   declare_constant(VM_Version::sparc64_family_m)                          \
   declare_constant(VM_Version::M_family_m)                                \
   declare_constant(VM_Version::T_family_m)                                \
--- a/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -29,6 +29,7 @@
 #define JVMCI_VM_SYMBOLS_DO(template, do_alias)
 #else
 #define JVMCI_VM_SYMBOLS_DO(template, do_alias)                                                                            \
+  template(jdk_vm_ci_runtime_JVMCI,                               "jdk/vm/ci/runtime/JVMCI")                               \
   template(jdk_vm_ci_hotspot_HotSpotCompiledCode,                 "jdk/vm/ci/hotspot/HotSpotCompiledCode")                 \
   template(jdk_vm_ci_hotspot_HotSpotCompiledCode_Comment,         "jdk/vm/ci/hotspot/HotSpotCompiledCode$Comment")         \
   template(jdk_vm_ci_hotspot_HotSpotCompiledNmethod,              "jdk/vm/ci/hotspot/HotSpotCompiledNmethod")              \
--- a/hotspot/src/share/vm/oops/method.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/oops/method.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -97,7 +97,7 @@
   // Fix and bury in Method*
   set_interpreter_entry(NULL); // sets i2i entry and from_int
   set_adapter_entry(NULL);
-  clear_code(); // from_c/from_i get set to c2i/i2i
+  clear_code(false /* don't need a lock */); // from_c/from_i get set to c2i/i2i
 
   if (access_flags.is_native()) {
     clear_native_function();
@@ -907,8 +907,8 @@
 }
 
 // Revert to using the interpreter and clear out the nmethod
-void Method::clear_code() {
-
+void Method::clear_code(bool acquire_lock /* = true */) {
+  MutexLockerEx pl(acquire_lock ? Patching_lock : NULL, Mutex::_no_safepoint_check_flag);
   // this may be NULL if c2i adapters have not been made yet
   // Only should happen at allocate time.
   if (adapter() == NULL) {
@@ -1077,6 +1077,7 @@
 
 // Install compiled code.  Instantly it can execute.
 void Method::set_code(methodHandle mh, CompiledMethod *code) {
+  MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
   assert( code, "use clear_code to remove code" );
   assert( mh->check_code(), "" );
 
--- a/hotspot/src/share/vm/oops/method.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/oops/method.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -436,7 +436,7 @@
   address verified_code_entry();
   bool check_code() const;      // Not inline to avoid circular ref
   CompiledMethod* volatile code() const                 { assert( check_code(), "" ); return (CompiledMethod *)OrderAccess::load_ptr_acquire(&_code); }
-  void clear_code();            // Clear out any compiled code
+  void clear_code(bool acquire_lock = true);    // Clear out any compiled code
   static void set_code(methodHandle mh, CompiledMethod* code);
   void set_adapter_entry(AdapterHandlerEntry* adapter) {
     constMethod()->set_adapter_entry(adapter);
--- a/hotspot/src/share/vm/oops/methodData.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/oops/methodData.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -1190,12 +1190,11 @@
 #if INCLUDE_JVMCI
     // Description of the different counters
     // ReceiverTypeData for instanceof/checkcast/aastore:
-    //   C1/C2: count is incremented on type overflow and decremented for failed type checks
-    //   JVMCI: count decremented for failed type checks and nonprofiled_count is incremented on type overflow
-    //          TODO (chaeubl): in fact, JVMCI should also increment the count for failed type checks to mimic the C1/C2 behavior
+    //   count is decremented for failed type checks
+    //   JVMCI only: nonprofiled_count is incremented on type overflow
     // VirtualCallData for invokevirtual/invokeinterface:
-    //   C1/C2: count is incremented on type overflow
-    //   JVMCI: count is incremented on type overflow, nonprofiled_count is incremented on method overflow
+    //   count is incremented on type overflow
+    //   JVMCI only: nonprofiled_count is incremented on method overflow
 
     // JVMCI is interested in knowing the percentage of type checks involving a type not explicitly in the profile
     nonprofiled_count_off_set = counter_cell_count,
--- a/hotspot/src/share/vm/opto/loopnode.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/opto/loopnode.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -1687,6 +1687,12 @@
     Node *init2 = phi2->in( LoopNode::EntryControl );
     int stride_con2 = incr2->in(2)->get_int();
 
+    // The ratio of the two strides cannot be represented as an int
+    // if stride_con2 is min_int and stride_con is -1.
+    if (stride_con2 == min_jint && stride_con == -1) {
+      continue;
+    }
+
     // The general case here gets a little tricky.  We want to find the
     // GCD of all possible parallel IV's and make a new IV using this
     // GCD for the loop.  Then all possible IVs are simple multiples of
--- a/hotspot/src/share/vm/opto/macro.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/opto/macro.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -439,12 +439,6 @@
     Node* adr = _igvn.transform(new AddPNode(base, base, MakeConX(offset)));
     const TypePtr* adr_type = _igvn.type(base)->is_ptr()->add_offset(offset);
     Node* m = ac->in(TypeFunc::Memory);
-    while (m->is_MergeMem()) {
-      m = m->as_MergeMem()->memory_at(C->get_alias_index(adr_type));
-      if (m->is_Proj() && m->in(0)->is_MemBar()) {
-        m = m->in(0)->in(TypeFunc::Memory);
-      }
-    }
     res = LoadNode::make(_igvn, ctl, m, adr, adr_type, type, bt, MemNode::unordered, LoadNode::Pinned);
   } else {
     if (ac->modifies(offset, offset, &_igvn, true)) {
@@ -978,6 +972,17 @@
   return true;
 }
 
+static void disconnect_projections(MultiNode* n, PhaseIterGVN& igvn) {
+  Node* ctl_proj = n->proj_out(TypeFunc::Control);
+  Node* mem_proj = n->proj_out(TypeFunc::Memory);
+  if (ctl_proj != NULL) {
+    igvn.replace_node(ctl_proj, n->in(0));
+  }
+  if (mem_proj != NULL) {
+    igvn.replace_node(mem_proj, n->in(TypeFunc::Memory));
+  }
+}
+
 // Process users of eliminated allocation.
 void PhaseMacroExpand::process_users_of_allocation(CallNode *alloc) {
   Node* res = alloc->result_cast();
@@ -1008,13 +1013,13 @@
             // Disconnect ArrayCopy node
             ArrayCopyNode* ac = n->as_ArrayCopy();
             assert(ac->is_clonebasic(), "unexpected array copy kind");
-            Node* ctl_proj = ac->proj_out(TypeFunc::Control);
-            Node* mem_proj = ac->proj_out(TypeFunc::Memory);
-            if (ctl_proj != NULL) {
-              _igvn.replace_node(ctl_proj, n->in(0));
-            }
-            if (mem_proj != NULL) {
-              _igvn.replace_node(mem_proj, n->in(TypeFunc::Memory));
+            Node* membar_after = ac->proj_out(TypeFunc::Control)->unique_ctrl_out();
+            disconnect_projections(ac, _igvn);
+            assert(alloc->in(0)->is_Proj() && alloc->in(0)->in(0)->Opcode() == Op_MemBarCPUOrder, "mem barrier expected before allocation");
+            Node* membar_before = alloc->in(0)->in(0);
+            disconnect_projections(membar_before->as_MemBar(), _igvn);
+            if (membar_after->is_MemBar()) {
+              disconnect_projections(membar_after->as_MemBar(), _igvn);
             }
           } else {
             eliminate_card_mark(n);
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -351,14 +351,6 @@
  *         Deprecated options should be tested in VMDeprecatedOptions.java.
  */
 
-// Obsolete or deprecated -XX flag.
-typedef struct {
-  const char* name;
-  JDK_Version deprecated_in; // When the deprecation warning started (or "undefined").
-  JDK_Version obsolete_in;   // When the obsolete warning started (or "undefined").
-  JDK_Version expired_in;    // When the option expires (or "undefined").
-} SpecialFlag;
-
 // The special_jvm_flags table declares options that are being deprecated and/or obsoleted. The
 // "deprecated_in" or "obsolete_in" fields may be set to "undefined", but not both.
 // When the JDK version reaches 'deprecated_in' limit, the JVM will process this flag on
@@ -380,6 +372,8 @@
   // -------------- Deprecated Flags --------------
   // --- Non-alias flags - sorted by obsolete_in then expired_in:
   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
+  { "AutoGCSelectPauseMillis",      JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
+  { "UseAutoGCSelectPolicy",        JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
   { "UseParNewGC",                  JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
   { "ConvertSleepToYield",          JDK_Version::jdk(9), JDK_Version::jdk(10),     JDK_Version::jdk(11) },
   { "ConvertYieldToSleep",          JDK_Version::jdk(9), JDK_Version::jdk(10),     JDK_Version::jdk(11) },
@@ -498,7 +492,14 @@
   }
 }
 
+extern bool lookup_special_flag_ext(const char *flag_name, SpecialFlag& flag);
+
 static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
+  // Allow extensions to have priority
+  if (lookup_special_flag_ext(flag_name, flag)) {
+    return true;
+  }
+
   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
     if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
       flag = special_jvm_flags[i];
@@ -1802,10 +1803,15 @@
 void Arguments::select_gc_ergonomically() {
 #if INCLUDE_ALL_GCS
   if (os::is_server_class_machine()) {
-    if (should_auto_select_low_pause_collector()) {
-      FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);
+    if (!UseAutoGCSelectPolicy) {
+       FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
     } else {
-      FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
+      if (should_auto_select_low_pause_collector()) {
+        FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);
+        FLAG_SET_ERGO_IF_DEFAULT(bool, UseParNewGC, true);
+      } else {
+        FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true);
+      }
     }
   } else {
     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
@@ -2870,11 +2876,13 @@
       if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true) != Flag::SUCCESS) {
         return JNI_EINVAL;
       }
+      handle_extra_cms_flags("-Xconcgc uses UseConcMarkSweepGC");
     // -Xnoconcgc
     } else if (match_option(option, "-Xnoconcgc")) {
       if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false) != Flag::SUCCESS) {
         return JNI_EINVAL;
       }
+      handle_extra_cms_flags("-Xnoconcgc uses UseConcMarkSweepGC");
     // -Xbatch
     } else if (match_option(option, "-Xbatch")) {
       if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) {
@@ -4157,6 +4165,15 @@
   return true;
 }
 
+void Arguments::handle_extra_cms_flags(const char* msg) {
+  SpecialFlag flag;
+  const char *flag_name = "UseConcMarkSweepGC";
+  if (lookup_special_flag(flag_name, flag)) {
+    handle_aliases_and_deprecation(flag_name, /* print warning */ true);
+    warning("%s", msg);
+  }
+}
+
 // Parse entry point called from JNI_CreateJavaVM
 
 jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
--- a/hotspot/src/share/vm/runtime/arguments.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/runtime/arguments.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -41,6 +41,14 @@
   typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args)  ATTRIBUTE_PRINTF(2, 0);
 }
 
+// Obsolete or deprecated -XX flag.
+struct SpecialFlag {
+  const char* name;
+  JDK_Version deprecated_in; // When the deprecation warning started (or "undefined").
+  JDK_Version obsolete_in;   // When the obsolete warning started (or "undefined").
+  JDK_Version expired_in;    // When the option expires (or "undefined").
+};
+
 // PathString is used as:
 //  - the underlying value for a SystemProperty
 //  - the path portion of an --patch-module module/path pair
@@ -519,6 +527,8 @@
 
   static bool handle_deprecated_print_gc_flags();
 
+  static void handle_extra_cms_flags(const char* msg);
+
   static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
                                  const JavaVMInitArgs *java_options_args,
                                  const JavaVMInitArgs *cmd_line_args);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/runtime/arguments_ext.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -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.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "runtime/arguments.hpp"
+
+bool lookup_special_flag_ext(const char *flag_name, SpecialFlag& flag) {
+  return false;
+}
--- a/hotspot/src/share/vm/runtime/mutex.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/runtime/mutex.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -452,7 +452,7 @@
   ParkEvent * const ESelf = Self->_MutexEvent;
   assert(_OnDeck != ESelf, "invariant");
 
-  // As an optimization, spinners could conditionally try to set ONDECK to _LBIT
+  // As an optimization, spinners could conditionally try to set _OnDeck to _LBIT
   // Synchronizer.cpp uses a similar optimization.
   if (TrySpin(Self)) goto Exeunt;
 
@@ -463,7 +463,7 @@
   OrderAccess::fence();
 
   // Optional optimization ... try barging on the inner lock
-  if ((NativeMonitorFlags & 32) && CASPTR (&_OnDeck, NULL, UNS(Self)) == 0) {
+  if ((NativeMonitorFlags & 32) && CASPTR (&_OnDeck, NULL, UNS(ESelf)) == 0) {
     goto OnDeck_LOOP;
   }
 
@@ -471,14 +471,14 @@
 
   // At any given time there is at most one ondeck thread.
   // ondeck implies not resident on cxq and not resident on EntryList
-  // Only the OnDeck thread can try to acquire -- contended for -- the lock.
+  // Only the OnDeck thread can try to acquire -- contend for -- the lock.
   // CONSIDER: use Self->OnDeck instead of m->OnDeck.
   // Deschedule Self so that others may run.
-  while (_OnDeck != ESelf) {
+  while (OrderAccess::load_ptr_acquire(&_OnDeck) != ESelf) {
     ParkCommon(ESelf, 0);
   }
 
-  // Self is now in the ONDECK position and will remain so until it
+  // Self is now in the OnDeck position and will remain so until it
   // manages to acquire the lock.
  OnDeck_LOOP:
   for (;;) {
@@ -501,8 +501,8 @@
   // A. Shift or defer dropping the inner lock until the subsequent IUnlock() operation.
   //    This might avoid potential reacquisition of the inner lock in IUlock().
   // B. While still holding the inner lock, attempt to opportunistically select
-  //    and unlink the next ONDECK thread from the EntryList.
-  //    If successful, set ONDECK to refer to that thread, otherwise clear ONDECK.
+  //    and unlink the next OnDeck thread from the EntryList.
+  //    If successful, set OnDeck to refer to that thread, otherwise clear OnDeck.
   //    It's critical that the select-and-unlink operation run in constant-time as
   //    it executes when holding the outer lock and may artificially increase the
   //    effective length of the critical section.
@@ -529,7 +529,7 @@
   OrderAccess::release_store(&_LockWord.Bytes[_LSBINDEX], 0); // drop outer lock
 
   OrderAccess::storeload();
-  ParkEvent * const w = _OnDeck;
+  ParkEvent * const w = _OnDeck; // raw load as we will just return if non-NULL
   assert(RelaxAssert || w != Thread::current()->_MutexEvent, "invariant");
   if (w != NULL) {
     // Either we have a valid ondeck thread or ondeck is transiently "locked"
@@ -537,7 +537,7 @@
     // OnDeck allows us to discriminate two cases.  If the latter, the
     // responsibility for progress and succession lies with that other thread.
     // For good performance, we also depend on the fact that redundant unpark()
-    // operations are cheap.  That is, repeated Unpark()ing of the ONDECK thread
+    // operations are cheap.  That is, repeated Unpark()ing of the OnDeck thread
     // is inexpensive.  This approach provides implicit futile wakeup throttling.
     // Note that the referent "w" might be stale with respect to the lock.
     // In that case the following unpark() is harmless and the worst that'll happen
@@ -586,8 +586,13 @@
     _EntryList = w->ListNext;
     // as a diagnostic measure consider setting w->_ListNext = BAD
     assert(UNS(_OnDeck) == _LBIT, "invariant");
-    _OnDeck = w;  // pass OnDeck to w.
-                  // w will clear OnDeck once it acquires the outer lock
+
+    // Pass OnDeck role to w, ensuring that _EntryList has been set first.
+    // w will clear _OnDeck once it acquires the outer lock.
+    // Note that once we set _OnDeck that thread can acquire the mutex, proceed
+    // with its critical section and then enter this code to unlock the mutex. So
+    // you can have multiple threads active in IUnlock at the same time.
+    OrderAccess::release_store_ptr(&_OnDeck, w);
 
     // Another optional optimization ...
     // For heavily contended locks it's not uncommon that some other
@@ -835,7 +840,7 @@
     // ESelf is now on the cxq, EntryList or at the OnDeck position.
     // The following fragment is extracted from Monitor::ILock()
     for (;;) {
-      if (_OnDeck == ESelf && TrySpin(Self)) break;
+      if (OrderAccess::load_ptr_acquire(&_OnDeck) == ESelf && TrySpin(Self)) break;
       ParkCommon(ESelf, 0);
     }
     assert(_OnDeck == ESelf, "invariant");
@@ -1050,10 +1055,10 @@
 
   // At any given time there is at most one ondeck thread.
   // ondeck implies not resident on cxq and not resident on EntryList
-  // Only the OnDeck thread can try to acquire -- contended for -- the lock.
+  // Only the OnDeck thread can try to acquire -- contend for -- the lock.
   // CONSIDER: use Self->OnDeck instead of m->OnDeck.
   for (;;) {
-    if (_OnDeck == ESelf && TrySpin(NULL)) break;
+    if (OrderAccess::load_ptr_acquire(&_OnDeck) == ESelf && TrySpin(NULL)) break;
     ParkCommon(ESelf, 0);
   }
 
--- a/hotspot/src/share/vm/runtime/mutex.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/runtime/mutex.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,7 +81,9 @@
 // *in that order*.  If their implementations change such that these
 // assumptions are violated, a whole lot of code will break.
 
-// The default length of monitor name is chosen to be 64 to avoid false sharing.
+// The default length of monitor name was originally chosen to be 64 to avoid
+// false sharing. Now, PaddedMonitor is available for this purpose.
+// TODO: Check if _name[MONITOR_NAME_LEN] should better get replaced by const char*.
 static const int MONITOR_NAME_LEN = 64;
 
 class Monitor : public CHeapObj<mtInternal> {
@@ -254,6 +256,18 @@
 
 };
 
+class PaddedMonitor : public Monitor {
+  enum {
+    CACHE_LINE_PADDING = (int)DEFAULT_CACHE_LINE_SIZE - (int)sizeof(Monitor),
+    PADDING_LEN = CACHE_LINE_PADDING > 0 ? CACHE_LINE_PADDING : 1
+  };
+  char _padding[PADDING_LEN];
+ public:
+  PaddedMonitor(int rank, const char *name, bool allow_vm_block = false,
+               SafepointCheckRequired safepoint_check_required = _safepoint_check_always) :
+    Monitor(rank, name, allow_vm_block, safepoint_check_required) {};
+};
+
 // Normally we'd expect Monitor to extend Mutex in the sense that a monitor
 // constructed from pthreads primitives might extend a mutex by adding
 // a condvar and some extra metadata.  In fact this was the case until J2SE7.
@@ -292,5 +306,16 @@
    }
 };
 
+class PaddedMutex : public Mutex {
+  enum {
+    CACHE_LINE_PADDING = (int)DEFAULT_CACHE_LINE_SIZE - (int)sizeof(Mutex),
+    PADDING_LEN = CACHE_LINE_PADDING > 0 ? CACHE_LINE_PADDING : 1
+  };
+  char _padding[PADDING_LEN];
+public:
+  PaddedMutex(int rank, const char *name, bool allow_vm_block = false,
+              SafepointCheckRequired safepoint_check_required = _safepoint_check_always) :
+    Mutex(rank, name, allow_vm_block, safepoint_check_required) {};
+};
 
 #endif // SHARE_VM_RUNTIME_MUTEX_HPP
--- a/hotspot/src/share/vm/runtime/mutexLocker.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -169,122 +169,123 @@
   _mutex_array[_num_mutex++] = var;                                      \
 }
 
+// Using Padded subclasses to prevent false sharing of these global monitors and mutexes.
 void mutex_init() {
-  def(tty_lock                     , Mutex  , event,       true,  Monitor::_safepoint_check_never);      // allow to lock in VM
+  def(tty_lock                     , PaddedMutex  , event,       true,  Monitor::_safepoint_check_never);      // allow to lock in VM
 
-  def(CGC_lock                     , Monitor, special,     true,  Monitor::_safepoint_check_never);      // coordinate between fore- and background GC
-  def(STS_lock                     , Monitor, leaf,        true,  Monitor::_safepoint_check_never);
+  def(CGC_lock                     , PaddedMonitor, special,     true,  Monitor::_safepoint_check_never);      // coordinate between fore- and background GC
+  def(STS_lock                     , PaddedMonitor, leaf,        true,  Monitor::_safepoint_check_never);
 
   if (UseConcMarkSweepGC || UseG1GC) {
-    def(FullGCCount_lock           , Monitor, leaf,        true,  Monitor::_safepoint_check_never);      // in support of ExplicitGCInvokesConcurrent
+    def(FullGCCount_lock           , PaddedMonitor, leaf,        true,  Monitor::_safepoint_check_never);      // in support of ExplicitGCInvokesConcurrent
   }
   if (UseG1GC) {
 
-    def(SATB_Q_FL_lock             , Mutex  , special,     true,  Monitor::_safepoint_check_never);
-    def(SATB_Q_CBL_mon             , Monitor, nonleaf,     true,  Monitor::_safepoint_check_never);
-    def(Shared_SATB_Q_lock         , Mutex,   nonleaf,     true,  Monitor::_safepoint_check_never);
+    def(SATB_Q_FL_lock             , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);
+    def(SATB_Q_CBL_mon             , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_never);
+    def(Shared_SATB_Q_lock         , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_never);
 
-    def(DirtyCardQ_FL_lock         , Mutex  , special,     true,  Monitor::_safepoint_check_never);
-    def(DirtyCardQ_CBL_mon         , Monitor, nonleaf,     true,  Monitor::_safepoint_check_never);
-    def(Shared_DirtyCardQ_lock     , Mutex,   nonleaf,     true,  Monitor::_safepoint_check_never);
+    def(DirtyCardQ_FL_lock         , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);
+    def(DirtyCardQ_CBL_mon         , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_never);
+    def(Shared_DirtyCardQ_lock     , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_never);
 
-    def(FreeList_lock              , Mutex,   leaf     ,   true,  Monitor::_safepoint_check_never);
-    def(SecondaryFreeList_lock     , Monitor, leaf     ,   true,  Monitor::_safepoint_check_never);
-    def(OldSets_lock               , Mutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
-    def(RootRegionScan_lock        , Monitor, leaf     ,   true,  Monitor::_safepoint_check_never);
-    def(MMUTracker_lock            , Mutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(FreeList_lock              , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(SecondaryFreeList_lock     , PaddedMonitor, leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(OldSets_lock               , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(RootRegionScan_lock        , PaddedMonitor, leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(MMUTracker_lock            , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
 
-    def(StringDedupQueue_lock      , Monitor, leaf,        true,  Monitor::_safepoint_check_never);
-    def(StringDedupTable_lock      , Mutex  , leaf,        true,  Monitor::_safepoint_check_never);
+    def(StringDedupQueue_lock      , PaddedMonitor, leaf,        true,  Monitor::_safepoint_check_never);
+    def(StringDedupTable_lock      , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_never);
 
-    def(MarkStackFreeList_lock     , Mutex , leaf      ,   true,  Monitor::_safepoint_check_never);
-    def(MarkStackChunkList_lock    , Mutex , leaf      ,   true,  Monitor::_safepoint_check_never);
+    def(MarkStackFreeList_lock     , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(MarkStackChunkList_lock    , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
   }
-  def(ParGCRareEvent_lock          , Mutex  , leaf     ,   true,  Monitor::_safepoint_check_sometimes);
-  def(DerivedPointerTableGC_lock   , Mutex,   leaf,        true,  Monitor::_safepoint_check_never);
-  def(CodeCache_lock               , Mutex  , special,     true,  Monitor::_safepoint_check_never);
-  def(RawMonitor_lock              , Mutex,   special,     true,  Monitor::_safepoint_check_never);
-  def(OopMapCacheAlloc_lock        , Mutex,   leaf,        true,  Monitor::_safepoint_check_always);     // used for oop_map_cache allocation.
+  def(ParGCRareEvent_lock          , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_sometimes);
+  def(DerivedPointerTableGC_lock   , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_never);
+  def(CodeCache_lock               , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);
+  def(RawMonitor_lock              , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);
+  def(OopMapCacheAlloc_lock        , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for oop_map_cache allocation.
 
-  def(Patching_lock                , Mutex  , special,     true,  Monitor::_safepoint_check_never);      // used for safepointing and code patching.
-  def(Service_lock                 , Monitor, special,     true,  Monitor::_safepoint_check_never);      // used for service thread operations
-  def(JmethodIdCreation_lock       , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for creating jmethodIDs.
+  def(Patching_lock                , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);      // used for safepointing and code patching.
+  def(Service_lock                 , PaddedMonitor, special,     true,  Monitor::_safepoint_check_never);      // used for service thread operations
+  def(JmethodIdCreation_lock       , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for creating jmethodIDs.
 
-  def(SystemDictionary_lock        , Monitor, leaf,        true,  Monitor::_safepoint_check_always);     // lookups done by VM thread
-  def(Module_lock                  , Mutex  , leaf+2,      true,  Monitor::_safepoint_check_always);
-  def(InlineCacheBuffer_lock       , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);
-  def(VMStatistic_lock             , Mutex  , leaf,        false, Monitor::_safepoint_check_always);
-  def(ExpandHeap_lock              , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);     // Used during compilation by VM thread
-  def(JNIHandleBlockFreeList_lock  , Mutex  , leaf,        true,  Monitor::_safepoint_check_never);      // handles are used by VM thread
-  def(SignatureHandlerLibrary_lock , Mutex  , leaf,        false, Monitor::_safepoint_check_always);
-  def(SymbolTable_lock             , Mutex  , leaf+2,      true,  Monitor::_safepoint_check_always);
-  def(StringTable_lock             , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);
-  def(ProfilePrint_lock            , Mutex  , leaf,        false, Monitor::_safepoint_check_always);     // serial profile printing
-  def(ExceptionCache_lock          , Mutex  , leaf,        false, Monitor::_safepoint_check_always);     // serial profile printing
-  def(OsrList_lock                 , Mutex  , leaf,        true,  Monitor::_safepoint_check_never);
-  def(Debug1_lock                  , Mutex  , leaf,        true,  Monitor::_safepoint_check_never);
+  def(SystemDictionary_lock        , PaddedMonitor, leaf,        true,  Monitor::_safepoint_check_always);     // lookups done by VM thread
+  def(Module_lock                  , PaddedMutex  , leaf+2,      true,  Monitor::_safepoint_check_always);
+  def(InlineCacheBuffer_lock       , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_always);
+  def(VMStatistic_lock             , PaddedMutex  , leaf,        false, Monitor::_safepoint_check_always);
+  def(ExpandHeap_lock              , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_always);     // Used during compilation by VM thread
+  def(JNIHandleBlockFreeList_lock  , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_never);      // handles are used by VM thread
+  def(SignatureHandlerLibrary_lock , PaddedMutex  , leaf,        false, Monitor::_safepoint_check_always);
+  def(SymbolTable_lock             , PaddedMutex  , leaf+2,      true,  Monitor::_safepoint_check_always);
+  def(StringTable_lock             , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_always);
+  def(ProfilePrint_lock            , PaddedMutex  , leaf,        false, Monitor::_safepoint_check_always);     // serial profile printing
+  def(ExceptionCache_lock          , PaddedMutex  , leaf,        false, Monitor::_safepoint_check_always);     // serial profile printing
+  def(OsrList_lock                 , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_never);
+  def(Debug1_lock                  , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_never);
 #ifndef PRODUCT
-  def(FullGCALot_lock              , Mutex  , leaf,        false, Monitor::_safepoint_check_always);     // a lock to make FullGCALot MT safe
+  def(FullGCALot_lock              , PaddedMutex  , leaf,        false, Monitor::_safepoint_check_always);     // a lock to make FullGCALot MT safe
 #endif
-  def(BeforeExit_lock              , Monitor, leaf,        true,  Monitor::_safepoint_check_always);
-  def(PerfDataMemAlloc_lock        , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for allocating PerfData memory for performance data
-  def(PerfDataManager_lock         , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for synchronized access to PerfDataManager resources
+  def(BeforeExit_lock              , PaddedMonitor, leaf,        true,  Monitor::_safepoint_check_always);
+  def(PerfDataMemAlloc_lock        , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for allocating PerfData memory for performance data
+  def(PerfDataManager_lock         , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for synchronized access to PerfDataManager resources
 
   // CMS_modUnionTable_lock                   leaf
   // CMS_bitMap_lock                          leaf 1
   // CMS_freeList_lock                        leaf 2
 
-  def(Safepoint_lock               , Monitor, safepoint,   true,  Monitor::_safepoint_check_sometimes);  // locks SnippetCache_lock/Threads_lock
+  def(Safepoint_lock               , PaddedMonitor, safepoint,   true,  Monitor::_safepoint_check_sometimes);  // locks SnippetCache_lock/Threads_lock
 
-  def(Threads_lock                 , Monitor, barrier,     true,  Monitor::_safepoint_check_sometimes);
+  def(Threads_lock                 , PaddedMonitor, barrier,     true,  Monitor::_safepoint_check_sometimes);
 
-  def(VMOperationQueue_lock        , Monitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);  // VM_thread allowed to block on these
-  def(VMOperationRequest_lock      , Monitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);
-  def(RetData_lock                 , Mutex  , nonleaf,     false, Monitor::_safepoint_check_always);
-  def(Terminator_lock              , Monitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);
-  def(VtableStubs_lock             , Mutex  , nonleaf,     true,  Monitor::_safepoint_check_always);
-  def(Notify_lock                  , Monitor, nonleaf,     true,  Monitor::_safepoint_check_always);
-  def(JNIGlobalHandle_lock         , Mutex  , nonleaf,     true,  Monitor::_safepoint_check_always);     // locks JNIHandleBlockFreeList_lock
-  def(JNICritical_lock             , Monitor, nonleaf,     true,  Monitor::_safepoint_check_always);     // used for JNI critical regions
-  def(AdapterHandlerLibrary_lock   , Mutex  , nonleaf,     true,  Monitor::_safepoint_check_always);
+  def(VMOperationQueue_lock        , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);  // VM_thread allowed to block on these
+  def(VMOperationRequest_lock      , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);
+  def(RetData_lock                 , PaddedMutex  , nonleaf,     false, Monitor::_safepoint_check_always);
+  def(Terminator_lock              , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);
+  def(VtableStubs_lock             , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_always);
+  def(Notify_lock                  , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_always);
+  def(JNIGlobalHandle_lock         , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_always);     // locks JNIHandleBlockFreeList_lock
+  def(JNICritical_lock             , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_always);     // used for JNI critical regions
+  def(AdapterHandlerLibrary_lock   , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_always);
 
-  def(Heap_lock                    , Monitor, nonleaf+1,   false, Monitor::_safepoint_check_sometimes);
-  def(JfieldIdCreation_lock        , Mutex  , nonleaf+1,   true,  Monitor::_safepoint_check_always);     // jfieldID, Used in VM_Operation
-  def(MemberNameTable_lock         , Mutex  , nonleaf+1,   false, Monitor::_safepoint_check_always);     // Used to protect MemberNameTable
+  def(Heap_lock                    , PaddedMonitor, nonleaf+1,   false, Monitor::_safepoint_check_sometimes);
+  def(JfieldIdCreation_lock        , PaddedMutex  , nonleaf+1,   true,  Monitor::_safepoint_check_always);     // jfieldID, Used in VM_Operation
+  def(MemberNameTable_lock         , PaddedMutex  , nonleaf+1,   false, Monitor::_safepoint_check_always);     // Used to protect MemberNameTable
 
-  def(CompiledIC_lock              , Mutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // locks VtableStubs_lock, InlineCacheBuffer_lock
-  def(CompileTaskAlloc_lock        , Mutex  , nonleaf+2,   true,  Monitor::_safepoint_check_always);
-  def(CompileStatistics_lock       , Mutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);
-  def(DirectivesStack_lock         , Mutex  , special,     true,  Monitor::_safepoint_check_never);
-  def(MultiArray_lock              , Mutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // locks SymbolTable_lock
+  def(CompiledIC_lock              , PaddedMutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // locks VtableStubs_lock, InlineCacheBuffer_lock
+  def(CompileTaskAlloc_lock        , PaddedMutex  , nonleaf+2,   true,  Monitor::_safepoint_check_always);
+  def(CompileStatistics_lock       , PaddedMutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);
+  def(DirectivesStack_lock         , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);
+  def(MultiArray_lock              , PaddedMutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // locks SymbolTable_lock
 
-  def(JvmtiThreadState_lock        , Mutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // Used by JvmtiThreadState/JvmtiEventController
-  def(Management_lock              , Mutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // used for JVM management
+  def(JvmtiThreadState_lock        , PaddedMutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // Used by JvmtiThreadState/JvmtiEventController
+  def(Management_lock              , PaddedMutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // used for JVM management
 
-  def(Compile_lock                 , Mutex  , nonleaf+3,   true,  Monitor::_safepoint_check_sometimes);
-  def(MethodData_lock              , Mutex  , nonleaf+3,   false, Monitor::_safepoint_check_always);
-  def(TouchedMethodLog_lock        , Mutex  , nonleaf+3,   false, Monitor::_safepoint_check_always);
+  def(Compile_lock                 , PaddedMutex  , nonleaf+3,   true,  Monitor::_safepoint_check_sometimes);
+  def(MethodData_lock              , PaddedMutex  , nonleaf+3,   false, Monitor::_safepoint_check_always);
+  def(TouchedMethodLog_lock        , PaddedMutex  , nonleaf+3,   false, Monitor::_safepoint_check_always);
 
-  def(MethodCompileQueue_lock      , Monitor, nonleaf+4,   true,  Monitor::_safepoint_check_always);
-  def(Debug2_lock                  , Mutex  , nonleaf+4,   true,  Monitor::_safepoint_check_never);
-  def(Debug3_lock                  , Mutex  , nonleaf+4,   true,  Monitor::_safepoint_check_never);
-  def(CompileThread_lock           , Monitor, nonleaf+5,   false, Monitor::_safepoint_check_always);
-  def(PeriodicTask_lock            , Monitor, nonleaf+5,   true,  Monitor::_safepoint_check_sometimes);
-  def(RedefineClasses_lock         , Monitor, nonleaf+5,   true,  Monitor::_safepoint_check_always);
+  def(MethodCompileQueue_lock      , PaddedMonitor, nonleaf+4,   true,  Monitor::_safepoint_check_always);
+  def(Debug2_lock                  , PaddedMutex  , nonleaf+4,   true,  Monitor::_safepoint_check_never);
+  def(Debug3_lock                  , PaddedMutex  , nonleaf+4,   true,  Monitor::_safepoint_check_never);
+  def(CompileThread_lock           , PaddedMonitor, nonleaf+5,   false, Monitor::_safepoint_check_always);
+  def(PeriodicTask_lock            , PaddedMonitor, nonleaf+5,   true,  Monitor::_safepoint_check_sometimes);
+  def(RedefineClasses_lock         , PaddedMonitor, nonleaf+5,   true,  Monitor::_safepoint_check_always);
   if (WhiteBoxAPI) {
-    def(Compilation_lock           , Monitor, leaf,        false, Monitor::_safepoint_check_never);
+    def(Compilation_lock           , PaddedMonitor, leaf,        false, Monitor::_safepoint_check_never);
   }
 
 #ifdef INCLUDE_TRACE
-  def(JfrMsg_lock                  , Monitor, leaf,        true,  Monitor::_safepoint_check_always);
-  def(JfrBuffer_lock               , Mutex,   leaf,        true,  Monitor::_safepoint_check_never);
-  def(JfrThreadGroups_lock         , Mutex,   leaf,        true,  Monitor::_safepoint_check_always);
-  def(JfrStream_lock               , Mutex,   leaf+1,      true,  Monitor::_safepoint_check_never);      // ensure to rank lower than 'safepoint'
-  def(JfrStacktrace_lock           , Mutex,   special,     true,  Monitor::_safepoint_check_sometimes);
+  def(JfrMsg_lock                  , PaddedMonitor, leaf,        true,  Monitor::_safepoint_check_always);
+  def(JfrBuffer_lock               , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_never);
+  def(JfrThreadGroups_lock         , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_always);
+  def(JfrStream_lock               , PaddedMutex  , leaf+1,      true,  Monitor::_safepoint_check_never);      // ensure to rank lower than 'safepoint'
+  def(JfrStacktrace_lock           , PaddedMutex  , special,     true,  Monitor::_safepoint_check_sometimes);
 #endif
 
 #ifndef SUPPORTS_NATIVE_CX8
-  def(UnsafeJlong_lock             , Mutex,   special,     false, Monitor::_safepoint_check_never);
+  def(UnsafeJlong_lock             , PaddedMutex  , special,     false, Monitor::_safepoint_check_never);
 #endif
 }
 
--- a/hotspot/test/Makefile	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/Makefile	Tue Oct 18 17:14:09 2016 +0000
@@ -66,6 +66,7 @@
   ifeq ($(ARCH), i386)
     ARCH=i586
   endif
+  NUM_CORES := $(shell LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line)
 endif
 ifeq ($(UNAME_S), Linux)
   PLATFORM = linux
@@ -74,6 +75,7 @@
   ifeq ($(ARCH), i386)
     ARCH = i586
   endif
+  NUM_CORES := $(shell cat /proc/cpuinfo  | grep -c processor)
 endif
 ifeq ($(UNAME_S), Darwin)
   PLATFORM = bsd
@@ -82,6 +84,7 @@
   ifeq ($(ARCH), i386)
     ARCH = i586
   endif
+  NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu)
 endif
 ifeq ($(findstring BSD,$(UNAME_S)), BSD)
   PLATFORM = bsd
@@ -115,6 +118,13 @@
     endif
   endif
   EXESUFFIX = .exe
+  ifneq ($(NUMBER_OF_PROCESSORS), )
+    NUM_CORES := $(NUMBER_OF_PROCESSORS)
+  else
+    ifneq ($(HOTSPOT_BUILD_JOBS), )
+      NUM_CORES := $(HOTSPOT_BUILD_JOBS)
+    endif
+  endif
 endif
 
 ifdef ALT_SLASH_JAVA
@@ -308,9 +318,22 @@
   TEST_SELECTION = $(TESTDIRS)
 endif
 
-ifdef CONCURRENCY
-  JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
+# Concurrency based on min(cores / 2, 12)
+ifdef NUM_CORES
+  CONCURRENCY := $(shell expr $(NUM_CORES) / 2)
+  ifeq ($(CONCURRENCY), 0)
+    CONCURRENCY := 1
+  else ifeq ($(shell expr $(CONCURRENCY) \> 12), 1)
+    CONCURRENCY := 12
+  endif
+else 
+  CONCURRENCY := 1
 endif
+JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
+
+# Make sure MaxRAMFraction is high enough to not cause OOM or swapping since we may end up with a lot of JVM's
+JTREG_BASIC_OPTIONS += -vmoption:-XX:MaxRAMFraction=$(shell expr $(CONCURRENCY) \* 4)
+
 ifdef EXTRA_JTREG_OPTIONS
   JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/arraycopy/TestEliminatedCloneBadMemEdge.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8166836
+ * @summary Elimination of clone's ArrayCopyNode may make compilation fail silently
+ * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestEliminatedCloneBadMemEdge::not_inlined TestEliminatedCloneBadMemEdge
+ *
+ */
+
+public class TestEliminatedCloneBadMemEdge implements Cloneable {
+
+    int f1;
+    int f2;
+    int f3;
+    int f4;
+    int f5;
+    int f6;
+    int f7;
+    int f8;
+    int f9;
+
+    static void not_inlined() {}
+
+    static void test(TestEliminatedCloneBadMemEdge o1) throws CloneNotSupportedException {
+        TestEliminatedCloneBadMemEdge o2 = (TestEliminatedCloneBadMemEdge)o1.clone();
+        not_inlined();
+        o2.f1 = 0x42;
+    }
+
+    static public void main(String[] args) throws CloneNotSupportedException {
+        TestEliminatedCloneBadMemEdge o1 = new TestEliminatedCloneBadMemEdge();
+        for (int i = 0; i < 20000; i++) {
+            test(o1);
+        }
+    }
+}
--- a/hotspot/test/compiler/c1/NullCheckTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/NullCheckTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/Test6579789.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/Test6579789.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/Test6795465.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/Test6795465.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/Test6849574.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/Test6849574.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/Test6855215.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/Test6855215.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/Test6932496.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/Test6932496.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/Test7042153.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/Test7042153.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/Test7090976.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/Test7090976.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/Test7103261.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/Test7103261.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/Test7123108.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/Test7123108.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/Test8004051.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/Test8004051.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/TestArrayCopy.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/TestArrayCopy.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/TestDeoptInt.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/TestDeoptInt.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c1/TestUnalignedLoad.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c1/TestUnalignedLoad.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/FloatingPointFoldingTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/FloatingPointFoldingTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/IVTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/IVTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/InterruptedTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/InterruptedTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/c2/Test6186134.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6186134.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6196102.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6196102.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6357214.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6357214.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6443505.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6443505.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6559156.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6559156.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6661247.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6661247.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/c2/Test6732154.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6732154.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6753639.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6753639.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6792161.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6792161.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6796786.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6796786.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6799693.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6799693.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/c2/Test6823453.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6823453.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/c2/Test6832293.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6832293.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/c2/Test6850611.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6850611.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6851282.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6851282.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6852078.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6852078.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6857159.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6857159.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6885584.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6885584.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6897150.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6897150.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6905845.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6905845.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6910605_1.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6910605_1.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6910605_2.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6910605_2.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6916644.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6916644.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6930043.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6930043.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6931567.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6931567.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6935022.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6935022.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6956668.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6956668.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6959129.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6959129.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6968348.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6968348.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6985295.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6985295.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test6992759.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test6992759.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7002666.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7002666.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7009359.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7009359.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7020614.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7020614.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7024475.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7024475.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7041100.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7041100.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7046096.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7046096.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7047069.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7047069.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7048332.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7048332.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7068051.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7068051.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7110586.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7110586.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7125879.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7125879.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7160610.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7160610.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7169782.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7169782.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7174363.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7174363.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7177917.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7177917.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test7190310.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7190310.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/c2/Test7190310_unsafe.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7190310_unsafe.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/c2/Test7199742.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test7199742.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/Test8002069.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/Test8002069.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/TestDominatingDeadCheckCast.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/TestDominatingDeadCheckCast.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr6340864/TestByteVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr6340864/TestByteVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr6340864/TestDoubleVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr6340864/TestDoubleVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr6340864/TestFloatVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr6340864/TestFloatVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr6340864/TestIntVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr6340864/TestIntVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr6340864/TestLongVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr6340864/TestLongVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr6340864/TestShortVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr6340864/TestShortVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr6663854/Test6663854.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr6663854/Test6663854.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr6711117/Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr6711117/Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/c2/cr6890943/Test6890943.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr6890943/Test6890943.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr7005594/Test7005594.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr7005594/Test7005594.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr7192963/TestByteVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr7192963/TestByteVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr7192963/TestDoubleVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr7192963/TestDoubleVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr7192963/TestFloatVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr7192963/TestFloatVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr7192963/TestIntVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr7192963/TestIntVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr7192963/TestLongVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr7192963/TestLongVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr7192963/TestShortVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr7192963/TestShortVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr7200264/TestIntVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr7200264/TestIntVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntAtomicCAS.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntAtomicCAS.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntAtomicOrdered.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntAtomicOrdered.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntAtomicVolatile.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntAtomicVolatile.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/codecache/stress/CodeCacheStressRunner.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codecache/stress/CodeCacheStressRunner.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.codecache.stress;
--- a/hotspot/test/compiler/codecache/stress/Helper.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codecache/stress/Helper.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.codecache.stress;
--- a/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/codecache/stress/RandomAllocationTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codecache/stress/RandomAllocationTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/codecache/stress/UnexpectedDeoptimizationTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codecache/stress/UnexpectedDeoptimizationTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/codegen/Test6431242.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/Test6431242.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/codegen/Test6909839.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/Test6909839.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/Test6942326.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/Test6942326.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/Test7009231.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/Test7009231.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/Test7100757.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/Test7100757.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestBooleanVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestBooleanVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestByteDoubleVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestByteDoubleVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestByteFloatVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestByteFloatVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestByteIntVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestByteIntVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestByteLongVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestByteLongVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestByteShortVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestByteShortVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestByteVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestByteVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestCharShortVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestCharShortVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestCharVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestCharVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestCharVect2.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestCharVect2.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestDoubleVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestDoubleVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestFloatDoubleVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestFloatDoubleVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestFloatVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestFloatVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestIntDoubleVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestIntDoubleVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestIntFloatVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestIntFloatVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestIntLongVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestIntLongVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestIntVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestIntVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestLongDoubleVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestLongDoubleVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestLongFloatVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestLongFloatVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestLongVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestLongVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestShortDoubleVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestShortDoubleVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestShortFloatVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestShortFloatVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestShortIntVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestShortIntVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestShortLongVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestShortLongVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/TestShortVect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/TestShortVect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/codegen/aes/TestAESBase.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/aes/TestAESBase.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,10 +19,8 @@
  * Please 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 compiler.codegen.aes;
 
 import jdk.test.lib.Utils;
--- a/hotspot/test/compiler/codegen/aes/TestAESDecode.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/aes/TestAESDecode.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.codegen.aes;
--- a/hotspot/test/compiler/codegen/aes/TestAESEncode.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/aes/TestAESEncode.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.codegen.aes;
--- a/hotspot/test/compiler/codegen/aes/TestAESMain.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/codegen/aes/TestAESMain.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/controldependency/TestEliminatedCastPPAtPhi.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/controldependency/TestEliminatedCastPPAtPhi.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.cpuflags;
--- a/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/cpuflags/predicate/AESSupportPredicate.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/cpuflags/predicate/AESSupportPredicate.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please 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 compiler.cpuflags.predicate;
 
 import sun.hotspot.cpuinfo.CPUInfo;
--- a/hotspot/test/compiler/escapeAnalysis/Test6726999.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/escapeAnalysis/Test6726999.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/escapeAnalysis/Test6775880.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/escapeAnalysis/Test6775880.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/escapeAnalysis/Test6895383.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/escapeAnalysis/Test6895383.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/escapeAnalysis/Test6896727.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/escapeAnalysis/Test6896727.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/escapeAnalysis/cr6795161/Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/escapeAnalysis/cr6795161/Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/floatingpoint/Test15FloatJNIArgs.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2015 SAP SE. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test
- * @bug 8139258
- * @summary Regression test for 8139258 which failed to properly pass float args
- *          to a jni function on ppc64le.
- *
- * @run main/othervm/native -Xint compiler.floatingpoint.Test15FloatJNIArgs
- * @run main/othervm/native -XX:+TieredCompilation -Xcomp compiler.floatingpoint.Test15FloatJNIArgs
- * @run main/othervm/native -XX:-TieredCompilation -Xcomp compiler.floatingpoint.Test15FloatJNIArgs
- */
-
-package compiler.floatingpoint;
-
-public class Test15FloatJNIArgs {
-    static {
-        try {
-            System.loadLibrary("Test15FloatJNIArgs");
-        } catch (UnsatisfiedLinkError e) {
-            System.out.println("could not load native lib: " + e);
-        }
-    }
-
-    public static native float add15floats(
-        float f1, float f2, float f3, float f4,
-        float f5, float f6, float f7, float f8,
-        float f9, float f10, float f11, float f12,
-        float f13, float f14, float f15);
-
-    static void test() throws Exception {
-        float sum = Test15FloatJNIArgs.add15floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
-                                                   1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
-        if (sum != 15.0f) {
-            throw new Error("Passed 15 times 1.0f to jni function which didn't add them properly: " + sum);
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        for (int i = 0; i < 200; ++i) {
-            test();
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/floatingpoint/TestFloatJNIArgs.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015, 2016 SAP SE. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8139258 8165673
+ * @summary Regression test for passing float args to a jni function.
+ *
+ *
+ * @run main/othervm/native -Xint compiler.floatingpoint.TestFloatJNIArgs
+ * @run main/othervm/native -XX:+TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs
+ * @run main/othervm/native -XX:-TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs
+ */
+
+package compiler.floatingpoint;
+
+public class TestFloatJNIArgs {
+    static {
+        try {
+            System.loadLibrary("TestFloatJNIArgs");
+        } catch (UnsatisfiedLinkError e) {
+            System.out.println("could not load native lib: " + e);
+        }
+    }
+
+    public static native float add15floats(
+        float f1, float f2, float f3, float f4,
+        float f5, float f6, float f7, float f8,
+        float f9, float f10, float f11, float f12,
+        float f13, float f14, float f15);
+
+    public static native float add10floats(
+        float f1, float f2, float f3, float f4,
+        float f5, float f6, float f7, float f8,
+        float f9, float f10);
+
+    public static native float addFloatsInts(
+        float f1, float f2, float f3, float f4,
+        float f5, float f6, float f7, float f8,
+        float f9, float f10, float f11, float f12,
+        float f13, float f14, float f15, int a16, int a17);
+
+    public static native double add15doubles(
+        double d1, double d2, double d3, double d4,
+        double d5, double d6, double d7, double d8,
+        double d9, double d10, double d11, double d12,
+        double d13, double d14, double d15);
+
+    static void test() throws Exception {
+        float sum = TestFloatJNIArgs.add15floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
+                                                 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
+        if (sum != 15.0f) {
+            throw new Error("Passed 15 times 1.0f to jni function which didn't add them properly: " + sum);
+        }
+
+        float sum1 = TestFloatJNIArgs.add10floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
+        if (sum1 != 10.0f) {
+            throw new Error("Passed 10 times 1.0f to jni function which didn't add them properly: " + sum1);
+        }
+
+        float sum2 = TestFloatJNIArgs.addFloatsInts(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
+                                                   1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1, 1);
+        if (sum2 != 17.0f) {
+            throw new Error("Passed 17 times 1 to jni function which didn't add them properly: " + sum2);
+        }
+
+        double dsum = TestFloatJNIArgs.add15doubles(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
+                                                      1.0, 1.0, 1.0, 1.0, 1.0, 1.0);
+        if (dsum != 15.0) {
+            throw new Error("Passed 15 times 1.0 to jni function which didn't add them properly: " + dsum);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        for (int i = 0; i < 200; ++i) {
+            test();
+        }
+    }
+}
--- a/hotspot/test/compiler/floatingpoint/libTest15FloatJNIArgs.c	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2015. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_Test15FloatJNIArgs_add15floats
-  (JNIEnv *env, jclass cls,
-   jfloat  f1, jfloat  f2, jfloat  f3, jfloat  f4,
-   jfloat  f5, jfloat  f6, jfloat  f7, jfloat  f8,
-   jfloat  f9, jfloat f10, jfloat f11, jfloat f12,
-   jfloat f13, jfloat f14, jfloat f15) {
-  return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + f13 + f14 + f15;
-}
-
-#ifdef __cplusplus
-}
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/floatingpoint/libTestFloatJNIArgs.c	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015, 2016. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_TestFloatJNIArgs_add15floats
+  (JNIEnv *env, jclass cls,
+   jfloat  f1, jfloat  f2, jfloat  f3, jfloat  f4,
+   jfloat  f5, jfloat  f6, jfloat  f7, jfloat  f8,
+   jfloat  f9, jfloat f10, jfloat f11, jfloat f12,
+   jfloat f13, jfloat f14, jfloat f15) {
+  return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + f13 + f14 + f15;
+}
+
+JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_TestFloatJNIArgs_add10floats
+  (JNIEnv *env, jclass cls,
+   jfloat  f1, jfloat  f2, jfloat  f3, jfloat  f4,
+   jfloat  f5, jfloat  f6, jfloat  f7, jfloat  f8,
+   jfloat  f9, jfloat f10) {
+  return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
+}
+
+JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_TestFloatJNIArgs_addFloatsInts
+  (JNIEnv *env, jclass cls,
+   jfloat  f1, jfloat  f2, jfloat  f3, jfloat  f4,
+   jfloat  f5, jfloat  f6, jfloat  f7, jfloat  f8,
+   jfloat  f9, jfloat f10, jfloat f11, jfloat f12,
+   jfloat f13, jfloat f14, jfloat f15, jint a16, jint a17) {
+  return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + f13 + f14 + f15 + a16 + a17;
+}
+
+JNIEXPORT jdouble JNICALL Java_compiler_floatingpoint_TestFloatJNIArgs_add15doubles
+  (JNIEnv *env, jclass cls,
+   jdouble  f1, jdouble  f2, jdouble  f3, jdouble  f4,
+   jdouble  f5, jdouble  f6, jdouble  f7, jdouble  f8,
+   jdouble  f9, jdouble f10, jdouble f11, jdouble f12,
+   jdouble f13, jdouble f14, jdouble f15) {
+  return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + f13 + f14 + f15;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
--- a/hotspot/test/compiler/gcbarriers/G1CrashTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/gcbarriers/G1CrashTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/gcbarriers/PreserveFPRegistersTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/gcbarriers/PreserveFPRegistersTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/inlining/InlineAccessors.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/inlining/InlineAccessors.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please 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 8140650
--- a/hotspot/test/compiler/interpreter/cr7116216/LargeFrame.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/interpreter/cr7116216/LargeFrame.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.interpreter.cr7116216;
--- a/hotspot/test/compiler/interpreter/cr7116216/StackOverflow.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/interpreter/cr7116216/StackOverflow.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/Test6982370.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/Test6982370.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bigInteger/TestMulAdd.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bigInteger/TestMulAdd.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bigInteger/TestMultiplyToLen.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bigInteger/TestMultiplyToLen.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bigInteger/TestMultiplyToLenReturnProfile.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bigInteger/TestMultiplyToLenReturnProfile.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bigInteger/TestSquareToLen.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bigInteger/TestSquareToLen.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/BMITestRunner.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/BMITestRunner.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.intrinsics.bmi;
--- a/hotspot/test/compiler/intrinsics/bmi/Expr.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/Expr.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.intrinsics.bmi;
--- a/hotspot/test/compiler/intrinsics/bmi/TestAndnI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestAndnI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestAndnL.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestAndnL.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsiI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsiI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsiL.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsiL.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsmskI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsmskI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsmskL.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsmskL.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsrI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsrI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsrL.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsrL.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestLzcntI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestLzcntI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestLzcntL.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestLzcntL.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestTzcntI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestTzcntI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/TestTzcntL.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/TestTzcntL.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.intrinsics.bmi.verifycode;
--- a/hotspot/test/compiler/intrinsics/klass/TestIsPrimitive.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/klass/TestIsPrimitive.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/intrinsics/object/TestClone.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/object/TestClone.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/intrinsics/sha/TestSHA.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/sha/TestSHA.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/unsafe/AllocateUninitializedArray.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/unsafe/AllocateUninitializedArray.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeUnalignedMismatchedAccesses.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeUnalignedMismatchedAccesses.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jsr292/CreatesInterfaceDotEqualsCallInfo.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/CreatesInterfaceDotEqualsCallInfo.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jsr292/LongReferenceCastingTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/LongReferenceCastingTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jsr292/MHInlineTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/MHInlineTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please 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 8062280
--- a/hotspot/test/compiler/jsr292/Test7082949.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/Test7082949.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/jsr292/TestArrayReturnType.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,71 @@
+/*
+ * 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 8134389
+ *
+ * @run main/othervm -Xbatch compiler.jsr292.TestArrayReturnType
+ * @run main/othervm -Xbatch -XX:-Inline compiler.jsr292.TestArrayReturnType
+ * @run main/othervm -Xbatch
+ *      -XX:CompileCommand=exclude,compiler.jsr292.TestArrayReturnType::testArrayReturnType
+ *      compiler.jsr292.TestArrayReturnType
+ */
+
+package compiler.jsr292;
+
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+public class TestArrayReturnType {
+
+    static final MethodHandle mh;
+    static int[] testArray = new int[1];
+    static {
+        try {
+            mh = MethodHandles.lookup().findStatic(TestArrayReturnType.class, "testArrayReturnType", MethodType.methodType(int[].class));
+        } catch (Exception e) {
+            throw new Error(e);
+        }
+    }
+
+    static int[] testArrayReturnType() {
+        return testArray;
+    }
+
+    public static void test()  throws Throwable {
+        int a[] = (int[])mh.invokeExact();
+        for (int i=0; i<a.length; i++) {
+            a[i] = 1;
+        }
+    }
+
+    public static void main(String[] args) throws Throwable {
+        for (int i=0; i<15000; i++) {
+            test();
+        }
+        System.out.println("TEST PASSED");
+    }
+}
--- a/hotspot/test/compiler/jsr292/cr6990212/Test6990212.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/cr6990212/Test6990212.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/ByteClassLoader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/ByteClassLoader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.jsr292.methodHandleExceptions;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/TestAMEnotNPE.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/TestAMEnotNPE.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/C.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/C.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Dok.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Dok.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/E.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/E.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/F.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/F.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/I.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/I.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Tdirect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Tdirect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 p;
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Treflect.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/p/Treflect.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 p;
--- a/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/common/JVMCIHelpers.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/common/JVMCIHelpers.java	Tue Oct 18 17:14:09 2016 +0000
@@ -25,17 +25,29 @@
 
 import jdk.vm.ci.code.CompilationRequest;
 import jdk.vm.ci.code.CompilationRequestResult;
-import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+import jdk.vm.ci.hotspot.HotSpotVMEventListener;
+import jdk.vm.ci.services.JVMCIServiceLocator;
 import jdk.vm.ci.runtime.JVMCICompiler;
 import jdk.vm.ci.runtime.JVMCIRuntime;
-import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
+import jdk.vm.ci.runtime.JVMCICompilerFactory;
 
 /*
  * A stub classes to be able to use jvmci
  */
-public class JVMCIHelpers {
+public class JVMCIHelpers extends JVMCIServiceLocator {
 
-    public static class EmptyVMEventListener extends HotSpotVMEventListener {
+    @Override
+    public <S> S getProvider(Class<S> service) {
+        if (service == JVMCICompilerFactory.class) {
+            return service.cast(new EmptyCompilerFactory());
+        }
+        if (service == HotSpotVMEventListener.class) {
+            return service.cast(new EmptyVMEventListener());
+        }
+        return null;
+    }
+
+    public static class EmptyVMEventListener implements HotSpotVMEventListener {
         // just empty, using default interface methods
     }
 
@@ -54,7 +66,7 @@
         }
     }
 
-    public static class EmptyCompilerFactory extends JVMCICompilerFactory {
+    public static class EmptyCompilerFactory implements JVMCICompilerFactory {
 
         @Override
         public String getCompilerName() {
--- a/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener
--- a/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.JVMCICompiler	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
--- a/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.services.JVMCICompilerFactory	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
--- a/hotspot/test/compiler/jvmci/common/testcases/TestCase.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/common/testcases/TestCase.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.jvmci.common.testcases;
--- a/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please 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 8136421
--- a/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/compilerToVM/CompileCodeTestCase.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/CompileCodeTestCase.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.jvmci.compilerToVM;
--- a/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.jvmci.compilerToVM;
--- a/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please 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 compiler.jvmci.compilerToVM;
 
 import compiler.jvmci.common.testcases.MultipleAbstractImplementer;
--- a/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/compilerToVM/DummyAbstractClass.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DummyAbstractClass.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.jvmci.compilerToVM;
--- a/hotspot/test/compiler/jvmci/compilerToVM/DummyClass.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DummyClass.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.jvmci.compilerToVM;
--- a/hotspot/test/compiler/jvmci/compilerToVM/DummyInterface.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DummyInterface.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.jvmci.compilerToVM;
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config	Tue Oct 18 17:14:09 2016 +0000
@@ -1,1 +1,2 @@
 compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest
+compiler.jvmci.common.JVMCIHelpers
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -37,9 +37,8 @@
  *
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.common.JVMCIHelpers
- * @run driver jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/
  * @run driver jdk.test.lib.FileInstaller ./JvmciNotifyBootstrapFinishedEventTest.config
- *     ./META-INF/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener
+ *     ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator
  * @run driver ClassFileInstaller
  *      compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
  *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
@@ -60,9 +59,10 @@
 package compiler.jvmci.events;
 
 import jdk.test.lib.Asserts;
-import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+import jdk.vm.ci.services.JVMCIServiceLocator;
+import jdk.vm.ci.hotspot.HotSpotVMEventListener;
 
-public class JvmciNotifyBootstrapFinishedEventTest extends HotSpotVMEventListener {
+public class JvmciNotifyBootstrapFinishedEventTest extends JVMCIServiceLocator implements HotSpotVMEventListener {
     private static final boolean BOOTSTRAP = Boolean
             .getBoolean("compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap");
     private static volatile int gotBoostrapNotification = 0;
@@ -76,6 +76,14 @@
     }
 
     @Override
+    public <S> S getProvider(Class<S> service) {
+        if (service == HotSpotVMEventListener.class) {
+            return service.cast(this);
+        }
+        return null;
+    }
+
+    @Override
     public void notifyBootstrapFinished() {
         gotBoostrapNotification++;
     }
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.config	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.config	Tue Oct 18 17:14:09 2016 +0000
@@ -1,1 +1,2 @@
 compiler.jvmci.events.JvmciNotifyInstallEventTest
+compiler.jvmci.common.JVMCIHelpers
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -38,9 +38,8 @@
  *
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.common.JVMCIHelpers
- * @run driver jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/
  * @run driver jdk.test.lib.FileInstaller ./JvmciNotifyInstallEventTest.config
- *     ./META-INF/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener
+ *     ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator
  * @run driver ClassFileInstaller
  *      compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
  *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
@@ -73,6 +72,7 @@
 import compiler.jvmci.common.testcases.SimpleClass;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.Utils;
+import jdk.vm.ci.services.JVMCIServiceLocator;
 import jdk.vm.ci.code.CompiledCode;
 import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.code.site.DataPatch;
@@ -82,13 +82,13 @@
 import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
-import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+import jdk.vm.ci.hotspot.HotSpotVMEventListener;
 import jdk.vm.ci.meta.Assumptions.Assumption;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 
 import java.lang.reflect.Method;
 
-public class JvmciNotifyInstallEventTest extends HotSpotVMEventListener {
+public class JvmciNotifyInstallEventTest extends JVMCIServiceLocator implements HotSpotVMEventListener {
     private static final String METHOD_NAME = "testMethod";
     private static final boolean FAIL_ON_INIT = !Boolean.getBoolean(
             "compiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit");
@@ -98,6 +98,14 @@
         new JvmciNotifyInstallEventTest().runTest();
     }
 
+    @Override
+    public <S> S getProvider(Class<S> service) {
+        if (service == HotSpotVMEventListener.class) {
+            return service.cast(this);
+        }
+        return null;
+    }
+
     private void runTest() {
         if (gotInstallNotification != 0) {
             throw new Error("Got install notification before test actions");
--- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventListener.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventListener.java	Tue Oct 18 17:14:09 2016 +0000
@@ -23,10 +23,11 @@
 
 package compiler.jvmci.events;
 
+import jdk.vm.ci.services.JVMCIServiceLocator;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
-import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
+import jdk.vm.ci.hotspot.HotSpotVMEventListener;
 
-public class JvmciShutdownEventListener extends HotSpotVMEventListener {
+public class JvmciShutdownEventListener extends JVMCIServiceLocator implements HotSpotVMEventListener {
     public static final String MESSAGE = "Shutdown notified";
     public static final String GOT_INTERNAL_ERROR = "Got internal error";
 
@@ -39,6 +40,14 @@
     }
 
     @Override
+    public <S> S getProvider(Class<S> service) {
+        if (service == HotSpotVMEventListener.class) {
+            return service.cast(this);
+        }
+        return null;
+    }
+
+    @Override
     public void notifyShutdown() {
         System.out.println(MESSAGE);
     }
--- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.config	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.config	Tue Oct 18 17:14:09 2016 +0000
@@ -1,1 +1,2 @@
 compiler.jvmci.events.JvmciShutdownEventListener
+compiler.jvmci.common.JVMCIHelpers
--- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -34,9 +34,8 @@
  *
  * @build compiler.jvmci.common.JVMCIHelpers
  *        compiler.jvmci.events.JvmciShutdownEventListener
- * @run driver jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/
  * @run driver jdk.test.lib.FileInstaller ./JvmciShutdownEventTest.config
- *     ./META-INF/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener
+ *     ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator
  * @run driver ClassFileInstaller
  *      compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
  *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 #include <stdio.h>
--- a/hotspot/test/compiler/linkage/LinkageErrors.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/linkage/LinkageErrors.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please 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 8132879
--- a/hotspot/test/compiler/loopopts/BadPredicateAfterPartialPeel.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/BadPredicateAfterPartialPeel.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/ConstFPVectorization.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/ConstFPVectorization.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/CountedLoopProblem.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/CountedLoopProblem.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/Test6659207.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/Test6659207.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/loopopts/Test7044738.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/Test7044738.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/Test7052494.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/Test7052494.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/TestArraysFillDeadControl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/TestArraysFillDeadControl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/TestCastIINoLoopLimitCheck.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/TestCastIINoLoopLimitCheck.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/TestDeadBackbranchArrayAccess.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/TestDeadBackbranchArrayAccess.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/loopopts/TestImpossibleIV.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2016 Google, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8166742
+ * @summary C2 IV elimination throws FPE
+ * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation TestImpossibleIV
+ * @author Chuck Rasbold rasbold@google.com
+ */
+
+/*
+ * Use -XX:-TieredCompilation to get C2 only.
+ * Use -XX:-BackgroundCompilation to wait for compilation before test exit.
+ */
+
+public class TestImpossibleIV {
+
+  static private void testMethod() {
+    int sum = 0;
+    // A unit count-down loop which has an induction variable with
+    // MIN_VALUE stride.
+    for (int i = 100000; i >= 0; i--) {
+      sum += Integer.MIN_VALUE;
+    }
+  }
+
+  public static void main(String[] args) {
+    testMethod();
+  }
+}
--- a/hotspot/test/compiler/loopopts/TestMoveStoresOutOfLoops.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/TestMoveStoresOutOfLoops.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/TestPredicateLostDependency.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/TestPredicateLostDependency.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/TestSplitIfUnswitchedLoopsEliminated.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/TestSplitIfUnswitchedLoopsEliminated.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.loopopts;
--- a/hotspot/test/compiler/loopopts/superword/ProdRed_Double.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/ProdRed_Double.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/ProdRed_Float.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/ProdRed_Float.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/ProdRed_Int.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/ProdRed_Int.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/ReductionPerf.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/ReductionPerf.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/SumRedAbsNeg_Double.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/SumRedAbsNeg_Double.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/SumRedAbsNeg_Float.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/SumRedAbsNeg_Float.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/SumRedSqrt_Double.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/SumRedSqrt_Double.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/SumRed_Double.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/SumRed_Double.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/SumRed_Float.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/SumRed_Float.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/SumRed_Int.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/SumRed_Int.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/SumRed_Long.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/SumRed_Long.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/memoryinitialization/ZeroTLABTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/memoryinitialization/ZeroTLABTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/rangechecks/PowerOf2SizedArraysChecks.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rangechecks/PowerOf2SizedArraysChecks.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rangechecks/TestRangeCheckExceptionHandlerLoopMain.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rangechecks/TestRangeCheckExceptionHandlerLoopMain.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/regalloc/TestVectorRegAlloc.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/regalloc/TestVectorRegAlloc.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.rtm.cli;
--- a/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.rtm.cli;
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.rtm.cli;
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortThresholdOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortThresholdOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestRTMLockingCalculationDelayOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMLockingCalculationDelayOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestRTMLockingThresholdOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMLockingThresholdOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestRTMRetryCountOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMRetryCountOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestRTMSpinLoopCountOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMSpinLoopCountOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMXendForLockBusyOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMXendForLockBusyOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/runtime/StackOverflowBug.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/runtime/StackOverflowBug.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/runtime/Test6778657.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/runtime/Test6778657.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/runtime/Test6826736.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/runtime/Test6826736.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/runtime/Test6859338.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/runtime/Test6859338.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/runtime/Test6892265.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/runtime/Test6892265.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/runtime/Test7088020.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/runtime/Test7088020.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/runtime/Test7196199.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/runtime/Test7196199.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/runtime/cr6891750/Test6891750.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/runtime/cr6891750/Test6891750.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/runtime/safepoints/TestRegisterRestoring.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/runtime/safepoints/TestRegisterRestoring.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,10 +19,8 @@
  * Please 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 8148490
--- a/hotspot/test/compiler/stable/TestStableMismatched.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/stable/TestStableMismatched.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/testlibrary/rtm/AbortProvoker.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/AbortProvoker.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/AbortType.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/AbortType.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/BufferOverflowProvoker.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/BufferOverflowProvoker.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/BusyLock.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/BusyLock.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/CompilableTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/CompilableTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/MemoryConflictProvoker.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/MemoryConflictProvoker.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/NestedAbortProvoker.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/NestedAbortProvoker.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/RTMLockingStatistics.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/RTMLockingStatistics.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/RTMTestBase.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/RTMTestBase.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm;
--- a/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedCPU.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedCPU.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm.predicate;
--- a/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedVM.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedVM.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 compiler.testlibrary.rtm.predicate;
--- a/hotspot/test/compiler/types/TestPhiElimination.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/types/TestPhiElimination.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/uncommontrap/UncommonTrapStackBang.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/uncommontrap/UncommonTrapStackBang.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /**
--- a/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/compiler/whitebox/GetNMethodTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/compiler/whitebox/GetNMethodTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/gc/TestCardTablePageCommits.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/TestCardTablePageCommits.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 import jdk.test.lib.JDKToolFinder;
 import jdk.test.lib.process.ProcessTools;
--- a/hotspot/test/gc/TestHumongousReferenceObject.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/TestHumongousReferenceObject.java	Tue Oct 18 17:14:09 2016 +0000
@@ -3,16 +3,16 @@
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General License version 2 only, as
+ * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
- * You should have received a copy of the GNU General License version
+ * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
--- a/hotspot/test/gc/TestSystemGC.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/TestSystemGC.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestSystemGC
--- a/hotspot/test/gc/arguments/AllocationHelper.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/AllocationHelper.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 import java.util.LinkedList;
 import java.util.concurrent.Callable;
--- a/hotspot/test/gc/arguments/FlagsValue.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/FlagsValue.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 import java.util.regex.*;
 
--- a/hotspot/test/gc/arguments/GCTypes.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/GCTypes.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* 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.
-*/
+ * 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.lang.management.GarbageCollectorMXBean;
 import java.lang.management.ManagementFactory;
--- a/hotspot/test/gc/arguments/HeapRegionUsageTool.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/HeapRegionUsageTool.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 import java.lang.management.ManagementFactory;
 import java.lang.management.MemoryPoolMXBean;
--- a/hotspot/test/gc/arguments/TestCMSHeapSizeFlags.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestCMSHeapSizeFlags.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestCMSHeapSizeFlags
--- a/hotspot/test/gc/arguments/TestG1ConcMarkStepDurationMillis.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestG1ConcMarkStepDurationMillis.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestG1ConcMarkStepDurationMillis
--- a/hotspot/test/gc/arguments/TestG1ConcRefinementThreads.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestG1ConcRefinementThreads.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestG1ConcRefinementThreads
--- a/hotspot/test/gc/arguments/TestG1HeapRegionSize.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestG1HeapRegionSize.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestG1HeapRegionSize
--- a/hotspot/test/gc/arguments/TestG1HeapSizeFlags.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestG1HeapSizeFlags.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestG1HeapSizeFlags
--- a/hotspot/test/gc/arguments/TestG1PercentageOptions.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestG1PercentageOptions.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +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.
-*/
+ * 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 TestG1PercentageOptions
--- a/hotspot/test/gc/arguments/TestInitialTenuringThreshold.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestInitialTenuringThreshold.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestInitialTenuringThreshold
--- a/hotspot/test/gc/arguments/TestMaxHeapSizeTools.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestMaxHeapSizeTools.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
--- a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +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.
-*/
+ * 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 TestMaxMinHeapFreeRatioFlags
--- a/hotspot/test/gc/arguments/TestMaxNewSize.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestMaxNewSize.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestMaxNewSize
--- a/hotspot/test/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestMinAndInitialSurvivorRatioFlags
--- a/hotspot/test/gc/arguments/TestMinInitialErgonomics.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestMinInitialErgonomics.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /**
  * @test TestMinInitialErgonomics
--- a/hotspot/test/gc/arguments/TestNewRatioFlag.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestNewRatioFlag.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestNewRatioFlag
--- a/hotspot/test/gc/arguments/TestNewSizeThreadIncrease.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestNewSizeThreadIncrease.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestNewSizeThreadIncrease
--- a/hotspot/test/gc/arguments/TestObjectTenuringFlags.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestObjectTenuringFlags.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestObjectTenuringFlags
--- a/hotspot/test/gc/arguments/TestParallelGCThreads.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestParallelGCThreads.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestParallelGCThreads
--- a/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestParallelHeapSizeFlags
--- a/hotspot/test/gc/arguments/TestSerialHeapSizeFlags.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestSerialHeapSizeFlags.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestSerialHeapSizeFlags
--- a/hotspot/test/gc/arguments/TestShrinkHeapInSteps.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestShrinkHeapInSteps.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +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.
-*/
+ * 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 TestShrinkHeapInSteps
--- a/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestSurvivorRatioFlag
--- a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestTargetSurvivorRatioFlag
--- a/hotspot/test/gc/arguments/TestUnrecognizedVMOptionsHandling.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestUnrecognizedVMOptionsHandling.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestUnrecognizedVMOptionsHandling
--- a/hotspot/test/gc/arguments/TestUseCompressedOopsErgo.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestUseCompressedOopsErgo.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestUseCompressedOopsErgo
--- a/hotspot/test/gc/arguments/TestUseCompressedOopsErgoTools.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestUseCompressedOopsErgoTools.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2015,Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 import com.sun.management.HotSpotDiagnosticMXBean;
 import com.sun.management.VMOption;
--- a/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestVerifyBeforeAndAfterGCFlags
--- a/hotspot/test/gc/cms/DisableResizePLAB.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/cms/DisableResizePLAB.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test DisableResizePLAB
--- a/hotspot/test/gc/cms/TestCMSScavengeBeforeRemark.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/cms/TestCMSScavengeBeforeRemark.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestCMSScavengeBeforeRemark
--- a/hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please 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 gc.g1.humongousObjects;
 
 import gc.testlibrary.Helpers;
--- a/hotspot/test/gc/g1/humongousObjects/G1SampleClass.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/G1SampleClass.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015,2016 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
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestNoAllocationsInHRegions.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/TestNoAllocationsInHRegions.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.g1.humongousObjects.objectGraphTest;
--- a/hotspot/test/gc/logging/TestPrintReferences.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/logging/TestPrintReferences.java	Tue Oct 18 17:14:09 2016 +0000
@@ -41,7 +41,7 @@
     OutputAnalyzer output = new OutputAnalyzer(pb_enabled.start());
 
     String countRegex = "[0-9]+ refs";
-    String timeRegex = "\\([0-9]+[.,][0-9]+s, [0-9]+[.,][0-9]+s\\) [0-9]+[.,][0-9]+ms";
+    String timeRegex = "[0-9]+[.,][0-9]+ms";
 
     output.shouldMatch(".* GC\\([0-9]+\\) SoftReference " + timeRegex + "\n" +
                        ".* GC\\([0-9]+\\) WeakReference " + timeRegex + "\n" +
--- a/hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 gc.logging;
--- a/hotspot/test/gc/startup_warnings/TestCMS.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/startup_warnings/TestCMS.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,31 +1,31 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
 * @test TestCMS
 * @key gc
-* @bug 8006398
-* @summary Test that CMS does not print a warning message
+* @bug 8006398 8155948
+* @summary Test that CMS prints a warning message only for a commercial build
 * @library /test/lib
 * @modules java.base/jdk.internal.misc
 *          java.management
@@ -33,16 +33,27 @@
 
 import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.process.OutputAnalyzer;
-
+import jdk.test.lib.BuildHelper;
 
 public class TestCMS {
 
-  public static void main(String args[]) throws Exception {
-    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseConcMarkSweepGC", "-version");
+  public static void runTest(String[] args) throws Exception {
+    boolean isCommercial = BuildHelper.isCommercialBuild();
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
     OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldNotContain("deprecated");
+    if (isCommercial) {
+      output.shouldContain("deprecated");
+    } else {
+      output.shouldNotContain("deprecated");
+    }
     output.shouldNotContain("error");
     output.shouldHaveExitValue(0);
   }
 
+  public static void main(String args[]) throws Exception {
+    runTest(new String[] {"-XX:+UseConcMarkSweepGC", "-version"});
+    runTest(new String[] {"-Xconcgc", "-version"});
+    runTest(new String[] {"-Xnoconcgc", "-version"});
+  }
+
 }
--- a/hotspot/test/gc/startup_warnings/TestDefNewCMS.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/startup_warnings/TestDefNewCMS.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
 * @test TestDefNewCMS
--- a/hotspot/test/gc/startup_warnings/TestG1.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/startup_warnings/TestG1.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
 * @test TestG1
--- a/hotspot/test/gc/startup_warnings/TestParNewCMS.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/startup_warnings/TestParNewCMS.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
 * @test TestParNewCMS
--- a/hotspot/test/gc/startup_warnings/TestParNewSerialOld.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/startup_warnings/TestParNewSerialOld.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
 * @test TestParNewSerialOld
--- a/hotspot/test/gc/startup_warnings/TestParallelGC.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/startup_warnings/TestParallelGC.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
 * @test TestParallelGC
--- a/hotspot/test/gc/startup_warnings/TestParallelScavengeSerialOld.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/startup_warnings/TestParallelScavengeSerialOld.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
 * @test TestParallelScavengeSerialOld
--- a/hotspot/test/gc/startup_warnings/TestSerialGC.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/startup_warnings/TestSerialGC.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
 * @test TestSerialGC
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/startup_warnings/TestUseAutoGCSelectPolicy.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test TestUseAutoGCSelectPolicy
+ * @key gc
+ * @bug 8166461 8167494
+ * @summary Test that UseAutoGCSelectPolicy and AutoGCSelectPauseMillis do print a warning message
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ */
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class TestUseAutoGCSelectPolicy {
+
+  public static void main(String args[]) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseAutoGCSelectPolicy", "-XX:AutoGCSelectPauseMillis=3000", "-version");
+    OutputAnalyzer output = new OutputAnalyzer(pb.start());
+    output.shouldContain("UseAutoGCSelectPolicy was deprecated in version 9.0");
+    output.shouldContain("AutoGCSelectPauseMillis was deprecated in version 9.0");
+    output.shouldNotContain("error");
+    output.shouldHaveExitValue(0);
+  }
+}
--- a/hotspot/test/gc/stress/TestGCOld.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/stress/TestGCOld.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,25 +1,25 @@
 /*
-* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* This code is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License version 2 only, as
-* published by the Free Software Foundation.
-*
-* This code is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-* version 2 for more details (a copy is included in the LICENSE file that
-* accompanied this code).
-*
-* You should have received a copy of the GNU General Public License version
-* 2 along with this work; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
-* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test TestGCOld
--- a/hotspot/test/gc/testlibrary/Helpers.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/gc/testlibrary/Helpers.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 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
@@ -19,7 +19,6 @@
  * Please 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 gc.testlibrary;
--- a/hotspot/test/native/GTestWrapper.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/GTestWrapper.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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
--- a/hotspot/test/native/gtestLauncher.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/gtestLauncher.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 #include "prims/jni.h"
--- a/hotspot/test/native/logging/logTestFixture.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/logTestFixture.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "logTestFixture.hpp"
 #include "logTestUtils.inline.hpp"
--- a/hotspot/test/native/logging/logTestFixture.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/logTestFixture.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "unittest.hpp"
 #include "utilities/globalDefinitions.hpp"
 
--- a/hotspot/test/native/logging/logTestUtils.inline.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/logTestUtils.inline.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "logging/log.hpp"
 #include "logging/logConfiguration.hpp"
 #include "logging/logStream.hpp"
--- a/hotspot/test/native/logging/test_gcTraceTime.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/test_gcTraceTime.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -48,8 +48,8 @@
   }
 
   const char* expected[] = {
-    "[gc,start", "] Test GC (Allocation Failure) (", "s)",
-    "[gc", "] Test GC (Allocation Failure) ", "M) (", "s, ", "s) ", "ms",
+    "[gc,start", "] Test GC (Allocation Failure)",
+    "[gc", "] Test GC (Allocation Failure) ", "M) ", "ms",
     NULL
   };
   EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected));
@@ -71,8 +71,8 @@
   }
 
   const char* expected[] = {
-    "[gc,ref,start", "] Test GC (Allocation Failure) (", "s)",
-    "[gc,ref", "] Test GC (Allocation Failure) ", "M) (", "s, ", "s) ", "ms",
+    "[gc,ref,start", "] Test GC (Allocation Failure)",
+    "[gc,ref", "] Test GC (Allocation Failure) ", "M) ", "ms",
     NULL
   };
   EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected));
@@ -92,17 +92,17 @@
   }
 
   const char* expected[] = {
-    // [2.975s][debug][gc,start] Test GC (Allocation Failure) (2.975s)
-    "[gc,start", "] Test GC (Allocation Failure) (", "s)",
-    // [2.975s][debug][gc      ] Test GC (Allocation Failure) (2.975s, 2.975s) 0.026ms
-    "[gc", "] Test GC (Allocation Failure) ", "(", "s, ", "s) ", "ms",
+    // [2.975s][debug][gc,start] Test GC (Allocation Failure)
+    "[gc,start", "] Test GC (Allocation Failure)",
+    // [2.975s][debug][gc      ] Test GC (Allocation Failure) 0.026ms
+    "[gc", "] Test GC (Allocation Failure) ", "ms",
     NULL
   };
   EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected));
 
   const char* not_expected[] = {
-      // [2.975s][debug][gc      ] Test GC 59M->59M(502M) (2.975s, 2.975s) 0.026ms
-      "[gc", "] Test GC ", "M) (", "s, ", "s) ", "ms",
+      // [2.975s][debug][gc      ] Test GC 59M->59M(502M) 0.026ms
+      "[gc", "] Test GC ", "M) ", "ms",
   };
   EXPECT_FALSE(file_contains_substrings_in_order(TestLogFileName, not_expected));
 }
@@ -123,10 +123,10 @@
   }
 
   const char* expected[] = {
-    // [2.975s][debug][gc,start] Test GC (2.975s)
-    "[gc,start", "] Test GC ", "s)",
-    // [2.975s][debug][gc      ] Test GC 59M->59M(502M) (2.975s, 2.975s) 0.026ms
-    "[gc", "] Test GC ", "M) (", "s, ", "s) ", "ms",
+    // [2.975s][debug][gc,start] Test GC
+    "[gc,start", "] Test GC",
+    // [2.975s][debug][gc      ] Test GC 59M->59M(502M) 0.026ms
+    "[gc", "] Test GC ", "M) ", "ms",
     NULL
   };
   EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected));
@@ -146,17 +146,17 @@
   }
 
   const char* expected[] = {
-    // [2.975s][debug][gc,start] Test GC (2.975s)
-    "[gc,start", "] Test GC ", "s)",
-    // [2.975s][debug][gc      ] Test GC (2.975s, 2.975s) 0.026ms
-    "[gc", "] Test GC ", "(", "s, ", "s) ", "ms",
+    // [2.975s][debug][gc,start] Test GC
+    "[gc,start", "] Test GC",
+    // [2.975s][debug][gc      ] Test GC 0.026ms
+    "[gc", "] Test GC ", "ms",
     NULL
   };
   EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected));
 
   const char* not_expected[] = {
-      // [2.975s][debug][gc      ] Test GC 59M->59M(502M) (2.975s, 2.975s) 0.026ms
-      "[gc", "] Test GC ", "M) (", "s, ", "s) ", "ms",
+      // [2.975s][debug][gc      ] Test GC 59M->59M(502M) 0.026ms
+      "[gc", "] Test GC ", "M) ", "ms",
   };
   EXPECT_FALSE(file_contains_substrings_in_order(TestLogFileName, not_expected));
 }
--- a/hotspot/test/native/logging/test_logConfiguration.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/test_logConfiguration.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "logTestFixture.hpp"
 #include "logTestUtils.inline.hpp"
--- a/hotspot/test/native/logging/test_logDecorations.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/test_logDecorations.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "logging/logDecorations.hpp"
 #include "logging/logTagSet.hpp"
--- a/hotspot/test/native/logging/test_logDecorators.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/test_logDecorators.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "logging/logDecorators.hpp"
 #include "unittest.hpp"
--- a/hotspot/test/native/logging/test_logFileOutput.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/test_logFileOutput.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "logTestUtils.inline.hpp"
 #include "logging/logFileOutput.hpp"
--- a/hotspot/test/native/logging/test_logLevel.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/test_logLevel.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "logging/logLevel.hpp"
 #include "unittest.hpp"
--- a/hotspot/test/native/logging/test_logOutputList.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/test_logOutputList.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "logging/logLevel.hpp"
 #include "logging/logOutput.hpp"
--- a/hotspot/test/native/logging/test_logTag.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/test_logTag.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "logging/logTag.hpp"
 #include "unittest.hpp"
--- a/hotspot/test/native/logging/test_logTagLevelExpression.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/test_logTagLevelExpression.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "logging/logLevel.hpp"
 #include "logging/logTagLevelExpression.hpp"
--- a/hotspot/test/native/logging/test_logTagSet.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/logging/test_logTagSet.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -10,7 +10,7 @@
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
- * ac_heapanied this code).
+ * accompanied this code).
  *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "logging/logLevel.hpp"
 #include "logging/logOutput.hpp"
--- a/hotspot/test/native/runtime/test_arguments.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/runtime/test_arguments.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
+
 #include "precompiled.hpp"
 #include "runtime/arguments.hpp"
 #include "unittest.hpp"
--- a/hotspot/test/native/runtime/test_classLoader.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/runtime/test_classLoader.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 #include "precompiled.hpp"
--- a/hotspot/test/native/runtime/test_globals.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/runtime/test_globals.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 #include "precompiled.hpp"
--- a/hotspot/test/native/runtime/test_os.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/runtime/test_os.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 #include "precompiled.hpp"
--- a/hotspot/test/native/unittest.hpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/unittest.hpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 #ifndef UNITTEST_HPP
--- a/hotspot/test/native/utilities/test_bitMap_setops.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/utilities/test_bitMap_setops.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 #include "precompiled.hpp"
--- a/hotspot/test/native/utilities/test_quicksort.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/native/utilities/test_quicksort.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 #include "precompiled.hpp"
--- a/hotspot/test/runtime/7116786/Test7116786.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/7116786/Test7116786.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/7167069/PrintAsFlag.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/7167069/PrintAsFlag.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/BootClassAppendProp/BootClassPathAppend.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/BootClassAppendProp/BootClassPathAppend.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * 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
--- a/hotspot/test/runtime/BootClassAppendProp/SunBootClassPath.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/BootClassAppendProp/SunBootClassPath.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * 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
--- a/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/Final/TestPutMain.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/Final/TestPutMain.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/InternalApi/ThreadCpuTimesDeadlock.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/InternalApi/ThreadCpuTimesDeadlock.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/MirrorFrame/Asmator.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/MirrorFrame/Asmator.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 import jdk.internal.org.objectweb.asm.*;
--- a/hotspot/test/runtime/MirrorFrame/Test8003720.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/MirrorFrame/Test8003720.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/MirrorFrame/Victim.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/MirrorFrame/Victim.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 public class Victim implements Test8003720.CallMe {
--- a/hotspot/test/runtime/MirrorFrame/VictimClassLoader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/MirrorFrame/VictimClassLoader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 public class VictimClassLoader extends ClassLoader {
--- a/hotspot/test/runtime/SelectionResolution/AbstractMethodErrorTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/AbstractMethodErrorTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-*
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Builder.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Builder.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ByteCodeClassLoader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ByteCodeClassLoader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ClassBuilder.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ClassBuilder.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ClassConstruct.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/ClassConstruct.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Clazz.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Clazz.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/HierarchyShape.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/HierarchyShape.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Interface.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Interface.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Method.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/Method.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/MethodData.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/MethodData.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 selectionresolution;
--- a/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/TestBuilder.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SelectionResolution/classes/selectionresolution/TestBuilder.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 selectionresolution;
--- a/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java	Tue Oct 18 17:14:09 2016 +0000
@@ -12,8 +12,7 @@
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
- * You should have received a copy of the GNU General Public License
- * version
+ * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
@@ -21,6 +20,7 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 /*
  * @test
  * @bug 8059510
--- a/hotspot/test/runtime/StackGuardPages/exeinvoke.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/StackGuardPages/exeinvoke.c	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /* This code tests the fact that we actually remove stack guard page when calling
--- a/hotspot/test/runtime/Throwable/StackTraceLogging.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/Throwable/StackTraceLogging.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/classFileParserBug/AnnotationTag.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/classFileParserBug/AnnotationTag.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/classFileParserBug/BadInitMethod.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/classFileParserBug/BadInitMethod.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/classFileParserBug/BadNameAndType.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/classFileParserBug/BadNameAndType.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/classFileParserBug/EnclosingMethod.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/classFileParserBug/EnclosingMethod.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/classFileParserBug/InitInInterface.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/classFileParserBug/InitInInterface.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/classFileParserBug/TestBadClassName.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/classFileParserBug/TestBadClassName.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/lambda-features/InvokespecialInterface.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/lambda-features/InvokespecialInterface.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/lambda-features/PublicStaticInterfaceMethodHandling.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/lambda-features/PublicStaticInterfaceMethodHandling.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/lambda-features/TestConcreteClassWithAbstractMethod.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/lambda-features/TestConcreteClassWithAbstractMethod.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/lambda-features/TestInterfaceInit.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/lambda-features/TestInterfaceInit.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/lambda-features/TestInterfaceOrder.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/lambda-features/TestInterfaceOrder.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/lambda-features/TestStaticandInstance.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/lambda-features/TestStaticandInstance.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/logging/BiasedLockingTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/BiasedLockingTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/CompressedOopsTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/CompressedOopsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/DefaultMethodsTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/DefaultMethodsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/ExceptionsTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/ExceptionsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/ItablesTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/ItablesTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/ModulesTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/ModulesTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/MonitorInflationTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/MonitorInflationTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/OsCpuLoggingTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/OsCpuLoggingTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/SafepointCleanupTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/SafepointCleanupTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/SafepointTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/SafepointTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/StartupTimeTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/StartupTimeTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/VMOperationTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/VMOperationTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/VerificationTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/VerificationTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/VtablesTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/VtablesTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/p1/A.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/p1/A.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/p1/C.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/p1/C.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/logging/p2/D.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/logging/p2/D.java	Tue Oct 18 17:14:09 2016 +0000
@@ -8,7 +8,7 @@
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
--- a/hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -67,10 +67,11 @@
     }
 
     public static void main(String[] args) throws Exception {
-        testOption("--add-modules", "java.sqlx", "jdk.module.addmods", "java.lang.module.ResolutionException");
+        testOption("--add-modules", "java.sqlx", "jdk.module.addmods.0", "java.lang.module.ResolutionException");
         testOption("--limit-modules", "java.sqlx", "jdk.module.limitmods", "java.lang.module.ResolutionException");
-        testOption("--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "java.lang.RuntimeException");
-        testOption("--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0", "java.lang.RuntimeException");
+        testOption("--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "WARNING: Unknown module: xyzz");
+        testOption("--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0",
+                   "WARNING: package xyzz not in java.base");
         testOption("--patch-module", "=d", "jdk.module.patch.0", "IllegalArgumentException");
     }
 }
--- a/hotspot/test/runtime/stackMapCheck/StackMapCheck.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/stackMapCheck/StackMapCheck.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,26 +1,25 @@
- /*
-  * 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.
-  *
-  */
+/*
+ * 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.
+ */
 
 /*
  * @test
--- a/hotspot/test/runtime/verifier/PrimIntArray.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/verifier/PrimIntArray.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 /*
--- a/hotspot/test/runtime/verifier/TraceClassRes.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/runtime/verifier/TraceClassRes.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * 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
--- a/hotspot/test/sanity/ExecuteInternalVMTests.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/sanity/ExecuteInternalVMTests.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,7 +19,6 @@
  * Please 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 ExecuteInternalVMTests
--- a/hotspot/test/serviceability/dcmd/vm/DynLibsTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/serviceability/dcmd/vm/DynLibsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,11 +1,3 @@
-import org.testng.annotations.Test;
-import org.testng.Assert;
-
-import jdk.test.lib.process.OutputAnalyzer;
-import jdk.test.lib.Platform;
-import jdk.test.lib.dcmd.CommandExecutor;
-import jdk.test.lib.dcmd.JMXExecutor;
-
 /*
  * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -29,6 +21,14 @@
  * questions.
  */
 
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.Platform;
+import jdk.test.lib.dcmd.CommandExecutor;
+import jdk.test.lib.dcmd.JMXExecutor;
+
 /*
  * @test
  * @summary Test of VM.dynlib diagnostic command via MBean
--- a/hotspot/test/serviceability/jvmti/TestLambdaFormRetransformation.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/serviceability/jvmti/TestLambdaFormRetransformation.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
--- a/hotspot/test/serviceability/logging/TestLogRotation.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/serviceability/logging/TestLogRotation.java	Tue Oct 18 17:14:09 2016 +0000
@@ -41,8 +41,8 @@
     public static void main(String[] args) throws Exception {
 
         long sizeOfLog = Long.parseLong(args[0]);
-        long lines = sizeOfLog / 80;
-        // full.GC generates ad least 1-line which is not shorter then 80 chars
+        long lines = sizeOfLog / 70;
+        // full.GC generates ad least 1-line which is not shorter then 70 chars
         // for some GC 2 shorter lines are generated
         for (long i = 0; i < lines; i++) {
             System.gc();
--- a/hotspot/test/serviceability/tmtools/share/common/TmTool.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/hotspot/test/serviceability/tmtools/share/common/TmTool.java	Tue Oct 18 17:14:09 2016 +0000
@@ -19,8 +19,8 @@
  * Please 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 common;
 
 import java.nio.file.Path;
--- a/jaxp/.hgtags	Wed Oct 12 12:24:41 2016 +0000
+++ b/jaxp/.hgtags	Tue Oct 18 17:14:09 2016 +0000
@@ -380,3 +380,5 @@
 f695240370c77a25fed88225a392e7d530cb4d78 jdk-9+135
 f1eafcb0eb7182b937bc93f214d8cabd01ec4d59 jdk-9+136
 a8d5fe567ae72b4931040e59dd4478363f9004f5 jdk-9+137
+69c3b12ba75b2e321dee731ac545e7fbff608451 jdk-9+138
+8991d71c5316bde259e6a417c1199b008ca3cdf0 jdk-9+139
--- a/jaxp/ASSEMBLY_EXCEPTION	Wed Oct 12 12:24:41 2016 +0000
+++ b/jaxp/ASSEMBLY_EXCEPTION	Tue Oct 18 17:14:09 2016 +0000
@@ -1,27 +1,27 @@
 
 OPENJDK ASSEMBLY EXCEPTION
 
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
 only ("GPL2"), with the following clarification and special exception.
 
     Linking this OpenJDK Code statically or dynamically with other code
     is making a combined work based on this library.  Thus, the terms
     and conditions of GPL2 cover the whole combination.
 
-    As a special exception, Sun gives you permission to link this
-    OpenJDK Code with certain code licensed by Sun as indicated at
+    As a special exception, Oracle gives you permission to link this
+    OpenJDK Code with certain code licensed by Oracle as indicated at
     http://openjdk.java.net/legal/exception-modules-2007-05-08.html
     ("Designated Exception Modules") to produce an executable,
     regardless of the license terms of the Designated Exception Modules,
     and to copy and distribute the resulting executable under GPL2,
     provided that the Designated Exception Modules continue to be
-    governed by the licenses under which they were offered by Sun.
+    governed by the licenses under which they were offered by Oracle.
 
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception).  If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception).  If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java	Tue Oct 18 17:14:09 2016 +0000
@@ -52,7 +52,7 @@
     private SymbolTable fSymbolTable            = null;
     private Locale fLocale                      = null;
 
-    private ArrayList<String> fIdList;
+    private HashSet<String> fIds;
     private ArrayList<String> fIdRefList;
 
     //
@@ -97,7 +97,7 @@
             String key;
             for (int i = 0; i < fIdRefList.size(); i++) {
                 key = fIdRefList.get(i);
-                if (fIdList == null || !fIdList.contains(key)) {
+                if (fIds == null || !fIds.contains(key)) {
                     if (missingIDs == null) {
                         missingIDs = new HashSet();
                     }
@@ -112,7 +112,7 @@
         fExtraChecking = true;
         fFacetChecking = true;
         fNamespaces = true;
-        fIdList = null;
+        fIds = null;
         fIdRefList = null;
         fEntityState = null;
         fNamespaceContext = null;
@@ -126,7 +126,7 @@
      * the two tables.
      */
     public void resetIDTables() {
-        fIdList = null;
+        fIds = null;
         fIdRefList = null;
     }
 
@@ -168,12 +168,11 @@
 
     // id
     public boolean isIdDeclared(String name) {
-        if (fIdList == null) return false;
-        return fIdList.contains(name);
+        return fIds != null && fIds.contains(name);
     }
     public void addId(String name) {
-        if (fIdList == null) fIdList = new ArrayList();
-        fIdList.add(name);
+        if (fIds == null) fIds = new HashSet<>();
+        fIds.add(name);
     }
 
     // idref
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
 
 package com.sun.xml.internal.stream.writers;
 
+import com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl;
+import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import javax.xml.XMLConstants;
@@ -57,7 +59,7 @@
  * Change StringBuffer to StringBuilder, when JDK 1.5 will be minimum requirement for SJSXP.
  */
 
-public class XMLDOMWriterImpl implements XMLStreamWriter  {
+public class XMLDOMWriterImpl implements XMLStreamWriterBase  {
 
 
     private Document ownerDoc = null;
@@ -552,7 +554,7 @@
      * @throws javax.xml.stream.XMLStreamException {@inheritDoc}
      */
     public void writeStartDocument(String version) throws XMLStreamException {
-        ownerDoc.setXmlVersion(version);
+        writeStartDocument(null, version, false, false);
     }
 
     /**
@@ -563,8 +565,20 @@
      * @throws javax.xml.stream.XMLStreamException {@inheritDoc}
      */
     public void writeStartDocument(String encoding, String version) throws XMLStreamException {
+        writeStartDocument(encoding, version, false, false);
+    }
+
+    @Override
+    public void writeStartDocument(String encoding, String version, boolean standalone, boolean standaloneSet) throws XMLStreamException {
+        if (encoding != null && ownerDoc.getClass().isAssignableFrom(DocumentImpl.class)) {
+            ((DocumentImpl)ownerDoc).setXmlEncoding(encoding);
+        }
+
         ownerDoc.setXmlVersion(version);
-        //TODO: What to do with encoding.-Venu
+
+        if (standaloneSet) {
+            ownerDoc.setXmlStandalone(standalone);
+        }
     }
 
     /**
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLEventWriterImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLEventWriterImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,14 +49,14 @@
 public class XMLEventWriterImpl implements XMLEventWriter{
 
     //delegate everything to XMLStreamWriter..
-    private XMLStreamWriter fStreamWriter ;
+    private final XMLStreamWriterBase fStreamWriter ;
     private static final boolean DEBUG = false;
     /**
      *
      * @param streamWriter
      */
     public XMLEventWriterImpl(XMLStreamWriter streamWriter){
-        fStreamWriter = streamWriter;
+        fStreamWriter = (XMLStreamWriterBase)streamWriter;
     }
 
     /**
@@ -89,7 +89,8 @@
                 StartDocument startDocument = (StartDocument)xMLEvent ;
                 if (DEBUG)System.out.println("Adding StartDocument = " + startDocument.toString());
                 try {
-                   fStreamWriter.writeStartDocument(startDocument.getCharacterEncodingScheme(), startDocument.getVersion());
+                   fStreamWriter.writeStartDocument(startDocument.getCharacterEncodingScheme(), startDocument.getVersion(),
+                           startDocument.isStandalone(), startDocument.standaloneSet());
                 }catch(XMLStreamException e) {
                     fStreamWriter.writeStartDocument(startDocument.getVersion());
                 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterBase.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,47 @@
+/*
+ * 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 com.sun.xml.internal.stream.writers;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * Base class for shared methods among XMLStreamWriter implementations.
+ */
+public interface XMLStreamWriterBase extends XMLStreamWriter {
+    /**
+     * Writes the XML declaration.
+     *
+     * @param encoding the specified encoding
+     * @param version the specified version
+     * @param standalone the flag indicating whether it is standalone
+     * @param standaloneSet the flag indicating whether the standalone attribute is set
+     * @throws XMLStreamException in case of an IOException
+     */
+    public void writeStartDocument(String encoding, String version,
+            boolean standalone, boolean standaloneSet)
+            throws XMLStreamException;
+}
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -71,7 +71,7 @@
  * @author Santiago.Pericas-Geertsen@sun.com
  * @author Sunitha.Reddy@sun.com
  */
-public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamWriter {
+public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamWriterBase {
 
     public static final String START_COMMENT = "<!--";
     public static final String END_COMMENT = "-->";
@@ -1112,90 +1112,55 @@
     }
 
     /**
-     * @throws XMLStreamException
+     * Writes the XML declaration.
+     *
+     * @throws XMLStreamException in case of an IOException
      */
     public void writeStartDocument() throws XMLStreamException {
-        try {
-            fWriter.write(DEFAULT_XMLDECL);
-        } catch (IOException ex) {
-            throw new XMLStreamException(ex);
-        }
+        writeStartDocument(null, null, false, false);
     }
 
     /**
-     * @param version
-     * @throws XMLStreamException
+     * Writes the XML declaration.
+     *
+     * @param version the specified version
+     * @throws XMLStreamException in case of an IOException
      */
     public void writeStartDocument(String version) throws XMLStreamException {
-        try {
-            if ((version == null) || version.equals("")) {
-                writeStartDocument();
-
-                return;
-            }
-
-            fWriter.write("<?xml version=\"");
-            fWriter.write(version);
-            fWriter.write("\"");
-
-            //fWriter.write(DEFAULT_ENCODING);
-            fWriter.write("?>");
-        } catch (IOException ex) {
-            throw new XMLStreamException(ex);
-        }
+        writeStartDocument(null, version, false, false);
     }
 
     /**
-     * @param encoding
-     * @param version
-     * @throws XMLStreamException
+     * Writes the XML declaration.
+     *
+     * @param encoding the specified encoding
+     * @param version the specified version
+     * @throws XMLStreamException in case of an IOException
      */
+    @Override
     public void writeStartDocument(String encoding, String version)
         throws XMLStreamException {
-        //Revisit : What about standalone ?
-        try {
-            if ((encoding == null) && (version == null)) {
-                writeStartDocument();
+        writeStartDocument(encoding, version, false, false);
+    }
 
-                return;
-            }
+    @Override
+    public void writeStartDocument(String encoding, String version,
+            boolean standalone, boolean standaloneSet)
+        throws XMLStreamException {
 
-            if (encoding == null) {
-                writeStartDocument(version);
-
+        try {
+            if ((encoding == null || encoding.length() == 0)
+                    && (version == null || version.length() == 0)
+                    && (!standaloneSet)) {
+                fWriter.write(DEFAULT_XMLDECL);
                 return;
             }
 
-            String streamEncoding = null;
-            if (fWriter instanceof OutputStreamWriter) {
-                streamEncoding = ((OutputStreamWriter) fWriter).getEncoding();
-            }
-            else if (fWriter instanceof UTF8OutputStreamWriter) {
-                streamEncoding = ((UTF8OutputStreamWriter) fWriter).getEncoding();
-            }
-            else if (fWriter instanceof XMLWriter) {
-                streamEncoding = ((OutputStreamWriter) ((XMLWriter)fWriter).getWriter()).getEncoding();
+            // Verify the encoding before writing anything
+            if (encoding != null && !encoding.equals("")) {
+                verifyEncoding(encoding);
             }
 
-            if (streamEncoding != null && !streamEncoding.equalsIgnoreCase(encoding)) {
-                // If the equality check failed, check for charset encoding aliases
-                boolean foundAlias = false;
-                Set aliases = Charset.forName(encoding).aliases();
-                for (Iterator it = aliases.iterator(); !foundAlias && it.hasNext(); ) {
-                    if (streamEncoding.equalsIgnoreCase((String) it.next())) {
-                        foundAlias = true;
-                    }
-                }
-                // If no alias matches the encoding name, then report error
-                if (!foundAlias) {
-                    throw new XMLStreamException("Underlying stream encoding '"
-                            + streamEncoding
-                            + "' and input paramter for writeStartDocument() method '"
-                            + encoding + "' do not match.");
-                }
-            }
-
-
             fWriter.write("<?xml version=\"");
 
             if ((version == null) || version.equals("")) {
@@ -1204,11 +1169,20 @@
                 fWriter.write(version);
             }
 
-            if (!encoding.equals("")) {
+            if (encoding != null && !encoding.equals("")) {
                 fWriter.write("\" encoding=\"");
                 fWriter.write(encoding);
             }
 
+            if (standaloneSet) {
+                fWriter.write("\" standalone=\"");
+                if (standalone) {
+                    fWriter.write("yes");
+                } else {
+                    fWriter.write("no");
+                }
+            }
+
             fWriter.write("\"?>");
         } catch (IOException ex) {
             throw new XMLStreamException(ex);
@@ -1216,6 +1190,45 @@
     }
 
     /**
+     * Verifies that the encoding is consistent between the underlying encoding
+     * and that specified.
+     *
+     * @param encoding the specified encoding
+     * @throws XMLStreamException if they do not match
+     */
+    private void verifyEncoding(String encoding) throws XMLStreamException {
+
+        String streamEncoding = null;
+        if (fWriter instanceof OutputStreamWriter) {
+            streamEncoding = ((OutputStreamWriter) fWriter).getEncoding();
+        }
+        else if (fWriter instanceof UTF8OutputStreamWriter) {
+            streamEncoding = ((UTF8OutputStreamWriter) fWriter).getEncoding();
+        }
+        else if (fWriter instanceof XMLWriter) {
+            streamEncoding = ((OutputStreamWriter) ((XMLWriter)fWriter).getWriter()).getEncoding();
+        }
+
+        if (streamEncoding != null && !streamEncoding.equalsIgnoreCase(encoding)) {
+            // If the equality check failed, check for charset encoding aliases
+            boolean foundAlias = false;
+            Set aliases = Charset.forName(encoding).aliases();
+            for (Iterator it = aliases.iterator(); !foundAlias && it.hasNext(); ) {
+                if (streamEncoding.equalsIgnoreCase((String) it.next())) {
+                    foundAlias = true;
+                }
+            }
+            // If no alias matches the encoding name, then report error
+            if (!foundAlias) {
+                throw new XMLStreamException("Underlying stream encoding '"
+                        + streamEncoding
+                        + "' and input paramter for writeStartDocument() method '"
+                        + encoding + "' do not match.");
+            }
+        }
+    }
+
+    /**
      * @param localName
      * @throws XMLStreamException
      */
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -20,21 +20,29 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package stream.XMLStreamWriterTest;
 
 import java.io.StringWriter;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventWriter;
 
 import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.transform.dom.DOMResult;
 
 import org.testng.Assert;
 import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
+import org.w3c.dom.Document;
 
 /*
  * @test
- * @bug 6347190
+ * @bug 6347190 8139584
  * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
  * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.XMLStreamWriterTest
  * @run testng/othervm stream.XMLStreamWriterTest.XMLStreamWriterTest
@@ -42,6 +50,48 @@
  */
 @Listeners({jaxp.library.BasePolicy.class})
 public class XMLStreamWriterTest {
+    /**
+     * @bug 8139584
+     * Verifies that the resulting XML contains the standalone setting.
+     */
+    @Test
+    public void testCreateStartDocument() throws XMLStreamException {
+
+        StringWriter stringWriter = new StringWriter();
+        XMLOutputFactory out = XMLOutputFactory.newInstance();
+        XMLEventFactory eventFactory = XMLEventFactory.newInstance();
+
+        XMLEventWriter eventWriter = out.createXMLEventWriter(stringWriter);
+
+        XMLEvent event = eventFactory.createStartDocument("iso-8859-15", "1.0", true);
+        eventWriter.add(event);
+        eventWriter.flush();
+        Assert.assertTrue(stringWriter.toString().contains("encoding=\"iso-8859-15\""));
+        Assert.assertTrue(stringWriter.toString().contains("version=\"1.0\""));
+        Assert.assertTrue(stringWriter.toString().contains("standalone=\"yes\""));
+    }
+
+    /**
+     * @bug 8139584
+     * Verifies that the resulting XML contains the standalone setting.
+     */
+    @Test
+    public void testCreateStartDocument_DOMWriter()
+            throws ParserConfigurationException, XMLStreamException {
+
+        XMLOutputFactory xof = XMLOutputFactory.newInstance();
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        Document doc = db.newDocument();
+        XMLEventWriter eventWriter = xof.createXMLEventWriter(new DOMResult(doc));
+        XMLEventFactory eventFactory = XMLEventFactory.newInstance();
+        XMLEvent event = eventFactory.createStartDocument("iso-8859-15", "1.0", true);
+        eventWriter.add(event);
+        eventWriter.flush();
+        Assert.assertEquals(doc.getXmlEncoding(), "iso-8859-15");
+        Assert.assertEquals(doc.getXmlVersion(), "1.0");
+        Assert.assertTrue(doc.getXmlStandalone());
+    }
 
     /**
      * Test of main method, of class TestXMLStreamWriter.
--- a/jaxws/.hgtags	Wed Oct 12 12:24:41 2016 +0000
+++ b/jaxws/.hgtags	Tue Oct 18 17:14:09 2016 +0000
@@ -383,3 +383,5 @@
 22631824f55128a7ab6605493b3001a37af6a168 jdk-9+135
 09ec13a99f50a4a346180d1e3b0fd8bc1ee399ce jdk-9+136
 297c16d401c534cb879809d2a746d21ca99d2954 jdk-9+137
+7d3a8f52b124db26ba8425c2931b748dd9d2791b jdk-9+138
+7a7aadf3c4500cc273c889aa1172d4fe3844bb6b jdk-9+139
--- a/jaxws/ASSEMBLY_EXCEPTION	Wed Oct 12 12:24:41 2016 +0000
+++ b/jaxws/ASSEMBLY_EXCEPTION	Tue Oct 18 17:14:09 2016 +0000
@@ -1,27 +1,27 @@
 
 OPENJDK ASSEMBLY EXCEPTION
 
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
 only ("GPL2"), with the following clarification and special exception.
 
     Linking this OpenJDK Code statically or dynamically with other code
     is making a combined work based on this library.  Thus, the terms
     and conditions of GPL2 cover the whole combination.
 
-    As a special exception, Sun gives you permission to link this
-    OpenJDK Code with certain code licensed by Sun as indicated at
+    As a special exception, Oracle gives you permission to link this
+    OpenJDK Code with certain code licensed by Oracle as indicated at
     http://openjdk.java.net/legal/exception-modules-2007-05-08.html
     ("Designated Exception Modules") to produce an executable,
     regardless of the license terms of the Designated Exception Modules,
     and to copy and distribute the resulting executable under GPL2,
     provided that the Designated Exception Modules continue to be
-    governed by the licenses under which they were offered by Sun.
+    governed by the licenses under which they were offered by Oracle.
 
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception).  If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception).  If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/jdk/.hgtags	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/.hgtags	Tue Oct 18 17:14:09 2016 +0000
@@ -380,3 +380,5 @@
 021369229cfd0b5feb76834b2ea498f47f43c0f3 jdk-9+135
 54c5931849a33a363e03fdffa141503f5cc4779d jdk-9+136
 e72df94364e3686e7d62059ce0d6b187b82da713 jdk-9+137
+665096863382bf23ce891307cf2a7511e77c1c88 jdk-9+138
+5518ac2f2ead5e594bd983f2047178136aafdfd0 jdk-9+139
--- a/jdk/ASSEMBLY_EXCEPTION	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/ASSEMBLY_EXCEPTION	Tue Oct 18 17:14:09 2016 +0000
@@ -1,27 +1,27 @@
 
 OPENJDK ASSEMBLY EXCEPTION
 
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
 only ("GPL2"), with the following clarification and special exception.
 
     Linking this OpenJDK Code statically or dynamically with other code
     is making a combined work based on this library.  Thus, the terms
     and conditions of GPL2 cover the whole combination.
 
-    As a special exception, Sun gives you permission to link this
-    OpenJDK Code with certain code licensed by Sun as indicated at
+    As a special exception, Oracle gives you permission to link this
+    OpenJDK Code with certain code licensed by Oracle as indicated at
     http://openjdk.java.net/legal/exception-modules-2007-05-08.html
     ("Designated Exception Modules") to produce an executable,
     regardless of the license terms of the Designated Exception Modules,
     and to copy and distribute the resulting executable under GPL2,
     provided that the Designated Exception Modules continue to be
-    governed by the licenses under which they were offered by Sun.
+    governed by the licenses under which they were offered by Oracle.
 
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception).  If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception).  If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/jdk/make/CompileDemos.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/CompileDemos.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -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
@@ -338,6 +338,7 @@
       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/demos/native/jvmti/$1, \
       OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/demos/image/jvmti/$1/lib, \
       LIBRARY := $1, \
+      STRIP_SYMBOLS := false, \
   ))
 
   $1 += $$(BUILD_DEMO_JVMTI_NATIVE_$1)
@@ -453,6 +454,7 @@
       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/demos/native/jni/Poller, \
       OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/demos/native, \
       LIBRARY := Poller, \
+      STRIP_SYMBOLS := false, \
   ))
 
   TARGETS += $(BUILD_DEMO_NATIVE_Poller)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/CompileModuleTools.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  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.
+#
+
+include $(SPEC)
+include MakeBase.gmk
+include JavaCompilation.gmk
+include SetupJavaCompilers.gmk
+
+TOOLS_CLASSES_DIR := $(BUILDTOOLS_OUTPUTDIR)/tools_jigsaw_classes
+
+$(eval $(call SetupJavaCompilation,BUILD_JIGSAW_TOOLS, \
+    SETUP := GENERATE_USINGJDKBYTECODE, \
+    SRC := $(JDK_TOPDIR)/make/src/classes, \
+    INCLUDES := build/tools/deps \
+                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/Import.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,225 +0,0 @@
-#
-# Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  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.
-#
-
-default: all
-
-include $(SPEC)
-include MakeBase.gmk
-
-################################################################################
-
-# Put the libraries here. Different locations for different target OS types.
-ifneq ($(OPENJDK_TARGET_OS), windows)
-  HOTSPOT_LIB_DIR := $(HOTSPOT_DIST)/lib$(OPENJDK_TARGET_CPU_LIBDIR)
-  BASE_INSTALL_LIBRARIES_HERE := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base$(OPENJDK_TARGET_CPU_LIBDIR)
-else
-  HOTSPOT_LIB_DIR := $(HOTSPOT_DIST)/bin
-  BASE_INSTALL_LIBRARIES_HERE := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base
-endif
-
-################################################################################
-#
-# Import hotspot
-#
-
-# Don't import jsig library for static builds
-ifneq ($(STATIC_BUILD), true)
-  JSIG_IMPORT = jsig.*
-else
-  JSIG_IMPORT =
-endif
-
-HOTSPOT_BASE_IMPORT_FILES := \
-    $(addprefix $(LIBRARY_PREFIX), jvm.* $(JSIG_IMPORT) jvm_db.* jvm_dtrace.*) \
-    Xusage.txt \
-    #
-
-$(eval $(call SetupCopyFiles,COPY_HOTSPOT_BASE, \
-    SRC := $(HOTSPOT_LIB_DIR), \
-    DEST := $(BASE_INSTALL_LIBRARIES_HERE), \
-    FILES := $(shell $(FIND) $(HOTSPOT_LIB_DIR) -type f  \
-        -a \( -name DUMMY $(addprefix -o$(SPACE)-name$(SPACE), $(HOTSPOT_BASE_IMPORT_FILES)) \) )))
-
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  $(eval $(call SetupCopyFiles,COPY_HOTSPOT_BASE_JVMLIB, \
-      SRC := $(HOTSPOT_DIST)/lib, \
-      DEST := $(BASE_INSTALL_LIBRARIES_HERE), \
-      FILES := $(wildcard $(HOTSPOT_DIST)/lib/*.lib)))
-endif
-
-BASE_TARGETS := $(COPY_HOTSPOT_BASE) $(COPY_HOTSPOT_BASE_JVMLIB)
-
-################################################################################
-
-ifneq ($(STATIC_BUILD), true)
-  ifeq ($(OPENJDK_TARGET_OS), macosx)
-    JSIG_DEBUGINFO := $(strip $(wildcard $(HOTSPOT_DIST)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig$(SHARED_LIBRARY_SUFFIX).dSYM) \
-        $(wildcard $(HOTSPOT_DIST)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.diz) )
-  else
-    JSIG_DEBUGINFO := $(strip $(wildcard $(HOTSPOT_DIST)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.debuginfo) \
-        $(wildcard $(HOTSPOT_DIST)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.diz) )
-  endif
-
-  ifneq ($(OPENJDK_TARGET_OS), windows)
-    ifeq ($(call check-jvm-variant, server), true)
-      BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/server/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX)
-      ifneq (, $(JSIG_DEBUGINFO))
-        BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/server/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))
-      endif
-    endif
-    ifeq ($(call check-jvm-variant, client), true)
-      BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/client/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX)
-      ifneq (, $(JSIG_DEBUGINFO))
-        BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/client/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))
-      endif
-    endif
-    ifneq ($(OPENJDK_TARGET_OS), macosx)
-      ifeq ($(call check-jvm-variant, minimal), true)
-        BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/minimal/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX)
-        ifneq (,$(JSIG_DEBUGINFO))
-          BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/minimal/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))
-        endif
-      endif
-    endif
-  endif
-endif
-
-$(BASE_INSTALL_LIBRARIES_HERE)/server/%$(SHARED_LIBRARY_SUFFIX): $(BASE_INSTALL_LIBRARIES_HERE)/%$(SHARED_LIBRARY_SUFFIX)
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(LN) -s ../$(@F) $@
-
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-  $(BASE_INSTALL_LIBRARIES_HERE)/server/%.dSYM:
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(LN) -s ../$(@F) $@
-
-  $(BASE_INSTALL_LIBRARIES_HERE)/server/%.diz : $(BASE_INSTALL_LIBRARIES_HERE)/%.diz
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(RM) $@.tmp $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM
-	$(LN) -s ../$(basename $(@F))$(SHARED_LIBRARY_SUFFIX).dSYM $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM
-	$(CD) $(@D) && $(ZIP) -q -y $@.tmp $(basename $(@F))$(SHARED_LIBRARY_SUFFIX).dSYM
-	$(RM) $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM
-	$(MV) $@.tmp $@
-else
-  $(BASE_INSTALL_LIBRARIES_HERE)/server/%.debuginfo: $(BASE_INSTALL_LIBRARIES_HERE)/%.debuginfo
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(LN) -s ../$(@F) $@
-
-  $(BASE_INSTALL_LIBRARIES_HERE)/server/%.diz: $(BASE_INSTALL_LIBRARIES_HERE)/%.diz
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(RM) $@.tmp $(basename $@).debuginfo
-	$(LN) -s ../$(basename $(@F)).debuginfo $(basename $@).debuginfo
-	$(CD) $(@D) && $(ZIP) -q -y $@.tmp $(basename $(@F)).debuginfo
-	$(RM) $(basename $@).debuginfo
-	$(MV) $@.tmp $@
-endif
-
-$(BASE_INSTALL_LIBRARIES_HERE)/client/%$(SHARED_LIBRARY_SUFFIX): $(BASE_INSTALL_LIBRARIES_HERE)/%$(SHARED_LIBRARY_SUFFIX)
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(LN) -s ../$(@F) $@
-
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-  $(BASE_INSTALL_LIBRARIES_HERE)/client/%.dSYM : $(BASE_INSTALL_LIBRARIES_HERE)/%.dSYM
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(LN) -s ../$(@F) $@
-
-  $(BASE_INSTALL_LIBRARIES_HERE)/client/%.diz : $(BASE_INSTALL_LIBRARIES_HERE)/%.diz
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(RM) $@.tmp $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM
-	$(LN) -s ../$(basename $(@F))$(SHARED_LIBRARY_SUFFIX).dSYM $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM
-	$(CD) $(@D) && $(ZIP) -q -y $@.tmp $(basename $(@F))$(SHARED_LIBRARY_SUFFIX).dSYM
-	$(RM) $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM
-	$(MV) $@.tmp $@
-else
-  $(BASE_INSTALL_LIBRARIES_HERE)/client/%.debuginfo: $(BASE_INSTALL_LIBRARIES_HERE)/%.debuginfo
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(LN) -s ../$(@F) $@
-
-  $(BASE_INSTALL_LIBRARIES_HERE)/client/%.diz: $(BASE_INSTALL_LIBRARIES_HERE)/%.diz
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(RM) $@.tmp $(basename $@).debuginfo
-	$(LN) -s ../$(basename $(@F)).debuginfo $(basename $@).debuginfo
-	$(CD) $(@D) && $(ZIP) -q -y $@.tmp $(basename $(@F)).debuginfo
-	$(RM) $(basename $@).debuginfo
-	$(MV) $@.tmp $@
-endif
-
-$(BASE_INSTALL_LIBRARIES_HERE)/minimal/%$(SHARED_LIBRARY_SUFFIX): $(BASE_INSTALL_LIBRARIES_HERE)/%$(SHARED_LIBRARY_SUFFIX)
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(LN) -s ../$(@F) $@
-
-ifneq ($(OPENJDK_TARGET_OS), macosx)
-  $(BASE_INSTALL_LIBRARIES_HERE)/minimal/%.debuginfo: $(BASE_INSTALL_LIBRARIES_HERE)/%.debuginfo
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(LN) -s ../$(@F) $@
-
-  $(BASE_INSTALL_LIBRARIES_HERE)/minimal/%.diz: $(BASE_INSTALL_LIBRARIES_HERE)/%.diz
-	$(MKDIR) -p $(@D)
-	$(RM) $@
-	$(RM) $@.tmp $(basename $@).debuginfo
-	$(LN) -s ../$(basename $(@F)).debuginfo $(basename $@).debuginfo
-	$(CD) $(@D) && $(ZIP) -q -y $@.tmp $(basename $(@F)).debuginfo
-	$(RM) $(basename $@).debuginfo
-	$(MV) $@.tmp $@
-endif
-
-################################################################################
-
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  $(eval $(call SetupCopyFiles,BASE_COPY_LIBS_BIN, \
-      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
-      DEST := $(JDK_OUTPUTDIR)/bin, \
-      FILES := $(filter-out %.lib, $(BASE_TARGETS))))
-
-  $(eval $(call SetupCopyFiles,BASE_COPY_LIBS_LIB, \
-      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
-      DEST := $(JDK_OUTPUTDIR)/lib, \
-      FILES := $(filter %.lib, $(BASE_TARGETS))))
-
-else
-  $(eval $(call SetupCopyFiles,BASE_COPY_LIBS, \
-      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
-      DEST := $(JDK_OUTPUTDIR)/lib, \
-      FILES := $(BASE_TARGETS)))
-endif
-
-################################################################################
-
-all: $(BASE_TARGETS) $(BASE_COPY_LIBS_BIN) $(BASE_COPY_LIBS_LIB) \
-    $(BASE_COPY_LIBS)
-
-.PHONY: default all
--- a/jdk/make/ModuleTools.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/ModuleTools.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -26,18 +26,14 @@
 include $(SPEC)
 include MakeBase.gmk
 include JavaCompilation.gmk
-include SetupJavaCompilers.gmk
 
 TOOLS_CLASSES_DIR := $(BUILDTOOLS_OUTPUTDIR)/tools_jigsaw_classes
 
-$(eval $(call SetupJavaCompilation,BUILD_JIGSAW_TOOLS, \
-    SETUP := GENERATE_USINGJDKBYTECODE, \
-    SRC := $(JDK_TOPDIR)/make/src/classes, \
-    INCLUDES := build/tools/deps \
-                build/tools/jigsaw, \
-    BIN := $(TOOLS_CLASSES_DIR), \
-    ADD_JAVAC_FLAGS := --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED ))
-
+# To avoid reevaluating the compilation setup for the tools each time this file
+# is included, the actual compilation is handled by CompileModuleTools.gmk. The
+# following trick is used to be able to declare a dependency on the built tools.
+BUILD_TOOLS_JDK := $(call SetupJavaCompilationCompileTarget, \
+    BUILD_JIGSAW_TOOLS, $(TOOLS_CLASSES_DIR))
 
 TOOL_GENGRAPHS := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \
     build.tools.jigsaw.GenGraphs
@@ -45,3 +41,8 @@
 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) \
+    -cp $(TOOLS_CLASSES_DIR) \
+    --add-exports java.base/jdk.internal.module=ALL-UNNAMED \
+    build.tools.jigsaw.AddPackagesAttribute
--- a/jdk/make/data/fontconfig/solaris.fontconfig.properties	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/fontconfig/solaris.fontconfig.properties	Tue Oct 18 17:14:09 2016 +0000
@@ -1,6 +1,6 @@
 #
-# 
-# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -30,602 +30,489 @@
 
 # Component Font Mappings
 
-allfonts.chinese-gb2312=-monotype-song-medium-r-normal--*-%d-*-*-m-*-gb2312.1980-0
-allfonts.chinese-gbk=-sun-song-medium-r-normal--*-%d-*-*-c-*-gbk-0
-allfonts.chinese-gb18030-0=-fangzheng-song-medium-r-normal--*-%d-*-*-m-*-gb18030.2000-0
-allfonts.chinese-gb18030-1=-fangzheng-song-medium-r-normal--*-%d-*-*-m-*-gb18030.2000-1
-allfonts.chinese-cns11643-1=-Hanyi-Ming-Medium-r-normal--*-%d-*-*-m-*-cns11643-1
-allfonts.chinese-cns11643-2=-Hanyi-Ming-Medium-r-normal--*-%d-*-*-m-*-cns11643-2
-allfonts.chinese-cns11643-3=-Hanyi-Ming-Medium-r-normal--*-%d-*-*-m-*-cns11643-3
-allfonts.chinese-big5=-hanyi-ming-medium-r-normal--*-%d-*-*-m-*-big5-1
-allfonts.chinese-hkscs=-hanyi-ming-medium-r-normal--*-%d-*-*-m-*-hkscs-1
-allfonts.dingbats=-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific
-allfonts.japanese-x0212=-ricoh-heiseimin-w3-r-normal--*-%d-*-*-m-*-jisx0212.1990-0
-allfonts.korean=-hanyang-kodig-medium-r-normal--*-%d-*-*-m-*-ksc5601.1987-0
-allfonts.korean-johab=-hanyang-kodig-medium-r-normal--*-%d-*-*-m-*-ksc5601.1992-3
+allfonts.chinese-gb2312=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.chinese-gbk=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.chinese-gb18030-0=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.chinese-gb18030-1=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.chinese-cns11643-1=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.chinese-cns11643-2=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.chinese-cns11643-3=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.chinese-big5=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.chinese-hkscs=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.dingbats=-microsoft-wingdings-medium-r-normal--*-%d-*-*-p-*-adobe-fontspecific
+allfonts.japanese-x0212=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.korean=-hanyang-gothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+allfonts.korean-johab=-hanyang-gothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
 allfonts.lucida=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
-allfonts.symbol=-*-symbol-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific
+allfonts.symbol=-monotype-symbol-medium-r-normal--*-%d-*-*-p-*-adobe-symbol
+allfonts.bengali=-misc-lohit bengali-medium-r-normal--0-0-0-0-p-0-iso10646-1
+allfonts.gujarati=-misc-lohit gujarati-medium-r-normal--0-0-0-0-p-0-iso10646-1
+allfonts.hindi=-misc-lohit hindi-medium-r-normal--0-0-0-0-p-0-iso10646-1
+allfonts.kannada=-misc-lohit kannada-medium-r-normal--0-0-0-0-p-0-iso10646-1
+allfonts.malayalam=-misc-lohit malayalam-medium-r-normal--0-0-0-0-p-0-iso10646-1
+allfonts.marathi=-misc-lohit marathi-medium-r-normal--0-0-0-0-p-0-iso10646-1
+allfonts.tamil=-misc-lohit tamil-medium-r-normal--0-0-0-0-p-0-iso10646-1
+allfonts.telugu=-misc-lohit telugu-medium-r-normal--0-0-0-0-p-0-iso10646-1
+allfonts.dejavusans=-misc-dejavu sans-medium-r-normal--0-0-0-0-p-0-iso10646-1
 
-serif.plain.arabic=-monotype-naskh-medium-r-normal--*-%d-*-*-p-*-iso8859-6
-serif.plain.cyrillic-iso8859-5=-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-5
-serif.plain.cyrillic-cp1251=-monotype-times-regular-r-normal--*-%d-*-*-p-*-ansi-1251
-serif.plain.cyrillic-koi8-r=-monotype-times-regular-r-normal--*-%d-*-*-p-*-koi8-r
-serif.plain.greek=-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-7
-serif.plain.hebrew=-monotype-timesnewroman-medium-r-normal--*-%d-*-*-p-*-iso8859-8
-serif.plain.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-serif.plain.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-serif.plain.latin-1=-monotype-times new roman-regular-r---*-%d-*-*-p-*-iso8859-1
-serif.plain.latin-2=-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-2
-serif.plain.latin-5=-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-9
-serif.plain.latin-7=-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-13
-serif.plain.latin-9=-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-15
-serif.plain.thai=-monotype-angsa-medium-r-normal--*-%d-*-*-m-*-tis620.2533-0
+serif.plain.arabic=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.cyrillic-iso8859-5=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.cyrillic-cp1251=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.cyrillic-koi8-r=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.greek=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.hebrew=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+serif.plain.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+serif.plain.latin-1=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.latin-2=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.latin-5=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.latin-7=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.latin-9=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.plain.thai=-monotype-angsana new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
 
-serif.bold.arabic=-monotype-naskh-bold-r-normal--*-%d-*-*-p-*-iso8859-6
-serif.bold.cyrillic-iso8859-5=-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-5
-serif.bold.cyrillic-cp1251=-monotype-times-bold-r-normal--*-%d-*-*-p-*-ansi-1251
-serif.bold.cyrillic-koi8-r=-monotype-times-bold-r-normal--*-%d-*-*-p-*-koi8-r
-serif.bold.greek=-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-7
-serif.bold.hebrew=-monotype-timesnewroman-bold-r-normal-bold-*-%d-*-*-p-*-iso8859-8
-serif.bold.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-serif.bold.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-serif.bold.latin-1=-monotype-times new roman-bold-r---*-%d-*-*-p-*-iso8859-1
-serif.bold.latin-2=-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-2
-serif.bold.latin-5=-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-9
-serif.bold.latin-7=-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-13
-serif.bold.latin-9=-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-15
-serif.bold.thai=-monotype-angsab-bold-r-normal--*-%d-*-*-m-*-tis620.2533-0
+serif.bold.arabic=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.cyrillic-iso8859-5=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.cyrillic-cp1251=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.cyrillic-koi8-r=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.greek=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.hebrew=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+serif.bold.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+serif.bold.latin-1=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.latin-2=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.latin-5=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.latin-7=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.latin-9=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bold.thai=-monotype-angsana new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
 
-serif.italic.arabic=-monotype-naskh-medium-r-normal--*-%d-*-*-p-*-iso8859-6
-serif.italic.cyrillic-iso8859-5=-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-5
-serif.italic.cyrillic-cp1251=-monotype-times-regular-i-normal--*-%d-*-*-p-*-ansi-1251
-serif.italic.cyrillic-koi8-r=-monotype-times-regular-i-normal--*-%d-*-*-p-*-koi8-r
-serif.italic.greek=-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-7
-serif.italic.hebrew=-monotype-timesnewroman-medium-i-normal-italic-*-%d-*-*-p-*-iso8859-8
-serif.italic.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-serif.italic.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-serif.italic.latin-1=-monotype-times new roman-regular-i---*-%d-*-*-p-*-iso8859-1
-serif.italic.latin-2=-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-2
-serif.italic.latin-5=-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-9
-serif.italic.latin-7=-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-13
-serif.italic.latin-9=-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-15
-serif.italic.thai=-monotype-angsai-medium-i-normal--*-%d-*-*-m-*-tis620.2533-0
+serif.italic.arabic=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.cyrillic-iso8859-5=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.cyrillic-cp1251=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.cyrillic-koi8-r=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.greek=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.hebrew=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+serif.italic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+serif.italic.latin-1=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.latin-2=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.latin-5=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.latin-7=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.latin-9=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.italic.thai=-monotype-angsana new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
 
-serif.bolditalic.arabic=-monotype-naskh-bold-r-normal--*-%d-*-*-p-*-iso8859-6
-serif.bolditalic.cyrillic-iso8859-5=-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-5
-serif.bolditalic.cyrillic-cp1251=-monotype-times-bold-i-normal--*-%d-*-*-p-*-ansi-1251
-serif.bolditalic.cyrillic-koi8-r=-monotype-times-bold-i-normal--*-%d-*-*-p-*-koi8-r
-serif.bolditalic.greek=-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-7
-serif.bolditalic.hebrew=-monotype-timesnewroman-bold-i-normal-bolditalic-*-%d-*-*-p-*-iso8859-8
-serif.bolditalic.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-serif.bolditalic.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-serif.bolditalic.latin-1=-monotype-times new roman-bold-i---*-%d-*-*-p-*-iso8859-1
-serif.bolditalic.latin-2=-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-2
-serif.bolditalic.latin-5=-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-9
-serif.bolditalic.latin-7=-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-13
-serif.bolditalic.latin-9=-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-15
-serif.bolditalic.thai=-monotype-angsaz-bold-i-normal--*-%d-*-*-m-*-tis620.2533-0
+serif.bolditalic.arabic=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.cyrillic-iso8859-5=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.cyrillic-cp1251=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.cyrillic-koi8-r=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.greek=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.hebrew=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+serif.bolditalic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+serif.bolditalic.latin-1=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.latin-2=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.latin-5=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.latin-7=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.latin-9=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+serif.bolditalic.thai=-monotype-angsana new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
 
-sansserif.plain.arabic=-monotype-naskh-medium-r-normal--*-%d-*-*-p-*-iso8859-6
-sansserif.plain.cyrillic-iso8859-5=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-5
-sansserif.plain.cyrillic-cp1251=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-ansi-1251
-sansserif.plain.cyrillic-koi8-r=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-koi8-r
-sansserif.plain.greek=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-7
-sansserif.plain.hebrew=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso8859-8
-sansserif.plain.japanese-x0201=-ricoh-hg gothic b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-sansserif.plain.japanese-x0208=-ricoh-hg gothic b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0
-sansserif.plain.latin-1=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-1
-sansserif.plain.latin-2=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-2
-sansserif.plain.latin-5=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-9
-sansserif.plain.latin-7=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-13
-sansserif.plain.latin-9=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-15
-sansserif.plain.thai=-monotype-browa-medium-r-normal--*-%d-*-*-m-*-tis620.2533-0
+sansserif.plain.arabic=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.cyrillic-iso8859-5=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.cyrillic-cp1251=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.cyrillic-koi8-r=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.greek=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.hebrew=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+sansserif.plain.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+sansserif.plain.latin-1=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.latin-2=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.latin-5=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.latin-7=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.latin-9=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.plain.thai=-monotype-browallia new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
 
-sansserif.bold.arabic=-monotype-naskh-bold-r-normal--*-%d-*-*-p-*-iso8859-6
-sansserif.bold.cyrillic-iso8859-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-5
-sansserif.bold.cyrillic-cp1251=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-ansi-1251
-sansserif.bold.cyrillic-koi8-r=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-koi8-r
-sansserif.bold.greek=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-7
-sansserif.bold.hebrew=-monotype-arial-bold-r-normal-Bold-*-%d-*-*-p-*-iso8859-8
-sansserif.bold.japanese-x0201=-ricoh-hg gothic b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-sansserif.bold.japanese-x0208=-ricoh-hg gothic b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0
-sansserif.bold.latin-1=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-1
-sansserif.bold.latin-2=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-2
-sansserif.bold.latin-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-9
-sansserif.bold.latin-7=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-13
-sansserif.bold.latin-9=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-15
-sansserif.bold.thai=-monotype-browab-bold-r-normal--*-%d-*-*-m-*-tis620.2533-0
+sansserif.bold.arabic=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.cyrillic-iso8859-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.cyrillic-cp1251=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.cyrillic-koi8-r=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.greek=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.hebrew=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+sansserif.bold.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+sansserif.bold.latin-1=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.latin-2=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.latin-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.latin-7=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.latin-9=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bold.thai=-monotype-browallia new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
 
-sansserif.italic.arabic=-monotype-naskh-medium-r-normal--*-%d-*-*-p-*-iso8859-6
-sansserif.italic.cyrillic-iso8859-5=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-5
-sansserif.italic.cyrillic-cp1251=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-ansi-1251
-sansserif.italic.cyrillic-koi8-r=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-koi8-r
-sansserif.italic.greek=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-7
-sansserif.italic.hebrew=-monotype-arial-medium-i-normal-Italic-*-%d-*-*-p-*-iso8859-8
-sansserif.italic.japanese-x0201=-ricoh-hg gothic b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-sansserif.italic.japanese-x0208=-ricoh-hg gothic b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0
-sansserif.italic.latin-1=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-1
-sansserif.italic.latin-2=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-2
-sansserif.italic.latin-5=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-9
-sansserif.italic.latin-7=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-13
-sansserif.italic.latin-9=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-15
-sansserif.italic.thai=-monotype-browai-medium-i-normal--*-%d-*-*-m-*-tis620.2533-0
+sansserif.italic.arabic=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.cyrillic-iso8859-5=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.cyrillic-cp1251=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.cyrillic-koi8-r=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.greek=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.hebrew=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+sansserif.italic.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+sansserif.italic.latin-1=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.latin-2=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.latin-5=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.latin-7=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.latin-9=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.italic.thai=-monotype-browallia new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
 
-sansserif.bolditalic.arabic=-monotype-naskh-bold-r-normal--*-%d-*-*-p-*-iso8859-6
-sansserif.bolditalic.cyrillic-iso8859-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-5
-sansserif.bolditalic.cyrillic-cp1251=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-ansi-1251
-sansserif.bolditalic.cyrillic-koi8-r=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-koi8-r
-sansserif.bolditalic.greek=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-7
-sansserif.bolditalic.hebrew=-monotype-arial-bold-i-normal-BoldItalic-*-%d-*-*-p-*-iso8859-8
-sansserif.bolditalic.japanese-x0201=-ricoh-hg gothic b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-sansserif.bolditalic.japanese-x0208=-ricoh-hg gothic b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0
-sansserif.bolditalic.latin-1=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-1
-sansserif.bolditalic.latin-2=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-2
-sansserif.bolditalic.latin-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-9
-sansserif.bolditalic.latin-7=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-13
-sansserif.bolditalic.latin-9=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-15
-sansserif.bolditalic.thai=-monotype-browaz-bold-i-normal--*-%d-*-*-m-*-tis620.2533-0
+sansserif.bolditalic.arabic=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.cyrillic-iso8859-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.cyrillic-cp1251=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.cyrillic-koi8-r=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.greek=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.hebrew=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+sansserif.bolditalic.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+sansserif.bolditalic.latin-1=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.latin-2=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.latin-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.latin-7=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.latin-9=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+sansserif.bolditalic.thai=-monotype-browallia new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
 
-monospaced.plain.arabic=-monotype-akhbar-medium-r-normal--*-%d-*-*-p-*-iso8859-6
-monospaced.plain.cyrillic-iso8859-5=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-5
-monospaced.plain.cyrillic-cp1251=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-ansi-1251
-monospaced.plain.cyrillic-koi8-r=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-koi8-r
-monospaced.plain.greek=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-7
-monospaced.plain.hebrew=-monotype-couriernew-medium-r-normal--*-%d-*-*-m-*-iso8859-8
-monospaced.plain.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-monospaced.plain.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-monospaced.plain.latin-1=-monotype-courier new-regular-r---*-%d-*-*-m-*-iso8859-1
-monospaced.plain.latin-2=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-2
-monospaced.plain.latin-5=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-9
-monospaced.plain.latin-7=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-13
-monospaced.plain.latin-9=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-15
-monospaced.plain.thai=-monotype-cordia-medium-r-normal--*-%d-*-*-m-*-tis620.2533-0
+monospaced.plain.arabic=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.cyrillic-iso8859-5=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.cyrillic-cp1251=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.cyrillic-koi8-r=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.greek=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.hebrew=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+monospaced.plain.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+monospaced.plain.latin-1=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.latin-2=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.latin-5=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.latin-7=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.latin-9=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.plain.thai=-monotype-cordia new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
 
-monospaced.bold.arabic=-monotype-akhbar-bold-r-normal--*-%d-*-*-p-*-iso8859-6
-monospaced.bold.cyrillic-iso8859-5=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-5
-monospaced.bold.cyrillic-cp1251=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-ansi-1251
-monospaced.bold.cyrillic-koi8-r=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-koi8-r
-monospaced.bold.greek=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-7
-monospaced.bold.hebrew=-monotype-couriernew-bold-r-normal-Bold-*-%d-*-*-m-*-iso8859-8
-monospaced.bold.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-monospaced.bold.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-monospaced.bold.latin-1=-monotype-courier new-bold-r---*-%d-*-*-m-*-iso8859-1
-monospaced.bold.latin-2=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-2
-monospaced.bold.latin-5=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-9
-monospaced.bold.latin-7=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-13
-monospaced.bold.latin-9=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-15
-monospaced.bold.thai=-monotype-cordiab-bold-r-normal--*-%d-*-*-m-*-tis620.2533-0
+monospaced.bold.arabic=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.cyrillic-iso8859-5=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.cyrillic-cp1251=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.cyrillic-koi8-r=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.greek=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.hebrew=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+monospaced.bold.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+monospaced.bold.latin-1=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.latin-2=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.latin-5=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.latin-7=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.latin-9=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bold.thai=-monotype-cordia new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
 
-monospaced.italic.arabic=-monotype-akhbar-medium-r-normal--*-%d-*-*-p-*-iso8859-6
-monospaced.italic.cyrillic-iso8859-5=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-5
-monospaced.italic.cyrillic-cp1251=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-ansi-1251
-monospaced.italic.cyrillic-koi8-r=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-koi8-r
-monospaced.italic.greek=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-7
-monospaced.italic.hebrew=-monotype-couriernew-medium-i-normal-Italic-*-%d-*-*-m-*-iso8859-8
-monospaced.italic.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-monospaced.italic.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-monospaced.italic.latin-1=-monotype-courier new-regular-i---*-%d-*-*-m-*-iso8859-1
-monospaced.italic.latin-2=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-2
-monospaced.italic.latin-5=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-9
-monospaced.italic.latin-7=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-13
-monospaced.italic.latin-9=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-15
-monospaced.italic.thai=-monotype-cordiai-medium-i-normal--*-%d-*-*-m-*-tis620.2533-0
+monospaced.italic.arabic=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.cyrillic-iso8859-5=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.cyrillic-cp1251=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.cyrillic-koi8-r=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.greek=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.hebrew=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+monospaced.italic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+monospaced.italic.latin-1=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.latin-2=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.latin-5=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.latin-7=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.latin-9=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.italic.thai=-monotype-cordia new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
 
-monospaced.bolditalic.arabic=-monotype-akhbar-bold-r-normal--*-%d-*-*-p-*-iso8859-6
-monospaced.bolditalic.cyrillic-iso8859-5=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-5
-monospaced.bolditalic.cyrillic-cp1251=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-ansi-1251
-monospaced.bolditalic.cyrillic-koi8-r=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-koi8-r
-monospaced.bolditalic.greek=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-7
-monospaced.bolditalic.hebrew=-monotype-couriernew-bold-i-normal-BoldItalic-*-%d-*-*-m-*-iso8859-8
-monospaced.bolditalic.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-monospaced.bolditalic.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-monospaced.bolditalic.latin-1=-monotype-courier new-bold-i---*-%d-*-*-m-*-iso8859-1
-monospaced.bolditalic.latin-2=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-2
-monospaced.bolditalic.latin-5=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-9
-monospaced.bolditalic.latin-7=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-13
-monospaced.bolditalic.latin-9=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-15
-monospaced.bolditalic.thai=-monotype-cordiaz-bold-i-normal--*-%d-*-*-m-*-tis620.2533-0
+monospaced.bolditalic.arabic=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.cyrillic-iso8859-5=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.cyrillic-cp1251=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.cyrillic-koi8-r=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.greek=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.hebrew=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+monospaced.bolditalic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+monospaced.bolditalic.latin-1=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.latin-2=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.latin-5=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.latin-7=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.latin-9=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+monospaced.bolditalic.thai=-monotype-cordia new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
 
-dialog.plain.arabic=-monotype-shayyal-medium-r-normal--*-%d-*-*-m-*-iso8859-6
-dialog.plain.cyrillic-iso8859-5=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-5
-dialog.plain.cyrillic-cp1251=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-ansi-1251
-dialog.plain.cyrillic-koi8-r=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-koi8-r
-dialog.plain.greek=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-7
-dialog.plain.hebrew=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso8859-8
-dialog.plain.japanese-x0201=-ricoh-hg gothic b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-dialog.plain.japanese-x0208=-ricoh-hg gothic b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0
-dialog.plain.latin-1=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-1
-dialog.plain.latin-2=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-2
-dialog.plain.latin-5=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-9
-dialog.plain.latin-7=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-13
-dialog.plain.latin-9=-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-15
-dialog.plain.thai=-monotype-browa-medium-r-normal--*-%d-*-*-m-*-tis620.2533-0
+dialog.plain.arabic=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.cyrillic-iso8859-5=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.cyrillic-cp1251=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.cyrillic-koi8-r=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.greek=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.hebrew=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialog.plain.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialog.plain.latin-1=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.latin-2=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.latin-5=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.latin-7=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.latin-9=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.plain.thai=-monotype-browallia new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
 
-dialog.bold.arabic=-monotype-shayyal-bold-r-normal--*-%d-*-*-m-*-iso8859-6
-dialog.bold.cyrillic-iso8859-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-5
-dialog.bold.cyrillic-cp1251=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-ansi-1251
-dialog.bold.cyrillic-koi8-r=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-koi8-r
-dialog.bold.greek=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-7
-dialog.bold.hebrew=-monotype-arial-bold-r-normal-Bold-*-%d-*-*-p-*-iso8859-8
-dialog.bold.japanese-x0201=-ricoh-hg gothic b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-dialog.bold.japanese-x0208=-ricoh-hg gothic b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0
-dialog.bold.latin-1=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-1
-dialog.bold.latin-2=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-2
-dialog.bold.latin-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-9
-dialog.bold.latin-7=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-13
-dialog.bold.latin-9=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-15
-dialog.bold.thai=-monotype-browab-bold-r-normal--*-%d-*-*-m-*-tis620.2533-0
+dialog.bold.arabic=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.cyrillic-iso8859-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.cyrillic-cp1251=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.cyrillic-koi8-r=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.greek=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.hebrew=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialog.bold.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialog.bold.latin-1=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.latin-2=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.latin-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.latin-7=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.latin-9=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bold.thai=-monotype-browallia new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
 
-dialog.italic.arabic=-monotype-shayyal-medium-r-normal--*-%d-*-*-m-*-iso8859-6
-dialog.italic.cyrillic-iso8859-5=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-5
-dialog.italic.cyrillic-cp1251=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-ansi-1251
-dialog.italic.cyrillic-koi8-r=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-koi8-r
-dialog.italic.greek=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-7
-dialog.italic.hebrew=-monotype-arial-medium-i-normal-Italic-*-%d-*-*-p-*-iso8859-8
-dialog.italic.japanese-x0201=-ricoh-hg gothic b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-dialog.italic.japanese-x0208=-ricoh-hg gothic b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0
-dialog.italic.latin-1=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-1
-dialog.italic.latin-2=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-2
-dialog.italic.latin-5=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-9
-dialog.italic.latin-7=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-13
-dialog.italic.latin-9=-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-15
-dialog.italic.thai=-monotype-browai-medium-i-normal--*-%d-*-*-m-*-tis620.2533-0
+dialog.italic.arabic=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.cyrillic-iso8859-5=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.cyrillic-cp1251=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.cyrillic-koi8-r=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.greek=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.hebrew=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialog.italic.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialog.italic.latin-1=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.latin-2=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.latin-5=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.latin-7=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.latin-9=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.italic.thai=-monotype-browallia new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
 
-dialog.bolditalic.arabic=-monotype-shayyal-bold-r-normal--*-%d-*-*-m-*-iso8859-6
-dialog.bolditalic.cyrillic-iso8859-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-5
-dialog.bolditalic.cyrillic-cp1251=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-ansi-1251
-dialog.bolditalic.cyrillic-koi8-r=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-koi8-r
-dialog.bolditalic.greek=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-7
-dialog.bolditalic.hebrew=-monotype-arial-bold-i-normal-BoldItalic-*-%d-*-*-p-*-iso8859-8
-dialog.bolditalic.japanese-x0201=-ricoh-hg gothic b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-dialog.bolditalic.japanese-x0208=-ricoh-hg gothic b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0
-dialog.bolditalic.latin-1=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-1
-dialog.bolditalic.latin-2=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-2
-dialog.bolditalic.latin-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-9
-dialog.bolditalic.latin-7=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-13
-dialog.bolditalic.latin-9=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-15
-dialog.bolditalic.thai=-monotype-browaz-bold-i-normal--*-%d-*-*-m-*-tis620.2533-0
+dialog.bolditalic.arabic=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.cyrillic-iso8859-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.cyrillic-cp1251=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.cyrillic-koi8-r=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.greek=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.hebrew=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialog.bolditalic.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialog.bolditalic.latin-1=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.latin-2=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.latin-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.latin-7=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.latin-9=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialog.bolditalic.thai=-monotype-browallia new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
 
-dialoginput.plain.arabic=-monotype-shayyal-medium-r-normal--*-%d-*-*-m-*-iso8859-6
-dialoginput.plain.cyrillic-iso8859-5=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-5
-dialoginput.plain.cyrillic-cp1251=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-ansi-1251
-dialoginput.plain.cyrillic-koi8-r=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-koi8-r
-dialoginput.plain.greek=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-7
-dialoginput.plain.hebrew=-monotype-couriernew-medium-r-normal--*-%d-*-*-m-*-iso8859-8
-dialoginput.plain.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-dialoginput.plain.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-dialoginput.plain.latin-1=-monotype-courier new-regular-r---*-%d-*-*-m-*-iso8859-1
-dialoginput.plain.latin-2=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-2
-dialoginput.plain.latin-5=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-9
-dialoginput.plain.latin-7=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-13
-dialoginput.plain.latin-9=-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-15
-dialoginput.plain.thai=-monotype-cordia-medium-r-normal--*-%d-*-*-m-*-tis620.2533-0
+dialoginput.plain.arabic=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.cyrillic-iso8859-5=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.cyrillic-cp1251=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.cyrillic-koi8-r=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.greek=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.hebrew=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialoginput.plain.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialoginput.plain.latin-1=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.latin-2=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.latin-5=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.latin-7=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.latin-9=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.plain.thai=-monotype-cordia new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
 
-dialoginput.bold.arabic=-monotype-shayyal-bold-r-normal--*-%d-*-*-m-*-iso8859-6
-dialoginput.bold.cyrillic-iso8859-5=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-5
-dialoginput.bold.cyrillic-cp1251=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-ansi-1251
-dialoginput.bold.cyrillic-koi8-r=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-koi8-r
-dialoginput.bold.greek=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-7
-dialoginput.bold.hebrew=-monotype-couriernew-bold-r-normal-Bold-*-%d-*-*-m-*-iso8859-8
-dialoginput.bold.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-dialoginput.bold.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-dialoginput.bold.latin-1=-monotype-courier new-bold-r---*-%d-*-*-m-*-iso8859-1
-dialoginput.bold.latin-2=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-2
-dialoginput.bold.latin-5=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-9
-dialoginput.bold.latin-7=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-13
-dialoginput.bold.latin-9=-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-15
-dialoginput.bold.thai=-monotype-cordiab-bold-r-normal--*-%d-*-*-m-*-tis620.2533-0
+dialoginput.bold.arabic=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.cyrillic-iso8859-5=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.cyrillic-cp1251=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.cyrillic-koi8-r=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.greek=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.hebrew=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialoginput.bold.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialoginput.bold.latin-1=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.latin-2=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.latin-5=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.latin-7=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.latin-9=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bold.thai=-monotype-cordia new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
 
-dialoginput.italic.arabic=-monotype-shayyal-medium-r-normal--*-%d-*-*-m-*-iso8859-6
-dialoginput.italic.cyrillic-iso8859-5=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-5
-dialoginput.italic.cyrillic-cp1251=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-ansi-1251
-dialoginput.italic.cyrillic-koi8-r=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-koi8-r
-dialoginput.italic.greek=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-7
-dialoginput.italic.hebrew=-monotype-couriernew-medium-i-normal-Italic-*-%d-*-*-m-*-iso8859-8
-dialoginput.italic.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-dialoginput.italic.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-dialoginput.italic.latin-1=-monotype-courier new-regular-i---*-%d-*-*-m-*-iso8859-1
-dialoginput.italic.latin-2=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-2
-dialoginput.italic.latin-5=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-9
-dialoginput.italic.latin-7=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-13
-dialoginput.italic.latin-9=-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-15
-dialoginput.italic.thai=-monotype-cordiai-medium-i-normal--*-%d-*-*-m-*-tis620.2533-0
+dialoginput.italic.arabic=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.cyrillic-iso8859-5=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.cyrillic-cp1251=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.cyrillic-koi8-r=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.greek=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.hebrew=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialoginput.italic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialoginput.italic.latin-1=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.latin-2=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.latin-5=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.latin-7=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.latin-9=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.italic.thai=-monotype-cordia new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
 
-dialoginput.bolditalic.arabic=-monotype-shayyal-bold-r-normal--*-%d-*-*-m-*-iso8859-6
-dialoginput.bolditalic.cyrillic-iso8859-5=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-5
-dialoginput.bolditalic.cyrillic-cp1251=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-ansi-1251
-dialoginput.bolditalic.cyrillic-koi8-r=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-koi8-r
-dialoginput.bolditalic.greek=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-7
-dialoginput.bolditalic.hebrew=-monotype-couriernew-bold-i-normal-BoldItalic-*-%d-*-*-m-*-iso8859-8
-dialoginput.bolditalic.japanese-x0201=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0
-dialoginput.bolditalic.japanese-x0208=-ricoh-hg mincho l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0
-dialoginput.bolditalic.latin-1=-monotype-courier new-bold-i---*-%d-*-*-m-*-iso8859-1
-dialoginput.bolditalic.latin-2=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-2
-dialoginput.bolditalic.latin-5=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-9
-dialoginput.bolditalic.latin-7=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-13
-dialoginput.bolditalic.latin-9=-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-15
-dialoginput.bolditalic.thai=-monotype-cordiaz-bold-i-normal--*-%d-*-*-m-*-tis620.2533-0
+dialoginput.bolditalic.arabic=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.cyrillic-iso8859-5=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.cyrillic-cp1251=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.cyrillic-koi8-r=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.greek=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.hebrew=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialoginput.bolditalic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
+dialoginput.bolditalic.latin-1=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.latin-2=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.latin-5=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.latin-7=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.latin-9=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
+dialoginput.bolditalic.thai=-monotype-cordia new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
 
 # Search Sequences
 
-sequence.allfonts=latin-1,dingbats,symbol
-
-sequence.allfonts.Big5=latin-1,chinese-big5,dingbats,symbol
+sequence.allfonts=latin-1
 
-sequence.allfonts.Big5-HKSCS-2001=latin-1,chinese-big5,chinese-hkscs,dingbats,symbol
+sequence.allfonts.Big5=latin-1,chinese-big5
 
-sequence.allfonts.windows-1251=cyrillic-cp1251,latin-1,dingbats,symbol
+sequence.allfonts.Big5-HKSCS-2001=latin-1,chinese-big5,chinese-hkscs
 
-sequence.allfonts.GB2312=latin-1,chinese-gbk,chinese-gb2312,dingbats,symbol
+sequence.allfonts.windows-1251=cyrillic-cp1251,latin-1
 
-sequence.allfonts.x-eucJP-Open=latin-1,japanese-x0201,japanese-x0208,japanese-x0212,dingbats,symbol
+sequence.allfonts.GB2312=latin-1,chinese-gb2312
 
-sequence.allfonts.EUC-KR=latin-1,korean,dingbats,symbol
+sequence.allfonts.x-eucJP-Open=latin-1,japanese-x0201,japanese-x0208,japanese-x0212
 
-sequence.allfonts.x-EUC-TW=latin-1,chinese-cns11643-1,chinese-cns11643-2,chinese-cns11643-3,dingbats,symbol
+sequence.allfonts.EUC-KR=latin-1,korean
 
-sequence.allfonts.GBK=latin-1,chinese-gbk,dingbats,symbol
+sequence.allfonts.x-EUC-TW=latin-1,chinese-cns11643-1,chinese-cns11643-2,chinese-cns11643-3
 
-sequence.allfonts.GB18030=latin-1,chinese-gb18030-0,chinese-gb18030-1,dingbats,symbol
+sequence.allfonts.GBK=latin-1,chinese-gbk
 
-sequence.allfonts.ISO-8859-2=latin-2,latin-1,dingbats,symbol
+sequence.allfonts.GB18030=latin-1,chinese-gb18030-0,chinese-gb18030-1
 
-sequence.allfonts.ISO-8859-5=cyrillic-iso8859-5,latin-1,dingbats,symbol
+sequence.allfonts.ISO-8859-2=latin-2,latin-1
 
-sequence.allfonts.ISO-8859-6=arabic,latin-1,dingbats,symbol
+sequence.allfonts.ISO-8859-5=cyrillic-iso8859-5,latin-1
 
-sequence.allfonts.ISO-8859-7=latin-1,greek,dingbats,symbol
+sequence.allfonts.ISO-8859-6=arabic,latin-1
 
-sequence.allfonts.ISO-8859-8=latin-1,hebrew,dingbats,symbol
+sequence.allfonts.ISO-8859-7=latin-1,greek
 
-sequence.allfonts.ISO-8859-9=latin-5,latin-1,dingbats,symbol
-
-sequence.allfonts.ISO-8859-13=latin-7,latin-1,dingbats,symbol
+sequence.allfonts.ISO-8859-8=latin-1,hebrew
 
-sequence.allfonts.ISO-8859-15=latin-9,dingbats,symbol
-
-sequence.allfonts.KOI8-R=cyrillic-koi8-r,latin-1,dingbats,symbol
+sequence.allfonts.ISO-8859-9=latin-5,latin-1
 
-sequence.allfonts.x-PCK=latin-1,japanese-x0201,japanese-x0208,japanese-x0212,dingbats,symbol
+sequence.allfonts.ISO-8859-13=latin-7,latin-1
 
-sequence.allfonts.TIS-620=latin-1,thai,dingbats,symbol
+sequence.allfonts.ISO-8859-15=latin-9
 
-sequence.allfonts.UTF-8=latin-1,latin-2,latin-7,cyrillic-iso8859-5,greek,latin-5,latin-9,\
-        japanese-x0201,japanese-x0208,japanese-x0212,korean-johab,\
-        chinese-gb2312,chinese-big5,dingbats,symbol
+sequence.allfonts.KOI8-R=cyrillic-koi8-r,latin-1
 
-sequence.allfonts.UTF-8.hi=latin-1,latin-2,latin-7,cyrillic-iso8859-5,greek,latin-5,latin-9,\
-        japanese-x0201,japanese-x0208,japanese-x0212,korean-johab,\
-        chinese-gb2312,chinese-big5,thai,dingbats,symbol
+sequence.allfonts.x-PCK=latin-1,japanese-x0201,japanese-x0208,japanese-x0212
+
+sequence.allfonts.TIS-620=latin-1,thai
 
-sequence.allfonts.UTF-8.ko=latin-1,latin-2,latin-7,cyrillic-iso8859-5,greek,latin-5,latin-9,\
-        korean-johab,japanese-x0201,japanese-x0208,japanese-x0212,\
-        chinese-gb2312,chinese-big5,dingbats,symbol
-
-sequence.allfonts.UTF-8.th=latin-1,latin-2,latin-7,cyrillic-iso8859-5,greek,latin-5,latin-9,\
-        thai,chinese-gb2312,chinese-big5,japanese-x0201,japanese-x0208,japanese-x0212,\
-        korean-johab,dingbats,symbol
+sequence.allfonts.UTF-8=latin-1
+sequence.allfonts.UTF-8.en=latin-1
+sequence.allfonts.UTF-8.hi=latin-1,hindi
+sequence.allfonts.UTF-8.be=latin-1,bengali
+sequence.allfonts.UTF-8.te=latin-1,telugu
+sequence.allfonts.UTF-8.mr=latin-1,marathi
+sequence.allfonts.UTF-8.ta=latin-1,tamil
+sequence.allfonts.UTF-8.gu=latin-1,gujarati
+sequence.allfonts.UTF-8.kn=latin-1,kannada
+sequence.allfonts.UTF-8.ma=latin-1,malayalam
 
-sequence.allfonts.UTF-8.zh.CN=latin-1,latin-2,latin-7,cyrillic-iso8859-5,greek,latin-5,latin-9,\
-        chinese-gb18030-0,chinese-gb18030-1,chinese-big5,chinese-hkscs,\
-        japanese-x0201,japanese-x0208,japanese-x0212,korean-johab,thai,dingbats,symbol
+sequence.allfonts.UTF-8.ko=latin-1,korean-johab,japanese-x0201,japanese-x0208,japanese-x0212
+
+sequence.allfonts.UTF-8.th=latin-1,thai
 
-sequence.allfonts.UTF-8.zh.HK=latin-1,latin-2,latin-7,cyrillic-iso8859-5,greek,latin-5,latin-9,\
-        chinese-big5,chinese-hkscs,chinese-gb18030-0,chinese-gb18030-1,\
-        japanese-x0201,japanese-x0208,japanese-x0212,korean-johab,thai,dingbats,symbol
+sequence.allfonts.UTF-8.zh.CN=latin-1,chinese-gb18030-0,chinese-gb18030-1,chinese-big5,chinese-hkscs
 
-sequence.allfonts.UTF-8.zh.TW=latin-1,latin-2,latin-7,cyrillic-iso8859-5,greek,latin-5,latin-9,\
-        chinese-big5,chinese-hkscs,chinese-gb18030-0,chinese-gb18030-1,\
-        japanese-x0201,japanese-x0208,japanese-x0212,korean-johab,thai,dingbats,symbol
+sequence.allfonts.UTF-8.zh.HK=latin-1,chinese-big5,chinese-hkscs,chinese-gb18030-0,chinese-gb18030-1
+
+sequence.allfonts.UTF-8.zh.TW=latin-1,chinese-big5,chinese-hkscs,chinese-gb18030-0,chinese-gb18030-1
 
 # the fallback sequence omits the following character subsets:
-# - latin-1, latin-2, latin-5, latin-7, latin-9: characters covered by lucida
-# - cyrillic-cp1251, cyrillic-iso8859-5, cyrillic-koi8-r: characters covered by lucida
-# - arabic, devanagari, greek, hebrew, thai: characters covered by lucida
-# - chinese-cns11643-1, chinese-cns11643-2, chinese-cns11643-3, chinese-hkscs: same file as chinese-big5
-# - chinese-gbk, chinese-gb18030-1: same file as chinese-gb18030-0
+# - chinese: all same file : just use chinese-gb18030-0
 # - japanese-x0208: same files as japanese-x0201
 # - japanese-x0212: same files as japanese-x0201
 # - korean: same file as korean-johab
-# - dingbats, symbol: included in all core sequences
-sequence.fallback=lucida,\
-        chinese-big5,chinese-gb2312,chinese-gb18030-0,\
-        japanese-x0201,korean-johab
-
-# Exclusion Ranges
-
-exclusion.chinese-cns11643-2=0390-03d6,2200-22ef,2701-27be
-exclusion.chinese-cns11643-3=0390-03d6,2200-22ef,2701-27be
+sequence.fallback=latin-1,latin-2,latin-7,cyrillic-iso8859-5,greek,latin-5,latin-9,\
+        arabic,hebrew,thai,lucida,\
+        chinese-gb18030-0,\
+        japanese-x0201,korean-johab,\
+        hindi,bengali,telugu,marathi,tamil,gujarati,kannada,malayalam,\
+        dejavusans,dingbats,symbol
 
 # Font File Names
 
-filename.-*-symbol-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific=/usr/openwin/lib/X11/fonts/TrueType/Symbol.ttf
+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-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-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-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
+filename.-monotype-angsana_new-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/angsai.ttf
+filename.-monotype-angsana_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/angsab.ttf
+filename.-monotype-angsana_new-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/angsaz.ttf
+filename.-monotype-browallia_new-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/browa.ttf
+filename.-monotype-browallia_new-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/browai.ttf
+filename.-monotype-browallia_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/browab.ttf
+filename.-monotype-browallia_new-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/browaz.ttf
+filename.-monotype-cordia_new-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cordia.ttf
+filename.-monotype-cordia_new-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cordiai.ttf
+filename.-monotype-cordia_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cordiab.ttf
+filename.-monotype-cordia_new-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cordiaz.ttf
+
+filename.-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1=/usr/share/fonts/TrueType/ipafont/ipag.otf
+filename.-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1=/usr/share/fonts/TrueType/ipafont/ipam.otf
+filename.-hanyang-gothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1=/usr/share/fonts/TrueType/hanyang/h2gtrm.ttf
+filename.-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1=/usr/share/fonts/TrueType/arphic/uming.ttf
+filename.-monotype-symbol-medium-r-normal--*-%d-*-*-p-*-adobe-symbol=/usr/share/fonts/TrueType/core/symbol.ttf
+filename.-microsoft-wingdings-medium-r-normal--*-%d-*-*-p-*-adobe-fontspecific=/usr/share/fonts/TrueType/core/wingdings.ttf
 filename.-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1=$JRE_LIB_FONTS/LucidaSansRegular.ttf
-filename.-fangzheng-song-medium-r-normal--*-%d-*-*-m-*-gb18030.2000-0=/usr/openwin/lib/locale/zh_CN.GB18030/X11/fonts/TrueType/songti.ttf
-filename.-fangzheng-song-medium-r-normal--*-%d-*-*-m-*-gb18030.2000-1=/usr/openwin/lib/locale/zh_CN.GB18030/X11/fonts/TrueType/songti.ttf
-filename.-hanyang-kodig-medium-r-normal--*-%d-*-*-m-*-ksc5601.1987-0=/usr/openwin/lib/locale/ko.UTF-8/X11/fonts/TrueType/h2gtrm.ttf
-filename.-hanyang-kodig-medium-r-normal--*-%d-*-*-m-*-ksc5601.1992-3=/usr/openwin/lib/locale/ko.UTF-8/X11/fonts/TrueType/h2gtrm.ttf
-filename.-hanyi-ming-medium-r-normal--*-%d-*-*-m-*-big5-1=/usr/openwin/lib/locale/zh_TW.BIG5/X11/fonts/TT/ming.ttf
-filename.-Hanyi-Ming-Medium-r-normal--*-%d-*-*-m-*-cns11643-1=/usr/openwin/lib/locale/zh_TW.BIG5/X11/fonts/TT/ming.ttf
-filename.-Hanyi-Ming-Medium-r-normal--*-%d-*-*-m-*-cns11643-2=/usr/openwin/lib/locale/zh_TW.BIG5/X11/fonts/TT/ming.ttf
-filename.-Hanyi-Ming-Medium-r-normal--*-%d-*-*-m-*-cns11643-3=/usr/openwin/lib/locale/zh_TW.BIG5/X11/fonts/TT/ming.ttf
-filename.-hanyi-ming-medium-r-normal--*-%d-*-*-m-*-hkscs-1=/usr/openwin/lib/locale/zh_TW.BIG5/X11/fonts/TT/ming.ttf
-filename.-monotype-akhbar-bold-r-normal--*-%d-*-*-p-*-iso8859-6=/usr/openwin/lib/locale/ar/X11/fonts/TrueType/AKHBARBD.ttf
-filename.-monotype-akhbar-medium-r-normal--*-%d-*-*-p-*-iso8859-6=/usr/openwin/lib/locale/ar/X11/fonts/TrueType/AKHBARMT.ttf
-filename.-monotype-angsa-medium-r-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/angsa.ttf
-filename.-monotype-angsab-bold-r-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/angsab.ttf
-filename.-monotype-angsai-medium-i-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/angsai.ttf
-filename.-monotype-angsaz-bold-i-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/angsaz.ttf
-filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBoldItalic.ttf
-filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBoldItalic.ttf
-filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBoldItalic.ttf
-filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/Arial-BoldItalic.ttf
-filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBoldItalic.ttf
-filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBoldItalic.ttf
-filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBoldItalic.ttf
-filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBoldItalic.ttf
-filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBoldItalic.ttf
-filename.-monotype-arial-bold-i-normal-BoldItalic-*-%d-*-*-p-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/arialbih.ttf
-filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBold.ttf
-filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBold.ttf
-filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBold.ttf
-filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/Arial-Bold.ttf
-filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBold.ttf
-filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBold.ttf
-filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBold.ttf
-filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBold.ttf
-filename.-monotype-arial-bold-r-normal-Bold-*-%d-*-*-p-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/arialb_h.ttf
-filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialBold.ttf
-filename.-monotype-arial-medium-i-normal-Italic-*-%d-*-*-p-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/ariali_h.ttf
-filename.-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/arial__h.ttf
-filename.-monotype-arial-regular-i-normal--*-%d-*-*-p-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialItalic.ttf
-filename.-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialItalic.ttf
-filename.-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialItalic.ttf
-filename.-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/Arial-Italic.ttf
-filename.-monotype-arial-regular-i-normal--*-%d-*-*-p-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialItalic.ttf
-filename.-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialItalic.ttf
-filename.-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialItalic.ttf
-filename.-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialItalic.ttf
-filename.-monotype-arial-regular-i-normal--*-%d-*-*-p-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialItalic.ttf
-filename.-monotype-arial-regular-r-normal--*-%d-*-*-p-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialRegular.ttf
-filename.-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialRegular.ttf
-filename.-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialRegular.ttf
-filename.-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/Arial.ttf
-filename.-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialRegular.ttf
-filename.-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialRegular.ttf
-filename.-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialRegular.ttf
-filename.-monotype-arial-regular-r-normal--*-%d-*-*-p-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialRegular.ttf
-filename.-monotype-arial-regular-r-normal--*-%d-*-*-p-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/ArialRegular.ttf
-filename.-monotype-browa-medium-r-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/browa.ttf
-filename.-monotype-browab-bold-r-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/browab.ttf
-filename.-monotype-browai-medium-i-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/browai.ttf
-filename.-monotype-browaz-bold-i-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/browaz.ttf
-filename.-monotype-cordia-medium-r-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/cordia.ttf
-filename.-monotype-cordiab-bold-r-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/cordiab.ttf
-filename.-monotype-cordiai-medium-i-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/cordiai.ttf
-filename.-monotype-cordiaz-bold-i-normal--*-%d-*-*-m-*-tis620.2533-0=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/cordiaz.ttf
-filename.-monotype-courier-bold-i-normal--*-%d-*-*-m-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBoldItalic.ttf
-filename.-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBoldItalic.ttf
-filename.-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBoldItalic.ttf
-filename.-monotype-courier-bold-i-normal--*-%d-*-*-m-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBoldItalic.ttf
-filename.-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBoldItalic.ttf
-filename.-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBoldItalic.ttf
-filename.-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBoldItalic.ttf
-filename.-monotype-courier-bold-i-normal--*-%d-*-*-m-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBoldItalic.ttf
-filename.-monotype-courier-bold-r-normal--*-%d-*-*-m-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBold.ttf
-filename.-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBold.ttf
-filename.-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBold.ttf
-filename.-monotype-courier-bold-r-normal--*-%d-*-*-m-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBold.ttf
-filename.-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBold.ttf
-filename.-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBold.ttf
-filename.-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBold.ttf
-filename.-monotype-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierBold.ttf
-filename.-monotype-courier-regular-i-normal--*-%d-*-*-m-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierItalic.ttf
-filename.-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierItalic.ttf
-filename.-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierItalic.ttf
-filename.-monotype-courier-regular-i-normal--*-%d-*-*-m-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierItalic.ttf
-filename.-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierItalic.ttf
-filename.-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierItalic.ttf
-filename.-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierItalic.ttf
-filename.-monotype-courier-regular-i-normal--*-%d-*-*-m-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierItalic.ttf
-filename.-monotype-courier-regular-r-normal--*-%d-*-*-m-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierRegular.ttf
-filename.-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierRegular.ttf
-filename.-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierRegular.ttf
-filename.-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierRegular.ttf
-filename.-monotype-courier-regular-r-normal--*-%d-*-*-m-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierRegular.ttf
-filename.-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierRegular.ttf
-filename.-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierRegular.ttf
-filename.-monotype-courier-regular-r-normal--*-%d-*-*-m-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/CourierRegular.ttf
-filename.-monotype-courier_new-bold-i---*-%d-*-*-m-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/CourierNew-BoldItalic.ttf
-filename.-monotype-courier_new-bold-r---*-%d-*-*-m-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/CourierNew-Bold.ttf
-filename.-monotype-courier_new-regular-i---*-%d-*-*-m-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/CourierNew-Italic.ttf
-filename.-monotype-courier_new-regular-r---*-%d-*-*-m-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/CourierNew.ttf
-filename.-monotype-couriernew-bold-i-normal-BoldItalic-*-%d-*-*-m-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/courbi_h.ttf
-filename.-monotype-couriernew-bold-r-normal-Bold-*-%d-*-*-m-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/courb__h.ttf
-filename.-monotype-couriernew-medium-i-normal-Italic-*-%d-*-*-m-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/couri__h.ttf
-filename.-monotype-couriernew-medium-r-normal--*-%d-*-*-m-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/cour___h.ttf
-filename.-monotype-naskh-bold-r-normal--*-%d-*-*-p-*-iso8859-6=/usr/openwin/lib/locale/ar/X11/fonts/TrueType/NASKHBD.ttf
-filename.-monotype-naskh-medium-r-normal--*-%d-*-*-p-*-iso8859-6=/usr/openwin/lib/locale/ar/X11/fonts/TrueType/NASKHMT.ttf
-filename.-monotype-shayyal-bold-r-normal--*-%d-*-*-m-*-iso8859-6=/usr/openwin/lib/locale/ar/X11/fonts/TrueType/SHAYBD.ttf
-filename.-monotype-shayyal-medium-r-normal--*-%d-*-*-m-*-iso8859-6=/usr/openwin/lib/locale/ar/X11/fonts/TrueType/SHAYMT.ttf
-filename.-monotype-song-medium-r-normal--*-%d-*-*-m-*-gb2312.1980-0=/usr/openwin/lib/locale/zh/X11/fonts/TrueType/msgbl.ttf
-filename.-monotype-times-bold-i-normal--*-%d-*-*-p-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBoldItalic.ttf
-filename.-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBoldItalic.ttf
-filename.-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBoldItalic.ttf
-filename.-monotype-times-bold-i-normal--*-%d-*-*-p-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBoldItalic.ttf
-filename.-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBoldItalic.ttf
-filename.-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBoldItalic.ttf
-filename.-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBoldItalic.ttf
-filename.-monotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBoldItalic.ttf
-filename.-monotype-times-bold-r-normal--*-%d-*-*-p-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBold.ttf
-filename.-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBold.ttf
-filename.-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBold.ttf
-filename.-monotype-times-bold-r-normal--*-%d-*-*-p-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBold.ttf
-filename.-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBold.ttf
-filename.-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBold.ttf
-filename.-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBold.ttf
-filename.-monotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesBold.ttf
-filename.-monotype-times-regular-i-normal--*-%d-*-*-p-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesItalic.ttf
-filename.-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesItalic.ttf
-filename.-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesItalic.ttf
-filename.-monotype-times-regular-i-normal--*-%d-*-*-p-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesItalic.ttf
-filename.-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesItalic.ttf
-filename.-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesItalic.ttf
-filename.-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesItalic.ttf
-filename.-monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesItalic.ttf
-filename.-monotype-times-regular-r-normal--*-%d-*-*-p-*-ansi-1251=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesRegular.ttf
-filename.-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-13=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesRegular.ttf
-filename.-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-15=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesRegular.ttf
-filename.-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-2=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesRegular.ttf
-filename.-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-5=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesRegular.ttf
-filename.-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-7=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesRegular.ttf
-filename.-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-9=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesRegular.ttf
-filename.-monotype-times-regular-r-normal--*-%d-*-*-p-*-koi8-r=/usr/openwin/lib/locale/euro_fonts/X11/fonts/TrueType/TimesRegular.ttf
-filename.-monotype-times_new_roman-bold-i---*-%d-*-*-p-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/TimesNewRoman-BoldItalic.ttf
-filename.-monotype-times_new_roman-bold-r---*-%d-*-*-p-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/TimesNewRoman-Bold.ttf
-filename.-monotype-times_new_roman-regular-i---*-%d-*-*-p-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/TimesNewRoman-Italic.ttf
-filename.-monotype-times_new_roman-regular-r---*-%d-*-*-p-*-iso8859-1=/usr/openwin/lib/X11/fonts/TrueType/TimesNewRoman.ttf
-filename.-monotype-timesnewroman-bold-i-normal-bolditalic-*-%d-*-*-p-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/timesbih.ttf
-filename.-monotype-timesnewroman-bold-r-normal-bold-*-%d-*-*-p-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/timesb_h.ttf
-filename.-monotype-timesnewroman-medium-i-normal-italic-*-%d-*-*-p-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/timesi_h.ttf
-filename.-monotype-timesnewroman-medium-r-normal--*-%d-*-*-p-*-iso8859-8=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/times__h.ttf
-filename.-ricoh-heiseimin-w3-r-normal--*-%d-*-*-m-*-jisx0212.1990-0=/usr/openwin/lib/locale/ja/X11/fonts/TT/hgmlsun.ttf
-filename.-ricoh-hg_gothic_b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0=/usr/openwin/lib/locale/ja/X11/fonts/TT/hggbsun.ttf
-filename.-ricoh-hg_gothic_b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0=/usr/openwin/lib/locale/ja/X11/fonts/TT/hggbsun.ttf
-filename.-ricoh-hg_mincho_l-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0=/usr/openwin/lib/locale/ja/X11/fonts/TT/hgmlsun.ttf
-filename.-ricoh-hg_mincho_l-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0=/usr/openwin/lib/locale/ja/X11/fonts/TT/hgmlsun.ttf
-filename.-sun-song-medium-r-normal--*-%d-*-*-c-*-gbk-0=/usr/openwin/lib/locale/zh_CN.GB18030/X11/fonts/TrueType/songti.ttf
-filename.-urw-itc_zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific=/usr/openwin/lib/X11/fonts/TrueType/MonotypeSorts.ttf
+filename.-misc-lohit_bengali-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Bengali.ttf
+filename.-misc-lohit_gujarati-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Gujarati.ttf
+filename.-misc-lohit_hindi-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Hindi.ttf
+filename.-misc-lohit_kannada-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Kannada.ttf
+filename.-misc-lohit_malayalam-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Malayalam.ttf
+filename.-misc-lohit_marathi-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Marathi.ttf
+filename.-misc-lohit_tamil-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Tamil.ttf
+filename.-misc-lohit_telugu-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Telugu.ttf
+filename.-misc-dejavu_sans-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/dejavu/DejaVuSans.ttf
 
 # AWT X11 font paths
-awtfontpath.latin-1=/usr/openwin/lib/X11/fonts/TrueType
-awtfontpath.latin-2=/usr/openwin/lib/locale/iso_8859_2/X11/fonts/TrueType
-awtfontpath.latin-5=/usr/openwin/lib/locale/iso_8859_9/X11/fonts/TrueType
-awtfontpath.latin-7=/usr/openwin/lib/locale/iso_8859_13/X11/fonts/TrueType
-awtfontpath.latin-9=/usr/openwin/lib/locale/iso_8859_15/X11/fonts/TrueType
-awtfontpath.hebrew=/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType
-awtfontpath.arabic=/usr/openwin/lib/locale/ar/X11/fonts/TrueType
-awtfontpath.thai=/usr/openwin/lib/locale/th_TH/X11/fonts/TrueType
-awtfontpath.greek=/usr/openwin/lib/locale/iso_8859_7/X11/fonts/TrueType
-awtfontpath.cyrillic-iso8859-5=/usr/openwin/lib/locale/iso_8859_5/X11/fonts/TrueType
-awtfontpath.cyrillic-cp1251=/usr/openwin/lib/locale/ru.ansi-1251/X11/fonts/TrueType
-awtfontpath.cyrillic-koi8-r=/usr/openwin/lib/locale/KOI8-R/X11/fonts/TrueType
-awtfontpath.korean=/usr/openwin/lib/locale/ko/X11/fonts/TrueType
-awtfontpath.korean-johab=/usr/openwin/lib/locale/ko.UTF-8/X11/fonts/TrueType
-awtfontpath.japanese-x0201=/usr/openwin/lib/locale/ja/X11/fonts/TT
-awtfontpath.japanese-x0208=/usr/openwin/lib/locale/ja/X11/fonts/TT
-awtfontpath.japanese-x0212=/usr/openwin/lib/locale/ja/X11/fonts/TT
-awtfontpath.chinese-gbk=/usr/openwin/lib/locale/zh.GBK/X11/fonts/TrueType
-awtfontpath.chinese-cns11643-1=/usr/openwin/lib/locale/zh_TW/X11/fonts/TrueType
-awtfontpath.chinese-cns11643-2=/usr/openwin/lib/locale/zh_TW/X11/fonts/TrueType
-awtfontpath.chinese-cns11643-3=/usr/openwin/lib/locale/zh_TW/X11/fonts/TrueType
-awtfontpath.chinese-big5=/usr/openwin/lib/locale/zh_TW.BIG5/X11/fonts/TT
-awtfontpath.chinese-gb2312=/usr/openwin/lib/locale/zh/X11/fonts/TrueType
-awtfontpath.chinese-gb18030-0=/usr/openwin/lib/locale/zh_CN.GB18030/X11/fonts/TrueType
-awtfontpath.chinese-gb18030-1=/usr/openwin/lib/locale/zh_CN.GB18030/X11/fonts/TrueType
-awtfontpath.chinese-hkscs=/usr/openwin/lib/locale/zh_HK.BIG5HK/X11/fonts/TT
+awtfontpath.latin-1=/usr/share/fonts/TrueType/core
+awtfontpath.latin-2=/usr/share/fonts/TrueType/core
+awtfontpath.latin-5=/usr/share/fonts/TrueType/core
+awtfontpath.latin-7=/usr/share/fonts/TrueType/core
+awtfontpath.latin-9=/usr/share/fonts/TrueType/core
+awtfontpath.hebrew=/usr/share/fonts/TrueType/core
+awtfontpath.arabic=/usr/share/fonts/TrueType/core
+awtfontpath.thai=/usr/share/fonts/TrueType/core
+awtfontpath.greek=/usr/share/fonts/TrueType/core
+awtfontpath.cyrillic-iso8859-5=/usr/share/fonts/TrueType/core
+awtfontpath.cyrillic-cp1251=/usr/share/fonts/TrueType/core
+awtfontpath.cyrillic-koi8-r=/usr/share/fonts/TrueType/core
+awtfontpath.korean=/usr/share/fonts/TrueType/hanyang
+awtfontpath.korean-johab=/usr/share/fonts/TrueType/hanyang
+awtfontpath.japanese-x0201=/usr/share/fonts/TrueType/ipafont
+awtfontpath.japanese-x0208=/usr/share/fonts/TrueType/ipafont
+awtfontpath.japanese-x0212=/usr/share/fonts/TrueType/ipafont
+awtfontpath.chinese-gbk=/usr/share/fonts/TrueType/arphic
+awtfontpath.chinese-cns11643-1=/usr/share/fonts/TrueType/arphic
+awtfontpath.chinese-cns11643-2=/usr/share/fonts/TrueType/arphic
+awtfontpath.chinese-cns11643-3=/usr/share/fonts/TrueType/arphic
+awtfontpath.chinese-big5=/usr/share/fonts/TrueType/arphic
+awtfontpath.chinese-gb2312=/usr/share/fonts/TrueType/arphic
+awtfontpath.chinese-gb18030-0=/usr/share/fonts/TrueType/arphic
+awtfontpath.chinese-gb18030-1=/usr/share/fonts/TrueType/arphic
+awtfontpath.chinese-hkscs=/usr/share/fonts/TrueType/arphic
+awtfontpath.bengali=/usr/share/fonts/TrueType/lohit
+awtfontpath.gujarati=/usr/share/fonts/TrueType/lohit
+awtfontpath.hindi=/usr/share/fonts/TrueType/lohit
+awtfontpath.kannada=/usr/share/fonts/TrueType/lohit
+awtfontpath.malayalam=/usr/share/fonts/TrueType/lohit
+awtfontpath.marathi=/usr/share/fonts/TrueType/lohit
+awtfontpath.tamil=/usr/share/fonts/TrueType/lohit
+awtfontpath.telugu=/usr/share/fonts/TrueType/lohit
+awtfontpath.dejavusans=/usr/share/fonts/TrueType/dejavu
 
 # Appended Font Path
 
-
-
--- a/jdk/make/data/tzdata/VERSION	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/VERSION	Tue Oct 18 17:14:09 2016 +0000
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2016f
+tzdata2016g
--- a/jdk/make/data/tzdata/africa	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/africa	Tue Oct 18 17:14:09 2016 +0000
@@ -487,7 +487,7 @@
 # http://www.libyaherald.com/2013/10/24/correction-no-time-change-tomorrow/
 #
 # From Paul Eggert (2013-10-25):
-# For now, assume they're reverting to the pre-2012 rules of permanent UTC+2.
+# For now, assume they're reverting to the pre-2012 rules of permanent UT +02.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Libya	1951	only	-	Oct	14	2:00	1:00	S
--- a/jdk/make/data/tzdata/antarctica	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/antarctica	Tue Oct 18 17:14:09 2016 +0000
@@ -33,9 +33,7 @@
 # http://www.spri.cam.ac.uk/bob/periant.htm
 # for information.
 # Unless otherwise specified, we have no time zone information.
-#
-# Except for the French entries,
-# I made up all time zone abbreviations mentioned here; corrections welcome!
+
 # FORMAT is '-00' and GMTOFF is 0 for locations while uninhabited.
 
 # Argentina - year-round bases
@@ -52,7 +50,7 @@
 #	previously sealers and scientific personnel wintered
 #	Margaret Turner reports
 #	http://web.archive.org/web/20021204222245/http://www.dstc.qut.edu.au/DST/marg/daylight.html
-#	(1999-09-30) that they're UTC+5, with no DST;
+#	(1999-09-30) that they're UT +05, with no DST;
 #	presumably this is when they have visitors.
 #
 # year-round bases
@@ -91,23 +89,22 @@
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Casey	0	-	-00	1969
-			8:00	-	AWST	2009 Oct 18  2:00
-						# Australian Western Std Time
-			11:00	-	CAST	2010 Mar  5  2:00  # Casey Time
-			8:00	-	AWST	2011 Oct 28  2:00
-			11:00	-	CAST	2012 Feb 21 17:00u
-			8:00	-	AWST
+			8:00	-	+08	2009 Oct 18  2:00
+			11:00	-	+11	2010 Mar  5  2:00
+			8:00	-	+08	2011 Oct 28  2:00
+			11:00	-	+11	2012 Feb 21 17:00u
+			8:00	-	+08
 Zone Antarctica/Davis	0	-	-00	1957 Jan 13
-			7:00	-	DAVT	1964 Nov    # Davis Time
+			7:00	-	+07	1964 Nov
 			0	-	-00	1969 Feb
-			7:00	-	DAVT	2009 Oct 18  2:00
-			5:00	-	DAVT	2010 Mar 10 20:00u
-			7:00	-	DAVT	2011 Oct 28  2:00
-			5:00	-	DAVT	2012 Feb 21 20:00u
-			7:00	-	DAVT
+			7:00	-	+07	2009 Oct 18  2:00
+			5:00	-	+05	2010 Mar 10 20:00u
+			7:00	-	+07	2011 Oct 28  2:00
+			5:00	-	+05	2012 Feb 21 20:00u
+			7:00	-	+07
 Zone Antarctica/Mawson	0	-	-00	1954 Feb 13
-			6:00	-	MAWT	2009 Oct 18  2:00 # Mawson Time
-			5:00	-	MAWT
+			6:00	-	+06	2009 Oct 18  2:00
+			5:00	-	+05
 # References:
 # Casey Weather (1998-02-26)
 # http://www.antdiv.gov.au/aad/exop/sfo/casey/casey_aws.html
@@ -161,7 +158,7 @@
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Indian/Kerguelen	0	-	-00	1950 # Port-aux-Français
-			5:00	-	TFT	# ISO code TF Time
+			5:00	-	+05
 #
 # year-round base in the main continent
 # Dumont d'Urville, Île des Pétrels, -6640+14001, since 1956-11
@@ -172,9 +169,9 @@
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/DumontDUrville 0 -	-00	1947
-			10:00	-	PMT	1952 Jan 14 # Port-Martin Time
+			10:00	-	+10	1952 Jan 14
 			0	-	-00	1956 Nov
-			10:00	-	DDUT	# Dumont-d'Urville Time
+			10:00	-	+10
 
 # France & Italy - year-round base
 # Concordia, -750600+1232000, since 2005
@@ -200,7 +197,7 @@
 # station of Japan, it's appropriate for the principal location.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Syowa	0	-	-00	1957 Jan 29
-			3:00	-	SYOT	# Syowa Time
+			3:00	-	+03
 # See:
 # NIPR Antarctic Research Activities (1999-08-17)
 # http://www.nipr.ac.jp/english/ara01.html
@@ -237,17 +234,17 @@
 # correct, but they should be quite close to the actual dates.
 #
 # From Paul Eggert (2014-03-21):
-# The CET-switching Troll rules require zic from tzcode 2014b or later, so as
+# The CET-switching Troll rules require zic from tz 2014b or later, so as
 # suggested by Bengt-Inge Larsson comment them out for now, and approximate
 # with only UTC and CEST.  Uncomment them when 2014b is more prevalent.
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-#Rule	Troll	2005	max	-	Mar	 1	1:00u	1:00	CET
-Rule	Troll	2005	max	-	Mar	lastSun	1:00u	2:00	CEST
-#Rule	Troll	2005	max	-	Oct	lastSun	1:00u	1:00	CET
-#Rule	Troll	2004	max	-	Nov	 7	1:00u	0:00	UTC
+#Rule	Troll	2005	max	-	Mar	 1	1:00u	1:00	+01
+Rule	Troll	2005	max	-	Mar	lastSun	1:00u	2:00	+02
+#Rule	Troll	2005	max	-	Oct	lastSun	1:00u	1:00	+01
+#Rule	Troll	2004	max	-	Nov	 7	1:00u	0:00	+00
 # Remove the following line when uncommenting the above '#Rule' lines.
-Rule	Troll	2004	max	-	Oct	lastSun	1:00u	0:00	UTC
+Rule	Troll	2004	max	-	Oct	lastSun	1:00u	0:00	+00
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Troll	0	-	-00	2005 Feb 12
 			0:00	Troll	%s
@@ -288,10 +285,10 @@
 # changes during the year and does not necessarily correspond to mean
 # solar noon.  So the Vostok time might have been whatever the clocks
 # happened to be during their visit.  So we still don't really know what time
-# it is at Vostok.  But we'll guess UTC+6.
+# it is at Vostok.  But we'll guess +06.
 #
 Zone Antarctica/Vostok	0	-	-00	1957 Dec 16
-			6:00	-	VOST	# Vostok time
+			6:00	-	+06
 
 # S Africa - year-round bases
 # Marion Island, -4653+03752
@@ -324,7 +321,7 @@
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Rothera	0	-	-00	1976 Dec  1
-			-3:00	-	ROTT	# Rothera time
+			-3:00	-	-03
 
 # Uruguay - year round base
 # Artigas, King George Island, -621104-0585107
--- a/jdk/make/data/tzdata/asia	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/asia	Tue Oct 18 17:14:09 2016 +0000
@@ -139,13 +139,11 @@
 # http://www.worldtimezone.com/dst_news/dst_news_armenia03.html
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Yerevan	2:58:00 -	LMT	1924 May  2
-			3:00	-	YERT	1957 Mar    # Yerevan Time
-			4:00 RussiaAsia YER%sT	1991 Mar 31  2:00s
-			3:00	1:00	YERST	1991 Sep 23 # independence
-			3:00 RussiaAsia	AM%sT	1995 Sep 24  2:00s
-			4:00	-	AMT	1997
-			4:00 RussiaAsia	AM%sT	2012 Feb  9
-			4:00	-	AMT
+			3:00	-	+03	1957 Mar
+			4:00 RussiaAsia +04/+05	1991 Mar 31  2:00s
+			3:00 RussiaAsia	+03/+04	1995 Sep 24  2:00s
+			4:00	-	+04	1997
+			4:00 RussiaAsia	+04/+05
 
 # Azerbaijan
 
@@ -166,13 +164,12 @@
 Rule	Azer	1997	2015	-	Oct	lastSun	 5:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Baku	3:19:24 -	LMT	1924 May  2
-			3:00	-	BAKT	1957 Mar    # Baku Time
-			4:00 RussiaAsia BAK%sT	1991 Mar 31  2:00s
-			3:00	1:00	BAKST	1991 Aug 30 # independence
-			3:00 RussiaAsia	AZ%sT	1992 Sep lastSun  2:00s
-			4:00	-	AZT	1996     # Azerbaijan Time
-			4:00	EUAsia	AZ%sT	1997
-			4:00	Azer	AZ%sT
+			3:00	-	+03	1957 Mar
+			4:00 RussiaAsia +04/+05	1991 Mar 31  2:00s
+			3:00 RussiaAsia	+03/+04	1992 Sep lastSun  2:00s
+			4:00	-	+04	1996
+			4:00	EUAsia	+04/+05	1997
+			4:00	Azer	+04/+05
 
 # Bahrain
 # See Asia/Qatar.
@@ -291,7 +288,7 @@
 # Milne says 6:24:40 was the meridian of the time ball observatory at Rangoon.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone	Asia/Rangoon	6:24:40 -	LMT	1880        # or Yangon
+Zone	Asia/Yangon	6:24:40 -	LMT	1880        # or Rangoon
 			6:24:40	-	RMT	1920        # Rangoon Mean Time?
 			6:30	-	BURT	1942 May    # Burma Time
 			9:00	-	JST	1945 May  3
@@ -406,7 +403,7 @@
 # Lewiston (ME) Daily Sun (1939-05-29), p 17, said "Even the time is
 # different - the occupied districts going by Tokyo time, an hour
 # ahead of that prevailing in the rest of Shanghai."  Guess that the
-# Xujiahui Observatory was under French control and stuck with UT+8.
+# Xujiahui Observatory was under French control and stuck with UT +08.
 #
 # In earlier versions of this file, China had many separate Zone entries, but
 # this was based on what were apparently incorrect data in Shanks & Pottenger.
@@ -415,26 +412,26 @@
 # Proposed in 1918 and theoretically in effect until 1949 (although in practice
 # mainly observed in coastal areas), the five zones were:
 #
-# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT+8.5
+# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT +08:30
 # Asia/Harbin (currently a link to Asia/Shanghai)
 # Heilongjiang (except Mohe county), Jilin
 #
-# Zhongyuan Time ("Central plain Time") UT+8
+# Zhongyuan Time ("Central plain Time") UT +08
 # Asia/Shanghai
 # most of China
 # This currently represents most other zones as well,
 # as apparently these regions have been the same since 1970.
 # Milne gives 8:05:43.2 for Xujiahui Observatory time; round to nearest.
-# Guo says Shanghai switched to UT+8 "from the end of the 19th century".
+# Guo says Shanghai switched to UT +08 "from the end of the 19th century".
 #
-# Long-shu Time (probably due to Long and Shu being two names of that area) UT+7
+# Long-shu Time (probably due to Long and Shu being two names of the area) UT +07
 # Asia/Chongqing (currently a link to Asia/Shanghai)
 # Guangxi, Guizhou, Hainan, Ningxia, Sichuan, Shaanxi, and Yunnan;
 # most of Gansu; west Inner Mongolia; west Qinghai; and the Guangdong
 # counties Deqing, Enping, Kaiping, Luoding, Taishan, Xinxing,
 # Yangchun, Yangjiang, Yu'nan, and Yunfu.
 #
-# Xin-zang Time ("Xinjiang-Tibet Time") UT+6
+# Xin-zang Time ("Xinjiang-Tibet Time") UT +06
 # Asia/Urumqi
 # This currently represents Kunlun Time as well,
 # as apparently the two regions have been the same since 1970.
@@ -447,7 +444,7 @@
 # Shihezi, Changji, Yanqi, Heshuo, Tuokexun, Tulufan, Shanshan, Hami,
 # Fukang, Kuitun, Kumukuli, Miquan, Qitai, and Turfan.
 #
-# Kunlun Time UT+5.5
+# Kunlun Time UT +05:30
 # Asia/Kashgar (currently a link to Asia/Urumqi)
 # West Tibet, including Pulan, Aheqi, Shufu, Shule;
 # West Xinjiang, including Aksu, Atushi, Yining, Hetian, Cele, Luopu, Nileke,
@@ -463,7 +460,7 @@
 #
 # On the other hand, ethnic Uyghurs, who make up about half the
 # population of Xinjiang, typically use "Xinjiang time" which is two
-# hours behind Beijing time, or UTC +0600. The government of the Xinjiang
+# hours behind Beijing time, or UT +06. The government of the Xinjiang
 # Uyghur Autonomous Region, (XAUR, or just Xinjiang for short) as well as
 # local governments such as the Ürümqi city government use both times in
 # publications, referring to what is popularly called Xinjiang time as
@@ -519,8 +516,8 @@
 # having the same time as Beijing.
 
 # From Paul Eggert (2014-06-30):
-# In the early days of the PRC, Tibet was given its own time zone (UT+6) but
-# this was withdrawn in 1959 and never reinstated; see Tubten Khétsun,
+# In the early days of the PRC, Tibet was given its own time zone (UT +06)
+# but this was withdrawn in 1959 and never reinstated; see Tubten Khétsun,
 # Memories of life in Lhasa under Chinese Rule, Columbia U Press, ISBN
 # 978-0231142861 (2008), translator's introduction by Matthew Akester, p x.
 # As this is before our 1970 cutoff, Tibet doesn't need a separate zone.
@@ -534,12 +531,12 @@
 # Republics, the Soviet Union, the Kuomintang, and the People's Republic of
 # China, and tracking down all these organizations' timekeeping rules would be
 # quite a trick.  Approximate this lost history by a transition from LMT to
-# XJT at the start of 1928, the year of accession of the warlord Jin Shuren,
+# UT +06 at the start of 1928, the year of accession of the warlord Jin Shuren,
 # which happens to be the date given by Shanks & Pottenger (no doubt as a
-# guess) as the transition from LMT.  Ignore the usage of UT+8 before
-# 1986-02-01 under the theory that the transition date to UT+8 is unknown and
+# guess) as the transition from LMT.  Ignore the usage of +08 before
+# 1986-02-01 under the theory that the transition date to +08 is unknown and
 # that the sort of users who prefer Asia/Urumqi now typically ignored the
-# UT+8 mandate back then.
+# +08 mandate back then.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Beijing time, used throughout China; represented by Shanghai.
@@ -744,7 +741,7 @@
 # be found from historical government announcement database.
 
 # From Paul Eggert (2014-07-03):
-# As per Yu-Cheng Chuang, say that Taiwan was at UT+9 from 1937-10-01
+# As per Yu-Cheng Chuang, say that Taiwan was at UT +09 from 1937-10-01
 # until 1945-09-21 at 01:00, overriding Shanks & Pottenger.
 # Likewise, use Yu-Cheng Chuang's data for DST in Taiwan.
 
@@ -858,16 +855,15 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Tbilisi	2:59:11 -	LMT	1880
 			2:59:11	-	TBMT	1924 May  2 # Tbilisi Mean Time
-			3:00	-	TBIT	1957 Mar    # Tbilisi Time
-			4:00 RussiaAsia TBI%sT	1991 Mar 31  2:00s
-			3:00	1:00	TBIST	1991 Apr  9 # independence
-			3:00 RussiaAsia GE%sT	1992        # Georgia Time
-			3:00 E-EurAsia	GE%sT	1994 Sep lastSun
-			4:00 E-EurAsia	GE%sT	1996 Oct lastSun
-			4:00	1:00	GEST	1997 Mar lastSun
-			4:00 E-EurAsia	GE%sT	2004 Jun 27
-			3:00 RussiaAsia	GE%sT	2005 Mar lastSun  2:00
-			4:00	-	GET
+			3:00	-	+03	1957 Mar
+			4:00 RussiaAsia +04/+05	1991 Mar 31  2:00s
+			3:00 RussiaAsia +03/+04	1992
+			3:00 E-EurAsia	+03/+04	1994 Sep lastSun
+			4:00 E-EurAsia	+04/+05	1996 Oct lastSun
+			4:00	1:00	+05	1997 Mar lastSun
+			4:00 E-EurAsia	+04/+05	2004 Jun 27
+			3:00 RussiaAsia	+03/+04	2005 Mar lastSun  2:00
+			4:00	-	+04
 
 # East Timor
 
@@ -944,7 +940,7 @@
 # These would be the earliest possible times for a change.
 # Régimes horaires pour le monde entier, by Henri Le Corre, (Éditions
 # Traditionnelles, 1987, Paris) says that Java and Madura switched
-# from JST to UTC+07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura
+# from UT +09 to +07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura
 # (Hollandia).  For now, assume all Indonesian locations other than Jayapura
 # switched on 1945-09-23.
 #
@@ -955,11 +951,11 @@
 # summary published by the Time and Frequency Laboratory of the
 # Research Center for Calibration, Instrumentation and Metrology,
 # Indonesia, <http://time.kim.lipi.go.id/time-eng.php> (2006-09-29).
-# The abbreviations are:
+# The time zone abbreviations and UT offsets are:
 #
-# WIB  - UTC+7 - Waktu Indonesia Barat (Indonesia western time)
-# WITA - UTC+8 - Waktu Indonesia Tengah (Indonesia central time)
-# WIT  - UTC+9 - Waktu Indonesia Timur (Indonesia eastern time)
+# WIB  - +07 - Waktu Indonesia Barat (Indonesia western time)
+# WITA - +08 - Waktu Indonesia Tengah (Indonesia central time)
+# WIT  - +09 - Waktu Indonesia Timur (Indonesia eastern time)
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Java, Sumatra
@@ -1848,11 +1844,11 @@
 Rule	Kyrgyz	1997	2004	-	Oct	lastSun	2:30	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Bishkek	4:58:24 -	LMT	1924 May  2
-			5:00	-	FRUT	1930 Jun 21 # Frunze Time
-			6:00 RussiaAsia FRU%sT	1991 Mar 31  2:00s
-			5:00	1:00	FRUST	1991 Aug 31  2:00 # independence
-			5:00	Kyrgyz	KG%sT	2005 Aug 12 # Kyrgyzstan Time
-			6:00	-	KGT
+			5:00	-	+05	1930 Jun 21
+			6:00 RussiaAsia +06/+07	1991 Mar 31  2:00s
+			5:00 RussiaAsia	+05/+06	1991 Aug 31  2:00
+			5:00	Kyrgyz	+05/+06	2005 Aug 12
+			6:00	-	+06
 
 ###############################################################################
 
@@ -1891,25 +1887,24 @@
 Rule	ROK	1987	1988	-	May	Sun>=8	2:00	1:00	D
 Rule	ROK	1987	1988	-	Oct	Sun>=8	3:00	0	S
 
-# From Paul Eggert (2014-10-30):
+# From Paul Eggert (2016-08-23):
 # The Korean Wikipedia entry gives the following sources for UT offsets:
 #
-# 1908: Official Journal Article No. 3994 (Edict No. 5)
+# 1908: Official Journal Article No. 3994 (decree No. 5)
 # 1912: Governor-General of Korea Official Gazette Issue No. 367
 #       (Announcement No. 338)
 # 1954: Presidential Decree No. 876 (1954-03-17)
 # 1961: Law No. 676 (1961-08-07)
-# 1987: Law No. 3919 (1986-12-31)
 #
-# The Wikipedia entry also has confusing information about a change
-# to UT+9 in April 1910, but then what would be the point of the later change
-# to UT+9 on 1912-01-01?  Omit the 1910 change for now.
+# (Another source "1987: Law No. 3919 (1986-12-31)" was in the 2014-10-30
+# edition of the Korean Wikipedia entry.)
 #
 # I guessed that time zone abbreviations through 1945 followed the same
 # rules as discussed under Taiwan, with nominal switches from JST to KST
 # when the respective cities were taken over by the Allies after WWII.
 #
-# For Pyongyang we have no information; guess no changes since World War II.
+# For Pyongyang, guess no changes from World War II until 2015, as we
+# have no information otherwise.
 
 # From Steffen Thorsen (2015-08-07):
 # According to many news sources, North Korea is going to change to
@@ -2069,7 +2064,7 @@
 # Bill Bonnet (2005-05-19) reports that the US Embassy in Ulaanbaatar says
 # there is only one time zone and that DST is observed, citing Microsoft
 # Windows XP as the source.  Risto Nykänen (2005-05-16) reports that
-# travelmongolia.org says there are two time zones (UTC+7, UTC+8) with no DST.
+# travelmongolia.org says there are two time zones (UT +07, +08) with no DST.
 # Oscar van Vlijmen (2005-05-20) reports that the Mongolian Embassy in
 # Washington, DC says there are two time zones, with DST observed.
 # He also found
@@ -2705,7 +2700,7 @@
 # earlier date.
 #
 # Shanks & Pottenger also state that until 1968-05-01 Saudi Arabia had two
-# time zones; the other zone, at UTC+4, was in the far eastern part of
+# time zones; the other zone, at UT +04, was in the far eastern part of
 # the country.  Ignore this, as it's before our 1970 cutoff.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -2974,10 +2969,10 @@
 # From Shanks & Pottenger.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dushanbe	4:35:12 -	LMT	1924 May  2
-			5:00	-	DUST	1930 Jun 21 # Dushanbe Time
-			6:00 RussiaAsia DUS%sT	1991 Mar 31  2:00s
-			5:00	1:00	DUSST	1991 Sep  9  2:00s
-			5:00	-	TJT	# Tajikistan Time
+			5:00	-	+05	1930 Jun 21
+			6:00 RussiaAsia +06/+07	1991 Mar 31  2:00s
+			5:00	1:00	+05/+06	1991 Sep  9  2:00s
+			5:00	-	+05
 
 # Thailand
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -2991,11 +2986,10 @@
 # From Shanks & Pottenger.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Ashgabat	3:53:32 -	LMT	1924 May  2 # or Ashkhabad
-			4:00	-	ASHT	1930 Jun 21 # Ashkhabad Time
-			5:00 RussiaAsia	ASH%sT	1991 Mar 31  2:00
-			4:00 RussiaAsia	ASH%sT	1991 Oct 27 # independence
-			4:00 RussiaAsia	TM%sT	1992 Jan 19  2:00
-			5:00	-	TMT
+			4:00	-	+04	1930 Jun 21
+			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00
+			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00
+			5:00	-	+05
 
 # United Arab Emirates
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -3007,20 +3001,18 @@
 # Byalokoz 1919 says Uzbekistan was 4:27:53.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Samarkand	4:27:53 -	LMT	1924 May  2
-			4:00	-	SAMT	1930 Jun 21 # Samarkand Time
-			5:00	-	SAMT	1981 Apr  1
-			5:00	1:00	SAMST	1981 Oct  1
-			6:00	-	TAST	1982 Apr  1 # Tashkent Time
-			5:00 RussiaAsia	SAM%sT	1991 Sep  1 # independence
-			5:00 RussiaAsia	UZ%sT	1992
-			5:00	-	UZT
+			4:00	-	+04	1930 Jun 21
+			5:00	-	+05	1981 Apr  1
+			5:00	1:00	+06	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1992
+			5:00	-	+05
 # Milne says Tashkent was 4:37:10.8; round to nearest.
 Zone	Asia/Tashkent	4:37:11 -	LMT	1924 May  2
-			5:00	-	TAST	1930 Jun 21 # Tashkent Time
-			6:00 RussiaAsia	TAS%sT	1991 Mar 31  2:00
-			5:00 RussiaAsia	TAS%sT	1991 Sep  1 # independence
-			5:00 RussiaAsia	UZ%sT	1992
-			5:00	-	UZT
+			5:00	-	+05	1930 Jun 21
+			6:00 RussiaAsia	+06/+07	1991 Mar 31  2:00
+			5:00 RussiaAsia	+05/+06	1992
+			5:00	-	+05
 
 # Vietnam
 
--- a/jdk/make/data/tzdata/australasia	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/australasia	Tue Oct 18 17:14:09 2016 +0000
@@ -568,7 +568,7 @@
 # Base the Bougainville entry on the Arawa-Kieta region, which appears to have
 # the most people even though it was devastated in the Bougainville Civil War.
 #
-# Although Shanks gives 1942-03-15 / 1943-11-01 for JST, these dates
+# Although Shanks gives 1942-03-15 / 1943-11-01 for UT +09, these dates
 # are apparently rough guesswork from the starts of military campaigns.
 # The World War II entries below are instead based on Arawa-Kieta.
 # The Japanese occupied Kieta in July 1942,
@@ -576,8 +576,8 @@
 # http://pwencycl.kgbudge.com/B/o/Bougainville.htm
 # and seem to have controlled it until their 1945-08-21 surrender.
 #
-# The Autonomous Region of Bougainville plans to switch from UTC+10 to UTC+11
-# on 2014-12-28 at 02:00.  They call UTC+11 "Bougainville Standard Time";
+# The Autonomous Region of Bougainville switched from UT +10 to +11
+# on 2014-12-28 at 02:00.  They call +11 "Bougainville Standard Time";
 # abbreviate this as BST.  See:
 # http://www.bougainville24.com/bougainville-issues/bougainville-gets-own-timezone/
 #
@@ -643,7 +643,7 @@
 # From Paul Eggert (2014-06-27):
 # The International Date Line Act 2011
 # http://www.parliament.gov.ws/images/ACTS/International_Date_Line_Act__2011_-_Eng.pdf
-# changed Samoa from UTC-11 to UTC+13, effective "12 o'clock midnight, on
+# changed Samoa from UT -11 to +13, effective "12 o'clock midnight, on
 # Thursday 29th December 2011".  The International Date Line was adjusted
 # accordingly.
 
@@ -738,7 +738,7 @@
 # 1886-1891; Baker was similar but exact dates are not known.
 # Inhabited by civilians 1935-1942; U.S. military bases 1943-1944;
 # uninhabited thereafter.
-# Howland observed Hawaii Standard Time (UT-10:30) in 1937;
+# Howland observed Hawaii Standard Time (UT -10:30) in 1937;
 # see page 206 of Elgen M. Long and Marie K. Long,
 # Amelia Earhart: the Mystery Solved, Simon & Schuster (2000).
 # So most likely Howland and Baker observed Hawaii Time from 1935
@@ -1496,7 +1496,7 @@
 # Zealand time.  I understand that is the time they keep locally, anyhow."
 # For now, assume this practice goes back to the introduction of standard time
 # in New Zealand, as this would make Chatham Islands time almost exactly match
-# LMT back when New Zealand was at UTC+11:30; also, assume Chatham Islands did
+# LMT back when New Zealand was at UT +11:30; also, assume Chatham Islands did
 # not observe New Zealand's prewar DST.
 
 ###############################################################################
@@ -1552,7 +1552,7 @@
 # For now, we assume the Ladrones switched at the same time as the Philippines;
 # see Asia/Manila.
 
-# US Public Law 106-564 (2000-12-23) made UTC+10 the official standard time,
+# US Public Law 106-564 (2000-12-23) made UT +10 the official standard time,
 # under the name "Chamorro Standard Time".  There is no official abbreviation,
 # but Congressman Robert A. Underwood, author of the bill that became law,
 # wrote in a press release (2000-12-27) that he will seek the use of "ChST".
@@ -1564,15 +1564,15 @@
 # "I am certain, having lived there for the past decade, that 'Truk'
 # (now properly known as Chuuk) ... is in the time zone GMT+10."
 #
-# Shanks & Pottenger write that Truk switched from UTC+10 to UTC+11
+# Shanks & Pottenger write that Truk switched from UT +10 to +11
 # on 1978-10-01; ignore this for now.
 
 # From Paul Eggert (1999-10-29):
 # The Federated States of Micronesia Visitors Board writes in
 # The Federated States of Micronesia - Visitor Information (1999-01-26)
 # http://www.fsmgov.org/info/clocks.html
-# that Truk and Yap are UTC+10, and Ponape and Kosrae are UTC+11.
-# We don't know when Kosrae switched from UTC+12; assume January 1 for now.
+# that Truk and Yap are UT +10, and Ponape and Kosrae are +11.
+# We don't know when Kosrae switched from +12; assume January 1 for now.
 
 
 # Midway
@@ -1638,11 +1638,11 @@
 # ordaining - by a masterpiece of diplomatic flattery - that
 # the Fourth of July should be celebrated twice in that year."
 
-# Although Shanks & Pottenger says they both switched to UTC-11:30
-# in 1911, and to UTC-11 in 1950. many earlier sources give UTC-11
+# Although Shanks & Pottenger says they both switched to UT -11:30
+# in 1911, and to -11 in 1950. many earlier sources give -11
 # for American Samoa, e.g., the US National Bureau of Standards
 # circular "Standard Time Throughout the World", 1932.
-# Assume American Samoa switched to UTC-11 in 1911, not 1950,
+# Assume American Samoa switched to -11 in 1911, not 1950,
 # and that after 1950 they agreed until (western) Samoa skipped a
 # day in 2011.  Assume also that the Samoas follow the US and New
 # Zealand's "ST"/"DT" style of daylight-saving abbreviations.
--- a/jdk/make/data/tzdata/backward	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/backward	Tue Oct 18 17:14:09 2016 +0000
@@ -59,6 +59,7 @@
 Link	Asia/Urumqi		Asia/Kashgar
 Link	Asia/Kathmandu		Asia/Katmandu
 Link	Asia/Macau		Asia/Macao
+Link	Asia/Yangon		Asia/Rangoon
 Link	Asia/Ho_Chi_Minh	Asia/Saigon
 Link	Asia/Jerusalem		Asia/Tel_Aviv
 Link	Asia/Thimphu		Asia/Thimbu
--- a/jdk/make/data/tzdata/etcetera	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/etcetera	Tue Oct 18 17:14:09 2016 +0000
@@ -31,6 +31,13 @@
 # need now for the entries that are not on UTC are for ships at sea
 # that cannot use POSIX TZ settings.
 
+# Starting with POSIX 1003.1-2001, the entries below are all
+# unnecessary as settings for the TZ environment variable.  E.g.,
+# instead of TZ='Etc/GMT+4' one can use the POSIX setting TZ='<-04>+4'.
+#
+# Do not use a POSIX TZ setting like TZ='GMT+4', which is four hours
+# behind GMT but uses the completely misleading abbreviation "GMT".
+
 Zone	Etc/GMT		0	-	GMT
 Zone	Etc/UTC		0	-	UTC
 Zone	Etc/UCT		0	-	UCT
@@ -49,23 +56,13 @@
 Link	Etc/GMT				Etc/GMT+0
 Link	Etc/GMT				Etc/GMT0
 
-# We use POSIX-style signs in the Zone names and the output abbreviations,
+# Be consistent with POSIX TZ settings in the Zone names,
 # even though this is the opposite of what many people expect.
 # POSIX has positive signs west of Greenwich, but many people expect
 # positive signs east of Greenwich.  For example, TZ='Etc/GMT+4' uses
-# the abbreviation "GMT+4" and corresponds to 4 hours behind UT
+# the abbreviation "-04" and corresponds to 4 hours behind UT
 # (i.e. west of Greenwich) even though many people would expect it to
 # mean 4 hours ahead of UT (i.e. east of Greenwich).
-#
-# In the draft 5 of POSIX 1003.1-200x, the angle bracket notation allows for
-# TZ='<GMT-4>+4'; if you want time zone abbreviations conforming to
-# ISO 8601 you can use TZ='<-0400>+4'.  Thus the commonly-expected
-# offset is kept within the angle bracket (and is used for display)
-# while the POSIX sign is kept outside the angle bracket (and is used
-# for calculation).
-#
-# Do not use a TZ setting like TZ='GMT+4', which is four hours behind
-# GMT but uses the completely misleading abbreviation "GMT".
 
 # Earlier incarnations of this package were not POSIX-compliant,
 # and had lines such as
@@ -74,30 +71,31 @@
 # way does a
 #		zic -l GMT-12
 # so we moved the names into the Etc subdirectory.
+# Also, the time zone abbreviations are now compatible with %z.
 
-Zone	Etc/GMT-14	14	-	GMT-14	# 14 hours ahead of GMT
-Zone	Etc/GMT-13	13	-	GMT-13
-Zone	Etc/GMT-12	12	-	GMT-12
-Zone	Etc/GMT-11	11	-	GMT-11
-Zone	Etc/GMT-10	10	-	GMT-10
-Zone	Etc/GMT-9	9	-	GMT-9
-Zone	Etc/GMT-8	8	-	GMT-8
-Zone	Etc/GMT-7	7	-	GMT-7
-Zone	Etc/GMT-6	6	-	GMT-6
-Zone	Etc/GMT-5	5	-	GMT-5
-Zone	Etc/GMT-4	4	-	GMT-4
-Zone	Etc/GMT-3	3	-	GMT-3
-Zone	Etc/GMT-2	2	-	GMT-2
-Zone	Etc/GMT-1	1	-	GMT-1
-Zone	Etc/GMT+1	-1	-	GMT+1
-Zone	Etc/GMT+2	-2	-	GMT+2
-Zone	Etc/GMT+3	-3	-	GMT+3
-Zone	Etc/GMT+4	-4	-	GMT+4
-Zone	Etc/GMT+5	-5	-	GMT+5
-Zone	Etc/GMT+6	-6	-	GMT+6
-Zone	Etc/GMT+7	-7	-	GMT+7
-Zone	Etc/GMT+8	-8	-	GMT+8
-Zone	Etc/GMT+9	-9	-	GMT+9
-Zone	Etc/GMT+10	-10	-	GMT+10
-Zone	Etc/GMT+11	-11	-	GMT+11
-Zone	Etc/GMT+12	-12	-	GMT+12
+Zone	Etc/GMT-14	14	-	+14
+Zone	Etc/GMT-13	13	-	+13
+Zone	Etc/GMT-12	12	-	+12
+Zone	Etc/GMT-11	11	-	+11
+Zone	Etc/GMT-10	10	-	+10
+Zone	Etc/GMT-9	9	-	+09
+Zone	Etc/GMT-8	8	-	+08
+Zone	Etc/GMT-7	7	-	+07
+Zone	Etc/GMT-6	6	-	+06
+Zone	Etc/GMT-5	5	-	+05
+Zone	Etc/GMT-4	4	-	+04
+Zone	Etc/GMT-3	3	-	+03
+Zone	Etc/GMT-2	2	-	+02
+Zone	Etc/GMT-1	1	-	+01
+Zone	Etc/GMT+1	-1	-	-01
+Zone	Etc/GMT+2	-2	-	-02
+Zone	Etc/GMT+3	-3	-	-03
+Zone	Etc/GMT+4	-4	-	-04
+Zone	Etc/GMT+5	-5	-	-05
+Zone	Etc/GMT+6	-6	-	-06
+Zone	Etc/GMT+7	-7	-	-07
+Zone	Etc/GMT+8	-8	-	-08
+Zone	Etc/GMT+9	-9	-	-09
+Zone	Etc/GMT+10	-10	-	-10
+Zone	Etc/GMT+11	-11	-	-11
+Zone	Etc/GMT+12	-12	-	-12
--- a/jdk/make/data/tzdata/europe	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/europe	Tue Oct 18 17:14:09 2016 +0000
@@ -98,8 +98,7 @@
 #        1:00       CET CEST CEMT Central Europe
 #        1:00:14    SET           Swedish (1879-1899)*
 #        2:00       EET EEST      Eastern Europe
-#        3:00       FET           Further-eastern Europe (2011-2014)*
-#        3:00       MSK MSD  MSM* Minsk, Moscow
+#        3:00       MSK MSD       Moscow
 
 # From Peter Ilieve (1994-12-04),
 # The original six [EU members]: Belgium, France, (West) Germany, Italy,
@@ -606,16 +605,33 @@
 Rule	E-Eur	1981	max	-	Mar	lastSun	 0:00	1:00	S
 Rule	E-Eur	1996	max	-	Oct	lastSun	 0:00	0	-
 
+
+# Daylight saving time for Russia and the Soviet Union
+#
+# The 1917-1921 decree URLs are from Alexander Belopolsky (2016-08-23).
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Russia	1917	only	-	Jul	 1	23:00	1:00	MST  # Moscow Summer Time
+#
+# Decree No. 142 (1917-12-22) http://istmat.info/node/28137
 Rule	Russia	1917	only	-	Dec	28	 0:00	0	MMT  # Moscow Mean Time
+#
+# Decree No. 497 (1918-05-30) http://istmat.info/node/30001
 Rule	Russia	1918	only	-	May	31	22:00	2:00	MDST # Moscow Double Summer Time
 Rule	Russia	1918	only	-	Sep	16	 1:00	1:00	MST
+#
+# Decree No. 258 (1919-05-29) http://istmat.info/node/37949
 Rule	Russia	1919	only	-	May	31	23:00	2:00	MDST
-Rule	Russia	1919	only	-	Jul	 1	 2:00	1:00	MSD
+#
+Rule	Russia	1919	only	-	Jul	 1	 0:00u	1:00	MSD
 Rule	Russia	1919	only	-	Aug	16	 0:00	0	MSK
+#
+# Decree No. 63 (1921-02-03) http://istmat.info/node/45840
 Rule	Russia	1921	only	-	Feb	14	23:00	1:00	MSD
-Rule	Russia	1921	only	-	Mar	20	23:00	2:00	MSM  # Midsummer
+#
+# Decree No. 121 (1921-03-07) http://istmat.info/node/45949
+Rule	Russia	1921	only	-	Mar	20	23:00	2:00	+05
+#
 Rule	Russia	1921	only	-	Sep	 1	 0:00	1:00	MSD
 Rule	Russia	1921	only	-	Oct	 1	 0:00	0	-
 # Act No. 925 of the Council of Ministers of the USSR (1980-10-24):
@@ -798,8 +814,6 @@
 # From Alexander Bokovoy (2014-10-09):
 # Belarussian government decided against changing to winter time....
 # http://eng.belta.by/all_news/society/Belarus-decides-against-adjusting-time-in-Russias-wake_i_76335.html
-# From Paul Eggert (2014-10-08):
-# Hence Belarus can share time zone abbreviations with Moscow again.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Europe/Minsk	1:50:16 -	LMT	1880
@@ -810,8 +824,7 @@
 			3:00	Russia	MSK/MSD	1990
 			3:00	-	MSK	1991 Mar 31  2:00s
 			2:00	Russia	EE%sT	2011 Mar 27  2:00s
-			3:00	-	FET	2014 Oct 26  1:00s
-			3:00	-	MSK
+			3:00	-	+03
 
 # Belgium
 #
@@ -1319,7 +1332,7 @@
 # http://www.parlament-berlin.de/pds-fraktion.nsf/727459127c8b66ee8525662300459099/defc77cb784f180ac1256c2b0030274b/$FILE/bersarint.pdf
 # says that Bersarin issued an order to use Moscow time on May 20.
 # However, Moscow did not observe daylight saving in 1945, so
-# this was equivalent to CEMT (GMT+3), not GMT+4.
+# this was equivalent to UT +03, not +04.
 
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
@@ -2283,7 +2296,6 @@
 # http://www.worldtimezone.com/dst_news/dst_news_russia-map-2014-07.html
 
 # From Paul Eggert (2006-03-22):
-# Except for Moscow after 1919-07-01, I invented the time zone abbreviations.
 # Moscow time zone abbreviations after 1919-07-01, and Moscow rules after 1991,
 # are from Andrey A. Chernov.  The rest is from Shanks & Pottenger,
 # except we follow Chernov's report that 1992 DST transitions were Sat
@@ -2359,7 +2371,7 @@
 			 2:00	Poland	CE%sT	1946
 			 3:00	Russia	MSK/MSD	1989 Mar 26  2:00s
 			 2:00	Russia	EE%sT	2011 Mar 27  2:00s
-			 3:00	-	FET	2014 Oct 26  2:00s
+			 3:00	-	+03	2014 Oct 26  2:00s
 			 2:00	-	EET
 
 
@@ -2412,6 +2424,16 @@
 # 78	RU-SPE	Saint Petersburg
 # 83	RU-NEN	Nenets Autonomous Okrug
 
+# From Paul Eggert (2016-08-23):
+# The Soviets switched to UT-based time in 1919.  Decree No. 59
+# (1919-02-08) http://istmat.info/node/35567 established UT-based time
+# zones, and Decree No. 147 (1919-03-29) http://istmat.info/node/35854
+# specified a transition date of 1919-07-01, apparently at 00:00 UT.
+# No doubt only the Soviet-controlled regions switched on that date;
+# later transitions to UT-based time in other parts of Russia are
+# taken from what appear to be guesses by Shanks.
+# (Thanks to Alexander Belopolsky for pointers to the decrees.)
+
 # From Stepan Golosunov (2016-03-07):
 # 11. Regions-violators, 1981-1982.
 # Wikipedia refers to
@@ -2453,7 +2475,7 @@
 # attributes the 1982 changes to the Act of the Council of Ministers
 # of the USSR No. 126 from 18.02.1982.  1980-925.txt also adds
 # Udmurtia to the list of affected territories and lists Khatangsky
-# district separately from Taymyr Autonomous Okurg.  Probably erroneously.
+# district separately from Taymyr Autonomous Okrug.  Probably erroneously.
 #
 # The affected territories are currently listed under Europe/Moscow,
 # Asia/Yekaterinburg and Asia/Krasnoyarsk.
@@ -2513,7 +2535,7 @@
 
 Zone Europe/Moscow	 2:30:17 -	LMT	1880
 			 2:30:17 -	MMT	1916 Jul  3 # Moscow Mean Time
-			 2:31:19 Russia	%s	1919 Jul  1  2:00
+			 2:31:19 Russia	%s	1919 Jul  1  0:00u
 			 3:00	Russia	%s	1921 Oct
 			 3:00	Russia	MSK/MSD	1922 Oct
 			 2:00	-	EET	1930 Jun 21
@@ -2596,22 +2618,21 @@
 # The 1988 transition is from USSR act No. 5 (1988-01-04).
 
 Zone Europe/Volgograd	 2:57:40 -	LMT	1920 Jan  3
-			 3:00	-	TSAT	1925 Apr  6 # Tsaritsyn Time
-			 3:00	-	STAT	1930 Jun 21 # Stalingrad Time
-			 4:00	-	STAT	1961 Nov 11
-			 4:00	Russia	VOL%sT	1988 Mar 27  2:00s # Volgograd T
-			 3:00	Russia	VOL%sT	1991 Mar 31  2:00s
-			 4:00	-	VOLT	1992 Mar 29  2:00s
-			 3:00	Russia	MSK/MSD	2011 Mar 27  2:00s
-			 4:00	-	MSK	2014 Oct 26  2:00s
-			 3:00	-	MSK
+			 3:00	-	+03	1930 Jun 21
+			 4:00	-	+04	1961 Nov 11
+			 4:00	Russia	+04/+05	1988 Mar 27  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 4:00	-	+04	1992 Mar 29  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04	2014 Oct 26  2:00s
+			 3:00	-	+03
 
 # From Paul Eggert (2016-03-18):
 # Europe/Kirov covers:
 # 43	RU-KIR	Kirov Oblast
 # The 1989 transition is from USSR act No. 227 (1989-03-14).
 #
-Zone Europe/Kirov	 3:18:48 -	LMT	1919 Jul  1  2:00
+Zone Europe/Kirov	 3:18:48 -	LMT	1919 Jul  1  0:00u
 			 3:00	-	+03	1930 Jun 21
 			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
 			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
@@ -2629,16 +2650,16 @@
 # Byalokoz 1919 says Samara was 3:20:20.
 # The 1989 transition is from USSR act No. 227 (1989-03-14).
 
-Zone Europe/Samara	 3:20:20 -	LMT	1919 Jul  1  2:00
-			 3:00	-	SAMT	1930 Jun 21 # Samara Time
-			 4:00	-	SAMT	1935 Jan 27
-			 4:00	Russia	KUY%sT	1989 Mar 26  2:00s # Kuybyshev
-			 3:00	Russia	MSK/MSD	1991 Mar 31  2:00s
-			 2:00	Russia	EE%sT	1991 Sep 29  2:00s
-			 3:00	-	SAMT	1991 Oct 20  3:00
-			 4:00	Russia	SAM%sT	2010 Mar 28  2:00s
-			 3:00	Russia	SAM%sT	2011 Mar 27  2:00s
-			 4:00	-	SAMT
+Zone Europe/Samara	 3:20:20 -	LMT	1919 Jul  1  0:00u
+			 3:00	-	+03	1930 Jun 21
+			 4:00	-	+04	1935 Jan 27
+			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 2:00	Russia	+02/+03	1991 Sep 29  2:00s
+			 3:00	-	+03	1991 Oct 20  3:00
+			 4:00	Russia	+04/+05	2010 Mar 28  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04
 
 # From Paul Eggert (2016-03-18):
 # Europe/Ulyanovsk covers:
@@ -2653,7 +2674,7 @@
 # From Matt Johnson (2016-03-09):
 # http://publication.pravo.gov.ru/Document/View/0001201603090051
 
-Zone Europe/Ulyanovsk	 3:13:36 -	LMT	1919 Jul  1  2:00
+Zone Europe/Ulyanovsk	 3:13:36 -	LMT	1919 Jul  1  0:00u
 			 3:00	-	+03	1930 Jun 21
 			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
 			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
@@ -2685,12 +2706,12 @@
 
 Zone Asia/Yekaterinburg	 4:02:33 -	LMT	1916 Jul  3
 			 3:45:05 -	PMT	1919 Jul 15  4:00
-			 4:00	-	SVET	1930 Jun 21 # Sverdlovsk Time
-			 5:00	Russia	SVE%sT	1991 Mar 31  2:00s
-			 4:00	Russia	SVE%sT	1992 Jan 19  2:00s
-			 5:00	Russia	YEK%sT	2011 Mar 27  2:00s
-			 6:00	-	YEKT	2014 Oct 26  2:00s
-			 5:00	-	YEKT
+			 4:00	-	+04	1930 Jun 21
+			 5:00	Russia	+05/+06	1991 Mar 31  2:00s
+			 4:00	Russia	+04/+05	1992 Jan 19  2:00s
+			 5:00	Russia	+05/+06	2011 Mar 27  2:00s
+			 6:00	-	+06	2014 Oct 26  2:00s
+			 5:00	-	+05
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
@@ -2700,12 +2721,12 @@
 # Byalokoz 1919 says Omsk was 4:53:30.
 
 Zone Asia/Omsk		 4:53:30 -	LMT	1919 Nov 14
-			 5:00	-	OMST	1930 Jun 21 # Omsk Time
-			 6:00	Russia	OMS%sT	1991 Mar 31  2:00s
-			 5:00	Russia	OMS%sT	1992 Jan 19  2:00s
-			 6:00	Russia	OMS%sT	2011 Mar 27  2:00s
-			 7:00	-	OMST	2014 Oct 26  2:00s
-			 6:00	-	OMST
+			 5:00	-	+05	1930 Jun 21
+			 6:00	Russia	+06/+07	1991 Mar 31  2:00s
+			 5:00	Russia	+05/+06	1992 Jan 19  2:00s
+			 6:00	Russia	+06/+07	2011 Mar 27  2:00s
+			 7:00	-	+07	2014 Oct 26  2:00s
+			 6:00	-	+06
 
 # From Paul Eggert (2016-02-22):
 # Asia/Barnaul covers:
@@ -2785,7 +2806,7 @@
 # Note that time belts (numbered from 2 (Moscow) to 12 according to their
 # GMT/UTC offset and having too many exceptions like regions formally
 # belonging to one belt but using time from another) were replaced
-# with time zones in 2011 with different numberings (there was a
+# with time zones in 2011 with different numbering (there was a
 # 2-hour gap between second and third zones in 2011-2014).
 
 # From Stepan Golosunov (2016-04-12):
@@ -2868,12 +2889,12 @@
 # Byalokoz 1919 says Krasnoyarsk was 6:11:26.
 
 Zone Asia/Krasnoyarsk	 6:11:26 -	LMT	1920 Jan  6
-			 6:00	-	KRAT	1930 Jun 21 # Krasnoyarsk Time
-			 7:00	Russia	KRA%sT	1991 Mar 31  2:00s
-			 6:00	Russia	KRA%sT	1992 Jan 19  2:00s
-			 7:00	Russia	KRA%sT	2011 Mar 27  2:00s
-			 8:00	-	KRAT	2014 Oct 26  2:00s
-			 7:00	-	KRAT
+			 6:00	-	+06	1930 Jun 21
+			 7:00	Russia	+07/+08	1991 Mar 31  2:00s
+			 6:00	Russia	+06/+07	1992 Jan 19  2:00s
+			 7:00	Russia	+07/+08	2011 Mar 27  2:00s
+			 8:00	-	+08	2014 Oct 26  2:00s
+			 7:00	-	+07
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
@@ -2890,12 +2911,12 @@
 
 Zone Asia/Irkutsk	 6:57:05 -	LMT	1880
 			 6:57:05 -	IMT	1920 Jan 25 # Irkutsk Mean Time
-			 7:00	-	IRKT	1930 Jun 21 # Irkutsk Time
-			 8:00	Russia	IRK%sT	1991 Mar 31  2:00s
-			 7:00	Russia	IRK%sT	1992 Jan 19  2:00s
-			 8:00	Russia	IRK%sT	2011 Mar 27  2:00s
-			 9:00	-	IRKT	2014 Oct 26  2:00s
-			 8:00	-	IRKT
+			 7:00	-	+07	1930 Jun 21
+			 8:00	Russia	+08/+09	1991 Mar 31  2:00s
+			 7:00	Russia	+07/+08	1992 Jan 19  2:00s
+			 8:00	Russia	+08/+09	2011 Mar 27  2:00s
+			 9:00	-	+09	2014 Oct 26  2:00s
+			 8:00	-	+08
 
 
 # From Tim Parenti (2014-07-06):
@@ -2912,13 +2933,13 @@
 # http://publication.pravo.gov.ru/Document/View/0001201512300107
 
 Zone Asia/Chita	 7:33:52 -	LMT	1919 Dec 15
-			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
-			 9:00	Russia	YAK%sT	1991 Mar 31  2:00s
-			 8:00	Russia	YAK%sT	1992 Jan 19  2:00s
-			 9:00	Russia	YAK%sT	2011 Mar 27  2:00s
-			10:00	-	YAKT	2014 Oct 26  2:00s
-			 8:00	-	IRKT	2016 Mar 27  2:00
-			 9:00	-	YAKT
+			 8:00	-	+08	1930 Jun 21
+			 9:00	Russia	+09/+10	1991 Mar 31  2:00s
+			 8:00	Russia	+08/+09	1992 Jan 19  2:00s
+			 9:00	Russia	+09/+10	2011 Mar 27  2:00s
+			10:00	-	+10	2014 Oct 26  2:00s
+			 8:00	-	+08	2016 Mar 27  2:00
+			 9:00	-	+09
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29):
@@ -2958,12 +2979,12 @@
 # Byalokoz 1919 says Yakutsk was 8:38:58.
 
 Zone Asia/Yakutsk	 8:38:58 -	LMT	1919 Dec 15
-			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
-			 9:00	Russia	YAK%sT	1991 Mar 31  2:00s
-			 8:00	Russia	YAK%sT	1992 Jan 19  2:00s
-			 9:00	Russia	YAK%sT	2011 Mar 27  2:00s
-			10:00	-	YAKT	2014 Oct 26  2:00s
-			 9:00	-	YAKT
+			 8:00	-	+08	1930 Jun 21
+			 9:00	Russia	+09/+10	1991 Mar 31  2:00s
+			 8:00	Russia	+08/+09	1992 Jan 19  2:00s
+			 9:00	Russia	+09/+10	2011 Mar 27  2:00s
+			10:00	-	+10	2014 Oct 26  2:00s
+			 9:00	-	+09
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29):
@@ -2981,12 +3002,12 @@
 # Go with Byalokoz.
 
 Zone Asia/Vladivostok	 8:47:31 -	LMT	1922 Nov 15
-			 9:00	-	VLAT	1930 Jun 21 # Vladivostok Time
-			10:00	Russia	VLA%sT	1991 Mar 31  2:00s
-			 9:00	Russia	VLA%sT	1992 Jan 19  2:00s
-			10:00	Russia	VLA%sT	2011 Mar 27  2:00s
-			11:00	-	VLAT	2014 Oct 26  2:00s
-			10:00	-	VLAT
+			 9:00	-	+09	1930 Jun 21
+			10:00	Russia	+10/+11	1991 Mar 31  2:00s
+			 9:00	Russia	+09/+10	1992 Jan 19  2:00s
+			10:00	Russia	+10/+11	2011 Mar 27  2:00s
+			11:00	-	+11	2014 Oct 26  2:00s
+			10:00	-	+10
 
 
 # From Tim Parenti (2014-07-03):
@@ -3004,14 +3025,14 @@
 # This transition is no doubt wrong, but we have no better info.
 
 Zone Asia/Khandyga	 9:02:13 -	LMT	1919 Dec 15
-			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
-			 9:00	Russia	YAK%sT	1991 Mar 31  2:00s
-			 8:00	Russia	YAK%sT	1992 Jan 19  2:00s
-			 9:00	Russia	YAK%sT	2004
-			10:00	Russia	VLA%sT	2011 Mar 27  2:00s
-			11:00	-	VLAT	2011 Sep 13  0:00s # Decree 725?
-			10:00	-	YAKT	2014 Oct 26  2:00s
-			 9:00	-	YAKT
+			 8:00	-	+08	1930 Jun 21
+			 9:00	Russia	+09/+10	1991 Mar 31  2:00s
+			 8:00	Russia	+08/+09	1992 Jan 19  2:00s
+			 9:00	Russia	+09/+10	2004
+			10:00	Russia	+10/+11	2011 Mar 27  2:00s
+			11:00	-	+11	2011 Sep 13  0:00s # Decree 725?
+			10:00	-	+10	2014 Oct 26  2:00s
+			 9:00	-	+09
 
 
 # From Tim Parenti (2014-07-03):
@@ -3027,15 +3048,14 @@
 
 # The Zone name should be Asia/Yuzhno-Sakhalinsk, but that's too long.
 Zone Asia/Sakhalin	 9:30:48 -	LMT	1905 Aug 23
-			 9:00	-	JCST	1937 Oct  1
-			 9:00	-	JST	1945 Aug 25
-			11:00	Russia	SAK%sT	1991 Mar 31  2:00s # Sakhalin T
-			10:00	Russia	SAK%sT	1992 Jan 19  2:00s
-			11:00	Russia	SAK%sT	1997 Mar lastSun  2:00s
-			10:00	Russia	SAK%sT	2011 Mar 27  2:00s
-			11:00	-	SAKT	2014 Oct 26  2:00s
-			10:00	-	SAKT	2016 Mar 27  2:00s
-			11:00	-	SAKT
+			 9:00	-	+09	1945 Aug 25
+			11:00	Russia	+11/+12	1991 Mar 31  2:00s # Sakhalin T
+			10:00	Russia	+10/+11	1992 Jan 19  2:00s
+			11:00	Russia	+11/+12	1997 Mar lastSun  2:00s
+			10:00	Russia	+10/+11	2011 Mar 27  2:00s
+			11:00	-	+11	2014 Oct 26  2:00s
+			10:00	-	+10	2016 Mar 27  2:00s
+			11:00	-	+11
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29):
@@ -3058,13 +3078,13 @@
 # http://publication.pravo.gov.ru/Document/View/0001201604050038
 
 Zone Asia/Magadan	10:03:12 -	LMT	1924 May  2
-			10:00	-	MAGT	1930 Jun 21 # Magadan Time
-			11:00	Russia	MAG%sT	1991 Mar 31  2:00s
-			10:00	Russia	MAG%sT	1992 Jan 19  2:00s
-			11:00	Russia	MAG%sT	2011 Mar 27  2:00s
-			12:00	-	MAGT	2014 Oct 26  2:00s
-			10:00	-	MAGT	2016 Apr 24  2:00s
-			11:00	-	MAGT
+			10:00	-	+10	1930 Jun 21 # Magadan Time
+			11:00	Russia	+11/+12	1991 Mar 31  2:00s
+			10:00	Russia	+10/+11	1992 Jan 19  2:00s
+			11:00	Russia	+11/+12	2011 Mar 27  2:00s
+			12:00	-	+12	2014 Oct 26  2:00s
+			10:00	-	+10	2016 Apr 24  2:00s
+			11:00	-	+11
 
 
 # From Tim Parenti (2014-07-06):
@@ -3107,17 +3127,14 @@
 # in Russian.)  In addition, Srednekolymsk appears to be a much older
 # settlement and the population of Zyryanka seems to be declining.
 # Go with Srednekolymsk.
-#
-# Since Magadan Oblast moves to UTC+10 on 2014-10-26, we cannot keep using MAGT
-# as the abbreviation.  Use SRET instead.
 
 Zone Asia/Srednekolymsk	10:14:52 -	LMT	1924 May  2
-			10:00	-	MAGT	1930 Jun 21 # Magadan Time
-			11:00	Russia	MAG%sT	1991 Mar 31  2:00s
-			10:00	Russia	MAG%sT	1992 Jan 19  2:00s
-			11:00	Russia	MAG%sT	2011 Mar 27  2:00s
-			12:00	-	MAGT	2014 Oct 26  2:00s
-			11:00	-	SRET	# Srednekolymsk Time
+			10:00	-	+10	1930 Jun 21
+			11:00	Russia	+11/+12	1991 Mar 31  2:00s
+			10:00	Russia	+10/+11	1992 Jan 19  2:00s
+			11:00	Russia	+11/+12	2011 Mar 27  2:00s
+			12:00	-	+12	2014 Oct 26  2:00s
+			11:00	-	+11
 
 
 # From Tim Parenti (2014-07-03):
@@ -3135,14 +3152,14 @@
 # UTC+12 since at least then, too.
 
 Zone Asia/Ust-Nera	 9:32:54 -	LMT	1919 Dec 15
-			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
-			 9:00	Russia	YAKT	1981 Apr  1
-			11:00	Russia	MAG%sT	1991 Mar 31  2:00s
-			10:00	Russia	MAG%sT	1992 Jan 19  2:00s
-			11:00	Russia	MAG%sT	2011 Mar 27  2:00s
-			12:00	-	MAGT	2011 Sep 13  0:00s # Decree 725?
-			11:00	-	VLAT	2014 Oct 26  2:00s
-			10:00	-	VLAT
+			 8:00	-	+08	1930 Jun 21
+			 9:00	Russia	+09/+10	1981 Apr  1
+			11:00	Russia	+11/+12	1991 Mar 31  2:00s
+			10:00	Russia	+10/+11	1992 Jan 19  2:00s
+			11:00	Russia	+11/+12	2011 Mar 27  2:00s
+			12:00	-	+12	2011 Sep 13  0:00s # Decree 725?
+			11:00	-	+11	2014 Oct 26  2:00s
+			10:00	-	+10
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
@@ -3155,12 +3172,12 @@
 # The Zone name should be Asia/Petropavlovsk-Kamchatski or perhaps
 # Asia/Petropavlovsk-Kamchatsky, but these are too long.
 Zone Asia/Kamchatka	10:34:36 -	LMT	1922 Nov 10
-			11:00	-	PETT	1930 Jun 21 # P-K Time
-			12:00	Russia	PET%sT	1991 Mar 31  2:00s
-			11:00	Russia	PET%sT	1992 Jan 19  2:00s
-			12:00	Russia	PET%sT	2010 Mar 28  2:00s
-			11:00	Russia	PET%sT	2011 Mar 27  2:00s
-			12:00	-	PETT
+			11:00	-	+11	1930 Jun 21
+			12:00	Russia	+12/+13	1991 Mar 31  2:00s
+			11:00	Russia	+11/+12	1992 Jan 19  2:00s
+			12:00	Russia	+12/+13	2010 Mar 28  2:00s
+			11:00	Russia	+11/+12	2011 Mar 27  2:00s
+			12:00	-	+12
 
 
 # From Tim Parenti (2014-07-03):
@@ -3168,13 +3185,13 @@
 # 87	RU-CHU	Chukotka Autonomous Okrug
 
 Zone Asia/Anadyr	11:49:56 -	LMT	1924 May  2
-			12:00	-	ANAT	1930 Jun 21 # Anadyr Time
-			13:00	Russia	ANA%sT	1982 Apr  1  0:00s
-			12:00	Russia	ANA%sT	1991 Mar 31  2:00s
-			11:00	Russia	ANA%sT	1992 Jan 19  2:00s
-			12:00	Russia	ANA%sT	2010 Mar 28  2:00s
-			11:00	Russia	ANA%sT	2011 Mar 27  2:00s
-			12:00	-	ANAT
+			12:00	-	+12	1930 Jun 21
+			13:00	Russia	+13/+14	1982 Apr  1  0:00s
+			12:00	Russia	+12/+13	1991 Mar 31  2:00s
+			11:00	Russia	+11/+12	1992 Jan 19  2:00s
+			12:00	Russia	+12/+13	2010 Mar 28  2:00s
+			11:00	Russia	+11/+12	2011 Mar 27  2:00s
+			12:00	-	+12
 
 
 # San Marino
@@ -3495,6 +3512,14 @@
 # Engineered Standard Time," said Twitter user @aysekarahasan.
 # http://www.bbc.com/news/world-europe-34631326
 
+# From Burak AYDIN (2016-09-08):
+# Turkey will stay in Daylight Saving Time even in winter....
+# http://www.resmigazete.gov.tr/eskiler/2016/09/20160908-2.pdf
+#
+# From Paul Eggert (2016-09-07):
+# The change is permanent, so this is the new standard time in Turkey.
+# It takes effect today, which is not much notice.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Turkey	1916	only	-	May	 1	0:00	1:00	S
 Rule	Turkey	1916	only	-	Oct	 1	0:00	0	-
@@ -3558,7 +3583,7 @@
 Zone	Europe/Istanbul	1:55:52 -	LMT	1880
 			1:56:56	-	IMT	1910 Oct # Istanbul Mean Time?
 			2:00	Turkey	EE%sT	1978 Oct 15
-			3:00	Turkey	TR%sT	1985 Apr 20 # Turkey Time
+			3:00	Turkey	+03/+04	1985 Apr 20
 			2:00	Turkey	EE%sT	2007
 			2:00	EU	EE%sT	2011 Mar 27  1:00u
 			2:00	-	EET	2011 Mar 28  1:00u
@@ -3566,7 +3591,8 @@
 			2:00	-	EET	2014 Mar 31  1:00u
 			2:00	EU	EE%sT	2015 Oct 25  1:00u
 			2:00	1:00	EEST	2015 Nov  8  1:00u
-			2:00	EU	EE%sT
+			2:00	EU	EE%sT	2016 Sep  7
+			3:00	-	+03
 Link	Europe/Istanbul	Asia/Istanbul	# Istanbul is in both continents.
 
 # Ukraine
--- a/jdk/make/data/tzdata/factory	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/factory	Tue Oct 18 17:14:09 2016 +0000
@@ -24,9 +24,10 @@
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
-# For companies who don't want to put time zone specification in
-# their installation procedures.  When users run date, they'll get the message.
-# Also useful for the "comp.sources" version.
+# For distributors who don't want to put time zone specification in
+# their installation procedures.  Users that run 'date' will get the
+# time zone abbreviation "-00", indicating that the actual time zone
+# is unknown.
 
 # Zone	NAME	GMTOFF	RULES	FORMAT
-Zone	Factory	0	- "Local time zone must be set--see zic manual page"
+Zone	Factory	0	-	-00
--- a/jdk/make/data/tzdata/leapseconds	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/leapseconds	Tue Oct 18 17:14:09 2016 +0000
@@ -79,6 +79,7 @@
 Leap	2008	Dec	31	23:59:60	+	S
 Leap	2012	Jun	30	23:59:60	+	S
 Leap	2015	Jun	30	23:59:60	+	S
+Leap	2016	Dec	31	23:59:60	+	S
 
-#	Updated through IERS Bulletin C51
-#	File expires on:  28 December 2016
+#	Updated through IERS Bulletin C52
+#	File expires on:  28 June 2017
--- a/jdk/make/data/tzdata/northamerica	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/northamerica	Tue Oct 18 17:14:09 2016 +0000
@@ -436,11 +436,42 @@
 # north of the Salmon River, and the towns of Burgdorf and Warren),
 # Nevada (except West Wendover), Oregon (except the northern 3/4 of
 # Malheur county), and Washington
+
+# From Paul Eggert (2016-08-20):
+# In early February 1948, in response to California's electricity shortage,
+# PG&E changed power frequency from 60 to 59.5 Hz during daylight hours,
+# causing electric clocks to lose six minutes per day.  (This did not change
+# legal time, and is not part of the data here.)  See:
+# Ross SA. An energy crisis from the past: Northern California in 1948.
+# Working Paper No. 8, Institute of Governmental Studies, UC Berkeley,
+# 1973-11.  http://escholarship.org/uc/item/8x22k30c
+#
+# In another measure to save electricity, DST was instituted from 1948-03-14
+# at 02:01 to 1949-01-16 at 02:00, with the governor having the option to move
+# the fallback transition earlier.  See pages 3-4 of:
+# http://clerk.assembly.ca.gov/sites/clerk.assembly.ca.gov/files/archive/Statutes/1948/48Vol1_Chapters.pdf
+#
+# In response:
+#
+#   Governor Warren received a torrent of objecting mail, and it is not too much
+#   to speculate that the objections to Daylight Saving Time were one important
+#   factor in the defeat of the Dewey-Warren Presidential ticket in California.
+#     -- Ross, p 25
+#
+# On December 8 the governor exercised the option, setting the date to January 1
+# (LA Times 1948-12-09).  The transition time was 02:00 (LA Times 1949-01-01).
+#
+# Despite the controversy, in 1949 California voters approved Proposition 12,
+# which established DST from April's last Sunday at 01:00 until September's
+# last Sunday at 02:00. This was amended by 1962's Proposition 6, which changed
+# the fall-back date to October's last Sunday. See:
+# http://repository.uchastings.edu/cgi/viewcontent.cgi?article=1501&context=ca_ballot_props
+# http://repository.uchastings.edu/cgi/viewcontent.cgi?article=1636&context=ca_ballot_props
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER
-Rule	CA	1948	only	-	Mar	14	2:00	1:00	D
+Rule	CA	1948	only	-	Mar	14	2:01	1:00	D
 Rule	CA	1949	only	-	Jan	 1	2:00	0	S
-Rule	CA	1950	1966	-	Apr	lastSun	2:00	1:00	D
+Rule	CA	1950	1966	-	Apr	lastSun	1:00	1:00	D
 Rule	CA	1950	1961	-	Sep	lastSun	2:00	0	S
 Rule	CA	1962	1966	-	Oct	lastSun	2:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -3304,7 +3335,7 @@
 # indicating that the normal ET rules are followed.
 #
 # From Paul Eggert (2014-08-19):
-# The 2014-08-13 Cabinet meeting decided to stay on UTC-4 year-round.  See:
+# The 2014-08-13 Cabinet meeting decided to stay on UT -04 year-round.  See:
 # http://tcweeklynews.com/daylight-savings-time-to-be-maintained-p5353-127.htm
 # Model this as a switch from EST/EDT to AST ...
 # From Chris Walton (2014-11-04):
--- a/jdk/make/data/tzdata/southamerica	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/southamerica	Tue Oct 18 17:14:09 2016 +0000
@@ -433,9 +433,9 @@
 # stuck on Summer daylight savings time even though the summer is over.
 
 # From Paul Eggert (2013-09-05):
-# Perhaps San Luis operates on the legal fiction that it is at UTC-4
+# Perhaps San Luis operates on the legal fiction that it is at -04
 # with perpetual summer time, but ordinary usage typically seems to
-# just say it's at UTC-3; see, for example,
+# just say it's at -03; see, for example,
 # http://es.wikipedia.org/wiki/Hora_oficial_argentina
 # We've documented similar situations as being plain changes to
 # standard time, so let's do that here too.  This does not change UTC
--- a/jdk/make/data/tzdata/zone.tab	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/data/tzdata/zone.tab	Tue Oct 18 17:14:09 2016 +0000
@@ -284,7 +284,7 @@
 MH	+0905+16720	Pacific/Kwajalein	Kwajalein
 MK	+4159+02126	Europe/Skopje
 ML	+1239-00800	Africa/Bamako
-MM	+1647+09610	Asia/Rangoon
+MM	+1647+09610	Asia/Yangon
 MN	+4755+10653	Asia/Ulaanbaatar	Mongolia (most areas)
 MN	+4801+09139	Asia/Hovd	Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan
 MN	+4804+11430	Asia/Choibalsan	Dornod, Sukhbaatar
--- a/jdk/make/lib/CoreLibraries.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/lib/CoreLibraries.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -218,7 +218,7 @@
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LDFLAGS_windows := -export:ZIP_Open -export:ZIP_Close -export:ZIP_FindEntry \
         -export:ZIP_ReadEntry -export:ZIP_GetNextEntry \
-        -export:ZIP_InflateFully -export:ZIP_CRC32, \
+        -export:ZIP_InflateFully -export:ZIP_CRC32 -export:ZIP_FreeEntry, \
     LIBS_unix := -ljvm -ljava $(LIBZ), \
     LIBS_solaris := -lc, \
     LIBS_windows := jvm.lib $(WIN_JAVA_LIB), \
@@ -236,10 +236,6 @@
 
 ##########################################################################################
 
-ifeq ($(OPENJDK_TARGET_OS), aix)
-  LIBJIMAGE_TOOLCHAIN := TOOLCHAIN_LINK_CXX
-endif # OPENJDK_TARGET_OS aix
-
 JIMAGELIB_CPPFLAGS := \
     -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \
     -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
@@ -249,7 +245,7 @@
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBJIMAGE, \
     LIBRARY := jimage, \
-    TOOLCHAIN := $(LIBJIMAGE_TOOLCHAIN), \
+    TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
     OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     OPTIMIZATION := LOW, \
     SRC := $(JDK_TOPDIR)/src/java.base/share/native/libjimage \
--- a/jdk/make/lib/NioLibraries.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/lib/NioLibraries.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -53,12 +53,7 @@
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), aix)
-  BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
-  BUILD_LIBNIO_EXFILES += \
-      /NativeThread.c
-  # Notice: we really need the leading slash here because otherwise every
-  # FILE_NAME in EXCLUDE_FILES will actually match any file ending in FILE_NAME
-  # (e.g. 'NativeThread.c' will also exclude 'AixNativeThread.c').
+  BUILD_LIBNIO_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
 endif
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBNIO, \
--- a/jdk/make/mapfiles/libnet/mapfile-vers	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/mapfiles/libnet/mapfile-vers	Tue Oct 18 17:14:09 2016 +0000
@@ -98,7 +98,6 @@
 		Java_sun_net_sdp_SdpSupport_create0;
 		Java_sun_net_spi_DefaultProxySelector_init;
 		Java_sun_net_spi_DefaultProxySelector_getSystemProxy;
-		NET_AllocSockaddr;
 		NET_SockaddrToInetAddress;
                 NET_SockaddrEqualsInetAddress;
 		NET_InetAddressToSockaddr;
--- a/jdk/make/mapfiles/libzip/mapfile-vers	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/mapfiles/libzip/mapfile-vers	Tue Oct 18 17:14:09 2016 +0000
@@ -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
@@ -49,6 +49,7 @@
 		Java_java_util_zip_Inflater_setDictionary;
 		ZIP_Close;
 		ZIP_CRC32;
+		ZIP_FreeEntry;
 		ZIP_FindEntry;
 		ZIP_GetEntry;
 		ZIP_GetNextEntry;
--- a/jdk/make/rmic/RmicCommon.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/make/rmic/RmicCommon.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -37,7 +37,7 @@
   RMIC_MAIN_CLASS := sun.rmi.rmic.Main
 endif
 
-RMIC := $(JAVA) $(INTERIM_OVERRIDE_MODULES_ARGS) $(RMIC_MAIN_CLASS)
+RMIC := $(JAVA_SMALL) $(INTERIM_OVERRIDE_MODULES_ARGS) $(RMIC_MAIN_CLASS)
 
 CLASSES_DIR := $(JDK_OUTPUTDIR)/modules
 # NOTE: If the smart javac dependency management is reintroduced, these classes risk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/src/classes/build/tools/jigsaw/AddPackagesAttribute.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package build.tools.jigsaw;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReference;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Optional;
+import java.util.Set;
+
+import jdk.internal.module.ModuleInfoExtender;
+
+/**
+ * Adds the Packages class file attribute to each module-info.class in an
+ * exploded build.
+ */
+
+public class AddPackagesAttribute {
+
+    public static void main(String[] args) throws IOException {
+
+        if (args.length != 1) {
+            System.err.println("Usage AddPackagesAttribute exploded-java-home");
+            System.exit(-1);
+        }
+
+        String home = args[0];
+        Path dir = Paths.get(home, "modules");
+
+        ModuleFinder finder = ModuleFinder.of(dir);
+
+        try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
+            for (Path entry : stream) {
+                Path mi = entry.resolve("module-info.class");
+                if (Files.isRegularFile(mi)) {
+                    String mn = entry.getFileName().toString();
+                    Optional<ModuleReference> omref = finder.find(mn);
+                    if (omref.isPresent()) {
+                        Set<String> packages = omref.get().descriptor().conceals();
+                        addPackagesAttribute(mi, packages);
+                    }
+                }
+            }
+        }
+    }
+
+    static void addPackagesAttribute(Path mi, Set<String> packages) throws IOException {
+        byte[] bytes;
+        try (InputStream in = Files.newInputStream(mi)) {
+            ModuleInfoExtender extender = ModuleInfoExtender.newExtender(in);
+            extender.conceals(packages);
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            extender.write(baos);
+            bytes = baos.toByteArray();
+        }
+
+        Files.write(mi, bytes);
+    }
+
+}
--- a/jdk/src/java.base/aix/native/libnio/ch/AixNativeThread.c	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <sys/types.h>
-#include <string.h>
-#include "jni.h"
-#include "jni_util.h"
-#include "jvm.h"
-#include "jlong.h"
-#include "sun_nio_ch_NativeThread.h"
-
-#include <pthread.h>
-#include <sys/signal.h>
-
-/* Also defined in src/aix/native/java/net/aix_close.c */
-#define INTERRUPT_SIGNAL (SIGRTMAX - 1)
-
-static void
-nullHandler(int sig)
-{
-}
-
-
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
-{
-    /* Install the null handler for INTERRUPT_SIGNAL. This might overwrite the
-     * handler previously installed by java/net/aix_close.c, but that's okay
-     * since neither handler actually does anything.  We install our own
-     * handler here simply out of paranoia; ultimately the two mechanisms
-     * should somehow be unified, perhaps within the VM.
-     */
-
-    sigset_t ss;
-    struct sigaction sa, osa;
-    sa.sa_handler = nullHandler;
-    sa.sa_flags = 0;
-    sigemptyset(&sa.sa_mask);
-    if (sigaction(INTERRUPT_SIGNAL, &sa, &osa) < 0)
-        JNU_ThrowIOExceptionWithLastError(env, "sigaction");
-}
-
-JNIEXPORT jlong JNICALL
-Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl)
-{
-    return (long)pthread_self();
-}
-
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread)
-{
-    if (pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL))
-        JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed");
-}
--- a/jdk/src/java.base/share/classes/java/io/FilePermission.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/FilePermission.java	Tue Oct 18 17:14:09 2016 +0000
@@ -25,11 +25,20 @@
 
 package java.io;
 
+import java.net.URI;
+import java.nio.file.*;
 import java.security.*;
 import java.util.Enumeration;
+import java.util.Objects;
 import java.util.StringJoiner;
 import java.util.Vector;
 import java.util.concurrent.ConcurrentHashMap;
+
+import jdk.internal.misc.JavaIOFilePermissionAccess;
+import jdk.internal.misc.SharedSecrets;
+import sun.nio.fs.DefaultFileSystemProvider;
+import sun.security.action.GetPropertyAction;
+import sun.security.util.FilePermCompat;
 import sun.security.util.SecurityConstants;
 
 /**
@@ -41,8 +50,11 @@
  * the file separator character, <code>File.separatorChar</code>) indicates
  * all the files and directories contained in that directory. A pathname
  * that ends with "/-" indicates (recursively) all files
- * and subdirectories contained in that directory. A pathname consisting of
- * the special token "&lt;&lt;ALL FILES&gt;&gt;" matches <b>any</b> file.
+ * and subdirectories contained in that directory. Such a pathname is called
+ * a wildcard pathname. Otherwise, it's a simple pathname.
+ * <P>
+ * A pathname consisting of the special token {@literal "<<ALL FILES>>"}
+ * matches <b>any</b> file.
  * <P>
  * Note: A pathname consisting of a single "*" indicates all the files
  * in the current directory, while a pathname consisting of a single "-"
@@ -75,12 +87,12 @@
  * <P>
  * Be careful when granting FilePermissions. Think about the implications
  * of granting read and especially write access to various files and
- * directories. The "&lt;&lt;ALL FILES&gt;&gt;" permission with write action is
+ * directories. The {@literal "<<ALL FILES>>"} permission with write action is
  * especially dangerous. This grants permission to write to the entire
  * file system. One thing this effectively allows is replacement of the
  * system binary, including the JVM runtime environment.
- *
- * <p>Please note: Code can always read a file from the same
+ * <P>
+ * Please note: Code can always read a file from the same
  * directory it's in (or a subdirectory of that directory); it does not
  * need explicit permission to do so.
  *
@@ -145,34 +157,127 @@
     private String actions; // Left null as long as possible, then
                             // created and re-used in the getAction function.
 
-    // canonicalized dir path. In the case of
-    // directories, it is the name "/blah/*" or "/blah/-" without
-    // the last character (the "*" or "-").
+    // canonicalized dir path. used by the "old" behavior (nb == false).
+    // In the case of directories, it is the name "/blah/*" or "/blah/-"
+    // without the last character (the "*" or "-").
 
     private transient String cpath;
 
+    // Following fields used by the "new" behavior (nb == true), in which
+    // input path is not canonicalized. For compatibility (so that granting
+    // FilePermission on "x" allows reading "`pwd`/x", an alternative path
+    // can be added so that both can be used in an implies() check. Please note
+    // the alternative path only deals with absolute/relative path, and does
+    // not deal with symlink/target.
+
+    private transient Path npath;       // normalized dir path.
+    private transient Path npath2;      // alternative normalized dir path.
+    private transient boolean allFiles; // whether this is <<ALL FILES>>
+
     // static Strings used by init(int mask)
     private static final char RECURSIVE_CHAR = '-';
     private static final char WILD_CHAR = '*';
 
-/*
-    public String toString()
-    {
-        StringBuffer sb = new StringBuffer();
-        sb.append("***\n");
-        sb.append("cpath = "+cpath+"\n");
-        sb.append("mask = "+mask+"\n");
-        sb.append("actions = "+getActions()+"\n");
-        sb.append("directory = "+directory+"\n");
-        sb.append("recursive = "+recursive+"\n");
-        sb.append("***\n");
-        return sb.toString();
-    }
-*/
+//    public String toString() {
+//        StringBuffer sb = new StringBuffer();
+//        sb.append("*** FilePermission on " + getName() + " ***");
+//        for (Field f : FilePermission.class.getDeclaredFields()) {
+//            if (!Modifier.isStatic(f.getModifiers())) {
+//                try {
+//                    sb.append(f.getName() + " = " + f.get(this));
+//                } catch (Exception e) {
+//                    sb.append(f.getName() + " = " + e.toString());
+//                }
+//                sb.append('\n');
+//            }
+//        }
+//        sb.append("***\n");
+//        return sb.toString();
+//    }
 
     private static final long serialVersionUID = 7930732926638008763L;
 
     /**
+     * Always use the internal default file system, in case it was modified
+     * with java.nio.file.spi.DefaultFileSystemProvider.
+     */
+    private static final java.nio.file.FileSystem builtInFS =
+            DefaultFileSystemProvider.create()
+                    .getFileSystem(URI.create("file:///"));
+
+    /**
+     * Creates FilePermission objects with special internals.
+     * See {@link FilePermCompat#newPermPlusAltPath(Permission)} and
+     * {@link FilePermCompat#newPermUsingAltPath(Permission)}.
+     */
+
+    private static final Path here = builtInFS.getPath(
+            GetPropertyAction.privilegedGetProperty("user.dir"));
+
+    /**
+     * A private constructor like a clone, only npath2 is not touched.
+     * @param input
+     */
+    private FilePermission(FilePermission input) {
+        super(input.getName());
+        this.npath = input.npath;
+        this.actions = input.actions;
+        this.allFiles = input.allFiles;
+        this.recursive = input.recursive;
+        this.directory = input.directory;
+        this.cpath = input.cpath;
+        this.mask = input.mask;
+    }
+
+    /**
+     * Returns the alternative path as a Path object, i.e. absolute path
+     * for a relative one, or vice versa.
+     *
+     * @param in a real path w/o "-" or "*" at the end, and not <<ALL FILES>>.
+     * @return the alternative path, or null if cannot find one.
+     */
+    private static Path altPath(Path in) {
+        try {
+            if (!in.isAbsolute()) {
+                return here.resolve(in).normalize();
+            } else {
+                return here.relativize(in).normalize();
+            }
+        } catch (IllegalArgumentException e) {
+            return null;
+        }
+    }
+
+    static {
+        SharedSecrets.setJavaIOFilePermissionAccess(
+            new JavaIOFilePermissionAccess() {
+                public FilePermission newPermPlusAltPath(FilePermission input) {
+                    if (input.npath2 == null && !input.allFiles) {
+                        Path npath2 = altPath(input.npath);
+                        if (npath2 != null) {
+                            FilePermission np = new FilePermission(input);
+                            np.npath2 = npath2;
+                            return np;
+                        }
+                    }
+                    return input;
+                }
+                public FilePermission newPermUsingAltPath(FilePermission input) {
+                    if (!input.allFiles) {
+                        Path npath2 = altPath(input.npath);
+                        if (npath2 != null) {
+                            FilePermission np = new FilePermission(input);
+                            np.npath = npath2;
+                            return np;
+                        }
+                    }
+                    return null;
+                }
+            }
+        );
+    }
+
+    /**
      * initialize a FilePermission object. Common to all constructors.
      * Also called during de-serialization.
      *
@@ -186,60 +291,106 @@
         if (mask == NONE)
                 throw new IllegalArgumentException("invalid actions mask");
 
-        if ((cpath = getName()) == null)
+        if (FilePermCompat.nb) {
+            String name = getName();
+
+            if (name == null)
+                throw new NullPointerException("name can't be null");
+
+            this.mask = mask;
+
+            if (name.equals("<<ALL FILES>>")) {
+                allFiles = true;
+                npath = builtInFS.getPath("");
+                // other fields remain default
+                return;
+            }
+
+            boolean rememberStar = false;
+            if (name.endsWith("*")) {
+                rememberStar = true;
+                recursive = false;
+                name = name.substring(0, name.length()-1) + "-";
+            }
+
+            try {
+                // new File() can "normalize" some name, for example, "/C:/X" on
+                // Windows. Some JDK codes generate such illegal names.
+                npath = builtInFS.getPath(new File(name).getPath())
+                        .normalize();
+            } catch (InvalidPathException ipe) {
+                // Still invalid. For compatibility reason, accept it
+                // but make this permission useless.
+                npath = builtInFS.getPath("-u-s-e-l-e-s-s-");
+                this.mask = NONE;
+            }
+
+            // lastName should always be non-null now
+            Path lastName = npath.getFileName();
+            if (lastName != null && lastName.toString().equals("-")) {
+                directory = true;
+                recursive = !rememberStar;
+                npath = npath.getParent();
+            }
+            if (npath == null) {
+                npath = builtInFS.getPath("");
+            }
+        } else {
+            if ((cpath = getName()) == null)
                 throw new NullPointerException("name can't be null");
 
-        this.mask = mask;
+            this.mask = mask;
 
-        if (cpath.equals("<<ALL FILES>>")) {
-            directory = true;
-            recursive = true;
-            cpath = "";
-            return;
-        }
+            if (cpath.equals("<<ALL FILES>>")) {
+                directory = true;
+                recursive = true;
+                cpath = "";
+                return;
+            }
 
-        // store only the canonical cpath if possible
-        cpath = AccessController.doPrivileged(new PrivilegedAction<>() {
-            public String run() {
-                try {
-                    String path = cpath;
-                    if (cpath.endsWith("*")) {
-                        // call getCanonicalPath with a path with wildcard character
-                        // replaced to avoid calling it with paths that are
-                        // intended to match all entries in a directory
-                        path = path.substring(0, path.length()-1) + "-";
-                        path = new File(path).getCanonicalPath();
-                        return path.substring(0, path.length()-1) + "*";
-                    } else {
-                        return new File(path).getCanonicalPath();
+            // store only the canonical cpath if possible
+            cpath = AccessController.doPrivileged(new PrivilegedAction<>() {
+                public String run() {
+                    try {
+                        String path = cpath;
+                        if (cpath.endsWith("*")) {
+                            // call getCanonicalPath with a path with wildcard character
+                            // replaced to avoid calling it with paths that are
+                            // intended to match all entries in a directory
+                            path = path.substring(0, path.length() - 1) + "-";
+                            path = new File(path).getCanonicalPath();
+                            return path.substring(0, path.length() - 1) + "*";
+                        } else {
+                            return new File(path).getCanonicalPath();
+                        }
+                    } catch (IOException ioe) {
+                        return cpath;
                     }
-                } catch (IOException ioe) {
-                    return cpath;
                 }
-            }
-        });
+            });
 
-        int len = cpath.length();
-        char last = ((len > 0) ? cpath.charAt(len - 1) : 0);
+            int len = cpath.length();
+            char last = ((len > 0) ? cpath.charAt(len - 1) : 0);
 
-        if (last == RECURSIVE_CHAR &&
-            cpath.charAt(len - 2) == File.separatorChar) {
-            directory = true;
-            recursive = true;
-            cpath = cpath.substring(0, --len);
-        } else if (last == WILD_CHAR &&
-            cpath.charAt(len - 2) == File.separatorChar) {
-            directory = true;
-            //recursive = false;
-            cpath = cpath.substring(0, --len);
-        } else {
-            // overkill since they are initialized to false, but
-            // commented out here to remind us...
-            //directory = false;
-            //recursive = false;
+            if (last == RECURSIVE_CHAR &&
+                    cpath.charAt(len - 2) == File.separatorChar) {
+                directory = true;
+                recursive = true;
+                cpath = cpath.substring(0, --len);
+            } else if (last == WILD_CHAR &&
+                    cpath.charAt(len - 2) == File.separatorChar) {
+                directory = true;
+                //recursive = false;
+                cpath = cpath.substring(0, --len);
+            } else {
+                // overkill since they are initialized to false, but
+                // commented out here to remind us...
+                //directory = false;
+                //recursive = false;
+            }
+
+            // XXX: at this point the path should be absolute. die if it isn't?
         }
-
-        // XXX: at this point the path should be absolute. die if it isn't?
     }
 
     /**
@@ -254,7 +405,7 @@
      * indicates all the files and directories contained in that directory.
      * A pathname that ends with "/-" indicates (recursively) all files and
      * subdirectories contained in that directory. The special pathname
-     * "&lt;&lt;ALL FILES&gt;&gt;" matches any file.
+     * {@literal "<<ALL FILES>>"} matches any file.
      *
      * <p>A pathname consisting of a single "*" indicates all the files
      * in the current directory, while a pathname consisting of a single "-"
@@ -264,6 +415,28 @@
      *
      * <p>A pathname containing an empty string represents an empty path.
      *
+     * @implNote In this implementation, the
+     * {@code jdk.io.permissionsUseCanonicalPath} system property dictates how
+     * the {@code path} argument is processed and stored.
+     * <P>
+     * If the value of the system property is set to {@code true}, {@code path}
+     * is canonicalized and stored as a String object named {@code cpath}.
+     * This means a relative path is converted to an absolute path, a Windows
+     * DOS-style 8.3 path is expanded to a long path, and a symbolic link is
+     * resolved to its target, etc.
+     * <P>
+     * If the value of the system property is set to {@code false}, {@code path}
+     * is converted to a {@link java.nio.file.Path} object named {@code npath}
+     * after {@link Path#normalize() normalization}. No canonicalization is
+     * performed which means the underlying file system is not accessed.
+     * <P>
+     * In either case, the "*" or "-" character at the end of a wildcard
+     * {@code path} is removed before canonicalization or normalization.
+     * It is stored in a separate wildcard flag field.
+     * <P>
+     * The default value of the {@code jdk.io.permissionsUseCanonicalPath}
+     * system property is {@code false} in this implementation.
+     *
      * @param path the pathname of the file/directory.
      * @param actions the action string.
      *
@@ -305,6 +478,38 @@
      *      "/tmp/*" encompasses all files in the "/tmp" directory,
      *      including the one named "foo".
      * </ul>
+     * <P>
+     * Precisely, a simple pathname implies another simple pathname
+     * if and only if they are equal. A simple pathname never implies
+     * a wildcard pathname. A wildcard pathname implies another wildcard
+     * pathname if and only if all simple pathnames implied by the latter
+     * are implied by the former. A wildcard pathname implies a simple
+     * pathname if and only if
+     * <ul>
+     *     <li>if the wildcard flag is "*", the simple pathname's path
+     *     must be right inside the wildcard pathname's path.
+     *     <li>if the wildcard flag is "-", the simple pathname's path
+     *     must be recursively inside the wildcard pathname's path.
+     * </ul>
+     * <P>
+     * {@literal "<<ALL FILES>>"} implies every other pathname. No pathname,
+     * except for {@literal "<<ALL FILES>>"} itself, implies
+     * {@literal "<<ALL FILES>>"}.
+     *
+     * @implNote
+     * If {@code jdk.io.permissionsUseCanonicalPath} is {@code true}, a
+     * simple {@code cpath} is inside a wildcard {@code cpath} if and only if
+     * after removing the base name (the last name in the pathname's name
+     * sequence) from the former the remaining part equals to the latter,
+     * a simple {@code cpath} is recursively inside a wildcard {@code cpath}
+     * if and only if the former starts with the latter.
+     * <p>
+     * If {@code jdk.io.permissionsUseCanonicalPath} is {@code false}, a
+     * simple {@code npath} is inside a wildcard {@code npath} if and only if
+     * {@code  simple_npath.relativize(wildcard_npath)} is exactly "..",
+     * a simple {@code npath} is recursively inside a wildcard {@code npath}
+     * if and only if {@code simple_npath.relativize(wildcard_npath)}
+     * is a series of one or more "..".
      *
      * @param p the permission to check against.
      *
@@ -334,45 +539,125 @@
      * @return the effective mask
      */
     boolean impliesIgnoreMask(FilePermission that) {
-        if (this.directory) {
-            if (this.recursive) {
-                // make sure that.path is longer then path so
-                // something like /foo/- does not imply /foo
-                if (that.directory) {
-                    return (that.cpath.length() >= this.cpath.length()) &&
-                            that.cpath.startsWith(this.cpath);
-                }  else {
-                    return ((that.cpath.length() > this.cpath.length()) &&
-                        that.cpath.startsWith(this.cpath));
+        if (FilePermCompat.nb) {
+            if (allFiles) {
+                return true;
+            }
+            if (that.allFiles) {
+                return false;
+            }
+            // Left at least same level of wildness as right
+            if ((this.recursive && that.recursive) != that.recursive
+                    || (this.directory && that.directory) != that.directory) {
+                return false;
+            }
+            // Same npath is good as long as both or neither are directories
+            if (this.npath.equals(that.npath)
+                    && this.directory == that.directory) {
+                return true;
+            }
+            int diff = containsPath(this.npath, that.npath);
+            // Right inside left is good if recursive
+            if (diff >= 1 && recursive) {
+                return true;
+            }
+            // Right right inside left if it is element in set
+            if (diff == 1 && directory && !that.directory) {
+                return true;
+            }
+
+            // Hack: if a npath2 field exists, apply the same checks
+            // on it as a fallback.
+            if (this.npath2 != null) {
+                if (this.npath2.equals(that.npath)
+                        && this.directory == that.directory) {
+                    return true;
+                }
+                diff = containsPath(this.npath2, that.npath);
+                if (diff >= 1 && recursive) {
+                    return true;
                 }
-            } else {
-                if (that.directory) {
-                    // if the permission passed in is a directory
-                    // specification, make sure that a non-recursive
-                    // permission (i.e., this object) can't imply a recursive
-                    // permission.
-                    if (that.recursive)
-                        return false;
-                    else
-                        return (this.cpath.equals(that.cpath));
+                if (diff == 1 && directory && !that.directory) {
+                    return true;
+                }
+            }
+
+            return false;
+        } else {
+            if (this.directory) {
+                if (this.recursive) {
+                    // make sure that.path is longer then path so
+                    // something like /foo/- does not imply /foo
+                    if (that.directory) {
+                        return (that.cpath.length() >= this.cpath.length()) &&
+                                that.cpath.startsWith(this.cpath);
+                    } else {
+                        return ((that.cpath.length() > this.cpath.length()) &&
+                                that.cpath.startsWith(this.cpath));
+                    }
                 } else {
-                    int last = that.cpath.lastIndexOf(File.separatorChar);
-                    if (last == -1)
-                        return false;
-                    else {
-                        // this.cpath.equals(that.cpath.substring(0, last+1));
-                        // Use regionMatches to avoid creating new string
-                        return (this.cpath.length() == (last + 1)) &&
-                            this.cpath.regionMatches(0, that.cpath, 0, last+1);
+                    if (that.directory) {
+                        // if the permission passed in is a directory
+                        // specification, make sure that a non-recursive
+                        // permission (i.e., this object) can't imply a recursive
+                        // permission.
+                        if (that.recursive)
+                            return false;
+                        else
+                            return (this.cpath.equals(that.cpath));
+                    } else {
+                        int last = that.cpath.lastIndexOf(File.separatorChar);
+                        if (last == -1)
+                            return false;
+                        else {
+                            // this.cpath.equals(that.cpath.substring(0, last+1));
+                            // Use regionMatches to avoid creating new string
+                            return (this.cpath.length() == (last + 1)) &&
+                                    this.cpath.regionMatches(0, that.cpath, 0, last + 1);
+                        }
                     }
                 }
+            } else if (that.directory) {
+                // if this is NOT recursive/wildcarded,
+                // do not let it imply a recursive/wildcarded permission
+                return false;
+            } else {
+                return (this.cpath.equals(that.cpath));
             }
-        } else if (that.directory) {
-            // if this is NOT recursive/wildcarded,
-            // do not let it imply a recursive/wildcarded permission
-            return false;
-        } else {
-            return (this.cpath.equals(that.cpath));
+        }
+    }
+
+    /**
+     * Returns the depth between an outer path p1 and an inner path p2. -1
+     * is returned if
+     *
+     * - p1 does not contains p2.
+     * - this is not decidable. For example, p1="../x", p2="y".
+     * - the depth is not decidable. For example, p1="/", p2="x".
+     *
+     * This method can return 2 if the depth is greater than 2.
+     *
+     * @param p1 the expected outer path, normalized
+     * @param p2 the expected inner path, normalized
+     * @return the depth in between
+     */
+    private static int containsPath(Path p1, Path p2) {
+        Path p;
+        try {
+            p = p2.relativize(p1).normalize();
+            if (p.getName(0).toString().isEmpty()) {
+                return 0;
+            } else {
+                for (Path item: p) {
+                    String s = item.toString();
+                    if (!s.equals("..")) {
+                        return -1;
+                    }
+                }
+                return p.getNameCount();
+            }
+        } catch (IllegalArgumentException iae) {
+            return -1;
         }
     }
 
@@ -380,6 +665,12 @@
      * Checks two FilePermission objects for equality. Checks that <i>obj</i> is
      * a FilePermission, and has the same pathname and actions as this object.
      *
+     * @implNote More specifically, two pathnames are the same if and only if
+     * they have the same wildcard flag and their {@code cpath}
+     * (if {@code jdk.io.permissionsUseCanonicalPath} is {@code true}) or
+     * {@code npath} (if {@code jdk.io.permissionsUseCanonicalPath}
+     * is {@code false}) are equal. Or they are both {@literal "<<ALL FILES>>"}.
+     *
      * @param obj the object we are testing for equality with this object.
      * @return <code>true</code> if obj is a FilePermission, and has the same
      *          pathname and actions as this FilePermission object,
@@ -395,10 +686,18 @@
 
         FilePermission that = (FilePermission) obj;
 
-        return (this.mask == that.mask) &&
-            this.cpath.equals(that.cpath) &&
-            (this.directory == that.directory) &&
-            (this.recursive == that.recursive);
+        if (FilePermCompat.nb) {
+            return (this.mask == that.mask) &&
+                    (this.allFiles == that.allFiles) &&
+                    this.npath.equals(that.npath) &&
+                    (this.directory == that.directory) &&
+                    (this.recursive == that.recursive);
+        } else {
+            return (this.mask == that.mask) &&
+                    this.cpath.equals(that.cpath) &&
+                    (this.directory == that.directory) &&
+                    (this.recursive == that.recursive);
+        }
     }
 
     /**
@@ -408,7 +707,11 @@
      */
     @Override
     public int hashCode() {
-        return 0;
+        if (FilePermCompat.nb) {
+            return Objects.hash(mask, allFiles, directory, recursive, npath);
+        } else {
+            return 0;
+        }
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,631 @@
+/*
+ * 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 java.io;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.Security;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Function;
+
+
+/**
+ * Filter classes, array lengths, and graph metrics during deserialization.
+ * If set on an {@link ObjectInputStream}, the {@link #checkInput checkInput(FilterInfo)}
+ * method is called to validate classes, the length of each array,
+ * the number of objects being read from the stream, the depth of the graph,
+ * and the total number of bytes read from the stream.
+ * <p>
+ * A filter can be set via {@link ObjectInputStream#setObjectInputFilter setObjectInputFilter}
+ * for an individual ObjectInputStream.
+ * A filter can be set via {@link Config#setSerialFilter(ObjectInputFilter) Config.setSerialFilter}
+ * to affect every {@code ObjectInputStream} that does not otherwise set a filter.
+ * <p>
+ * A filter determines whether the arguments are {@link Status#ALLOWED ALLOWED}
+ * or {@link Status#REJECTED REJECTED} and should return the appropriate status.
+ * If the filter cannot determine the status it should return
+ * {@link Status#UNDECIDED UNDECIDED}.
+ * Filters should be designed for the specific use case and expected types.
+ * A filter designed for a particular use may be passed a class that is outside
+ * of the scope of the filter. If the purpose of the filter is to black-list classes
+ * then it can reject a candidate class that matches and report UNDECIDED for others.
+ * A filter may be called with class equals {@code null}, {@code arrayLength} equal -1,
+ * the depth, number of references, and stream size and return a status
+ * that reflects only one or only some of the values.
+ * This allows a filter to specific about the choice it is reporting and
+ * to use other filters without forcing either allowed or rejected status.
+ *
+ * <p>
+ * Typically, a custom filter should check if a process-wide filter
+ * is configured and defer to it if so. For example,
+ * <pre>{@code
+ * ObjectInputFilter.Status checkInput(FilterInfo info) {
+ *     ObjectInputFilter serialFilter = ObjectInputFilter.Config.getSerialFilter();
+ *     if (serialFilter != null) {
+ *         ObjectInputFilter.Status status = serialFilter.checkInput(info);
+ *         if (status != ObjectInputFilter.Status.UNDECIDED) {
+ *             // The process-wide filter overrides this filter
+ *             return status;
+ *         }
+ *     }
+ *     if (info.serialClass() != null &&
+ *         Remote.class.isAssignableFrom(info.serialClass())) {
+ *         return Status.REJECTED;      // Do not allow Remote objects
+ *     }
+ *     return Status.UNDECIDED;
+ * }
+ *}</pre>
+ * <p>
+ * Unless otherwise noted, passing a {@code null} argument to a
+ * method in this interface and its nested classes will cause a
+ * {@link NullPointerException} to be thrown.
+ *
+ * @see ObjectInputStream#setObjectInputFilter(ObjectInputFilter)
+ * @since 9
+ */
+@FunctionalInterface
+public interface ObjectInputFilter {
+
+    /**
+     * Check the class, array length, number of object references, depth,
+     * stream size, and other available filtering information.
+     * Implementations of this method check the contents of the object graph being created
+     * during deserialization. The filter returns {@link Status#ALLOWED Status.ALLOWED},
+     * {@link Status#REJECTED Status.REJECTED}, or {@link Status#UNDECIDED Status.UNDECIDED}.
+     *
+     * @param filterInfo provides information about the current object being deserialized,
+     *             if any, and the status of the {@link ObjectInputStream}
+     * @return  {@link Status#ALLOWED Status.ALLOWED} if accepted,
+     *          {@link Status#REJECTED Status.REJECTED} if rejected,
+     *          {@link Status#UNDECIDED Status.UNDECIDED} if undecided.
+     * @since 9
+     */
+    Status checkInput(FilterInfo filterInfo);
+
+    /**
+     * FilterInfo provides access to information about the current object
+     * being deserialized and the status of the {@link ObjectInputStream}.
+     * @since 9
+     */
+    interface FilterInfo {
+        /**
+         * The class of an object being deserialized.
+         * For arrays, it is the array type.
+         * For example, the array class name of a 2 dimensional array of strings is
+         * "{@code [[Ljava.lang.String;}".
+         * To check the array's element type, iteratively use
+         * {@link Class#getComponentType() Class.getComponentType} while the result
+         * is an array and then check the class.
+         * The {@code serialClass is null} in the case where a new object is not being
+         * created and to give the filter a chance to check the depth, number of
+         * references to existing objects, and the stream size.
+         *
+         * @return class of an object being deserialized; may be null
+         */
+        Class<?> serialClass();
+
+        /**
+         * The number of array elements when deserializing an array of the class.
+         *
+         * @return the non-negative number of array elements when deserializing
+         * an array of the class, otherwise -1
+         */
+        long arrayLength();
+
+        /**
+         * The current depth.
+         * The depth starts at {@code 1} and increases for each nested object and
+         * decrements when each nested object returns.
+         *
+         * @return the current depth
+         */
+        long depth();
+
+        /**
+         * The current number of object references.
+         *
+         * @return the non-negative current number of object references
+         */
+        long references();
+
+        /**
+         * The current number of bytes consumed.
+         * @implSpec  {@code streamBytes} is implementation specific
+         * and may not be directly related to the object in the stream
+         * that caused the callback.
+         *
+         * @return the non-negative current number of bytes consumed
+         */
+        long streamBytes();
+    }
+
+    /**
+     * The status of a check on the class, array length, number of references,
+     * depth, and stream size.
+     *
+     * @since 9
+     */
+    enum Status {
+        /**
+         * The status is undecided, not allowed and not rejected.
+         */
+        UNDECIDED,
+        /**
+         * The status is allowed.
+         */
+        ALLOWED,
+        /**
+         * The status is rejected.
+         */
+        REJECTED;
+    }
+
+    /**
+     * A utility class to set and get the process-wide filter or create a filter
+     * from a pattern string. If a process-wide filter is set, it will be
+     * used for each {@link ObjectInputStream} that does not set its own filter.
+     * <p>
+     * When setting the filter, it should be stateless and idempotent,
+     * reporting the same result when passed the same arguments.
+     * <p>
+     * The filter is configured using the {@link java.security.Security}
+     * property {@code jdk.serialFilter} and can be overridden by
+     * the System property {@code jdk.serialFilter}.
+     *
+     * The syntax is the same as for the {@link #createFilter(String) createFilter} method.
+     *
+     * @since 9
+     */
+    final class Config {
+        /* No instances. */
+        private Config() {}
+
+        /**
+         * Lock object for process-wide filter.
+         */
+        private final static Object serialFilterLock = new Object();
+
+        /**
+         * Debug: Logger
+         */
+        private final static System.Logger configLog;
+
+        /**
+         * Logger for debugging.
+         */
+        static void filterLog(System.Logger.Level level, String msg, Object... args) {
+            if (configLog != null) {
+                configLog.log(level, msg, args);
+            }
+        }
+
+        /**
+         * The name for the process-wide deserialization filter.
+         * Used as a system property and a java.security.Security property.
+         */
+        private final static String SERIAL_FILTER_PROPNAME = "jdk.serialFilter";
+
+        /**
+         * The process-wide filter; may be null.
+         * Lookup the filter in java.security.Security or
+         * the system property.
+         */
+        private final static ObjectInputFilter configuredFilter;
+
+        static {
+            configuredFilter = AccessController
+                    .doPrivileged((PrivilegedAction<ObjectInputFilter>) () -> {
+                        String props = System.getProperty(SERIAL_FILTER_PROPNAME);
+                        if (props == null) {
+                            props = Security.getProperty(SERIAL_FILTER_PROPNAME);
+                        }
+                        if (props != null) {
+                            System.Logger log =
+                                    System.getLogger("java.io.serialization");
+                            log.log(System.Logger.Level.INFO,
+                                    "Creating serialization filter from {0}", props);
+                            try {
+                                return createFilter(props);
+                            } catch (RuntimeException re) {
+                                log.log(System.Logger.Level.ERROR,
+                                        "Error configuring filter: {0}", re);
+                            }
+                        }
+                        return null;
+                    });
+            configLog = (configuredFilter != null) ? System.getLogger("java.io.serialization") : null;
+        }
+
+        /**
+         * Current configured filter.
+         */
+        private static ObjectInputFilter serialFilter = configuredFilter;
+
+        /**
+         * Returns the process-wide serialization filter or {@code null} if not configured.
+         *
+         * @return the process-wide serialization filter or {@code null} if not configured
+         */
+        public static ObjectInputFilter getSerialFilter() {
+            synchronized (serialFilterLock) {
+                return serialFilter;
+            }
+        }
+
+        /**
+         * Set the process-wide filter if it has not already been configured or set.
+         *
+         * @param filter the serialization filter to set as the process-wide filter; not null
+         * @throws SecurityException if there is security manager and the
+         *       {@code SerializablePermission("serialFilter")} is not granted
+         * @throws IllegalStateException if the filter has already been set {@code non-null}
+         */
+        public static void setSerialFilter(ObjectInputFilter filter) {
+            Objects.requireNonNull(filter, "filter");
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION);
+            }
+            synchronized (serialFilterLock) {
+                if (serialFilter != null) {
+                    throw new IllegalStateException("Serial filter can only be set once");
+                }
+                serialFilter = filter;
+            }
+        }
+
+        /**
+         * Returns an ObjectInputFilter from a string of patterns.
+         * <p>
+         * Patterns are separated by ";" (semicolon). Whitespace is significant and
+         * is considered part of the pattern.
+         * If a pattern includes an equals assignment, "{@code =}" it sets a limit.
+         * If a limit appears more than once the last value is used.
+         * <ul>
+         *     <li>maxdepth={@code value} - the maximum depth of a graph</li>
+         *     <li>maxrefs={@code value}  - the maximum number of internal references</li>
+         *     <li>maxbytes={@code value} - the maximum number of bytes in the input stream</li>
+         *     <li>maxarray={@code value} - the maximum array length allowed</li>
+         * </ul>
+         * <p>
+         * Other patterns match or reject class or package name
+         * as returned from {@link Class#getName() Class.getName()} and
+         * if an optional module name is present
+         * {@link java.lang.reflect.Module#getName() class.getModule().getName()}.
+         * Note that for arrays the element type is used in the pattern,
+         * not the array type.
+         * <ul>
+         * <li>If the pattern starts with "!", the class is rejected if the remaining pattern is matched;
+         *     otherwise the class is allowed if the pattern matches.
+         * <li>If the pattern contains "/", the non-empty prefix up to the "/" is the module name;
+         *     if the module name matches the module name of the class then
+         *     the remaining pattern is matched with the class name.
+         *     If there is no "/", the module name is not compared.
+         * <li>If the pattern ends with ".**" it matches any class in the package and all subpackages.
+         * <li>If the pattern ends with ".*" it matches any class in the package.
+         * <li>If the pattern ends with "*", it matches any class with the pattern as a prefix.
+         * <li>If the pattern is equal to the class name, it matches.
+         * <li>Otherwise, the pattern is not matched.
+         * </ul>
+         * <p>
+         * The resulting filter performs the limit checks and then
+         * tries to match the class, if any. If any of the limits are exceeded,
+         * the filter returns {@link Status#REJECTED Status.REJECTED}.
+         * If the class is an array type, the class to be matched is the element type.
+         * Arrays of any number of dimensions are treated the same as the element type.
+         * For example, a pattern of "{@code !example.Foo}",
+         * rejects creation of any instance or array of {@code example.Foo}.
+         * The first pattern that matches, working from left to right, determines
+         * the {@link Status#ALLOWED Status.ALLOWED}
+         * or {@link Status#REJECTED Status.REJECTED} result.
+         * If nothing matches, the result is {@link Status#UNDECIDED Status.UNDECIDED}.
+         *
+         * @param pattern the pattern string to parse; not null
+         * @return a filter to check a class being deserialized; may be null;
+         *          {@code null} if no patterns
+         * @throws IllegalArgumentException
+         *                if a limit is missing the name, or the long value
+         *                is not a number or is negative,
+         *                or the module name is missing if the pattern contains "/"
+         *                or if the package is missing for ".*" and ".**"
+         */
+        public static ObjectInputFilter createFilter(String pattern) {
+            Objects.requireNonNull(pattern, "pattern");
+            return Global.createFilter(pattern);
+        }
+
+        /**
+         * Implementation of ObjectInputFilter that performs the checks of
+         * the process-wide serialization filter. If configured, it will be
+         * used for all ObjectInputStreams that do not set their own filters.
+         *
+         */
+        final static class Global implements ObjectInputFilter {
+            /**
+             * The pattern used to create the filter.
+             */
+            private final String pattern;
+            /**
+             * The list of class filters.
+             */
+            private final List<Function<Class<?>, Status>> filters;
+            /**
+             * Maximum allowed bytes in the stream.
+             */
+            private long maxStreamBytes;
+            /**
+             * Maximum depth of the graph allowed.
+             */
+            private long maxDepth;
+            /**
+             * Maximum number of references in a graph.
+             */
+            private long maxReferences;
+            /**
+             * Maximum length of any array.
+             */
+            private long maxArrayLength;
+
+            /**
+             * Returns an ObjectInputFilter from a string of patterns.
+             *
+             * @param pattern the pattern string to parse
+             * @return a filter to check a class being deserialized; not null
+             * @throws IllegalArgumentException if the parameter is malformed
+             *                if the pattern is missing the name, the long value
+             *                is not a number or is negative.
+             */
+            static ObjectInputFilter createFilter(String pattern) {
+                Global filter = new Global(pattern);
+                return filter.isEmpty() ? null : filter;
+            }
+
+            /**
+             * Construct a new filter from the pattern String.
+             *
+             * @param pattern a pattern string of filters
+             * @throws IllegalArgumentException if the pattern is malformed
+             */
+            private Global(String pattern) {
+                this.pattern = pattern;
+
+                maxArrayLength = Long.MAX_VALUE; // Default values are unlimited
+                maxDepth = Long.MAX_VALUE;
+                maxReferences = Long.MAX_VALUE;
+                maxStreamBytes = Long.MAX_VALUE;
+
+                String[] patterns = pattern.split(";");
+                filters = new ArrayList<>(patterns.length);
+                for (int i = 0; i < patterns.length; i++) {
+                    String p = patterns[i];
+                    int nameLen = p.length();
+                    if (nameLen == 0) {
+                        continue;
+                    }
+                    if (parseLimit(p)) {
+                        // If the pattern contained a limit setting, i.e. type=value
+                        continue;
+                    }
+                    boolean negate = p.charAt(0) == '!';
+                    int poffset = negate ? 1 : 0;
+
+                    // isolate module name, if any
+                    int slash = p.indexOf('/', poffset);
+                    if (slash == poffset) {
+                        throw new IllegalArgumentException("module name is missing in: \"" + pattern + "\"");
+                    }
+                    final String moduleName = (slash >= 0) ? p.substring(poffset, slash) : null;
+                    poffset = (slash >= 0) ? slash + 1 : poffset;
+
+                    final Function<Class<?>, Status> patternFilter;
+                    if (p.endsWith("*")) {
+                        // Wildcard cases
+                        if (p.endsWith(".*")) {
+                            // Pattern is a package name with a wildcard
+                            final String pkg = p.substring(poffset, nameLen - 1);
+                            if (pkg.length() < 2) {
+                                throw new IllegalArgumentException("package missing in: \"" + pattern + "\"");
+                            }
+                            if (negate) {
+                                // A Function that fails if the class starts with the pattern, otherwise don't care
+                                patternFilter = c -> matchesPackage(c, pkg) ? Status.REJECTED : Status.UNDECIDED;
+                            } else {
+                                // A Function that succeeds if the class starts with the pattern, otherwise don't care
+                                patternFilter = c -> matchesPackage(c, pkg) ? Status.ALLOWED : Status.UNDECIDED;
+                            }
+                        } else if (p.endsWith(".**")) {
+                            // Pattern is a package prefix with a double wildcard
+                            final String pkgs = p.substring(poffset, nameLen - 2);
+                            if (pkgs.length() < 2) {
+                                throw new IllegalArgumentException("package missing in: \"" + pattern + "\"");
+                            }
+                            if (negate) {
+                                // A Function that fails if the class starts with the pattern, otherwise don't care
+                                patternFilter = c -> c.getName().startsWith(pkgs) ? Status.REJECTED : Status.UNDECIDED;
+                            } else {
+                                // A Function that succeeds if the class starts with the pattern, otherwise don't care
+                                patternFilter = c -> c.getName().startsWith(pkgs) ? Status.ALLOWED : Status.UNDECIDED;
+                            }
+                        } else {
+                            // Pattern is a classname (possibly empty) with a trailing wildcard
+                            final String className = p.substring(poffset, nameLen - 1);
+                            if (negate) {
+                                // A Function that fails if the class starts with the pattern, otherwise don't care
+                                patternFilter = c -> c.getName().startsWith(className) ? Status.REJECTED : Status.UNDECIDED;
+                            } else {
+                                // A Function that succeeds if the class starts with the pattern, otherwise don't care
+                                patternFilter = c -> c.getName().startsWith(className) ? Status.ALLOWED : Status.UNDECIDED;
+                            }
+                        }
+                    } else {
+                        final String name = p.substring(poffset);
+                        if (name.isEmpty()) {
+                            throw new IllegalArgumentException("class or package missing in: \"" + pattern + "\"");
+                        }
+                        // Pattern is a class name
+                        if (negate) {
+                            // A Function that fails if the class equals the pattern, otherwise don't care
+                            patternFilter = c -> c.getName().equals(name) ? Status.REJECTED : Status.UNDECIDED;
+                        } else {
+                            // A Function that succeeds if the class equals the pattern, otherwise don't care
+                            patternFilter = c -> c.getName().equals(name) ? Status.ALLOWED : Status.UNDECIDED;
+                        }
+                    }
+                    // If there is a moduleName, combine the module name check with the package/class check
+                    if (moduleName == null) {
+                        filters.add(patternFilter);
+                    } else {
+                        filters.add(c -> moduleName.equals(c.getModule().getName()) ? patternFilter.apply(c) : Status.UNDECIDED);
+                    }
+                }
+            }
+
+            /**
+             * Returns if this filter has any checks.
+             * @return {@code true} if the filter has any checks, {@code false} otherwise
+             */
+            private boolean isEmpty() {
+                return filters.isEmpty() &&
+                        maxArrayLength == Long.MAX_VALUE &&
+                        maxDepth == Long.MAX_VALUE &&
+                        maxReferences == Long.MAX_VALUE &&
+                        maxStreamBytes == Long.MAX_VALUE;
+            }
+
+            /**
+             * Parse out a limit for one of maxarray, maxdepth, maxbytes, maxreferences.
+             *
+             * @param pattern a string with a type name, '=' and a value
+             * @return {@code true} if a limit was parsed, else {@code false}
+             * @throws IllegalArgumentException if the pattern is missing
+             *                the name, the Long value is not a number or is negative.
+             */
+            private boolean parseLimit(String pattern) {
+                int eqNdx = pattern.indexOf('=');
+                if (eqNdx < 0) {
+                    // not a limit pattern
+                    return false;
+                }
+                String valueString = pattern.substring(eqNdx + 1);
+                if (pattern.startsWith("maxdepth=")) {
+                    maxDepth = parseValue(valueString);
+                } else if (pattern.startsWith("maxarray=")) {
+                    maxArrayLength = parseValue(valueString);
+                } else if (pattern.startsWith("maxrefs=")) {
+                    maxReferences = parseValue(valueString);
+                } else if (pattern.startsWith("maxbytes=")) {
+                    maxStreamBytes = parseValue(valueString);
+                } else {
+                    throw new IllegalArgumentException("unknown limit: " + pattern.substring(0, eqNdx));
+                }
+                return true;
+            }
+
+            /**
+             * Parse the value of a limit and check that it is non-negative.
+             * @param string inputstring
+             * @return the parsed value
+             * @throws IllegalArgumentException if parsing the value fails or the value is negative
+             */
+            private static long parseValue(String string) throws IllegalArgumentException {
+                // Parse a Long from after the '=' to the end
+                long value = Long.parseLong(string);
+                if (value < 0) {
+                    throw new IllegalArgumentException("negative limit: " + string);
+                }
+                return value;
+            }
+
+            /**
+             * {@inheritDoc}
+             */
+            @Override
+            public Status checkInput(FilterInfo filterInfo) {
+                if (filterInfo.references() < 0
+                        || filterInfo.depth() < 0
+                        || filterInfo.streamBytes() < 0
+                        || filterInfo.references() > maxReferences
+                        || filterInfo.depth() > maxDepth
+                        || filterInfo.streamBytes() > maxStreamBytes) {
+                    return Status.REJECTED;
+                }
+
+                Class<?> clazz = filterInfo.serialClass();
+                if (clazz != null) {
+                    if (clazz.isArray()) {
+                        if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > maxArrayLength) {
+                            // array length is too big
+                            return Status.REJECTED;
+                        }
+                        do {
+                            // Arrays are decided based on the component type
+                            clazz = clazz.getComponentType();
+                        } while (clazz.isArray());
+                    }
+
+                    if (clazz.isPrimitive())  {
+                        // Primitive types are undecided; let someone else decide
+                        return Status.UNDECIDED;
+                    } else {
+                        // Find any filter that allowed or rejected the class
+                        final Class<?> cl = clazz;
+                        Optional<Status> status = filters.stream()
+                                .map(f -> f.apply(cl))
+                                .filter(p -> p != Status.UNDECIDED)
+                                .findFirst();
+                        return status.orElse(Status.UNDECIDED);
+                    }
+                }
+                return Status.UNDECIDED;
+            }
+
+            /**
+             * Returns {@code true} if the class is in the package.
+             *
+             * @param c   a class
+             * @param pkg a package name (including the trailing ".")
+             * @return {@code true} if the class is in the package,
+             * otherwise {@code false}
+             */
+            private static boolean matchesPackage(Class<?> c, String pkg) {
+                String n = c.getName();
+                return n.startsWith(pkg) && n.lastIndexOf('.') == pkg.length() - 1;
+            }
+
+            /**
+             * Returns the pattern used to create this filter.
+             * @return the pattern used to create this filter
+             */
+            @Override
+            public String toString() {
+                return pattern;
+            }
+        }
+    }
+}
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,6 +26,7 @@
 package java.io;
 
 import java.io.ObjectStreamClass.WeakClassKey;
+import java.lang.System.Logger;
 import java.lang.ref.ReferenceQueue;
 import java.lang.reflect.Array;
 import java.lang.reflect.Modifier;
@@ -37,10 +38,12 @@
 import java.security.PrivilegedExceptionAction;
 import java.util.Arrays;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+
 import static java.io.ObjectStreamClass.processQueue;
-import jdk.internal.misc.JavaObjectInputStreamAccess;
+
 import jdk.internal.misc.ObjectStreamClassValidator;
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.misc.Unsafe;
@@ -172,6 +175,16 @@
  * protected) or that there are get and set methods that can be used to restore
  * the state.
  *
+ * <p>The contents of the stream can be filtered during deserialization.
+ * If a {@linkplain #setObjectInputFilter(ObjectInputFilter) filter is set}
+ * on an ObjectInputStream, the {@link ObjectInputFilter} can check that
+ * the classes, array lengths, number of references in the stream, depth, and
+ * number of bytes consumed from the input stream are allowed and
+ * if not, can terminate deserialization.
+ * A {@linkplain ObjectInputFilter.Config#setSerialFilter(ObjectInputFilter) process-wide filter}
+ * can be configured that is applied to each {@code ObjectInputStream} unless replaced
+ * using {@link #setObjectInputFilter(ObjectInputFilter) setObjectInputFilter}.
+ *
  * <p>Any exception that occurs while deserializing an object will be caught by
  * the ObjectInputStream and abort the reading process.
  *
@@ -240,12 +253,32 @@
             new ReferenceQueue<>();
     }
 
+    /*
+     * Separate class to defer initialization of logging until needed.
+     */
+    private static class Logging {
+        /*
+         * Logger for ObjectInputFilter results.
+         * Setup the filter logger if it is set to DEBUG or TRACE.
+         * (Assuming it will not change).
+         */
+        static final System.Logger filterLogger;
+
+        static {
+            Logger filterLog = System.getLogger("java.io.serialization");
+            filterLogger = (filterLog.isLoggable(Logger.Level.DEBUG)
+                    || filterLog.isLoggable(Logger.Level.TRACE)) ? filterLog : null;
+        }
+    }
+
     /** filter stream for handling block data conversion */
     private final BlockDataInputStream bin;
     /** validation callback list */
     private final ValidationList vlist;
     /** recursion depth */
-    private int depth;
+    private long depth;
+    /** Total number of references to any type of object, class, enum, proxy, etc. */
+    private long totalObjectRefs;
     /** whether stream is closed */
     private boolean closed;
 
@@ -269,11 +302,20 @@
     private SerialCallbackContext curContext;
 
     /**
+     * Filter of class descriptors and classes read from the stream;
+     * may be null.
+     */
+    private ObjectInputFilter serialFilter;
+
+    /**
      * Creates an ObjectInputStream that reads from the specified InputStream.
      * A serialization stream header is read from the stream and verified.
      * This constructor will block until the corresponding ObjectOutputStream
      * has written and flushed the header.
      *
+     * <p>The serialization filter is initialized to the value of
+     * {@linkplain ObjectInputFilter.Config#getSerialFilter() the process-wide filter}.
+     *
      * <p>If a security manager is installed, this constructor will check for
      * the "enableSubclassImplementation" SerializablePermission when invoked
      * directly or indirectly by the constructor of a subclass which overrides
@@ -295,6 +337,7 @@
         bin = new BlockDataInputStream(in);
         handles = new HandleTable(10);
         vlist = new ValidationList();
+        serialFilter = ObjectInputFilter.Config.getSerialFilter();
         enableOverride = false;
         readStreamHeader();
         bin.setBlockDataMode(true);
@@ -305,6 +348,9 @@
      * ObjectInputStream to not have to allocate private data just used by this
      * implementation of ObjectInputStream.
      *
+     * <p>The serialization filter is initialized to the value of
+     * {@linkplain ObjectInputFilter.Config#getSerialFilter() the process-wide filter}.
+     *
      * <p>If there is a security manager installed, this method first calls the
      * security manager's <code>checkPermission</code> method with the
      * <code>SerializablePermission("enableSubclassImplementation")</code>
@@ -325,6 +371,7 @@
         bin = null;
         handles = null;
         vlist = null;
+        serialFilter = ObjectInputFilter.Config.getSerialFilter();
         enableOverride = true;
     }
 
@@ -332,7 +379,7 @@
      * Read an object from the ObjectInputStream.  The class of the object, the
      * signature of the class, and the values of the non-transient and
      * non-static fields of the class and all of its supertypes are read.
-     * Default deserializing for a class can be overriden using the writeObject
+     * Default deserializing for a class can be overridden using the writeObject
      * and readObject methods.  Objects referenced by this object are read
      * transitively so that a complete equivalent graph of objects is
      * reconstructed by readObject.
@@ -343,6 +390,10 @@
      * priorities. The callbacks are registered by objects (in the readObject
      * special methods) as they are individually restored.
      *
+     * <p>The serialization filter, when not {@code null}, is invoked for
+     * each object (regular or class) read to reconstruct the root object.
+     * See {@link #setObjectInputFilter(ObjectInputFilter) setObjectInputFilter} for details.
+     *
      * <p>Exceptions are thrown for problems with the InputStream and for
      * classes that should not be deserialized.  All exceptions are fatal to
      * the InputStream and leave it in an indeterminate state; it is up to the
@@ -438,6 +489,10 @@
      * invocation of readObject or readUnshared on the ObjectInputStream,
      * even if the underlying data stream has been manipulated.
      *
+     * <p>The serialization filter, when not {@code null}, is invoked for
+     * each object (regular or class) read to reconstruct the root object.
+     * See {@link #setObjectInputFilter(ObjectInputFilter) setObjectInputFilter} for details.
+     *
      * <p>ObjectInputStream subclasses which override this method can only be
      * constructed in security contexts possessing the
      * "enableSubclassImplementation" SerializablePermission; any attempt to
@@ -1094,6 +1149,134 @@
     }
 
     /**
+     * Returns the serialization filter for this stream.
+     * The serialization filter is the most recent filter set in
+     * {@link #setObjectInputFilter setObjectInputFilter} or
+     * the initial process-wide filter from
+     * {@link ObjectInputFilter.Config#getSerialFilter() ObjectInputFilter.Config.getSerialFilter}.
+     *
+     * @return the serialization filter for the stream; may be null
+     * @since 9
+     */
+    public final ObjectInputFilter getObjectInputFilter() {
+        return serialFilter;
+    }
+
+    /**
+     * Set the serialization filter for the stream.
+     * The filter's {@link ObjectInputFilter#checkInput checkInput} method is called
+     * for each class and reference in the stream.
+     * The filter can check any or all of the class, the array length, the number
+     * of references, the depth of the graph, and the size of the input stream.
+     * <p>
+     * If the filter returns {@link ObjectInputFilter.Status#REJECTED Status.REJECTED},
+     * {@code null} or throws a {@link RuntimeException},
+     * the active {@code readObject} or {@code readUnshared}
+     * throws {@link InvalidClassException}, otherwise deserialization
+     * continues uninterrupted.
+     * <p>
+     * The serialization filter is initialized to the value of
+     * {@link ObjectInputFilter.Config#getSerialFilter() ObjectInputFilter.Config.getSerialFilter}
+     * when the {@code  ObjectInputStream} is constructed and can be set
+     * to a custom filter only once.
+     *
+     * @implSpec
+     * The filter, when not {@code null}, is invoked during {@link #readObject readObject}
+     * and {@link #readUnshared readUnshared} for each object
+     * (regular or class) in the stream including the following:
+     * <ul>
+     *     <li>each object reference previously deserialized from the stream
+     *     (class is {@code null}, arrayLength is -1),
+     *     <li>each regular class (class is not {@code null}, arrayLength is -1),
+     *     <li>each interface of a dynamic proxy and the dynamic proxy class itself
+     *     (class is not {@code null}, arrayLength is -1),
+     *     <li>each array is filtered using the array type and length of the array
+     *     (class is the array type, arrayLength is the requested length),
+     *     <li>each object replaced by its class' {@code readResolve} method
+     *         is filtered using the replacement object's class, if not {@code null},
+     *         and if it is an array, the arrayLength, otherwise -1,
+     *     <li>and each object replaced by {@link #resolveObject resolveObject}
+     *         is filtered using the replacement object's class, if not {@code null},
+     *         and if it is an array, the arrayLength, otherwise -1.
+     * </ul>
+     *
+     * When the {@link ObjectInputFilter#checkInput checkInput} method is invoked
+     * it is given access to the current class, the array length,
+     * the current number of references already read from the stream,
+     * the depth of nested calls to {@link #readObject readObject} or
+     * {@link #readUnshared readUnshared},
+     * and the implementation dependent number of bytes consumed from the input stream.
+     * <p>
+     * Each call to {@link #readObject readObject} or
+     * {@link #readUnshared readUnshared} increases the depth by 1
+     * before reading an object and decreases by 1 before returning
+     * normally or exceptionally.
+     * The depth starts at {@code 1} and increases for each nested object and
+     * decrements when each nested call returns.
+     * The count of references in the stream starts at {@code 1} and
+     * is increased before reading an object.
+     *
+     * @param filter the filter, may be null
+     * @throws SecurityException if there is security manager and the
+     *       {@code SerializablePermission("serialFilter")} is not granted
+     * @throws IllegalStateException if the {@linkplain #getObjectInputFilter() current filter}
+     *       is not {@code null} and is not the process-wide filter
+     * @since 9
+     */
+    public final void setObjectInputFilter(ObjectInputFilter filter) {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION);
+        }
+        // Allow replacement of the process-wide filter if not already set
+        if (serialFilter != null &&
+                serialFilter != ObjectInputFilter.Config.getSerialFilter()) {
+            throw new IllegalStateException("filter can not be set more than once");
+        }
+        this.serialFilter = filter;
+    }
+
+    /**
+     * Invoke the serialization filter if non-null.
+     * If the filter rejects or an exception is thrown, throws InvalidClassException.
+     *
+     * @param clazz the class; may be null
+     * @param arrayLength the array length requested; use {@code -1} if not creating an array
+     * @throws InvalidClassException if it rejected by the filter or
+     *        a {@link RuntimeException} is thrown
+     */
+    private void filterCheck(Class<?> clazz, int arrayLength)
+            throws InvalidClassException {
+        if (serialFilter != null) {
+            RuntimeException ex = null;
+            ObjectInputFilter.Status status;
+            try {
+                status = serialFilter.checkInput(new FilterValues(clazz, arrayLength,
+                        totalObjectRefs, depth, bin.getBytesRead()));
+            } catch (RuntimeException e) {
+                // Preventive interception of an exception to log
+                status = ObjectInputFilter.Status.REJECTED;
+                ex = e;
+            }
+            if (Logging.filterLogger != null) {
+                // Debug logging of filter checks that fail; Tracing for those that succeed
+                Logging.filterLogger.log(status == null || status == ObjectInputFilter.Status.REJECTED
+                                ? Logger.Level.DEBUG
+                                : Logger.Level.TRACE,
+                        "ObjectInputFilter {0}: {1}, array length: {2}, nRefs: {3}, depth: {4}, bytes: {5}, ex: {6}",
+                        status, clazz, arrayLength, totalObjectRefs, depth, bin.getBytesRead(),
+                        Objects.toString(ex, "n/a"));
+            }
+            if (status == null ||
+                    status == ObjectInputFilter.Status.REJECTED) {
+                InvalidClassException ice = new InvalidClassException("filter status: " + status);
+                ice.initCause(ex);
+                throw ice;
+            }
+        }
+    }
+
+    /**
      * Provide access to the persistent fields read from the input stream.
      */
     public abstract static class GetField {
@@ -1280,7 +1463,7 @@
      */
     private static Boolean auditSubclass(Class<?> subcl) {
         return AccessController.doPrivileged(
-            new PrivilegedAction<>() {
+            new PrivilegedAction<Boolean>() {
                 public Boolean run() {
                     for (Class<?> cl = subcl;
                          cl != ObjectInputStream.class;
@@ -1340,6 +1523,7 @@
         }
 
         depth++;
+        totalObjectRefs++;
         try {
             switch (tc) {
                 case TC_NULL:
@@ -1416,6 +1600,15 @@
         }
         Object rep = resolveObject(obj);
         if (rep != obj) {
+            // The type of the original object has been filtered but resolveObject
+            // may have replaced it;  filter the replacement's type
+            if (rep != null) {
+                if (rep.getClass().isArray()) {
+                    filterCheck(rep.getClass(), Array.getLength(rep));
+                } else {
+                    filterCheck(rep.getClass(), -1);
+                }
+            }
             handles.setObject(passHandle, rep);
         }
         return rep;
@@ -1486,6 +1679,7 @@
             throw new InvalidObjectException(
                 "cannot read back reference to unshared object");
         }
+        filterCheck(null, -1);       // just a check for number of references, depth, no class
         return obj;
     }
 
@@ -1590,6 +1784,10 @@
                 ReflectUtil.checkProxyPackageAccess(
                         getClass().getClassLoader(),
                         cl.getInterfaces());
+                // Filter the interfaces
+                for (Class<?> clazz : cl.getInterfaces()) {
+                    filterCheck(clazz, -1);
+                }
             }
         } catch (ClassNotFoundException ex) {
             resolveEx = ex;
@@ -1598,6 +1796,9 @@
 
         desc.initProxy(cl, resolveEx, readClassDesc(false));
 
+        // Call filterCheck on the definition
+        filterCheck(desc.forClass(), -1);
+
         handles.finish(descHandle);
         passHandle = descHandle;
         return desc;
@@ -1645,8 +1846,12 @@
 
         desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));
 
+        // Call filterCheck on the definition
+        filterCheck(desc.forClass(), -1);
+
         handles.finish(descHandle);
         passHandle = descHandle;
+
         return desc;
     }
 
@@ -1687,6 +1892,8 @@
         ObjectStreamClass desc = readClassDesc(false);
         int len = bin.readInt();
 
+        filterCheck(desc.forClass(), len);
+
         Object array = null;
         Class<?> cl, ccl = null;
         if ((cl = desc.forClass()) != null) {
@@ -1835,6 +2042,14 @@
                 rep = cloneArray(rep);
             }
             if (rep != obj) {
+                // Filter the replacement object
+                if (rep != null) {
+                    if (rep.getClass().isArray()) {
+                        filterCheck(rep.getClass(), Array.getLength(rep));
+                    } else {
+                        filterCheck(rep.getClass(), -1);
+                    }
+                }
                 handles.setObject(passHandle, obj = rep);
             }
         }
@@ -2360,7 +2575,7 @@
             try {
                 while (list != null) {
                     AccessController.doPrivileged(
-                        new PrivilegedExceptionAction<>()
+                        new PrivilegedExceptionAction<Void>()
                     {
                         public Void run() throws InvalidObjectException {
                             list.obj.validateObject();
@@ -2384,6 +2599,51 @@
     }
 
     /**
+     * Hold a snapshot of values to be passed to an ObjectInputFilter.
+     */
+    static class FilterValues implements ObjectInputFilter.FilterInfo {
+        final Class<?> clazz;
+        final long arrayLength;
+        final long totalObjectRefs;
+        final long depth;
+        final long streamBytes;
+
+        public FilterValues(Class<?> clazz, long arrayLength, long totalObjectRefs,
+                            long depth, long streamBytes) {
+            this.clazz = clazz;
+            this.arrayLength = arrayLength;
+            this.totalObjectRefs = totalObjectRefs;
+            this.depth = depth;
+            this.streamBytes = streamBytes;
+        }
+
+        @Override
+        public Class<?> serialClass() {
+            return clazz;
+        }
+
+        @Override
+        public long arrayLength() {
+            return arrayLength;
+        }
+
+        @Override
+        public long references() {
+            return totalObjectRefs;
+        }
+
+        @Override
+        public long depth() {
+            return depth;
+        }
+
+        @Override
+        public long streamBytes() {
+            return streamBytes;
+        }
+    }
+
+    /**
      * Input stream supporting single-byte peek operations.
      */
     private static class PeekInputStream extends InputStream {
@@ -2392,6 +2652,8 @@
         private final InputStream in;
         /** peeked byte */
         private int peekb = -1;
+        /** total bytes read from the stream */
+        private long totalBytesRead = 0;
 
         /**
          * Creates new PeekInputStream on top of given underlying stream.
@@ -2405,7 +2667,12 @@
          * that it does not consume the read value.
          */
         int peek() throws IOException {
-            return (peekb >= 0) ? peekb : (peekb = in.read());
+            if (peekb >= 0) {
+                return peekb;
+            }
+            peekb = in.read();
+            totalBytesRead += peekb >= 0 ? 1 : 0;
+            return peekb;
         }
 
         public int read() throws IOException {
@@ -2414,21 +2681,27 @@
                 peekb = -1;
                 return v;
             } else {
-                return in.read();
+                int nbytes = in.read();
+                totalBytesRead += nbytes >= 0 ? 1 : 0;
+                return nbytes;
             }
         }
 
         public int read(byte[] b, int off, int len) throws IOException {
+            int nbytes;
             if (len == 0) {
                 return 0;
             } else if (peekb < 0) {
-                return in.read(b, off, len);
+                nbytes = in.read(b, off, len);
+                totalBytesRead += nbytes >= 0 ? nbytes : 0;
+                return nbytes;
             } else {
                 b[off++] = (byte) peekb;
                 len--;
                 peekb = -1;
-                int n = in.read(b, off, len);
-                return (n >= 0) ? (n + 1) : 1;
+                nbytes = in.read(b, off, len);
+                totalBytesRead += nbytes >= 0 ? nbytes : 0;
+                return (nbytes >= 0) ? (nbytes + 1) : 1;
             }
         }
 
@@ -2453,7 +2726,9 @@
                 skipped++;
                 n--;
             }
-            return skipped + in.skip(n);
+            n = skipped + in.skip(n);
+            totalBytesRead += n;
+            return n;
         }
 
         public int available() throws IOException {
@@ -2463,6 +2738,10 @@
         public void close() throws IOException {
             in.close();
         }
+
+        public long getBytesRead() {
+            return totalBytesRead;
+        }
     }
 
     private static final Unsafe UNSAFE = Unsafe.getUnsafe();
@@ -3346,6 +3625,14 @@
                     throw new UTFDataFormatException();
             }
         }
+
+        /**
+         * Returns the number of bytes read from the input stream.
+         * @return the number of bytes read from the input stream
+         */
+        long getBytesRead() {
+            return in.getBytesRead();
+        }
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/io/ObjectStreamConstants.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/ObjectStreamConstants.java	Tue Oct 18 17:14:09 2016 +0000
@@ -199,6 +199,16 @@
      */
     static final SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION =
                     new SerializablePermission("enableSubclassImplementation");
+
+    /**
+     * Enable setting the process-wide serial filter.
+     *
+     * @see java.io.ObjectInputFilter.Config#setSerialFilter(ObjectInputFilter)
+     * @since 9
+     */
+    static final SerializablePermission SERIAL_FILTER_PERMISSION =
+            new SerializablePermission("serialFilter");
+
    /**
     * A Stream Protocol Version. <p>
     *
--- a/jdk/src/java.base/share/classes/java/io/SerializablePermission.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/SerializablePermission.java	Tue Oct 18 17:14:09 2016 +0000
@@ -40,7 +40,7 @@
  * The target name is the name of the Serializable permission (see below).
  *
  * <P>
- * The following table lists all the possible SerializablePermission target names,
+ * The following table lists the standard {@code SerializablePermission} target names,
  * and for each provides a description of what the permission allows
  * and a discussion of the risks of granting code the permission.
  *
@@ -73,6 +73,13 @@
  * malignant data.</td>
  * </tr>
  *
+ * <tr>
+ *   <td>serialFilter</td>
+ *   <td>Setting a filter for ObjectInputStreams.</td>
+ *   <td>Code could remove a configured filter and remove protections
+ *       already established.</td>
+ * </tr>
+ *
  * </table>
  *
  * @see java.security.BasicPermission
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -292,9 +292,6 @@
         new ProtectionDomain(new CodeSource(null, (Certificate[]) null),
                              null, this, null);
 
-    // The initiating protection domains for all classes loaded by this loader
-    private final Set<ProtectionDomain> domains;
-
     // Invoked by the VM to record every loaded class with this loader.
     void addClass(Class<?> c) {
         classes.addElement(c);
@@ -349,13 +346,11 @@
         if (ParallelLoaders.isRegistered(this.getClass())) {
             parallelLockMap = new ConcurrentHashMap<>();
             package2certs = new ConcurrentHashMap<>();
-            domains = Collections.synchronizedSet(new HashSet<>());
             assertionLock = new Object();
         } else {
             // no finer-grained lock; lock on the classloader instance
             parallelLockMap = null;
             package2certs = new Hashtable<>();
-            domains = new HashSet<>();
             assertionLock = this;
         }
     }
@@ -640,7 +635,6 @@
                 }, new AccessControlContext(new ProtectionDomain[] {pd}));
             }
         }
-        domains.add(pd);
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/lang/Math.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/Math.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1626,7 +1626,7 @@
      *
      * @since 9
      */
-    // @HotSpotIntrinsicCandidate
+    @HotSpotIntrinsicCandidate
     public static double fma(double a, double b, double c) {
         /*
          * Infinity and NaN arithmetic is not quite the same with two
@@ -1743,7 +1743,7 @@
      *
      * @since 9
      */
-    // @HotSpotIntrinsicCandidate
+    @HotSpotIntrinsicCandidate
     public static float fma(float a, float b, float c) {
         /*
          *  Since the double format has more than twice the precision
--- a/jdk/src/java.base/share/classes/java/lang/String.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/String.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1516,11 +1516,12 @@
      * @return  a hash code value for this object.
      */
     public int hashCode() {
-        if (hash == 0 && value.length > 0) {
-            hash = isLatin1() ? StringLatin1.hashCode(value)
-                              : StringUTF16.hashCode(value);
+        int h = hash;
+        if (h == 0 && value.length > 0) {
+            hash = h = isLatin1() ? StringLatin1.hashCode(value)
+                                  : StringUTF16.hashCode(value);
         }
-        return hash;
+        return h;
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1962,12 +1962,12 @@
      * This method is bound as the predicate in {@linkplain MethodHandles#countedLoop(MethodHandle, MethodHandle,
      * MethodHandle) counting loops}.
      *
+     * @param limit the upper bound of the parameter, statically bound at loop creation time.
      * @param counter the counter parameter, passed in during loop execution.
-     * @param limit the upper bound of the parameter, statically bound at loop creation time.
      *
      * @return whether the counter has reached the limit.
      */
-    static boolean countedLoopPredicate(int counter, int limit) {
+    static boolean countedLoopPredicate(int limit, int counter) {
         return counter < limit;
     }
 
@@ -1975,27 +1975,16 @@
      * This method is bound as the step function in {@linkplain MethodHandles#countedLoop(MethodHandle, MethodHandle,
      * MethodHandle) counting loops} to increment the counter.
      *
+     * @param limit the upper bound of the loop counter (ignored).
      * @param counter the loop counter.
      *
      * @return the loop counter incremented by 1.
      */
-    static int countedLoopStep(int counter, int limit) {
+    static int countedLoopStep(int limit, int counter) {
         return counter + 1;
     }
 
     /**
-     * This method is bound as a filter in {@linkplain MethodHandles#countedLoop(MethodHandle, MethodHandle, MethodHandle,
-     * MethodHandle) counting loops} to pass the correct counter value to the body.
-     *
-     * @param counter the loop counter.
-     *
-     * @return the loop counter decremented by 1.
-     */
-    static int decrementCounter(int counter) {
-        return counter - 1;
-    }
-
-    /**
      * This is bound to initialize the loop-local iterator in {@linkplain MethodHandles#iteratedLoop iterating loops}.
      *
      * @param it the {@link Iterable} over which the loop iterates.
@@ -2164,12 +2153,11 @@
             MH_arrayIdentity         =  5,
             MH_countedLoopPred       =  6,
             MH_countedLoopStep       =  7,
-            MH_iteratePred           =  8,
-            MH_initIterator          =  9,
+            MH_initIterator          =  8,
+            MH_iteratePred           =  9,
             MH_iterateNext           = 10,
-            MH_decrementCounter      = 11,
-            MH_Array_newInstance     = 12,
-            MH_LIMIT                 = 13;
+            MH_Array_newInstance     = 11,
+            MH_LIMIT                 = 12;
 
     static MethodHandle getConstantHandle(int idx) {
         MethodHandle handle = HANDLES[idx];
@@ -2220,18 +2208,15 @@
                 case MH_countedLoopStep:
                     return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "countedLoopStep",
                             MethodType.methodType(int.class, int.class, int.class));
-                case MH_iteratePred:
-                    return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "iteratePredicate",
-                            MethodType.methodType(boolean.class, Iterator.class));
                 case MH_initIterator:
                     return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "initIterator",
                             MethodType.methodType(Iterator.class, Iterable.class));
+                case MH_iteratePred:
+                    return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "iteratePredicate",
+                            MethodType.methodType(boolean.class, Iterator.class));
                 case MH_iterateNext:
                     return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "iterateNext",
                             MethodType.methodType(Object.class, Iterator.class));
-                case MH_decrementCounter:
-                    return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "decrementCounter",
-                            MethodType.methodType(int.class, int.class));
                 case MH_Array_newInstance:
                     return IMPL_LOOKUP.findStatic(Array.class, "newInstance",
                             MethodType.methodType(Object.class, Class.class, int.class));
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Tue Oct 18 17:14:09 2016 +0000
@@ -44,8 +44,6 @@
 import java.lang.reflect.Modifier;
 import java.lang.reflect.ReflectPermission;
 import java.nio.ByteOrder;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.BitSet;
@@ -3114,7 +3112,7 @@
      * @see MethodHandles#explicitCastArguments
      * @since 9
      */
-    public static  MethodHandle zero(Class<?> type) {
+    public static MethodHandle zero(Class<?> type) {
         Objects.requireNonNull(type);
         return type.isPrimitive() ?  zero(Wrapper.forPrimitiveType(type), type) : zero(Wrapper.OBJECT, type);
     }
@@ -3403,7 +3401,8 @@
                 throw newIllegalArgumentException("illegal pos", pos, newTypes);
             }
             addTypes = addTypes.subList(pos, add);
-            add -= pos; assert(addTypes.size() == add);
+            add -= pos;
+            assert(addTypes.size() == add);
         }
         // Do not add types which already match the existing arguments.
         if (match > add || !oldTypes.equals(addTypes.subList(0, match))) {
@@ -3413,7 +3412,8 @@
             throw newIllegalArgumentException("argument lists do not match", oldTypes, newTypes);
         }
         addTypes = addTypes.subList(match, add);
-        add -= match; assert(addTypes.size() == add);
+        add -= match;
+        assert(addTypes.size() == add);
         // newTypes:     (   P*[pos], M*[match], A*[add] )
         // target: ( S*[skip],        M*[match]  )
         MethodHandle adapter = target;
@@ -3423,26 +3423,37 @@
         // adapter: (S*[skip],        M*[match], A*[add] )
         if (pos > 0) {
             adapter = dropArguments0(adapter, skip, newTypes.subList(0, pos));
-       }
+        }
         // adapter: (S*[skip], P*[pos], M*[match], A*[add] )
         return adapter;
     }
 
     /**
-     * Adapts a target method handle to match the given parameter type list, if necessary, by adding dummy arguments.
-     * Some leading parameters are first skipped; they will be left unchanged and are otherwise ignored.
-     * The remaining types in the target's parameter type list must be contained as a sub-list of the given type list,
-     * at the given position.
-     * Any non-matching parameter types (before or after the matching sub-list) are inserted in corresponding
-     * positions of the target method handle's parameters, as if by {@link #dropArguments}.
-     * (More precisely, elements in the new list before {@code pos} are inserted into the target list at {@code skip},
-     * while elements in the new list after the match beginning at {@code pos} are inserted at the end of the
-     * target list.)
-     * The target's return type will be unchanged.
+     * Adapts a target method handle to match the given parameter type list. If necessary, adds dummy arguments. Some
+     * leading parameters can be skipped before matching begins. The remaining types in the {@code target}'s parameter
+     * type list must be a sub-list of the {@code newTypes} type list at the starting position {@code pos}. The
+     * resulting handle will have the target handle's parameter type list, with any non-matching parameter types (before
+     * or after the matching sub-list) inserted in corresponding positions of the target's original parameters, as if by
+     * {@link #dropArguments(MethodHandle, int, Class[])}.
+     * <p>
+     * The resulting handle will have the same return type as the target handle.
+     * <p>
+     * In more formal terms, assume these two type lists:<ul>
+     * <li>The target handle has the parameter type list {@code S..., M...}, with as many types in {@code S} as
+     * indicated by {@code skip}. The {@code M} types are those that are supposed to match part of the given type list,
+     * {@code newTypes}.
+     * <li>The {@code newTypes} list contains types {@code P..., M..., A...}, with as many types in {@code P} as
+     * indicated by {@code pos}. The {@code M} types are precisely those that the {@code M} types in the target handle's
+     * parameter type list are supposed to match. The types in {@code A} are additional types found after the matching
+     * sub-list.
+     * </ul>
+     * Given these assumptions, the result of an invocation of {@code dropArgumentsToMatch} will have the parameter type
+     * list {@code S..., P..., M..., A...}, with the {@code P} and {@code A} types inserted as if by
+     * {@link #dropArguments(MethodHandle, int, Class[])}.
+     * <p>
      * @apiNote
-     * Two method handles whose argument lists are "effectively identical" (i.e., identical
-     * in a common prefix) may be mutually converted to a common type
-     * by two calls to {@code dropArgumentsToMatch}, as follows:
+     * Two method handles whose argument lists are "effectively identical" (i.e., identical in a common prefix) may be
+     * mutually converted to a common type by two calls to {@code dropArgumentsToMatch}, as follows:
      * <blockquote><pre>{@code
 import static java.lang.invoke.MethodHandles.*;
 import static java.lang.invoke.MethodType.*;
@@ -3461,14 +3472,15 @@
      * }</pre></blockquote>
      * @param target the method handle to adapt
      * @param skip number of targets parameters to disregard (they will be unchanged)
-     * @param newTypes the desired argument list of the method handle
+     * @param newTypes the list of types to match {@code target}'s parameter type list to
      * @param pos place in {@code newTypes} where the non-skipped target parameters must occur
      * @return a possibly adapted method handle
      * @throws NullPointerException if either argument is null
      * @throws IllegalArgumentException if any element of {@code newTypes} is {@code void.class},
      *         or if {@code skip} is negative or greater than the arity of the target,
      *         or if {@code pos} is negative or greater than the newTypes list size,
-     *         or if the non-skipped target parameter types match the new types at {@code pos}
+     *         or if {@code newTypes} does not contain the {@code target}'s non-skipped parameter types at position
+     *         {@code pos}.
      * @since 9
      */
     public static
@@ -3922,6 +3934,113 @@
         return foldArguments(target, 0, combiner);
     }
 
+    /**
+     * Adapts a target method handle by pre-processing some of its arguments, starting at a given position, and then
+     * calling the target with the result of the pre-processing, inserted into the original sequence of arguments just
+     * before the folded arguments.
+     * <p>
+     * This method is closely related to {@link #foldArguments(MethodHandle, MethodHandle)}, but allows to control the
+     * position in the parameter list at which folding takes place. The argument controlling this, {@code pos}, is a
+     * zero-based index. The aforementioned method {@link #foldArguments(MethodHandle, MethodHandle)} assumes position
+     * 0.
+     * <p>
+     * @apiNote Example:
+     * <blockquote><pre>{@code
+    import static java.lang.invoke.MethodHandles.*;
+    import static java.lang.invoke.MethodType.*;
+    ...
+    MethodHandle trace = publicLookup().findVirtual(java.io.PrintStream.class,
+    "println", methodType(void.class, String.class))
+    .bindTo(System.out);
+    MethodHandle cat = lookup().findVirtual(String.class,
+    "concat", methodType(String.class, String.class));
+    assertEquals("boojum", (String) cat.invokeExact("boo", "jum"));
+    MethodHandle catTrace = foldArguments(cat, 1, trace);
+    // also prints "jum":
+    assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
+     * }</pre></blockquote>
+     * <p>Here is pseudocode for the resulting adapter. In the code, {@code T}
+     * represents the result type of the {@code target} and resulting adapter.
+     * {@code V}/{@code v} represent the type and value of the parameter and argument
+     * of {@code target} that precedes the folding position; {@code V} also is
+     * the result type of the {@code combiner}. {@code A}/{@code a} denote the
+     * types and values of the {@code N} parameters and arguments at the folding
+     * position. {@code Z}/{@code z} and {@code B}/{@code b} represent the types
+     * and values of the {@code target} parameters and arguments that precede and
+     * follow the folded parameters and arguments starting at {@code pos},
+     * respectively.
+     * <blockquote><pre>{@code
+     * // there are N arguments in A...
+     * T target(Z..., V, A[N]..., B...);
+     * V combiner(A...);
+     * T adapter(Z... z, A... a, B... b) {
+     *   V v = combiner(a...);
+     *   return target(z..., v, a..., b...);
+     * }
+     * // and if the combiner has a void return:
+     * T target2(Z..., A[N]..., B...);
+     * void combiner2(A...);
+     * T adapter2(Z... z, A... a, B... b) {
+     *   combiner2(a...);
+     *   return target2(z..., a..., b...);
+     * }
+     * }</pre></blockquote>
+     * <p>
+     * <em>Note:</em> The resulting adapter is never a {@linkplain MethodHandle#asVarargsCollector
+     * variable-arity method handle}, even if the original target method handle was.
+     *
+     * @param target the method handle to invoke after arguments are combined
+     * @param pos the position at which to start folding and at which to insert the folding result; if this is {@code
+     *            0}, the effect is the same as for {@link #foldArguments(MethodHandle, MethodHandle)}.
+     * @param combiner method handle to call initially on the incoming arguments
+     * @return method handle which incorporates the specified argument folding logic
+     * @throws NullPointerException if either argument is null
+     * @throws IllegalArgumentException if either of the following two conditions holds:
+     *          (1) {@code combiner}'s return type is non-{@code void} and not the same as the argument type at position
+     *              {@code pos} of the target signature;
+     *          (2) the {@code N} argument types at position {@code pos} of the target signature (skipping one matching
+     *              the {@code combiner}'s return type) are not identical with the argument types of {@code combiner}.
+     *
+     * @see #foldArguments(MethodHandle, MethodHandle)
+     * @since 9
+     */
+    public static MethodHandle foldArguments(MethodHandle target, int pos, MethodHandle combiner) {
+        MethodType targetType = target.type();
+        MethodType combinerType = combiner.type();
+        Class<?> rtype = foldArgumentChecks(pos, targetType, combinerType);
+        BoundMethodHandle result = target.rebind();
+        boolean dropResult = rtype == void.class;
+        LambdaForm lform = result.editor().foldArgumentsForm(1 + pos, dropResult, combinerType.basicType());
+        MethodType newType = targetType;
+        if (!dropResult) {
+            newType = newType.dropParameterTypes(pos, pos + 1);
+        }
+        result = result.copyWithExtendL(newType, lform, combiner);
+        return result;
+    }
+
+    /**
+     * As {@see foldArguments(MethodHandle, int, MethodHandle)}, but with the
+     * added capability of selecting the arguments from the targets parameters
+     * to call the combiner with. This allows us to avoid some simple cases of
+     * permutations and padding the combiner with dropArguments to select the
+     * right argument, which may ultimately produce fewer intermediaries.
+     */
+    static MethodHandle foldArguments(MethodHandle target, int pos, MethodHandle combiner, int ... argPositions) {
+        MethodType targetType = target.type();
+        MethodType combinerType = combiner.type();
+        Class<?> rtype = foldArgumentChecks(pos, targetType, combinerType, argPositions);
+        BoundMethodHandle result = target.rebind();
+        boolean dropResult = rtype == void.class;
+        LambdaForm lform = result.editor().foldArgumentsForm(1 + pos, dropResult, combinerType.basicType(), argPositions);
+        MethodType newType = targetType;
+        if (!dropResult) {
+            newType = newType.dropParameterTypes(pos, pos + 1);
+        }
+        result = result.copyWithExtendL(newType, lform, combiner);
+        return result;
+    }
+
     private static Class<?> foldArgumentChecks(int foldPos, MethodType targetType, MethodType combinerType) {
         int foldArgs   = combinerType.parameterCount();
         Class<?> rtype = combinerType.returnType();
@@ -4125,32 +4244,69 @@
      * iteration. Upon termination of the loop due to one of the predicates, a corresponding finalizer is run and
      * delivers the loop's result, which is the return value of the resulting handle.
      * <p>
-     * Intuitively, every loop is formed by one or more "clauses", each specifying a local iteration value and/or a loop
+     * Intuitively, every loop is formed by one or more "clauses", each specifying a local <em>iteration variable</em> and/or a loop
      * exit. Each iteration of the loop executes each clause in order. A clause can optionally update its iteration
      * variable; it can also optionally perform a test and conditional loop exit. In order to express this logic in
-     * terms of method handles, each clause will determine four actions:<ul>
-     * <li>Before the loop executes, the initialization of an iteration variable or loop invariant local.
-     * <li>When a clause executes, an update step for the iteration variable.
-     * <li>When a clause executes, a predicate execution to test for loop exit.
-     * <li>If a clause causes a loop exit, a finalizer execution to compute the loop's return value.
+     * terms of method handles, each clause will specify up to four independent actions:<ul>
+     * <li><em>init:</em> Before the loop executes, the initialization of an iteration variable {@code v} of type {@code V}.
+     * <li><em>step:</em> When a clause executes, an update step for the iteration variable {@code v}.
+     * <li><em>pred:</em> When a clause executes, a predicate execution to test for loop exit.
+     * <li><em>fini:</em> If a clause causes a loop exit, a finalizer execution to compute the loop's return value.
      * </ul>
+     * The full sequence of all iteration variable types, in clause order, will be notated as {@code (V...)}.
+     * The values themselves will be {@code (v...)}.  When we speak of "parameter lists", we will usually
+     * be referring to types, but in some contexts (describing execution) the lists will be of actual values.
      * <p>
      * Some of these clause parts may be omitted according to certain rules, and useful default behavior is provided in
      * this case. See below for a detailed description.
      * <p>
-     * Each clause function, with the exception of clause initializers, is able to observe the entire loop state,
-     * because it will be passed <em>all</em> current iteration variable values, as well as all incoming loop
-     * parameters. Most clause functions will not need all of this information, but they will be formally connected as
-     * if by {@link #dropArguments}.
+     * <em>Parameters optional everywhere:</em>
+     * Each clause function is allowed but not required to accept a parameter for each iteration variable {@code v}.
+     * As an exception, the init functions cannot take any {@code v} parameters,
+     * because those values are not yet computed when the init functions are executed.
+     * Any clause function may neglect to take any trailing subsequence of parameters it is entitled to take.
+     * In fact, any clause function may take no arguments at all.
      * <p>
+     * <em>Loop parameters:</em>
+     * A clause function may take all the iteration variable values it is entitled to, in which case
+     * it may also take more trailing parameters. Such extra values are called <em>loop parameters</em>,
+     * with their types and values notated as {@code (A...)} and {@code (a...)}.
+     * These become the parameters of the resulting loop handle, to be supplied whenever the loop is executed.
+     * (Since init functions do not accept iteration variables {@code v}, any parameter to an
+     * init function is automatically a loop parameter {@code a}.)
+     * As with iteration variables, clause functions are allowed but not required to accept loop parameters.
+     * These loop parameters act as loop-invariant values visible across the whole loop.
+     * <p>
+     * <em>Parameters visible everywhere:</em>
+     * Each non-init clause function is permitted to observe the entire loop state, because it can be passed the full
+     * list {@code (v... a...)} of current iteration variable values and incoming loop parameters.
+     * The init functions can observe initial pre-loop state, in the form {@code (a...)}.
+     * Most clause functions will not need all of this information, but they will be formally connected to it
+     * as if by {@link #dropArguments}.
+     * <a name="astar"></a>
+     * More specifically, we shall use the notation {@code (V*)} to express an arbitrary prefix of a full
+     * sequence {@code (V...)} (and likewise for {@code (v*)}, {@code (A*)}, {@code (a*)}).
+     * In that notation, the general form of an init function parameter list
+     * is {@code (A*)}, and the general form of a non-init function parameter list is {@code (V*)} or {@code (V... A*)}.
+     * <p>
+     * <em>Checking clause structure:</em>
      * Given a set of clauses, there is a number of checks and adjustments performed to connect all the parts of the
      * loop. They are spelled out in detail in the steps below. In these steps, every occurrence of the word "must"
-     * corresponds to a place where {@link IllegalArgumentException} may be thrown if the required constraint is not met
-     * by the inputs to the loop combinator. The term "effectively identical", applied to parameter type lists, means
-     * that they must be identical, or else one list must be a proper prefix of the other.
+     * corresponds to a place where {@link IllegalArgumentException} will be thrown if the required constraint is not
+     * met by the inputs to the loop combinator.
+     * <p>
+     * <em>Effectively identical sequences:</em>
+     * <a name="effid"></a>
+     * A parameter list {@code A} is defined to be <em>effectively identical</em> to another parameter list {@code B}
+     * if {@code A} and {@code B} are identical, or if {@code A} is shorter and is identical with a proper prefix of {@code B}.
+     * When speaking of an unordered set of parameter lists, we say they the set is "effectively identical"
+     * as a whole if the set contains a longest list, and all members of the set are effectively identical to
+     * that longest list.
+     * For example, any set of type sequences of the form {@code (V*)} is effectively identical,
+     * and the same is true if more sequences of the form {@code (V... A*)} are added.
      * <p>
      * <em>Step 0: Determine clause structure.</em><ol type="a">
-     * <li>The clause array (of type {@code MethodHandle[][]} must be non-{@code null} and contain at least one element.
+     * <li>The clause array (of type {@code MethodHandle[][]}) must be non-{@code null} and contain at least one element.
      * <li>The clause array may not contain {@code null}s or sub-arrays longer than four elements.
      * <li>Clauses shorter than four elements are treated as if they were padded by {@code null} elements to length
      * four. Padding takes place by appending elements to the array.
@@ -4158,30 +4314,35 @@
      * <li>Each clause is treated as a four-tuple of functions, called "init", "step", "pred", and "fini".
      * </ol>
      * <p>
-     * <em>Step 1A: Determine iteration variables.</em><ol type="a">
-     * <li>Examine init and step function return types, pairwise, to determine each clause's iteration variable type.
-     * <li>If both functions are omitted, use {@code void}; else if one is omitted, use the other's return type; else
-     * use the common return type (they must be identical).
+     * <em>Step 1A: Determine iteration variable types {@code (V...)}.</em><ol type="a">
+     * <li>The iteration variable type for each clause is determined using the clause's init and step return types.
+     * <li>If both functions are omitted, there is no iteration variable for the corresponding clause ({@code void} is
+     * used as the type to indicate that). If one of them is omitted, the other's return type defines the clause's
+     * iteration variable type. If both are given, the common return type (they must be identical) defines the clause's
+     * iteration variable type.
      * <li>Form the list of return types (in clause order), omitting all occurrences of {@code void}.
-     * <li>This list of types is called the "common prefix".
+     * <li>This list of types is called the "iteration variable types" ({@code (V...)}).
      * </ol>
      * <p>
-     * <em>Step 1B: Determine loop parameters.</em><ul>
-     * <li><b>If at least one init function is given,</b><ol type="a">
-     *   <li>Examine init function parameter lists.
-     *   <li>Omitted init functions are deemed to have {@code null} parameter lists.
-     *   <li>All init function parameter lists must be effectively identical.
-     *   <li>The longest parameter list (which is necessarily unique) is called the "common suffix".
-     * </ol>
-     * <li><b>If no init function is given,</b><ol type="a">
-     *   <li>Examine the suffixes of the step, pred, and fini parameter lists, after removing the "common prefix".
-     *   <li>The longest of these suffixes is taken as the "common suffix".
-     * </ol></ul>
+     * <em>Step 1B: Determine loop parameters {@code (A...)}.</em><ul>
+     * <li>Examine and collect init function parameter lists (which are of the form {@code (A*)}).
+     * <li>Examine and collect the suffixes of the step, pred, and fini parameter lists, after removing the iteration variable types.
+     * (They must have the form {@code (V... A*)}; collect the {@code (A*)} parts only.)
+     * <li>Do not collect suffixes from step, pred, and fini parameter lists that do not begin with all the iteration variable types.
+     * (These types will checked in step 2, along with all the clause function types.)
+     * <li>Omitted clause functions are ignored.  (Equivalently, they are deemed to have empty parameter lists.)
+     * <li>All of the collected parameter lists must be effectively identical.
+     * <li>The longest parameter list (which is necessarily unique) is called the "external parameter list" ({@code (A...)}).
+     * <li>If there is no such parameter list, the external parameter list is taken to be the empty sequence.
+     * <li>The combined list consisting of iteration variable types followed by the external parameter types is called
+     * the "internal parameter list".
+     * </ul>
      * <p>
      * <em>Step 1C: Determine loop return type.</em><ol type="a">
      * <li>Examine fini function return types, disregarding omitted fini functions.
-     * <li>If there are no fini functions, use {@code void} as the loop return type.
-     * <li>Otherwise, use the common return type of the fini functions; they must all be identical.
+     * <li>If there are no fini functions, the loop return type is {@code void}.
+     * <li>Otherwise, the common return type {@code R} of the fini functions (their return types must be identical) defines the loop return
+     * type.
      * </ol>
      * <p>
      * <em>Step 1D: Check other types.</em><ol type="a">
@@ -4190,69 +4351,107 @@
      * </ol>
      * <p>
      * <em>Step 2: Determine parameter lists.</em><ol type="a">
-     * <li>The parameter list for the resulting loop handle will be the "common suffix".
-     * <li>The parameter list for init functions will be adjusted to the "common suffix". (Note that their parameter
-     * lists are already effectively identical to the common suffix.)
-     * <li>The parameter list for non-init (step, pred, and fini) functions will be adjusted to the common prefix
-     * followed by the common suffix, called the "common parameter sequence".
-     * <li>Every non-init, non-omitted function parameter list must be effectively identical to the common parameter
-     * sequence.
+     * <li>The parameter list for the resulting loop handle will be the external parameter list {@code (A...)}.
+     * <li>The parameter list for init functions will be adjusted to the external parameter list.
+     * (Note that their parameter lists are already effectively identical to this list.)
+     * <li>The parameter list for every non-omitted, non-init (step, pred, and fini) function must be
+     * effectively identical to the internal parameter list {@code (V... A...)}.
      * </ol>
      * <p>
      * <em>Step 3: Fill in omitted functions.</em><ol type="a">
-     * <li>If an init function is omitted, use a {@linkplain #constant constant function} of the appropriate
-     * {@code null}/zero/{@code false}/{@code void} type. (For this purpose, a constant {@code void} is simply a
-     * function which does nothing and returns {@code void}; it can be obtained from another constant function by
-     * {@linkplain MethodHandle#asType type conversion}.)
+     * <li>If an init function is omitted, use a {@linkplain #empty default value} for the clause's iteration variable
+     * type.
      * <li>If a step function is omitted, use an {@linkplain #identity identity function} of the clause's iteration
      * variable type; insert dropped argument parameters before the identity function parameter for the non-{@code void}
      * iteration variables of preceding clauses. (This will turn the loop variable into a local loop invariant.)
-     * <li>If a pred function is omitted, the corresponding fini function must also be omitted.
      * <li>If a pred function is omitted, use a constant {@code true} function. (This will keep the loop going, as far
-     * as this clause is concerned.)
-     * <li>If a fini function is omitted, use a constant {@code null}/zero/{@code false}/{@code void} function of the
+     * as this clause is concerned.  Note that in such cases the corresponding fini function is unreachable.)
+     * <li>If a fini function is omitted, use a {@linkplain #empty default value} for the
      * loop return type.
      * </ol>
      * <p>
      * <em>Step 4: Fill in missing parameter types.</em><ol type="a">
-     * <li>At this point, every init function parameter list is effectively identical to the common suffix, but some
-     * lists may be shorter. For every init function with a short parameter list, pad out the end of the list by
-     * {@linkplain #dropArguments dropping arguments}.
-     * <li>At this point, every non-init function parameter list is effectively identical to the common parameter
-     * sequence, but some lists may be shorter. For every non-init function with a short parameter list, pad out the end
-     * of the list by {@linkplain #dropArguments dropping arguments}.
+     * <li>At this point, every init function parameter list is effectively identical to the external parameter list {@code (A...)},
+     * but some lists may be shorter. For every init function with a short parameter list, pad out the end of the list.
+     * <li>At this point, every non-init function parameter list is effectively identical to the internal parameter
+     * list {@code (V... A...)}, but some lists may be shorter. For every non-init function with a short parameter list,
+     * pad out the end of the list.
+     * <li>Argument lists are padded out by {@linkplain #dropArgumentsToMatch dropping unused trailing arguments}.
      * </ol>
      * <p>
      * <em>Final observations.</em><ol type="a">
      * <li>After these steps, all clauses have been adjusted by supplying omitted functions and arguments.
-     * <li>All init functions have a common parameter type list, which the final loop handle will also have.
-     * <li>All fini functions have a common return type, which the final loop handle will also have.
-     * <li>All non-init functions have a common parameter type list, which is the common parameter sequence, of
-     * (non-{@code void}) iteration variables followed by loop parameters.
-     * <li>Each pair of init and step functions agrees in their return types.
-     * <li>Each non-init function will be able to observe the current values of all iteration variables, by means of the
-     * common prefix.
+     * <li>All init functions have a common parameter type list {@code (A...)}, which the final loop handle will also have.
+     * <li>All fini functions have a common return type {@code R}, which the final loop handle will also have.
+     * <li>All non-init functions have a common parameter type list {@code (V... A...)}, of
+     * (non-{@code void}) iteration variables {@code V} followed by loop parameters.
+     * <li>Each pair of init and step functions agrees in their return type {@code V}.
+     * <li>Each non-init function will be able to observe the current values {@code (v...)} of all iteration variables.
+     * <li>Every function will be able to observe the incoming values {@code (a...)} of all loop parameters.
      * </ol>
      * <p>
+     * <em>Example.</em> As a consequence of step 1A above, the {@code loop} combinator has the following property:
+     * <ul>
+     * <li>Given {@code N} clauses {@code Cn = {null, Sn, Pn}} with {@code n = 1..N}.
+     * <li>Suppose predicate handles {@code Pn} are either {@code null} or have no parameters.
+     * (Only one {@code Pn} has to be non-{@code null}.)
+     * <li>Suppose step handles {@code Sn} have signatures {@code (B1..BX)Rn}, for some constant {@code X>=N}.
+     * <li>Suppose {@code Q} is the count of non-void types {@code Rn}, and {@code (V1...VQ)} is the sequence of those types.
+     * <li>It must be that {@code Vn == Bn} for {@code n = 1..min(X,Q)}.
+     * <li>The parameter types {@code Vn} will be interpreted as loop-local state elements {@code (V...)}.
+     * <li>Any remaining types {@code BQ+1..BX} (if {@code Q<X}) will determine
+     * the resulting loop handle's parameter types {@code (A...)}.
+     * </ul>
+     * In this example, the loop handle parameters {@code (A...)} were derived from the step functions,
+     * which is natural if most of the loop computation happens in the steps.  For some loops,
+     * the burden of computation might be heaviest in the pred functions, and so the pred functions
+     * might need to accept the loop parameter values.  For loops with complex exit logic, the fini
+     * functions might need to accept loop parameters, and likewise for loops with complex entry logic,
+     * where the init functions will need the extra parameters.  For such reasons, the rules for
+     * determining these parameters are as symmetric as possible, across all clause parts.
+     * In general, the loop parameters function as common invariant values across the whole
+     * loop, while the iteration variables function as common variant values, or (if there is
+     * no step function) as internal loop invariant temporaries.
+     * <p>
      * <em>Loop execution.</em><ol type="a">
-     * <li>When the loop is called, the loop input values are saved in locals, to be passed (as the common suffix) to
+     * <li>When the loop is called, the loop input values are saved in locals, to be passed to
      * every clause function. These locals are loop invariant.
-     * <li>Each init function is executed in clause order (passing the common suffix) and the non-{@code void} values
-     * are saved (as the common prefix) into locals. These locals are loop varying (unless their steps are identity
-     * functions, as noted above).
-     * <li>All function executions (except init functions) will be passed the common parameter sequence, consisting of
-     * the non-{@code void} iteration values (in clause order) and then the loop inputs (in argument order).
+     * <li>Each init function is executed in clause order (passing the external arguments {@code (a...)})
+     * and the non-{@code void} values are saved (as the iteration variables {@code (v...)}) into locals.
+     * These locals will be loop varying (unless their steps behave as identity functions, as noted above).
+     * <li>All function executions (except init functions) will be passed the internal parameter list, consisting of
+     * the non-{@code void} iteration values {@code (v...)} (in clause order) and then the loop inputs {@code (a...)}
+     * (in argument order).
      * <li>The step and pred functions are then executed, in clause order (step before pred), until a pred function
      * returns {@code false}.
-     * <li>The non-{@code void} result from a step function call is used to update the corresponding loop variable. The
-     * updated value is immediately visible to all subsequent function calls.
+     * <li>The non-{@code void} result from a step function call is used to update the corresponding value in the
+     * sequence {@code (v...)} of loop variables.
+     * The updated value is immediately visible to all subsequent function calls.
      * <li>If a pred function returns {@code false}, the corresponding fini function is called, and the resulting value
-     * is returned from the loop as a whole.
+     * (of type {@code R}) is returned from the loop as a whole.
+     * <li>If all the pred functions always return true, no fini function is ever invoked, and the loop cannot exit
+     * except by throwing an exception.
      * </ol>
      * <p>
-     * Here is pseudocode for the resulting loop handle. In the code, {@code V}/{@code v} represent the types / values
-     * of loop variables; {@code A}/{@code a}, those of arguments passed to the resulting loop; and {@code R}, the
-     * result types of finalizers as well as of the resulting loop.
+     * <em>Usage tips.</em>
+     * <ul>
+     * <li>Although each step function will receive the current values of <em>all</em> the loop variables,
+     * sometimes a step function only needs to observe the current value of its own variable.
+     * In that case, the step function may need to explicitly {@linkplain #dropArguments drop all preceding loop variables}.
+     * This will require mentioning their types, in an expression like {@code dropArguments(step, 0, V0.class, ...)}.
+     * <li>Loop variables are not required to vary; they can be loop invariant.  A clause can create
+     * a loop invariant by a suitable init function with no step, pred, or fini function.  This may be
+     * useful to "wire" an incoming loop argument into the step or pred function of an adjacent loop variable.
+     * <li>If some of the clause functions are virtual methods on an instance, the instance
+     * itself can be conveniently placed in an initial invariant loop "variable", using an initial clause
+     * like {@code new MethodHandle[]{identity(ObjType.class)}}.  In that case, the instance reference
+     * will be the first iteration variable value, and it will be easy to use virtual
+     * methods as clause parts, since all of them will take a leading instance reference matching that value.
+     * </ul>
+     * <p>
+     * Here is pseudocode for the resulting loop handle. As above, {@code V} and {@code v} represent the types
+     * and values of loop variables; {@code A} and {@code a} represent arguments passed to the whole loop;
+     * and {@code R} is the common result type of all finalizers as well as of the resulting loop.
      * <blockquote><pre>{@code
      * V... init...(A...);
      * boolean pred...(V..., A...);
@@ -4270,6 +4469,9 @@
      *   }
      * }
      * }</pre></blockquote>
+     * Note that the parameter type lists {@code (V...)} and {@code (A...)} have been expanded
+     * to their full length, even though individual clause functions may neglect to take them all.
+     * As noted above, missing parameters are filled in as if by {@link #dropArgumentsToMatch}.
      * <p>
      * @apiNote Example:
      * <blockquote><pre>{@code
@@ -4286,6 +4488,43 @@
      * MethodHandle loop = MethodHandles.loop(counterClause, accumulatorClause);
      * assertEquals(120, loop.invoke(5));
      * }</pre></blockquote>
+     * The same example, dropping arguments and using combinators:
+     * <blockquote><pre>{@code
+     * // simplified implementation of the factorial function as a loop handle
+     * static int inc(int i) { return i + 1; } // drop acc, k
+     * static int mult(int i, int acc) { return i * acc; } //drop k
+     * static boolean cmp(int i, int k) { return i < k; }
+     * // assume MH_inc, MH_mult, and MH_cmp are handles to the above methods
+     * // null initializer for counter, should initialize to 0
+     * MethodHandle MH_one = MethodHandles.constant(int.class, 1);
+     * MethodHandle MH_pred = MethodHandles.dropArguments(MH_cmp, 1, int.class); // drop acc
+     * MethodHandle MH_fin = MethodHandles.dropArguments(MethodHandles.identity(int.class), 0, int.class); // drop i
+     * MethodHandle[] counterClause = new MethodHandle[]{null, MH_inc};
+     * MethodHandle[] accumulatorClause = new MethodHandle[]{MH_one, MH_mult, MH_pred, MH_fin};
+     * MethodHandle loop = MethodHandles.loop(counterClause, accumulatorClause);
+     * assertEquals(720, loop.invoke(6));
+     * }</pre></blockquote>
+     * A similar example, using a helper object to hold a loop parameter:
+     * <blockquote><pre>{@code
+     * // instance-based implementation of the factorial function as a loop handle
+     * static class FacLoop {
+     *   final int k;
+     *   FacLoop(int k) { this.k = k; }
+     *   int inc(int i) { return i + 1; }
+     *   int mult(int i, int acc) { return i * acc; }
+     *   boolean pred(int i) { return i < k; }
+     *   int fin(int i, int acc) { return acc; }
+     * }
+     * // assume MH_FacLoop is a handle to the constructor
+     * // assume MH_inc, MH_mult, MH_pred, and MH_fin are handles to the above methods
+     * // null initializer for counter, should initialize to 0
+     * MethodHandle MH_one = MethodHandles.constant(int.class, 1);
+     * MethodHandle[] instanceClause = new MethodHandle[]{MH_FacLoop};
+     * MethodHandle[] counterClause = new MethodHandle[]{null, MH_inc};
+     * MethodHandle[] accumulatorClause = new MethodHandle[]{MH_one, MH_mult, MH_pred, MH_fin};
+     * MethodHandle loop = MethodHandles.loop(instanceClause, counterClause, accumulatorClause);
+     * assertEquals(5040, loop.invoke(7));
+     * }</pre></blockquote>
      *
      * @param clauses an array of arrays (4-tuples) of {@link MethodHandle}s adhering to the rules described above.
      *
@@ -4301,7 +4540,7 @@
      */
     public static MethodHandle loop(MethodHandle[]... clauses) {
         // Step 0: determine clause structure.
-        checkLoop0(clauses);
+        loopChecks0(clauses);
 
         List<MethodHandle> init = new ArrayList<>();
         List<MethodHandle> step = new ArrayList<>();
@@ -4318,7 +4557,7 @@
         assert Stream.of(init, step, pred, fini).map(List::size).distinct().count() == 1;
         final int nclauses = init.size();
 
-        // Step 1A: determine iteration variables.
+        // Step 1A: determine iteration variables (V...).
         final List<Class<?>> iterationVariableTypes = new ArrayList<>();
         for (int i = 0; i < nclauses; ++i) {
             MethodHandle in = init.get(i);
@@ -4326,7 +4565,7 @@
             if (in == null && st == null) {
                 iterationVariableTypes.add(void.class);
             } else if (in != null && st != null) {
-                checkLoop1a(i, in, st);
+                loopChecks1a(i, in, st);
                 iterationVariableTypes.add(in.type().returnType());
             } else {
                 iterationVariableTypes.add(in == null ? st.type().returnType() : in.type().returnType());
@@ -4335,20 +4574,20 @@
         final List<Class<?>> commonPrefix = iterationVariableTypes.stream().filter(t -> t != void.class).
                 collect(Collectors.toList());
 
-        // Step 1B: determine loop parameters.
+        // Step 1B: determine loop parameters (A...).
         final List<Class<?>> commonSuffix = buildCommonSuffix(init, step, pred, fini, commonPrefix.size());
-        checkLoop1b(init, commonSuffix);
+        loopChecks1b(init, commonSuffix);
 
         // Step 1C: determine loop return type.
         // Step 1D: check other types.
         final Class<?> loopReturnType = fini.stream().filter(Objects::nonNull).map(MethodHandle::type).
                 map(MethodType::returnType).findFirst().orElse(void.class);
-        checkLoop1cd(pred, fini, loopReturnType);
+        loopChecks1cd(pred, fini, loopReturnType);
 
         // Step 2: determine parameter lists.
         final List<Class<?>> commonParameterSequence = new ArrayList<>(commonPrefix);
         commonParameterSequence.addAll(commonSuffix);
-        checkLoop2(step, pred, fini, commonParameterSequence);
+        loopChecks2(step, pred, fini, commonParameterSequence);
 
         // Step 3: fill in omitted functions.
         for (int i = 0; i < nclauses; ++i) {
@@ -4382,6 +4621,79 @@
         return MethodHandleImpl.makeLoop(loopReturnType, commonSuffix, finit, fstep, fpred, ffini);
     }
 
+    private static void loopChecks0(MethodHandle[][] clauses) {
+        if (clauses == null || clauses.length == 0) {
+            throw newIllegalArgumentException("null or no clauses passed");
+        }
+        if (Stream.of(clauses).anyMatch(Objects::isNull)) {
+            throw newIllegalArgumentException("null clauses are not allowed");
+        }
+        if (Stream.of(clauses).anyMatch(c -> c.length > 4)) {
+            throw newIllegalArgumentException("All loop clauses must be represented as MethodHandle arrays with at most 4 elements.");
+        }
+    }
+
+    private static void loopChecks1a(int i, MethodHandle in, MethodHandle st) {
+        if (in.type().returnType() != st.type().returnType()) {
+            throw misMatchedTypes("clause " + i + ": init and step return types", in.type().returnType(),
+                    st.type().returnType());
+        }
+    }
+
+    private static List<Class<?>> longestParameterList(Stream<MethodHandle> mhs, int skipSize) {
+        final List<Class<?>> empty = List.of();
+        final List<Class<?>> longest = mhs.filter(Objects::nonNull).
+                // take only those that can contribute to a common suffix because they are longer than the prefix
+                        map(MethodHandle::type).
+                        filter(t -> t.parameterCount() > skipSize).
+                        map(MethodType::parameterList).
+                        reduce((p, q) -> p.size() >= q.size() ? p : q).orElse(empty);
+        return longest.size() == 0 ? empty : longest.subList(skipSize, longest.size());
+    }
+
+    private static List<Class<?>> longestParameterList(List<List<Class<?>>> lists) {
+        final List<Class<?>> empty = List.of();
+        return lists.stream().reduce((p, q) -> p.size() >= q.size() ? p : q).orElse(empty);
+    }
+
+    private static List<Class<?>> buildCommonSuffix(List<MethodHandle> init, List<MethodHandle> step, List<MethodHandle> pred, List<MethodHandle> fini, int cpSize) {
+        final List<Class<?>> longest1 = longestParameterList(Stream.of(step, pred, fini).flatMap(List::stream), cpSize);
+        final List<Class<?>> longest2 = longestParameterList(init.stream(), 0);
+        return longestParameterList(Arrays.asList(longest1, longest2));
+    }
+
+    private static void loopChecks1b(List<MethodHandle> init, List<Class<?>> commonSuffix) {
+        if (init.stream().filter(Objects::nonNull).map(MethodHandle::type).
+                anyMatch(t -> !t.effectivelyIdenticalParameters(0, commonSuffix))) {
+            throw newIllegalArgumentException("found non-effectively identical init parameter type lists: " + init +
+                    " (common suffix: " + commonSuffix + ")");
+        }
+    }
+
+    private static void loopChecks1cd(List<MethodHandle> pred, List<MethodHandle> fini, Class<?> loopReturnType) {
+        if (fini.stream().filter(Objects::nonNull).map(MethodHandle::type).map(MethodType::returnType).
+                anyMatch(t -> t != loopReturnType)) {
+            throw newIllegalArgumentException("found non-identical finalizer return types: " + fini + " (return type: " +
+                    loopReturnType + ")");
+        }
+
+        if (!pred.stream().filter(Objects::nonNull).findFirst().isPresent()) {
+            throw newIllegalArgumentException("no predicate found", pred);
+        }
+        if (pred.stream().filter(Objects::nonNull).map(MethodHandle::type).map(MethodType::returnType).
+                anyMatch(t -> t != boolean.class)) {
+            throw newIllegalArgumentException("predicates must have boolean return type", pred);
+        }
+    }
+
+    private static void loopChecks2(List<MethodHandle> step, List<MethodHandle> pred, List<MethodHandle> fini, List<Class<?>> commonParameterSequence) {
+        if (Stream.of(step, pred, fini).flatMap(List::stream).filter(Objects::nonNull).map(MethodHandle::type).
+                anyMatch(t -> !t.effectivelyIdenticalParameters(0, commonParameterSequence))) {
+            throw newIllegalArgumentException("found non-effectively identical parameter type lists:\nstep: " + step +
+                    "\npred: " + pred + "\nfini: " + fini + " (common parameter sequence: " + commonParameterSequence + ")");
+        }
+    }
+
     private static List<MethodHandle> fillParameterTypes(List<MethodHandle> hs, final List<Class<?>> targetParams) {
         return hs.stream().map(h -> {
             int pc = h.type().parameterCount();
@@ -4395,26 +4707,60 @@
     }
 
     /**
-     * Constructs a {@code while} loop from an initializer, a body, and a predicate. This is a convenience wrapper for
-     * the {@linkplain #loop(MethodHandle[][]) generic loop combinator}.
+     * Constructs a {@code while} loop from an initializer, a body, and a predicate.
+     * This is a convenience wrapper for the {@linkplain #loop(MethodHandle[][]) generic loop combinator}.
+     * <p>
+     * The {@code pred} handle describes the loop condition; and {@code body}, its body. The loop resulting from this
+     * method will, in each iteration, first evaluate the predicate and then execute its body (if the predicate
+     * evaluates to {@code true}).
+     * The loop will terminate once the predicate evaluates to {@code false} (the body will not be executed in this case).
+     * <p>
+     * The {@code init} handle describes the initial value of an additional optional loop-local variable.
+     * In each iteration, this loop-local variable, if present, will be passed to the {@code body}
+     * and updated with the value returned from its invocation. The result of loop execution will be
+     * the final value of the additional loop-local variable (if present).
      * <p>
-     * The loop handle's result type is the same as the sole loop variable's, i.e., the result type of {@code init}.
-     * The parameter type list of {@code init} also determines that of the resulting handle. The {@code pred} handle
-     * must have an additional leading parameter of the same type as {@code init}'s result, and so must the {@code
-     * body}. These constraints follow directly from those described for the {@linkplain MethodHandles#loop(MethodHandle[][])
-     * generic loop combinator}.
+     * The following rules hold for these argument handles:<ul>
+     * <li>The {@code body} handle must not be {@code null}; its type must be of the form
+     * {@code (V A...)V}, where {@code V} is non-{@code void}, or else {@code (A...)void}.
+     * (In the {@code void} case, we assign the type {@code void} to the name {@code V},
+     * and we will write {@code (V A...)V} with the understanding that a {@code void} type {@code V}
+     * is quietly dropped from the parameter list, leaving {@code (A...)V}.)
+     * <li>The parameter list {@code (V A...)} of the body is called the <em>internal parameter list</em>.
+     * It will constrain the parameter lists of the other loop parts.
+     * <li>If the iteration variable type {@code V} is dropped from the internal parameter list, the resulting shorter
+     * list {@code (A...)} is called the <em>external parameter list</em>.
+     * <li>The body return type {@code V}, if non-{@code void}, determines the type of an
+     * additional state variable of the loop.
+     * The body must both accept and return a value of this type {@code V}.
+     * <li>If {@code init} is non-{@code null}, it must have return type {@code V}.
+     * Its parameter list (of some <a href="MethodHandles.html#astar">form {@code (A*)}</a>) must be
+     * <a href="MethodHandles.html#effid">effectively identical</a>
+     * to the external parameter list {@code (A...)}.
+     * <li>If {@code init} is {@code null}, the loop variable will be initialized to its
+     * {@linkplain #empty default value}.
+     * <li>The {@code pred} handle must not be {@code null}.  It must have {@code boolean} as its return type.
+     * Its parameter list (either empty or of the form {@code (V A*)}) must be
+     * effectively identical to the internal parameter list.
+     * </ul>
+     * <p>
+     * The resulting loop handle's result type and parameter signature are determined as follows:<ul>
+     * <li>The loop handle's result type is the result type {@code V} of the body.
+     * <li>The loop handle's parameter types are the types {@code (A...)},
+     * from the external parameter list.
+     * </ul>
      * <p>
      * Here is pseudocode for the resulting loop handle. In the code, {@code V}/{@code v} represent the type / value of
      * the sole loop variable as well as the result type of the loop; and {@code A}/{@code a}, that of the argument
      * passed to the loop.
      * <blockquote><pre>{@code
-     * V init(A);
-     * boolean pred(V, A);
-     * V body(V, A);
-     * V whileLoop(A a) {
-     *   V v = init(a);
-     *   while (pred(v, a)) {
-     *     v = body(v, a);
+     * V init(A...);
+     * boolean pred(V, A...);
+     * V body(V, A...);
+     * V whileLoop(A... a...) {
+     *   V v = init(a...);
+     *   while (pred(v, a...)) {
+     *     v = body(v, a...);
      *   }
      *   return v;
      * }
@@ -4439,58 +4785,96 @@
      * }</pre></blockquote>
      *
      * <p>
-     * @implSpec The implementation of this method is equivalent to:
+     * @apiNote The implementation of this method can be expressed as follows:
      * <blockquote><pre>{@code
      * MethodHandle whileLoop(MethodHandle init, MethodHandle pred, MethodHandle body) {
+     *     MethodHandle fini = (body.type().returnType() == void.class
+     *                         ? null : identity(body.type().returnType()));
      *     MethodHandle[]
-     *         checkExit = {null, null, pred, identity(init.type().returnType())},
-     *         varBody = {init, body};
+     *         checkExit = { null, null, pred, fini },
+     *         varBody   = { init, body };
      *     return loop(checkExit, varBody);
      * }
      * }</pre></blockquote>
      *
-     * @param init initializer: it should provide the initial value of the loop variable. This controls the loop's
-     *             result type. Passing {@code null} or a {@code void} init function will make the loop's result type
-     *             {@code void}.
-     * @param pred condition for the loop, which may not be {@code null}.
-     * @param body body of the loop, which may not be {@code null}.
+     * @param init optional initializer, providing the initial value of the loop variable.
+     *             May be {@code null}, implying a default initial value.  See above for other constraints.
+     * @param pred condition for the loop, which may not be {@code null}. Its result type must be {@code boolean}. See
+     *             above for other constraints.
+     * @param body body of the loop, which may not be {@code null}. It controls the loop parameters and result type.
+     *             See above for other constraints.
      *
-     * @return the value of the loop variable as the loop terminates.
-     * @throws IllegalArgumentException if any argument has a type inconsistent with the loop structure
+     * @return a method handle implementing the {@code while} loop as described by the arguments.
+     * @throws IllegalArgumentException if the rules for the arguments are violated.
+     * @throws NullPointerException if {@code pred} or {@code body} are {@code null}.
      *
-     * @see MethodHandles#loop(MethodHandle[][])
+     * @see #loop(MethodHandle[][])
+     * @see #doWhileLoop(MethodHandle, MethodHandle, MethodHandle)
      * @since 9
      */
     public static MethodHandle whileLoop(MethodHandle init, MethodHandle pred, MethodHandle body) {
-        MethodHandle fin = init == null || init.type().returnType() == void.class ? zero(void.class) :
-                identity(init.type().returnType());
-        MethodHandle[] checkExit = {null, null, pred, fin};
-        MethodHandle[] varBody = {init, body};
+        whileLoopChecks(init, pred, body);
+        MethodHandle fini = identityOrVoid(body.type().returnType());
+        MethodHandle[] checkExit = { null, null, pred, fini };
+        MethodHandle[] varBody = { init, body };
         return loop(checkExit, varBody);
     }
 
     /**
-     * Constructs a {@code do-while} loop from an initializer, a body, and a predicate. This is a convenience wrapper
-     * for the {@linkplain MethodHandles#loop(MethodHandle[][]) generic loop combinator}.
+     * Constructs a {@code do-while} loop from an initializer, a body, and a predicate.
+     * This is a convenience wrapper for the {@linkplain #loop(MethodHandle[][]) generic loop combinator}.
+     * <p>
+     * The {@code pred} handle describes the loop condition; and {@code body}, its body. The loop resulting from this
+     * method will, in each iteration, first execute its body and then evaluate the predicate.
+     * The loop will terminate once the predicate evaluates to {@code false} after an execution of the body.
+     * <p>
+     * The {@code init} handle describes the initial value of an additional optional loop-local variable.
+     * In each iteration, this loop-local variable, if present, will be passed to the {@code body}
+     * and updated with the value returned from its invocation. The result of loop execution will be
+     * the final value of the additional loop-local variable (if present).
      * <p>
-     * The loop handle's result type is the same as the sole loop variable's, i.e., the result type of {@code init}.
-     * The parameter type list of {@code init} also determines that of the resulting handle. The {@code pred} handle
-     * must have an additional leading parameter of the same type as {@code init}'s result, and so must the {@code
-     * body}. These constraints follow directly from those described for the {@linkplain MethodHandles#loop(MethodHandle[][])
-     * generic loop combinator}.
+     * The following rules hold for these argument handles:<ul>
+     * <li>The {@code body} handle must not be {@code null}; its type must be of the form
+     * {@code (V A...)V}, where {@code V} is non-{@code void}, or else {@code (A...)void}.
+     * (In the {@code void} case, we assign the type {@code void} to the name {@code V},
+     * and we will write {@code (V A...)V} with the understanding that a {@code void} type {@code V}
+     * is quietly dropped from the parameter list, leaving {@code (A...)V}.)
+     * <li>The parameter list {@code (V A...)} of the body is called the <em>internal parameter list</em>.
+     * It will constrain the parameter lists of the other loop parts.
+     * <li>If the iteration variable type {@code V} is dropped from the internal parameter list, the resulting shorter
+     * list {@code (A...)} is called the <em>external parameter list</em>.
+     * <li>The body return type {@code V}, if non-{@code void}, determines the type of an
+     * additional state variable of the loop.
+     * The body must both accept and return a value of this type {@code V}.
+     * <li>If {@code init} is non-{@code null}, it must have return type {@code V}.
+     * Its parameter list (of some <a href="MethodHandles.html#astar">form {@code (A*)}</a>) must be
+     * <a href="MethodHandles.html#effid">effectively identical</a>
+     * to the external parameter list {@code (A...)}.
+     * <li>If {@code init} is {@code null}, the loop variable will be initialized to its
+     * {@linkplain #empty default value}.
+     * <li>The {@code pred} handle must not be {@code null}.  It must have {@code boolean} as its return type.
+     * Its parameter list (either empty or of the form {@code (V A*)}) must be
+     * effectively identical to the internal parameter list.
+     * </ul>
+     * <p>
+     * The resulting loop handle's result type and parameter signature are determined as follows:<ul>
+     * <li>The loop handle's result type is the result type {@code V} of the body.
+     * <li>The loop handle's parameter types are the types {@code (A...)},
+     * from the external parameter list.
+     * </ul>
      * <p>
      * Here is pseudocode for the resulting loop handle. In the code, {@code V}/{@code v} represent the type / value of
      * the sole loop variable as well as the result type of the loop; and {@code A}/{@code a}, that of the argument
      * passed to the loop.
      * <blockquote><pre>{@code
-     * V init(A);
-     * boolean pred(V, A);
-     * V body(V, A);
-     * V doWhileLoop(A a) {
-     *   V v = init(a);
+     * V init(A...);
+     * boolean pred(V, A...);
+     * V body(V, A...);
+     * V doWhileLoop(A... a...) {
+     *   V v = init(a...);
      *   do {
-     *     v = body(v, a);
-     *   } while (pred(v, a));
+     *     v = body(v, a...);
+     *   } while (pred(v, a...));
      *   return v;
      * }
      * }</pre></blockquote>
@@ -4507,59 +4891,491 @@
      * }</pre></blockquote>
      *
      * <p>
-     * @implSpec The implementation of this method is equivalent to:
+     * @apiNote The implementation of this method can be expressed as follows:
      * <blockquote><pre>{@code
      * MethodHandle doWhileLoop(MethodHandle init, MethodHandle body, MethodHandle pred) {
-     *     MethodHandle[] clause = { init, body, pred, identity(init.type().returnType()) };
+     *     MethodHandle fini = (body.type().returnType() == void.class
+     *                         ? null : identity(body.type().returnType()));
+     *     MethodHandle[] clause = { init, body, pred, fini };
      *     return loop(clause);
      * }
      * }</pre></blockquote>
      *
+     * @param init optional initializer, providing the initial value of the loop variable.
+     *             May be {@code null}, implying a default initial value.  See above for other constraints.
+     * @param body body of the loop, which may not be {@code null}. It controls the loop parameters and result type.
+     *             See above for other constraints.
+     * @param pred condition for the loop, which may not be {@code null}. Its result type must be {@code boolean}. See
+     *             above for other constraints.
      *
-     * @param init initializer: it should provide the initial value of the loop variable. This controls the loop's
-     *             result type. Passing {@code null} or a {@code void} init function will make the loop's result type
-     *             {@code void}.
-     * @param pred condition for the loop, which may not be {@code null}.
-     * @param body body of the loop, which may not be {@code null}.
+     * @return a method handle implementing the {@code while} loop as described by the arguments.
+     * @throws IllegalArgumentException if the rules for the arguments are violated.
+     * @throws NullPointerException if {@code pred} or {@code body} are {@code null}.
      *
-     * @return the value of the loop variable as the loop terminates.
-     * @throws IllegalArgumentException if any argument has a type inconsistent with the loop structure
-     *
-     * @see MethodHandles#loop(MethodHandle[][])
+     * @see #loop(MethodHandle[][])
+     * @see #whileLoop(MethodHandle, MethodHandle, MethodHandle)
      * @since 9
      */
     public static MethodHandle doWhileLoop(MethodHandle init, MethodHandle body, MethodHandle pred) {
-        MethodHandle fin = init == null || init.type().returnType() == void.class ? zero(void.class) :
-                identity(init.type().returnType());
-        MethodHandle[] clause = {init, body, pred, fin};
+        whileLoopChecks(init, pred, body);
+        MethodHandle fini = identityOrVoid(body.type().returnType());
+        MethodHandle[] clause = {init, body, pred, fini };
         return loop(clause);
     }
 
+    private static void whileLoopChecks(MethodHandle init, MethodHandle pred, MethodHandle body) {
+        Objects.requireNonNull(pred);
+        Objects.requireNonNull(body);
+        MethodType bodyType = body.type();
+        Class<?> returnType = bodyType.returnType();
+        List<Class<?>> innerList = bodyType.parameterList();
+        List<Class<?>> outerList = innerList;
+        if (returnType == void.class) {
+            // OK
+        } else if (innerList.size() == 0 || innerList.get(0) != returnType) {
+            // leading V argument missing => error
+            MethodType expected = bodyType.insertParameterTypes(0, returnType);
+            throw misMatchedTypes("body function", bodyType, expected);
+        } else {
+            outerList = innerList.subList(1, innerList.size());
+        }
+        MethodType predType = pred.type();
+        if (predType.returnType() != boolean.class ||
+                !predType.effectivelyIdenticalParameters(0, innerList)) {
+            throw misMatchedTypes("loop predicate", predType, methodType(boolean.class, innerList));
+        }
+        if (init != null) {
+            MethodType initType = init.type();
+            if (initType.returnType() != returnType ||
+                    !initType.effectivelyIdenticalParameters(0, outerList)) {
+                throw misMatchedTypes("loop initializer", initType, methodType(returnType, outerList));
+            }
+        }
+    }
+
+    /**
+     * Constructs a loop that runs a given number of iterations.
+     * This is a convenience wrapper for the {@linkplain #loop(MethodHandle[][]) generic loop combinator}.
+     * <p>
+     * The number of iterations is determined by the {@code iterations} handle evaluation result.
+     * The loop counter {@code i} is an extra loop iteration variable of type {@code int}.
+     * It will be initialized to 0 and incremented by 1 in each iteration.
+     * <p>
+     * If the {@code body} handle returns a non-{@code void} type {@code V}, a leading loop iteration variable
+     * of that type is also present.  This variable is initialized using the optional {@code init} handle,
+     * or to the {@linkplain #empty default value} of type {@code V} if that handle is {@code null}.
+     * <p>
+     * In each iteration, the iteration variables are passed to an invocation of the {@code body} handle.
+     * A non-{@code void} value returned from the body (of type {@code V}) updates the leading
+     * iteration variable.
+     * The result of the loop handle execution will be the final {@code V} value of that variable
+     * (or {@code void} if there is no {@code V} variable).
+     * <p>
+     * The following rules hold for the argument handles:<ul>
+     * <li>The {@code iterations} handle must not be {@code null}, and must return
+     * the type {@code int}, referred to here as {@code I} in parameter type lists.
+     * <li>The {@code body} handle must not be {@code null}; its type must be of the form
+     * {@code (V I A...)V}, where {@code V} is non-{@code void}, or else {@code (I A...)void}.
+     * (In the {@code void} case, we assign the type {@code void} to the name {@code V},
+     * and we will write {@code (V I A...)V} with the understanding that a {@code void} type {@code V}
+     * is quietly dropped from the parameter list, leaving {@code (I A...)V}.)
+     * <li>The parameter list {@code (V I A...)} of the body contributes to a list
+     * of types called the <em>internal parameter list</em>.
+     * It will constrain the parameter lists of the other loop parts.
+     * <li>As a special case, if the body contributes only {@code V} and {@code I} types,
+     * with no additional {@code A} types, then the internal parameter list is extended by
+     * the argument types {@code A...} of the {@code iterations} handle.
+     * <li>If the iteration variable types {@code (V I)} are dropped from the internal parameter list, the resulting shorter
+     * list {@code (A...)} is called the <em>external parameter list</em>.
+     * <li>The body return type {@code V}, if non-{@code void}, determines the type of an
+     * additional state variable of the loop.
+     * The body must both accept a leading parameter and return a value of this type {@code V}.
+     * <li>If {@code init} is non-{@code null}, it must have return type {@code V}.
+     * Its parameter list (of some <a href="MethodHandles.html#astar">form {@code (A*)}</a>) must be
+     * <a href="MethodHandles.html#effid">effectively identical</a>
+     * to the external parameter list {@code (A...)}.
+     * <li>If {@code init} is {@code null}, the loop variable will be initialized to its
+     * {@linkplain #empty default value}.
+     * <li>The parameter list of {@code iterations} (of some form {@code (A*)}) must be
+     * effectively identical to the external parameter list {@code (A...)}.
+     * </ul>
+     * <p>
+     * The resulting loop handle's result type and parameter signature are determined as follows:<ul>
+     * <li>The loop handle's result type is the result type {@code V} of the body.
+     * <li>The loop handle's parameter types are the types {@code (A...)},
+     * from the external parameter list.
+     * </ul>
+     * <p>
+     * Here is pseudocode for the resulting loop handle. In the code, {@code V}/{@code v} represent the type / value of
+     * the second loop variable as well as the result type of the loop; and {@code A...}/{@code a...} represent
+     * arguments passed to the loop.
+     * <blockquote><pre>{@code
+     * int iterations(A...);
+     * V init(A...);
+     * V body(V, int, A...);
+     * V countedLoop(A... a...) {
+     *   int end = iterations(a...);
+     *   V v = init(a...);
+     *   for (int i = 0; i < end; ++i) {
+     *     v = body(v, i, a...);
+     *   }
+     *   return v;
+     * }
+     * }</pre></blockquote>
+     * <p>
+     * @apiNote Example with a fully conformant body method:
+     * <blockquote><pre>{@code
+     * // String s = "Lambdaman!"; for (int i = 0; i < 13; ++i) { s = "na " + s; } return s;
+     * // => a variation on a well known theme
+     * static String step(String v, int counter, String init) { return "na " + v; }
+     * // assume MH_step is a handle to the method above
+     * MethodHandle fit13 = MethodHandles.constant(int.class, 13);
+     * MethodHandle start = MethodHandles.identity(String.class);
+     * MethodHandle loop = MethodHandles.countedLoop(fit13, start, MH_step);
+     * assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke("Lambdaman!"));
+     * }</pre></blockquote>
+     * <p>
+     * @apiNote Example with the simplest possible body method type,
+     * and passing the number of iterations to the loop invocation:
+     * <blockquote><pre>{@code
+     * // String s = "Lambdaman!"; for (int i = 0; i < 13; ++i) { s = "na " + s; } return s;
+     * // => a variation on a well known theme
+     * static String step(String v, int counter ) { return "na " + v; }
+     * // assume MH_step is a handle to the method above
+     * MethodHandle count = MethodHandles.dropArguments(MethodHandles.identity(int.class), 1, String.class);
+     * MethodHandle start = MethodHandles.dropArguments(MethodHandles.identity(String.class), 0, int.class);
+     * MethodHandle loop = MethodHandles.countedLoop(count, start, MH_step);  // (v, i) -> "na " + v
+     * assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke(13, "Lambdaman!"));
+     * }</pre></blockquote>
+     * <p>
+     * @apiNote Example that treats the number of iterations, string to append to, and string to append
+     * as loop parameters:
+     * <blockquote><pre>{@code
+     * // String s = "Lambdaman!", t = "na"; for (int i = 0; i < 13; ++i) { s = t + " " + s; } return s;
+     * // => a variation on a well known theme
+     * static String step(String v, int counter, int iterations_, String pre, String start_) { return pre + " " + v; }
+     * // assume MH_step is a handle to the method above
+     * MethodHandle count = MethodHandles.identity(int.class);
+     * MethodHandle start = MethodHandles.dropArguments(MethodHandles.identity(String.class), 0, int.class, String.class);
+     * MethodHandle loop = MethodHandles.countedLoop(count, start, MH_step);  // (v, i, _, pre, _) -> pre + " " + v
+     * assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke(13, "na", "Lambdaman!"));
+     * }</pre></blockquote>
+     * <p>
+     * @apiNote Example that illustrates the usage of {@link #dropArgumentsToMatch(MethodHandle, int, List, int)}
+     * to enforce a loop type:
+     * <blockquote><pre>{@code
+     * // String s = "Lambdaman!", t = "na"; for (int i = 0; i < 13; ++i) { s = t + " " + s; } return s;
+     * // => a variation on a well known theme
+     * static String step(String v, int counter, String pre) { return pre + " " + v; }
+     * // assume MH_step is a handle to the method above
+     * MethodType loopType = methodType(String.class, String.class, int.class, String.class);
+     * MethodHandle count = MethodHandles.dropArgumentsToMatch(MethodHandles.identity(int.class),    0, loopType.parameterList(), 1);
+     * MethodHandle start = MethodHandles.dropArgumentsToMatch(MethodHandles.identity(String.class), 0, loopType.parameterList(), 2);
+     * MethodHandle body  = MethodHandles.dropArgumentsToMatch(MH_step,                              2, loopType.parameterList(), 0);
+     * MethodHandle loop = MethodHandles.countedLoop(count, start, body);  // (v, i, pre, _, _) -> pre + " " + v
+     * assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke("na", 13, "Lambdaman!"));
+     * }</pre></blockquote>
+     * <p>
+     * @apiNote The implementation of this method can be expressed as follows:
+     * <blockquote><pre>{@code
+     * MethodHandle countedLoop(MethodHandle iterations, MethodHandle init, MethodHandle body) {
+     *     return countedLoop(empty(iterations.type()), iterations, init, body);
+     * }
+     * }</pre></blockquote>
+     *
+     * @param iterations a non-{@code null} handle to return the number of iterations this loop should run. The handle's
+     *                   result type must be {@code int}. See above for other constraints.
+     * @param init optional initializer, providing the initial value of the loop variable.
+     *             May be {@code null}, implying a default initial value.  See above for other constraints.
+     * @param body body of the loop, which may not be {@code null}.
+     *             It controls the loop parameters and result type in the standard case (see above for details).
+     *             It must accept its own return type (if non-void) plus an {@code int} parameter (for the counter),
+     *             and may accept any number of additional types.
+     *             See above for other constraints.
+     *
+     * @return a method handle representing the loop.
+     * @throws NullPointerException if either of the {@code iterations} or {@code body} handles is {@code null}.
+     * @throws IllegalArgumentException if any argument violates the rules formulated above.
+     *
+     * @see #countedLoop(MethodHandle, MethodHandle, MethodHandle, MethodHandle)
+     * @since 9
+     */
+    public static MethodHandle countedLoop(MethodHandle iterations, MethodHandle init, MethodHandle body) {
+        return countedLoop(empty(iterations.type()), iterations, init, body);
+    }
+
     /**
-     * Constructs a loop that runs a given number of iterations. The loop counter is an {@code int} initialized from the
-     * {@code iterations} handle evaluation result. The counter is passed to the {@code body} function, so that must
-     * accept an initial {@code int} argument. The result of the loop execution is the final value of the additional
-     * local state. This is a convenience wrapper for the {@linkplain MethodHandles#loop(MethodHandle[][]) generic loop
-     * combinator}.
+     * Constructs a loop that counts over a range of numbers.
+     * This is a convenience wrapper for the {@linkplain #loop(MethodHandle[][]) generic loop combinator}.
+     * <p>
+     * The loop counter {@code i} is a loop iteration variable of type {@code int}.
+     * The {@code start} and {@code end} handles determine the start (inclusive) and end (exclusive)
+     * values of the loop counter.
+     * The loop counter will be initialized to the {@code int} value returned from the evaluation of the
+     * {@code start} handle and run to the value returned from {@code end} (exclusively) with a step width of 1.
+     * <p>
+     * If the {@code body} handle returns a non-{@code void} type {@code V}, a leading loop iteration variable
+     * of that type is also present.  This variable is initialized using the optional {@code init} handle,
+     * or to the {@linkplain #empty default value} of type {@code V} if that handle is {@code null}.
+     * <p>
+     * In each iteration, the iteration variables are passed to an invocation of the {@code body} handle.
+     * A non-{@code void} value returned from the body (of type {@code V}) updates the leading
+     * iteration variable.
+     * The result of the loop handle execution will be the final {@code V} value of that variable
+     * (or {@code void} if there is no {@code V} variable).
      * <p>
-     * The result type and parameter type list of {@code init} determine those of the resulting handle. The {@code
-     * iterations} handle must accept the same parameter types as {@code init} but return an {@code int}. The {@code
-     * body} handle must accept the same parameter types as well, preceded by an {@code int} parameter for the counter,
-     * and a parameter of the same type as {@code init}'s result. These constraints follow directly from those described
-     * for the {@linkplain MethodHandles#loop(MethodHandle[][]) generic loop combinator}.
+     * The following rules hold for the argument handles:<ul>
+     * <li>The {@code start} and {@code end} handles must not be {@code null}, and must both return
+     * the common type {@code int}, referred to here as {@code I} in parameter type lists.
+     * <li>The {@code body} handle must not be {@code null}; its type must be of the form
+     * {@code (V I A...)V}, where {@code V} is non-{@code void}, or else {@code (I A...)void}.
+     * (In the {@code void} case, we assign the type {@code void} to the name {@code V},
+     * and we will write {@code (V I A...)V} with the understanding that a {@code void} type {@code V}
+     * is quietly dropped from the parameter list, leaving {@code (I A...)V}.)
+     * <li>The parameter list {@code (V I A...)} of the body contributes to a list
+     * of types called the <em>internal parameter list</em>.
+     * It will constrain the parameter lists of the other loop parts.
+     * <li>As a special case, if the body contributes only {@code V} and {@code I} types,
+     * with no additional {@code A} types, then the internal parameter list is extended by
+     * the argument types {@code A...} of the {@code end} handle.
+     * <li>If the iteration variable types {@code (V I)} are dropped from the internal parameter list, the resulting shorter
+     * list {@code (A...)} is called the <em>external parameter list</em>.
+     * <li>The body return type {@code V}, if non-{@code void}, determines the type of an
+     * additional state variable of the loop.
+     * The body must both accept a leading parameter and return a value of this type {@code V}.
+     * <li>If {@code init} is non-{@code null}, it must have return type {@code V}.
+     * Its parameter list (of some <a href="MethodHandles.html#astar">form {@code (A*)}</a>) must be
+     * <a href="MethodHandles.html#effid">effectively identical</a>
+     * to the external parameter list {@code (A...)}.
+     * <li>If {@code init} is {@code null}, the loop variable will be initialized to its
+     * {@linkplain #empty default value}.
+     * <li>The parameter list of {@code start} (of some form {@code (A*)}) must be
+     * effectively identical to the external parameter list {@code (A...)}.
+     * <li>Likewise, the parameter list of {@code end} must be effectively identical
+     * to the external parameter list.
+     * </ul>
+     * <p>
+     * The resulting loop handle's result type and parameter signature are determined as follows:<ul>
+     * <li>The loop handle's result type is the result type {@code V} of the body.
+     * <li>The loop handle's parameter types are the types {@code (A...)},
+     * from the external parameter list.
+     * </ul>
      * <p>
      * Here is pseudocode for the resulting loop handle. In the code, {@code V}/{@code v} represent the type / value of
-     * the sole loop variable as well as the result type of the loop; and {@code A}/{@code a}, that of the argument
-     * passed to the loop.
+     * the second loop variable as well as the result type of the loop; and {@code A...}/{@code a...} represent
+     * arguments passed to the loop.
+     * <blockquote><pre>{@code
+     * int start(A...);
+     * int end(A...);
+     * V init(A...);
+     * V body(V, int, A...);
+     * V countedLoop(A... a...) {
+     *   int e = end(a...);
+     *   int s = start(a...);
+     *   V v = init(a...);
+     *   for (int i = s; i < e; ++i) {
+     *     v = body(v, i, a...);
+     *   }
+     *   return v;
+     * }
+     * }</pre></blockquote>
+     *
+     * <p>
+     * @apiNote The implementation of this method can be expressed as follows:
      * <blockquote><pre>{@code
-     * int iterations(A);
-     * V init(A);
-     * V body(int, V, A);
-     * V countedLoop(A a) {
-     *   int end = iterations(a);
-     *   V v = init(a);
-     *   for (int i = 0; i < end; ++i) {
-     *     v = body(i, v, a);
+     * MethodHandle countedLoop(MethodHandle start, MethodHandle end, MethodHandle init, MethodHandle body) {
+     *     MethodHandle returnVar = dropArguments(identity(init.type().returnType()), 0, int.class, int.class);
+     *     // assume MH_increment and MH_predicate are handles to implementation-internal methods with
+     *     // the following semantics:
+     *     // MH_increment: (int limit, int counter) -> counter + 1
+     *     // MH_predicate: (int limit, int counter) -> counter < limit
+     *     Class<?> counterType = start.type().returnType();  // int
+     *     Class<?> returnType = body.type().returnType();
+     *     MethodHandle incr = MH_increment, pred = MH_predicate, retv = null;
+     *     if (returnType != void.class) {  // ignore the V variable
+     *         incr = dropArguments(incr, 1, returnType);  // (limit, v, i) => (limit, i)
+     *         pred = dropArguments(pred, 1, returnType);  // ditto
+     *         retv = dropArguments(identity(returnType), 0, counterType); // ignore limit
+     *     }
+     *     body = dropArguments(body, 0, counterType);  // ignore the limit variable
+     *     MethodHandle[]
+     *         loopLimit  = { end, null, pred, retv }, // limit = end(); i < limit || return v
+     *         bodyClause = { init, body },            // v = init(); v = body(v, i)
+     *         indexVar   = { start, incr };           // i = start(); i = i + 1
+     *     return loop(loopLimit, bodyClause, indexVar);
+     * }
+     * }</pre></blockquote>
+     *
+     * @param start a non-{@code null} handle to return the start value of the loop counter, which must be {@code int}.
+     *              See above for other constraints.
+     * @param end a non-{@code null} handle to return the end value of the loop counter (the loop will run to
+     *            {@code end-1}). The result type must be {@code int}. See above for other constraints.
+     * @param init optional initializer, providing the initial value of the loop variable.
+     *             May be {@code null}, implying a default initial value.  See above for other constraints.
+     * @param body body of the loop, which may not be {@code null}.
+     *             It controls the loop parameters and result type in the standard case (see above for details).
+     *             It must accept its own return type (if non-void) plus an {@code int} parameter (for the counter),
+     *             and may accept any number of additional types.
+     *             See above for other constraints.
+     *
+     * @return a method handle representing the loop.
+     * @throws NullPointerException if any of the {@code start}, {@code end}, or {@code body} handles is {@code null}.
+     * @throws IllegalArgumentException if any argument violates the rules formulated above.
+     *
+     * @see #countedLoop(MethodHandle, MethodHandle, MethodHandle)
+     * @since 9
+     */
+    public static MethodHandle countedLoop(MethodHandle start, MethodHandle end, MethodHandle init, MethodHandle body) {
+        countedLoopChecks(start, end, init, body);
+        Class<?> counterType = start.type().returnType();  // int, but who's counting?
+        Class<?> limitType   = end.type().returnType();    // yes, int again
+        Class<?> returnType  = body.type().returnType();
+        MethodHandle incr = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopStep);
+        MethodHandle pred = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopPred);
+        MethodHandle retv = null;
+        if (returnType != void.class) {
+            incr = dropArguments(incr, 1, returnType);  // (limit, v, i) => (limit, i)
+            pred = dropArguments(pred, 1, returnType);  // ditto
+            retv = dropArguments(identity(returnType), 0, counterType);
+        }
+        body = dropArguments(body, 0, counterType);  // ignore the limit variable
+        MethodHandle[]
+            loopLimit  = { end, null, pred, retv }, // limit = end(); i < limit || return v
+            bodyClause = { init, body },            // v = init(); v = body(v, i)
+            indexVar   = { start, incr };           // i = start(); i = i + 1
+        return loop(loopLimit, bodyClause, indexVar);
+    }
+
+    private static void countedLoopChecks(MethodHandle start, MethodHandle end, MethodHandle init, MethodHandle body) {
+        Objects.requireNonNull(start);
+        Objects.requireNonNull(end);
+        Objects.requireNonNull(body);
+        Class<?> counterType = start.type().returnType();
+        if (counterType != int.class) {
+            MethodType expected = start.type().changeReturnType(int.class);
+            throw misMatchedTypes("start function", start.type(), expected);
+        } else if (end.type().returnType() != counterType) {
+            MethodType expected = end.type().changeReturnType(counterType);
+            throw misMatchedTypes("end function", end.type(), expected);
+        }
+        MethodType bodyType = body.type();
+        Class<?> returnType = bodyType.returnType();
+        List<Class<?>> innerList = bodyType.parameterList();
+        // strip leading V value if present
+        int vsize = (returnType == void.class ? 0 : 1);
+        if (vsize != 0 && (innerList.size() == 0 || innerList.get(0) != returnType)) {
+            // argument list has no "V" => error
+            MethodType expected = bodyType.insertParameterTypes(0, returnType);
+            throw misMatchedTypes("body function", bodyType, expected);
+        } else if (innerList.size() <= vsize || innerList.get(vsize) != counterType) {
+            // missing I type => error
+            MethodType expected = bodyType.insertParameterTypes(vsize, counterType);
+            throw misMatchedTypes("body function", bodyType, expected);
+        }
+        List<Class<?>> outerList = innerList.subList(vsize + 1, innerList.size());
+        if (outerList.isEmpty()) {
+            // special case; take lists from end handle
+            outerList = end.type().parameterList();
+            innerList = bodyType.insertParameterTypes(vsize + 1, outerList).parameterList();
+        }
+        MethodType expected = methodType(counterType, outerList);
+        if (!start.type().effectivelyIdenticalParameters(0, outerList)) {
+            throw misMatchedTypes("start parameter types", start.type(), expected);
+        }
+        if (end.type() != start.type() &&
+            !end.type().effectivelyIdenticalParameters(0, outerList)) {
+            throw misMatchedTypes("end parameter types", end.type(), expected);
+        }
+        if (init != null) {
+            MethodType initType = init.type();
+            if (initType.returnType() != returnType ||
+                !initType.effectivelyIdenticalParameters(0, outerList)) {
+                throw misMatchedTypes("loop initializer", initType, methodType(returnType, outerList));
+            }
+        }
+    }
+
+    /**
+     * Constructs a loop that ranges over the values produced by an {@code Iterator<T>}.
+     * This is a convenience wrapper for the {@linkplain #loop(MethodHandle[][]) generic loop combinator}.
+     * <p>
+     * The iterator itself will be determined by the evaluation of the {@code iterator} handle.
+     * Each value it produces will be stored in a loop iteration variable of type {@code T}.
+     * <p>
+     * If the {@code body} handle returns a non-{@code void} type {@code V}, a leading loop iteration variable
+     * of that type is also present.  This variable is initialized using the optional {@code init} handle,
+     * or to the {@linkplain #empty default value} of type {@code V} if that handle is {@code null}.
+     * <p>
+     * In each iteration, the iteration variables are passed to an invocation of the {@code body} handle.
+     * A non-{@code void} value returned from the body (of type {@code V}) updates the leading
+     * iteration variable.
+     * The result of the loop handle execution will be the final {@code V} value of that variable
+     * (or {@code void} if there is no {@code V} variable).
+     * <p>
+     * The following rules hold for the argument handles:<ul>
+     * <li>The {@code body} handle must not be {@code null}; its type must be of the form
+     * {@code (V T A...)V}, where {@code V} is non-{@code void}, or else {@code (T A...)void}.
+     * (In the {@code void} case, we assign the type {@code void} to the name {@code V},
+     * and we will write {@code (V T A...)V} with the understanding that a {@code void} type {@code V}
+     * is quietly dropped from the parameter list, leaving {@code (T A...)V}.)
+     * <li>The parameter list {@code (V T A...)} of the body contributes to a list
+     * of types called the <em>internal parameter list</em>.
+     * It will constrain the parameter lists of the other loop parts.
+     * <li>As a special case, if the body contributes only {@code V} and {@code T} types,
+     * with no additional {@code A} types, then the internal parameter list is extended by
+     * the argument types {@code A...} of the {@code iterator} handle; if it is {@code null} the
+     * single type {@code Iterable} is added and constitutes the {@code A...} list.
+     * <li>If the iteration variable types {@code (V T)} are dropped from the internal parameter list, the resulting shorter
+     * list {@code (A...)} is called the <em>external parameter list</em>.
+     * <li>The body return type {@code V}, if non-{@code void}, determines the type of an
+     * additional state variable of the loop.
+     * The body must both accept a leading parameter and return a value of this type {@code V}.
+     * <li>If {@code init} is non-{@code null}, it must have return type {@code V}.
+     * Its parameter list (of some <a href="MethodHandles.html#astar">form {@code (A*)}</a>) must be
+     * <a href="MethodHandles.html#effid">effectively identical</a>
+     * to the external parameter list {@code (A...)}.
+     * <li>If {@code init} is {@code null}, the loop variable will be initialized to its
+     * {@linkplain #empty default value}.
+     * <li>If the {@code iterator} handle is non-{@code null}, it must have the return
+     * type {@code java.util.Iterator} or a subtype thereof.
+     * The iterator it produces when the loop is executed will be assumed
+     * to yield values which can be converted to type {@code T}.
+     * <li>The parameter list of an {@code iterator} that is non-{@code null} (of some form {@code (A*)}) must be
+     * effectively identical to the external parameter list {@code (A...)}.
+     * <li>If {@code iterator} is {@code null} it defaults to a method handle which behaves
+     * like {@link java.lang.Iterable#iterator()}.  In that case, the internal parameter list
+     * {@code (V T A...)} must have at least one {@code A} type, and the default iterator
+     * handle parameter is adjusted to accept the leading {@code A} type, as if by
+     * the {@link MethodHandle#asType asType} conversion method.
+     * The leading {@code A} type must be {@code Iterable} or a subtype thereof, or an array type.
+     * This conversion step, done at loop construction time, must not throw a {@code WrongMethodTypeException}.
+     * </ul>
+     * <p>
+     * The type {@code T} may be either a primitive or reference.
+     * Since type {@code Iterator<T>} is erased in the method handle representation to the raw type {@code Iterator},
+     * the {@code iteratedLoop} combinator adjusts the leading argument type for {@code body} to {@code Object}
+     * as if by the {@link MethodHandle#asType asType} conversion method.
+     * Therefore, if an iterator of the wrong type appears as the loop is executed, runtime exceptions may occur
+     * as the result of dynamic conversions performed by {@link MethodHandle#asType(MethodType)}.
+     * <p>
+     * The resulting loop handle's result type and parameter signature are determined as follows:<ul>
+     * <li>The loop handle's result type is the result type {@code V} of the body.
+     * <li>The loop handle's parameter types are the types {@code (A...)},
+     * from the external parameter list.
+     * </ul>
+     * <p>
+     * Here is pseudocode for the resulting loop handle. In the code, {@code V}/{@code v} represent the type / value of
+     * the loop variable as well as the result type of the loop; {@code T}/{@code t}, that of the elements of the
+     * structure the loop iterates over, and {@code A...}/{@code a...} represent arguments passed to the loop.
+     * <blockquote><pre>{@code
+     * Iterator<T> iterator(A...);  // defaults to Iterable::iterator
+     * V init(A...);
+     * V body(V,T,A...);
+     * V iteratedLoop(A... a...) {
+     *   Iterator<T> it = iterator(a...);
+     *   V v = init(a...);
+     *   for (T t : it) {
+     *     v = body(v, t, a...);
      *   }
      *   return v;
      * }
@@ -4567,243 +5383,164 @@
      * <p>
      * @apiNote Example:
      * <blockquote><pre>{@code
-     * // String s = "Lambdaman!"; for (int i = 0; i < 13; ++i) { s = "na " + s; } return s;
-     * // => a variation on a well known theme
-     * static String start(String arg) { return arg; }
-     * static String step(int counter, String v, String arg) { return "na " + v; }
-     * // assume MH_start and MH_step are handles to the two methods above
-     * MethodHandle fit13 = MethodHandles.constant(int.class, 13);
-     * MethodHandle loop = MethodHandles.countedLoop(fit13, MH_start, MH_step);
-     * assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke("Lambdaman!"));
-     * }</pre></blockquote>
-     *
-     * <p>
-     * @implSpec The implementation of this method is equivalent to:
-     * <blockquote><pre>{@code
-     * MethodHandle countedLoop(MethodHandle iterations, MethodHandle init, MethodHandle body) {
-     *     return countedLoop(null, iterations, init, body);  // null => constant zero
-     * }
-     * }</pre></blockquote>
-     *
-     * @param iterations a handle to return the number of iterations this loop should run.
-     * @param init initializer for additional loop state. This determines the loop's result type.
-     *             Passing {@code null} or a {@code void} init function will make the loop's result type
-     *             {@code void}.
-     * @param body the body of the loop, which must not be {@code null}.
-     *             It must accept an initial {@code int} parameter (for the counter), and then any
-     *             additional loop-local variable plus loop parameters.
-     *
-     * @return a method handle representing the loop.
-     * @throws IllegalArgumentException if any argument has a type inconsistent with the loop structure
-     *
-     * @since 9
-     */
-    public static MethodHandle countedLoop(MethodHandle iterations, MethodHandle init, MethodHandle body) {
-        return countedLoop(null, iterations, init, body);
-    }
-
-    /**
-     * Constructs a loop that counts over a range of numbers. The loop counter is an {@code int} that will be
-     * initialized to the {@code int} value returned from the evaluation of the {@code start} handle and run to the
-     * value returned from {@code end} (exclusively) with a step width of 1. The counter value is passed to the {@code
-     * body} function in each iteration; it has to accept an initial {@code int} parameter
-     * for that. The result of the loop execution is the final value of the additional local state
-     * obtained by running {@code init}.
-     * This is a
-     * convenience wrapper for the {@linkplain MethodHandles#loop(MethodHandle[][]) generic loop combinator}.
-     * <p>
-     * The constraints for the {@code init} and {@code body} handles are the same as for {@link
-     * #countedLoop(MethodHandle, MethodHandle, MethodHandle)}. Additionally, the {@code start} and {@code end} handles
-     * must return an {@code int} and accept the same parameters as {@code init}.
-     * <p>
-     * Here is pseudocode for the resulting loop handle. In the code, {@code V}/{@code v} represent the type / value of
-     * the sole loop variable as well as the result type of the loop; and {@code A}/{@code a}, that of the argument
-     * passed to the loop.
-     * <blockquote><pre>{@code
-     * int start(A);
-     * int end(A);
-     * V init(A);
-     * V body(int, V, A);
-     * V countedLoop(A a) {
-     *   int s = start(a);
-     *   int e = end(a);
-     *   V v = init(a);
-     *   for (int i = s; i < e; ++i) {
-     *     v = body(i, v, a);
-     *   }
-     *   return v;
-     * }
-     * }</pre></blockquote>
-     *
-     * <p>
-     * @implSpec The implementation of this method is equivalent to:
-     * <blockquote><pre>{@code
-     * MethodHandle countedLoop(MethodHandle start, MethodHandle end, MethodHandle init, MethodHandle body) {
-     *     MethodHandle returnVar = dropArguments(identity(init.type().returnType()), 0, int.class, int.class);
-     *     // assume MH_increment and MH_lessThan are handles to x+1 and x<y of type int,
-     *     // assume MH_decrement is a handle to x-1 of type int
-     *     MethodHandle[]
-     *         indexVar = {start, MH_increment}, // i = start; i = i+1
-     *         loopLimit = {end, null,
-     *                       filterArgument(MH_lessThan, 0, MH_decrement), returnVar}, // i-1<end
-     *         bodyClause = {init,
-     *                       filterArgument(dropArguments(body, 1, int.class), 0, MH_decrement}; // v = body(i-1, v)
-     *     return loop(indexVar, loopLimit, bodyClause);
-     * }
-     * }</pre></blockquote>
-     *
-     * @param start a handle to return the start value of the loop counter.
-     *              If it is {@code null}, a constant zero is assumed.
-     * @param end a non-{@code null} handle to return the end value of the loop counter (the loop will run to {@code end-1}).
-     * @param init initializer for additional loop state. This determines the loop's result type.
-     *             Passing {@code null} or a {@code void} init function will make the loop's result type
-     *             {@code void}.
-     * @param body the body of the loop, which must not be {@code null}.
-     *             It must accept an initial {@code int} parameter (for the counter), and then any
-     *             additional loop-local variable plus loop parameters.
-     *
-     * @return a method handle representing the loop.
-     * @throws IllegalArgumentException if any argument has a type inconsistent with the loop structure
-     *
-     * @since 9
-     */
-    public static MethodHandle countedLoop(MethodHandle start, MethodHandle end, MethodHandle init, MethodHandle body) {
-        Class<?> resultType;
-        MethodHandle actualInit;
-        if (init == null) {
-            resultType = body == null ? void.class : body.type().returnType();
-            actualInit = empty(methodType(resultType));
-        } else {
-            resultType = init.type().returnType();
-            actualInit = init;
-        }
-        MethodHandle defaultResultHandle = resultType == void.class ? zero(void.class) : identity(resultType);
-        MethodHandle actualBody = body == null ? dropArguments(defaultResultHandle, 0, int.class) : body;
-        MethodHandle returnVar = dropArguments(defaultResultHandle, 0, int.class, int.class);
-        MethodHandle actualEnd = end == null ? constant(int.class, 0) : end;
-        MethodHandle decr = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_decrementCounter);
-        MethodHandle[] indexVar = {start, MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopStep)};
-        MethodHandle[] loopLimit = {actualEnd, null,
-                filterArgument(MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopPred), 0, decr),
-                returnVar};
-        MethodHandle[] bodyClause = {actualInit, filterArgument(dropArguments(actualBody, 1, int.class), 0, decr)};
-        return loop(indexVar, loopLimit, bodyClause);
-    }
-
-    /**
-     * Constructs a loop that ranges over the elements produced by an {@code Iterator<T>}.
-     * The iterator will be produced by the evaluation of the {@code iterator} handle.
-     * This handle must have {@link java.util.Iterator} as its return type.
-     * If this handle is passed as {@code null} the method {@link Iterable#iterator} will be used instead,
-     * and will be applied to a leading argument of the loop handle.
-     * Each value produced by the iterator is passed to the {@code body}, which must accept an initial {@code T} parameter.
-     * The result of the loop execution is the final value of the additional local state
-     * obtained by running {@code init}.
-     * <p>
-     * This is a convenience wrapper for the
-     * {@linkplain MethodHandles#loop(MethodHandle[][]) generic loop combinator}, and the constraints imposed on the {@code body}
-     * handle follow directly from those described for the latter.
-     * <p>
-     * Here is pseudocode for the resulting loop handle. In the code, {@code V}/{@code v} represent the type / value of
-     * the loop variable as well as the result type of the loop; {@code T}/{@code t}, that of the elements of the
-     * structure the loop iterates over, and {@code A}/{@code a}, that of the argument passed to the loop.
-     * <blockquote><pre>{@code
-     * Iterator<T> iterator(A);  // defaults to Iterable::iterator
-     * V init(A);
-     * V body(T,V,A);
-     * V iteratedLoop(A a) {
-     *   Iterator<T> it = iterator(a);
-     *   V v = init(a);
-     *   for (T t : it) {
-     *     v = body(t, v, a);
-     *   }
-     *   return v;
-     * }
-     * }</pre></blockquote>
-     * <p>
-     * The type {@code T} may be either a primitive or reference.
-     * Since type {@code Iterator<T>} is erased in the method handle representation to the raw type
-     * {@code Iterator}, the {@code iteratedLoop} combinator adjusts the leading argument type for {@code body}
-     * to {@code Object} as if by the {@link MethodHandle#asType asType} conversion method.
-     * Therefore, if an iterator of the wrong type appears as the loop is executed,
-     * runtime exceptions may occur as the result of dynamic conversions performed by {@code asType}.
-     * <p>
-     * @apiNote Example:
-     * <blockquote><pre>{@code
-     * // reverse a list
-     * static List<String> reverseStep(String e, List<String> r, List<String> l) {
+     * // get an iterator from a list
+     * static List<String> reverseStep(List<String> r, String e) {
      *   r.add(0, e);
      *   return r;
      * }
-     * static List<String> newArrayList(List<String> l) { return new ArrayList<>(); }
-     * // assume MH_reverseStep, MH_newArrayList are handles to the above methods
+     * static List<String> newArrayList() { return new ArrayList<>(); }
+     * // assume MH_reverseStep and MH_newArrayList are handles to the above methods
      * MethodHandle loop = MethodHandles.iteratedLoop(null, MH_newArrayList, MH_reverseStep);
      * List<String> list = Arrays.asList("a", "b", "c", "d", "e");
      * List<String> reversedList = Arrays.asList("e", "d", "c", "b", "a");
      * assertEquals(reversedList, (List<String>) loop.invoke(list));
      * }</pre></blockquote>
      * <p>
-     * @implSpec The implementation of this method is equivalent to (excluding error handling):
+     * @apiNote The implementation of this method can be expressed approximately as follows:
      * <blockquote><pre>{@code
      * MethodHandle iteratedLoop(MethodHandle iterator, MethodHandle init, MethodHandle body) {
-     *     // assume MH_next and MH_hasNext are handles to methods of Iterator
-     *     Class<?> itype = iterator.type().returnType();
-     *     Class<?> ttype = body.type().parameterType(0);
-     *     MethodHandle returnVar = dropArguments(identity(init.type().returnType()), 0, itype);
+     *     // assume MH_next, MH_hasNext, MH_startIter are handles to methods of Iterator/Iterable
+     *     Class<?> returnType = body.type().returnType();
+     *     Class<?> ttype = body.type().parameterType(returnType == void.class ? 0 : 1);
      *     MethodHandle nextVal = MH_next.asType(MH_next.type().changeReturnType(ttype));
+     *     MethodHandle retv = null, step = body, startIter = iterator;
+     *     if (returnType != void.class) {
+     *         // the simple thing first:  in (I V A...), drop the I to get V
+     *         retv = dropArguments(identity(returnType), 0, Iterator.class);
+     *         // body type signature (V T A...), internal loop types (I V A...)
+     *         step = swapArguments(body, 0, 1);  // swap V <-> T
+     *     }
+     *     if (startIter == null)  startIter = MH_getIter;
      *     MethodHandle[]
-     *         iterVar = {iterator, null, MH_hasNext, returnVar}, // it = iterator(); while (it.hasNext)
-     *         bodyClause = {init, filterArgument(body, 0, nextVal)};  // v = body(t, v, a);
+     *         iterVar    = { startIter, null, MH_hasNext, retv }, // it = iterator; while (it.hasNext())
+     *         bodyClause = { init, filterArguments(step, 0, nextVal) };  // v = body(v, t, a)
      *     return loop(iterVar, bodyClause);
      * }
      * }</pre></blockquote>
      *
-     * @param iterator a handle to return the iterator to start the loop.
-     *             The handle must have {@link java.util.Iterator} as its return type.
-     *             Passing {@code null} will make the loop call {@link Iterable#iterator()} on the first
-     *             incoming value.
-     * @param init initializer for additional loop state. This determines the loop's result type.
-     *             Passing {@code null} or a {@code void} init function will make the loop's result type
-     *             {@code void}.
-     * @param body the body of the loop, which must not be {@code null}.
-     *             It must accept an initial {@code T} parameter (for the iterated values), and then any
-     *             additional loop-local variable plus loop parameters.
+     * @param iterator an optional handle to return the iterator to start the loop.
+     *                 If non-{@code null}, the handle must return {@link java.util.Iterator} or a subtype.
+     *                 See above for other constraints.
+     * @param init optional initializer, providing the initial value of the loop variable.
+     *             May be {@code null}, implying a default initial value.  See above for other constraints.
+     * @param body body of the loop, which may not be {@code null}.
+     *             It controls the loop parameters and result type in the standard case (see above for details).
+     *             It must accept its own return type (if non-void) plus a {@code T} parameter (for the iterated values),
+     *             and may accept any number of additional types.
+     *             See above for other constraints.
      *
      * @return a method handle embodying the iteration loop functionality.
-     * @throws IllegalArgumentException if any argument has a type inconsistent with the loop structure
+     * @throws NullPointerException if the {@code body} handle is {@code null}.
+     * @throws IllegalArgumentException if any argument violates the above requirements.
      *
      * @since 9
      */
     public static MethodHandle iteratedLoop(MethodHandle iterator, MethodHandle init, MethodHandle body) {
-        checkIteratedLoop(iterator, body);
-        Class<?> resultType = init == null ?
-                body == null ? void.class : body.type().returnType() :
-                init.type().returnType();
-        boolean voidResult = resultType == void.class;
-
-        MethodHandle initIterator;
-        if (iterator == null) {
-            MethodHandle initit = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_initIterator);
-            initIterator = initit.asType(initit.type().changeParameterType(0,
-                    body.type().parameterType(voidResult ? 1 : 2)));
-        } else {
-            initIterator = iterator.asType(iterator.type().changeReturnType(Iterator.class));
+        Class<?> iterableType = iteratedLoopChecks(iterator, init, body);
+        Class<?> returnType = body.type().returnType();
+        MethodHandle hasNext = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_iteratePred);
+        MethodHandle nextRaw = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_iterateNext);
+        MethodHandle startIter;
+        MethodHandle nextVal;
+        {
+            MethodType iteratorType;
+            if (iterator == null) {
+                // derive argument type from body, if available, else use Iterable
+                startIter = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_initIterator);
+                iteratorType = startIter.type().changeParameterType(0, iterableType);
+            } else {
+                // force return type to the internal iterator class
+                iteratorType = iterator.type().changeReturnType(Iterator.class);
+                startIter = iterator;
+            }
+            Class<?> ttype = body.type().parameterType(returnType == void.class ? 0 : 1);
+            MethodType nextValType = nextRaw.type().changeReturnType(ttype);
+
+            // perform the asType transforms under an exception transformer, as per spec.:
+            try {
+                startIter = startIter.asType(iteratorType);
+                nextVal = nextRaw.asType(nextValType);
+            } catch (WrongMethodTypeException ex) {
+                throw new IllegalArgumentException(ex);
+            }
+        }
+
+        MethodHandle retv = null, step = body;
+        if (returnType != void.class) {
+            // the simple thing first:  in (I V A...), drop the I to get V
+            retv = dropArguments(identity(returnType), 0, Iterator.class);
+            // body type signature (V T A...), internal loop types (I V A...)
+            step = swapArguments(body, 0, 1);  // swap V <-> T
         }
 
-        Class<?> ttype = body.type().parameterType(0);
-
-        MethodHandle returnVar =
-                dropArguments(voidResult ? zero(void.class) : identity(resultType), 0, Iterator.class);
-        MethodHandle initnx = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_iterateNext);
-        MethodHandle nextVal = initnx.asType(initnx.type().changeReturnType(ttype));
-
-        MethodHandle[] iterVar = {initIterator, null, MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_iteratePred),
-                returnVar};
-        MethodHandle[] bodyClause = {init, filterArgument(body, 0, nextVal)};
-
+        MethodHandle[]
+            iterVar    = { startIter, null, hasNext, retv },
+            bodyClause = { init, filterArgument(step, 0, nextVal) };
         return loop(iterVar, bodyClause);
     }
 
+    private static Class<?> iteratedLoopChecks(MethodHandle iterator, MethodHandle init, MethodHandle body) {
+        Objects.requireNonNull(body);
+        MethodType bodyType = body.type();
+        Class<?> returnType = bodyType.returnType();
+        List<Class<?>> innerList = bodyType.parameterList();
+        // strip leading V value if present
+        int vsize = (returnType == void.class ? 0 : 1);
+        if (vsize != 0 && (innerList.size() == 0 || innerList.get(0) != returnType)) {
+            // argument list has no "V" => error
+            MethodType expected = bodyType.insertParameterTypes(0, returnType);
+            throw misMatchedTypes("body function", bodyType, expected);
+        } else if (innerList.size() <= vsize) {
+            // missing T type => error
+            MethodType expected = bodyType.insertParameterTypes(vsize, Object.class);
+            throw misMatchedTypes("body function", bodyType, expected);
+        }
+        //Class<?> elementType = innerList.get(vsize);  // do not need this
+        List<Class<?>> outerList = innerList.subList(vsize + 1, innerList.size());
+        if (outerList.isEmpty()) {
+            // special case; take lists from iterator handle
+            outerList = ((iterator != null)
+                    ? iterator.type().parameterList()
+                    : Arrays.asList(Iterable.class));
+            innerList = bodyType.insertParameterTypes(vsize + 1, outerList).parameterList();
+        }
+        if (iterator != null) {
+            MethodType itype = iterator.type();
+            if (!Iterator.class.isAssignableFrom(itype.returnType())) {
+                throw newIllegalArgumentException("iteratedLoop first argument must have Iterator return type");
+            }
+            if (!itype.effectivelyIdenticalParameters(0, outerList)) {
+                MethodType expected = methodType(itype.returnType(), outerList);
+                throw misMatchedTypes("iterator parameters", itype, expected);
+            }
+        }
+        if (init != null) {
+            MethodType initType = init.type();
+            if (initType.returnType() != returnType ||
+                    !initType.effectivelyIdenticalParameters(0, outerList)) {
+                throw misMatchedTypes("loop initializer", initType, methodType(returnType, outerList));
+            }
+        }
+        Class<?> iterableType = outerList.isEmpty() ? null : outerList.get(0);
+        if (iterableType != null && !Iterable.class.isAssignableFrom(iterableType) && !iterableType.isArray()) {
+            throw newIllegalArgumentException(
+                    "inferred first loop argument must be an array or inherit from Iterable: " + iterableType);
+        }
+        return iterableType;  // help the caller a bit
+    }
+
+    /*non-public*/ static MethodHandle swapArguments(MethodHandle mh, int i, int j) {
+        // there should be a better way to uncross my wires
+        int arity = mh.type().parameterCount();
+        int[] order = new int[arity];
+        for (int k = 0; k < arity; k++)  order[k] = k;
+        order[i] = j; order[j] = i;
+        Class<?>[] types = mh.type().parameterArray();
+        Class<?> ti = types[i]; types[i] = types[j]; types[j] = ti;
+        MethodType swapType = methodType(mh.type().returnType(), types);
+        return permuteArguments(mh, swapType, order);
+    }
+
     /**
      * Makes a method handle that adapts a {@code target} method handle by wrapping it in a {@code try-finally} block.
      * Another method handle, {@code cleanup}, represents the functionality of the {@code finally} block. Any exception
@@ -4885,7 +5622,7 @@
         List<Class<?>> cleanupParamTypes = cleanup.type().parameterList();
         Class<?> rtype = target.type().returnType();
 
-        checkTryFinally(target, cleanup);
+        tryFinallyChecks(target, cleanup);
 
         // Match parameter lists: if the cleanup has a shorter parameter list than the target, add ignored arguments.
         // The cleanup parameter list (minus the leading Throwable and result parameters) must be a sublist of the
@@ -4896,210 +5633,22 @@
         return MethodHandleImpl.makeTryFinally(target.asFixedArity(), cleanup.asFixedArity(), rtype, targetParamTypes);
     }
 
-    /**
-     * Adapts a target method handle by pre-processing some of its arguments, starting at a given position, and then
-     * calling the target with the result of the pre-processing, inserted into the original sequence of arguments just
-     * before the folded arguments.
-     * <p>
-     * This method is closely related to {@link #foldArguments(MethodHandle, MethodHandle)}, but allows to control the
-     * position in the parameter list at which folding takes place. The argument controlling this, {@code pos}, is a
-     * zero-based index. The aforementioned method {@link #foldArguments(MethodHandle, MethodHandle)} assumes position
-     * 0.
-     * <p>
-     * @apiNote Example:
-     * <blockquote><pre>{@code
-    import static java.lang.invoke.MethodHandles.*;
-    import static java.lang.invoke.MethodType.*;
-    ...
-    MethodHandle trace = publicLookup().findVirtual(java.io.PrintStream.class,
-    "println", methodType(void.class, String.class))
-    .bindTo(System.out);
-    MethodHandle cat = lookup().findVirtual(String.class,
-    "concat", methodType(String.class, String.class));
-    assertEquals("boojum", (String) cat.invokeExact("boo", "jum"));
-    MethodHandle catTrace = foldArguments(cat, 1, trace);
-    // also prints "jum":
-    assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
-     * }</pre></blockquote>
-     * <p>Here is pseudocode for the resulting adapter. In the code, {@code T}
-     * represents the result type of the {@code target} and resulting adapter.
-     * {@code V}/{@code v} represent the type and value of the parameter and argument
-     * of {@code target} that precedes the folding position; {@code V} also is
-     * the result type of the {@code combiner}. {@code A}/{@code a} denote the
-     * types and values of the {@code N} parameters and arguments at the folding
-     * position. {@code Z}/{@code z} and {@code B}/{@code b} represent the types
-     * and values of the {@code target} parameters and arguments that precede and
-     * follow the folded parameters and arguments starting at {@code pos},
-     * respectively.
-     * <blockquote><pre>{@code
-     * // there are N arguments in A...
-     * T target(Z..., V, A[N]..., B...);
-     * V combiner(A...);
-     * T adapter(Z... z, A... a, B... b) {
-     *   V v = combiner(a...);
-     *   return target(z..., v, a..., b...);
-     * }
-     * // and if the combiner has a void return:
-     * T target2(Z..., A[N]..., B...);
-     * void combiner2(A...);
-     * T adapter2(Z... z, A... a, B... b) {
-     *   combiner2(a...);
-     *   return target2(z..., a..., b...);
-     * }
-     * }</pre></blockquote>
-     * <p>
-     * <em>Note:</em> The resulting adapter is never a {@linkplain MethodHandle#asVarargsCollector
-     * variable-arity method handle}, even if the original target method handle was.
-     *
-     * @param target the method handle to invoke after arguments are combined
-     * @param pos the position at which to start folding and at which to insert the folding result; if this is {@code
-     *            0}, the effect is the same as for {@link #foldArguments(MethodHandle, MethodHandle)}.
-     * @param combiner method handle to call initially on the incoming arguments
-     * @return method handle which incorporates the specified argument folding logic
-     * @throws NullPointerException if either argument is null
-     * @throws IllegalArgumentException if {@code combiner}'s return type
-     *          is non-void and not the same as the argument type at position {@code pos} of
-     *          the target signature, or if the {@code N} argument types at position {@code pos}
-     *          of the target signature
-     *          (skipping one matching the {@code combiner}'s return type)
-     *          are not identical with the argument types of {@code combiner}
-     *
-     * @see #foldArguments(MethodHandle, MethodHandle)
-     * @since 9
-     */
-    public static MethodHandle foldArguments(MethodHandle target, int pos, MethodHandle combiner) {
-        MethodType targetType = target.type();
-        MethodType combinerType = combiner.type();
-        Class<?> rtype = foldArgumentChecks(pos, targetType, combinerType);
-        BoundMethodHandle result = target.rebind();
-        boolean dropResult = rtype == void.class;
-        LambdaForm lform = result.editor().foldArgumentsForm(1 + pos, dropResult, combinerType.basicType());
-        MethodType newType = targetType;
-        if (!dropResult) {
-            newType = newType.dropParameterTypes(pos, pos + 1);
-        }
-        result = result.copyWithExtendL(newType, lform, combiner);
-        return result;
-    }
-
-    /**
-     * As {@see foldArguments(MethodHandle, int, MethodHandle)}, but with the
-     * added capability of selecting the arguments from the targets parameters
-     * to call the combiner with. This allows us to avoid some simple cases of
-     * permutations and padding the combiner with dropArguments to select the
-     * right argument, which may ultimately produce fewer intermediaries.
-     */
-    static MethodHandle foldArguments(MethodHandle target, int pos, MethodHandle combiner, int ... argPositions) {
-        MethodType targetType = target.type();
-        MethodType combinerType = combiner.type();
-        Class<?> rtype = foldArgumentChecks(pos, targetType, combinerType, argPositions);
-        BoundMethodHandle result = target.rebind();
-        boolean dropResult = rtype == void.class;
-        LambdaForm lform = result.editor().foldArgumentsForm(1 + pos, dropResult, combinerType.basicType(), argPositions);
-        MethodType newType = targetType;
-        if (!dropResult) {
-            newType = newType.dropParameterTypes(pos, pos + 1);
-        }
-        result = result.copyWithExtendL(newType, lform, combiner);
-        return result;
-    }
-
-    private static void checkLoop0(MethodHandle[][] clauses) {
-        if (clauses == null || clauses.length == 0) {
-            throw newIllegalArgumentException("null or no clauses passed");
-        }
-        if (Stream.of(clauses).anyMatch(Objects::isNull)) {
-            throw newIllegalArgumentException("null clauses are not allowed");
-        }
-        if (Stream.of(clauses).anyMatch(c -> c.length > 4)) {
-            throw newIllegalArgumentException("All loop clauses must be represented as MethodHandle arrays with at most 4 elements.");
-        }
-    }
-
-    private static void checkLoop1a(int i, MethodHandle in, MethodHandle st) {
-        if (in.type().returnType() != st.type().returnType()) {
-            throw misMatchedTypes("clause " + i + ": init and step return types", in.type().returnType(),
-                    st.type().returnType());
-        }
-    }
-
-    private static List<Class<?>> buildCommonSuffix(List<MethodHandle> init, List<MethodHandle> step, List<MethodHandle> pred, List<MethodHandle> fini, int cpSize) {
-        final List<Class<?>> empty = List.of();
-        final List<MethodHandle> nonNullInits = init.stream().filter(Objects::nonNull).collect(Collectors.toList());
-        if (nonNullInits.isEmpty()) {
-            final List<Class<?>> longest = Stream.of(step, pred, fini).flatMap(List::stream).filter(Objects::nonNull).
-                    // take only those that can contribute to a common suffix because they are longer than the prefix
-                    map(MethodHandle::type).filter(t -> t.parameterCount() > cpSize).map(MethodType::parameterList).
-                    reduce((p, q) -> p.size() >= q.size() ? p : q).orElse(empty);
-            return longest.size() == 0 ? empty : longest.subList(cpSize, longest.size());
-        } else {
-            return nonNullInits.stream().map(MethodHandle::type).map(MethodType::parameterList).
-                    reduce((p, q) -> p.size() >= q.size() ? p : q).get();
-        }
-    }
-
-    private static void checkLoop1b(List<MethodHandle> init, List<Class<?>> commonSuffix) {
-        if (init.stream().filter(Objects::nonNull).map(MethodHandle::type).map(MethodType::parameterList).
-                anyMatch(pl -> !pl.equals(commonSuffix.subList(0, pl.size())))) {
-            throw newIllegalArgumentException("found non-effectively identical init parameter type lists: " + init +
-                    " (common suffix: " + commonSuffix + ")");
-        }
-    }
-
-    private static void checkLoop1cd(List<MethodHandle> pred, List<MethodHandle> fini, Class<?> loopReturnType) {
-        if (fini.stream().filter(Objects::nonNull).map(MethodHandle::type).map(MethodType::returnType).
-                anyMatch(t -> t != loopReturnType)) {
-            throw newIllegalArgumentException("found non-identical finalizer return types: " + fini + " (return type: " +
-                    loopReturnType + ")");
-        }
-
-        if (!pred.stream().filter(Objects::nonNull).findFirst().isPresent()) {
-            throw newIllegalArgumentException("no predicate found", pred);
-        }
-        if (pred.stream().filter(Objects::nonNull).map(MethodHandle::type).map(MethodType::returnType).
-                anyMatch(t -> t != boolean.class)) {
-            throw newIllegalArgumentException("predicates must have boolean return type", pred);
-        }
-    }
-
-    private static void checkLoop2(List<MethodHandle> step, List<MethodHandle> pred, List<MethodHandle> fini, List<Class<?>> commonParameterSequence) {
-        final int cpSize = commonParameterSequence.size();
-        if (Stream.of(step, pred, fini).flatMap(List::stream).filter(Objects::nonNull).map(MethodHandle::type).
-                map(MethodType::parameterList).
-                anyMatch(pl -> pl.size() > cpSize || !pl.equals(commonParameterSequence.subList(0, pl.size())))) {
-            throw newIllegalArgumentException("found non-effectively identical parameter type lists:\nstep: " + step +
-                    "\npred: " + pred + "\nfini: " + fini + " (common parameter sequence: " + commonParameterSequence + ")");
-        }
-    }
-
-    private static void checkIteratedLoop(MethodHandle iterator, MethodHandle body) {
-        if (null != iterator && !Iterator.class.isAssignableFrom(iterator.type().returnType())) {
-            throw newIllegalArgumentException("iteratedLoop first argument must have Iterator return type");
-        }
-        if (null == body) {
-            throw newIllegalArgumentException("iterated loop body must not be null");
-        }
-    }
-
-    private static void checkTryFinally(MethodHandle target, MethodHandle cleanup) {
+    private static void tryFinallyChecks(MethodHandle target, MethodHandle cleanup) {
         Class<?> rtype = target.type().returnType();
         if (rtype != cleanup.type().returnType()) {
             throw misMatchedTypes("target and return types", cleanup.type().returnType(), rtype);
         }
-        List<Class<?>> cleanupParamTypes = cleanup.type().parameterList();
-        if (!Throwable.class.isAssignableFrom(cleanupParamTypes.get(0))) {
+        MethodType cleanupType = cleanup.type();
+        if (!Throwable.class.isAssignableFrom(cleanupType.parameterType(0))) {
             throw misMatchedTypes("cleanup first argument and Throwable", cleanup.type(), Throwable.class);
         }
-        if (rtype != void.class && cleanupParamTypes.get(1) != rtype) {
+        if (rtype != void.class && cleanupType.parameterType(1) != rtype) {
             throw misMatchedTypes("cleanup second argument and target return type", cleanup.type(), rtype);
         }
         // The cleanup parameter list (minus the leading Throwable and result parameters) must be a sublist of the
         // target parameter list.
         int cleanupArgIndex = rtype == void.class ? 1 : 2;
-        List<Class<?>> cleanupArgSuffix = cleanupParamTypes.subList(cleanupArgIndex, cleanupParamTypes.size());
-        List<Class<?>> targetParamTypes = target.type().parameterList();
-        if (targetParamTypes.size() < cleanupArgSuffix.size() ||
-                !cleanupArgSuffix.equals(targetParamTypes.subList(0, cleanupParamTypes.size() - cleanupArgIndex))) {
+        if (!cleanupType.effectivelyIdenticalParameters(cleanupArgIndex, target.type().parameterList())) {
             throw misMatchedTypes("cleanup parameters after (Throwable,result) and target parameter list prefix",
                     cleanup.type(), target.type());
         }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java	Tue Oct 18 17:14:09 2016 +0000
@@ -809,6 +809,28 @@
         return sj.toString();
     }
 
+    /** True if my parameter list is effectively identical to the given full list,
+     *  after skipping the given number of my own initial parameters.
+     *  In other words, after disregarding {@code skipPos} parameters,
+     *  my remaining parameter list is no longer than the {@code fullList}, and
+     *  is equal to the same-length initial sublist of {@code fullList}.
+     */
+    /*non-public*/
+    boolean effectivelyIdenticalParameters(int skipPos, List<Class<?>> fullList) {
+        int myLen = ptypes.length, fullLen = fullList.size();
+        if (skipPos > myLen || myLen - skipPos > fullLen)
+            return false;
+        List<Class<?>> myList = Arrays.asList(ptypes);
+        if (skipPos != 0) {
+            myList = myList.subList(skipPos, myLen);
+            myLen -= skipPos;
+        }
+        if (fullLen == myLen)
+            return myList.equals(fullList);
+        else
+            return myList.equals(fullList.subList(0, myLen));
+    }
+
     /** True if the old return type can always be viewed (w/o casting) under new return type,
      *  and the new parameters can be viewed (w/o casting) under the old parameter types.
      */
--- a/jdk/src/java.base/share/classes/java/lang/module/ModulePath.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModulePath.java	Tue Oct 18 17:14:09 2016 +0000
@@ -56,6 +56,8 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
+import jdk.internal.jmod.JmodFile;
+import jdk.internal.jmod.JmodFile.Section;
 import jdk.internal.module.ConfigurableModuleFinder;
 import jdk.internal.perf.PerfCounter;
 
@@ -294,11 +296,11 @@
 
     // -- jmod files --
 
-    private Set<String> jmodPackages(ZipFile zf) {
-        return zf.stream()
-            .filter(e -> e.getName().startsWith("classes/") &&
-                    e.getName().endsWith(".class"))
-            .map(e -> toPackageName(e.getName().substring(8)))
+    private Set<String> jmodPackages(JmodFile jf) {
+        return jf.stream()
+            .filter(e -> e.section() == Section.CLASSES)
+            .map(JmodFile.Entry::name)
+            .map(this::toPackageName)
             .filter(pkg -> pkg.length() > 0) // module-info
             .collect(Collectors.toSet());
     }
@@ -311,14 +313,10 @@
      * @throws InvalidModuleDescriptorException
      */
     private ModuleReference readJMod(Path file) throws IOException {
-        try (ZipFile zf = new ZipFile(file.toString())) {
-            ZipEntry ze = zf.getEntry("classes/" + MODULE_INFO);
-            if (ze == null) {
-                throw new IOException(MODULE_INFO + " is missing: " + file);
-            }
+        try (JmodFile jf = new JmodFile(file)) {
             ModuleDescriptor md;
-            try (InputStream in = zf.getInputStream(ze)) {
-                md = ModuleDescriptor.read(in, () -> jmodPackages(zf));
+            try (InputStream in = jf.getInputStream(Section.CLASSES, MODULE_INFO)) {
+                md = ModuleDescriptor.read(in, () -> jmodPackages(jf));
             }
             return ModuleReferences.newJModModule(md, file);
         }
--- a/jdk/src/java.base/share/classes/java/net/MulticastSocket.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/net/MulticastSocket.java	Tue Oct 18 17:14:09 2016 +0000
@@ -93,23 +93,19 @@
     /**
      * Create a multicast socket.
      *
-     * <p>If there is a security manager,
-     * its {@code checkListen} method is first called
-     * with 0 as its argument to ensure the operation is allowed.
-     * This could result in a SecurityException.
+     * <p>
+     * If there is a security manager, its {@code checkListen} method is first
+     * called with 0 as its argument to ensure the operation is allowed. This
+     * could result in a SecurityException.
      * <p>
      * When the socket is created the
-     * {@link DatagramSocket#setReuseAddress(boolean)} method is
-     * called to enable the SO_REUSEADDR socket option. When
-     * {@link StandardSocketOptions#SO_REUSEPORT SO_REUSEPORT} is
-     * supported then
-     * {@link DatagramSocketImpl#setOption(SocketOption, Object)}
-     * is called to enable the socket option.
+     * {@link DatagramSocket#setReuseAddress(boolean)} method is called to
+     * enable the SO_REUSEADDR socket option.
      *
-     * @exception IOException if an I/O exception occurs
-     * while creating the MulticastSocket
-     * @exception  SecurityException  if a security manager exists and its
-     *             {@code checkListen} method doesn't allow the operation.
+     * @exception IOException if an I/O exception occurs while creating the
+     * MulticastSocket
+     * @exception SecurityException if a security manager exists and its
+     * {@code checkListen} method doesn't allow the operation.
      * @see SecurityManager#checkListen
      * @see java.net.DatagramSocket#setReuseAddress(boolean)
      * @see java.net.DatagramSocketImpl#setOption(SocketOption, Object)
@@ -174,17 +170,13 @@
         // Enable SO_REUSEADDR before binding
         setReuseAddress(true);
 
-        // Enable SO_REUSEPORT if supported before binding
-        if (supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
-            this.setOption(StandardSocketOptions.SO_REUSEPORT, true);
-        }
-
         if (bindaddr != null) {
             try {
                 bind(bindaddr);
             } finally {
-                if (!isBound())
+                if (!isBound()) {
                     close();
+                }
             }
         }
     }
--- a/jdk/src/java.base/share/classes/java/security/AccessControlContext.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/security/AccessControlContext.java	Tue Oct 18 17:14:09 2016 +0000
@@ -27,7 +27,9 @@
 
 import java.util.ArrayList;
 import java.util.List;
+
 import sun.security.util.Debug;
+import sun.security.util.FilePermCompat;
 import sun.security.util.SecurityConstants;
 
 
@@ -175,7 +177,7 @@
 
     /**
      * package private to allow calls from ProtectionDomain without performing
-     * the security check for {@linkplain SecurityConstants.CREATE_ACC_PERMISSION}
+     * the security check for {@linkplain SecurityConstants#CREATE_ACC_PERMISSION}
      * permission
      */
     AccessControlContext(AccessControlContext acc,
@@ -253,7 +255,8 @@
                 if (perms[i].getClass() == AllPermission.class) {
                     parent = null;
                 }
-                tmp[i] = perms[i];
+                // Add altPath into permission for compatibility.
+                tmp[i] = FilePermCompat.newPermPlusAltPath(perms[i]);
             }
         }
 
@@ -443,7 +446,7 @@
         }
 
         for (int i=0; i< context.length; i++) {
-            if (context[i] != null &&  !context[i].implies(perm)) {
+            if (context[i] != null && !context[i].impliesWithAltFilePerm(perm)) {
                 if (dumpDebug) {
                     debug.println("access denied " + perm);
                 }
--- a/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java	Tue Oct 18 17:14:09 2016 +0000
@@ -32,13 +32,14 @@
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import jdk.internal.misc.JavaSecurityAccess;
 import jdk.internal.misc.JavaSecurityProtectionDomainAccess;
 import static jdk.internal.misc.JavaSecurityProtectionDomainAccess.ProtectionDomainCache;
 import jdk.internal.misc.SharedSecrets;
+import sun.security.provider.PolicyFile;
 import sun.security.util.Debug;
+import sun.security.util.FilePermCompat;
 import sun.security.util.SecurityConstants;
 
 /**
@@ -303,11 +304,71 @@
         }
 
         if (!staticPermissions &&
-            Policy.getPolicyNoCheck().implies(this, perm))
+            Policy.getPolicyNoCheck().implies(this, perm)) {
+            return true;
+        }
+        if (permissions != null) {
+            return permissions.implies(perm);
+        }
+
+        return false;
+    }
+
+    /**
+     * This method has the same logic flow as {@link #implies} except that
+     * when the {@link FilePermCompat#compat} flag is on it ensures
+     * FilePermission compatibility after JDK-8164705. {@code implies()}
+     * is called when compat flag is not on or user has extended
+     * {@code ProtectionDomain}.
+     *
+     * This method is called by {@link AccessControlContext#checkPermission}
+     * and not intended to be called by an application.
+     */
+    boolean impliesWithAltFilePerm(Permission perm) {
+
+        // If this is a subclass of ProtectionDomain. Call the old method.
+        if (!FilePermCompat.compat || getClass() != ProtectionDomain.class) {
+            return implies(perm);
+        }
+
+        if (hasAllPerm) {
+            // internal permission collection already has AllPermission -
+            // no need to go to policy
             return true;
-        if (permissions != null)
-            return permissions.implies(perm);
+        }
+
+        Permission p2 = null;
+        boolean p2Calculated = false;
 
+        if (!staticPermissions) {
+            Policy policy = Policy.getPolicyNoCheck();
+            if (policy instanceof PolicyFile) {
+                // The PolicyFile implementation supports compatibility
+                // inside and it also covers the static permissions.
+                return policy.implies(this, perm);
+            } else {
+                if (policy.implies(this, perm)) {
+                    return true;
+                }
+                p2 = FilePermCompat.newPermUsingAltPath(perm);
+                p2Calculated = true;
+                if (p2 != null && policy.implies(this, p2)) {
+                    return true;
+                }
+            }
+        }
+        if (permissions != null) {
+            if (permissions.implies(perm)) {
+                return true;
+            } else {
+                if (!p2Calculated) {
+                    p2 = FilePermCompat.newPermUsingAltPath(perm);
+                }
+                if (p2 != null) {
+                    return permissions.implies(p2);
+                }
+            }
+        }
         return false;
     }
 
--- a/jdk/src/java.base/share/classes/java/text/DecimalFormat.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/text/DecimalFormat.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, 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
@@ -968,7 +968,7 @@
      *     Decimal  : min = 0. max = 3.
      *
      */
-    private void checkAndSetFastPathStatus() {
+    private boolean checkAndSetFastPathStatus() {
 
         boolean fastPathWasOn = isFastPath;
 
@@ -998,12 +998,27 @@
         } else
             isFastPath = false;
 
+        resetFastPathData(fastPathWasOn);
+        fastPathCheckNeeded = false;
+
+        /*
+         * Returns true after successfully checking the fast path condition and
+         * setting the fast path data. The return value is used by the
+         * fastFormat() method to decide whether to call the resetFastPathData
+         * method to reinitialize fast path data or is it already initialized
+         * in this method.
+         */
+        return true;
+    }
+
+    private void resetFastPathData(boolean fastPathWasOn) {
         // Since some instance properties may have changed while still falling
         // in the fast-path case, we need to reinitialize fastPathData anyway.
         if (isFastPath) {
             // We need to instantiate fastPathData if not already done.
-            if (fastPathData == null)
+            if (fastPathData == null) {
                 fastPathData = new FastPathData();
+            }
 
             // Sets up the locale specific constants used when formatting.
             // '0' is our default representation of zero.
@@ -1011,22 +1026,27 @@
             fastPathData.groupingChar = symbols.getGroupingSeparator();
 
             // Sets up fractional constants related to currency/decimal pattern.
-            fastPathData.fractionalMaxIntBound = (isCurrencyFormat) ? 99 : 999;
-            fastPathData.fractionalScaleFactor = (isCurrencyFormat) ? 100.0d : 1000.0d;
+            fastPathData.fractionalMaxIntBound = (isCurrencyFormat)
+                    ? 99 : 999;
+            fastPathData.fractionalScaleFactor = (isCurrencyFormat)
+                    ? 100.0d : 1000.0d;
 
             // Records the need for adding prefix or suffix
-            fastPathData.positiveAffixesRequired =
-                (positivePrefix.length() != 0) || (positiveSuffix.length() != 0);
-            fastPathData.negativeAffixesRequired =
-                (negativePrefix.length() != 0) || (negativeSuffix.length() != 0);
+            fastPathData.positiveAffixesRequired
+                    = (positivePrefix.length() != 0)
+                        || (positiveSuffix.length() != 0);
+            fastPathData.negativeAffixesRequired
+                    = (negativePrefix.length() != 0)
+                        || (negativeSuffix.length() != 0);
 
             // Creates a cached char container for result, with max possible size.
             int maxNbIntegralDigits = 10;
             int maxNbGroups = 3;
-            int containerSize =
-                Math.max(positivePrefix.length(), negativePrefix.length()) +
-                maxNbIntegralDigits + maxNbGroups + 1 + maximumFractionDigits +
-                Math.max(positiveSuffix.length(), negativeSuffix.length());
+            int containerSize
+                    = Math.max(positivePrefix.length(), negativePrefix.length())
+                    + maxNbIntegralDigits + maxNbGroups + 1
+                    + maximumFractionDigits
+                    + Math.max(positiveSuffix.length(), negativeSuffix.length());
 
             fastPathData.fastPathContainer = new char[containerSize];
 
@@ -1038,17 +1058,18 @@
 
             // Sets up fixed index positions for integral and fractional digits.
             // Sets up decimal point in cached result container.
-            int longestPrefixLength =
-                Math.max(positivePrefix.length(), negativePrefix.length());
-            int decimalPointIndex =
-                maxNbIntegralDigits + maxNbGroups + longestPrefixLength;
-
-            fastPathData.integralLastIndex    = decimalPointIndex - 1;
+            int longestPrefixLength
+                    = Math.max(positivePrefix.length(),
+                            negativePrefix.length());
+            int decimalPointIndex
+                    = maxNbIntegralDigits + maxNbGroups + longestPrefixLength;
+
+            fastPathData.integralLastIndex = decimalPointIndex - 1;
             fastPathData.fractionalFirstIndex = decimalPointIndex + 1;
-            fastPathData.fastPathContainer[decimalPointIndex] =
-                isCurrencyFormat ?
-                symbols.getMonetaryDecimalSeparator() :
-                symbols.getDecimalSeparator();
+            fastPathData.fastPathContainer[decimalPointIndex]
+                    = isCurrencyFormat
+                            ? symbols.getMonetaryDecimalSeparator()
+                            : symbols.getDecimalSeparator();
 
         } else if (fastPathWasOn) {
             // Previous state was fast-path and is no more.
@@ -1059,8 +1080,6 @@
             fastPathData.charsPositivePrefix = null;
             fastPathData.charsNegativePrefix = null;
         }
-
-        fastPathCheckNeeded = false;
     }
 
     /**
@@ -1554,9 +1573,11 @@
      * @return the formatted result for {@code d} as a string.
      */
     String fastFormat(double d) {
+        boolean isDataSet = false;
         // (Re-)Evaluates fast-path status if needed.
-        if (fastPathCheckNeeded)
-            checkAndSetFastPathStatus();
+        if (fastPathCheckNeeded) {
+            isDataSet = checkAndSetFastPathStatus();
+        }
 
         if (!isFastPath )
             // DecimalFormat instance is not in a fast-path state.
@@ -1580,9 +1601,21 @@
         if (d > MAX_INT_AS_DOUBLE)
             // Filters out values that are outside expected fast-path range
             return null;
-        else
+        else {
+            if (!isDataSet) {
+                /*
+                 * If the fast path data is not set through
+                 * checkAndSetFastPathStatus() and fulfil the
+                 * fast path conditions then reset the data
+                 * directly through resetFastPathData()
+                 */
+                resetFastPathData(isFastPath);
+            }
             fastDoubleFormat(d, negative);
 
+        }
+
+
         // Returns a new string from updated fastPathContainer.
         return new String(fastPathData.fastPathContainer,
                           fastPathData.firstUsedIndex,
--- a/jdk/src/java.base/share/classes/java/time/format/ZoneName.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/time/format/ZoneName.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,8 @@
 package java.time.format;
 
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
 
 /**
  * A helper class to map a zone name to metazone and back to the
@@ -335,6 +332,7 @@
         "America/Eirunepe", "Amazon", "America/Manaus",
         "Africa/Nairobi", "Africa_Eastern", "Africa/Nairobi",
         "Asia/Yakutsk", "Yakutsk", "Asia/Yakutsk",
+        "Asia/Yangon", "Myanmar", "Asia/Rangoon",
         "America/Goose_Bay", "Atlantic", "America/Halifax",
         "Africa/Maseru", "Africa_Southern", "Africa/Johannesburg",
         "America/Swift_Current", "America_Central", "America/Chicago",
@@ -770,6 +768,7 @@
         "America/Indianapolis", "America/Indiana/Indianapolis",
         "Europe/Belfast", "Europe/London",
         "America/Kralendijk", "America/Curacao",
+        "Asia/Rangoon", "Asia/Yangon",
     };
 
     private static final Map<String, String> zidToMzone = new HashMap<>();
--- a/jdk/src/java.base/share/classes/java/util/ArrayList.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/ArrayList.java	Tue Oct 18 17:14:09 2016 +0000
@@ -876,6 +876,9 @@
         int lastRet = -1; // index of last element returned; -1 if no such
         int expectedModCount = modCount;
 
+        // prevent creating a synthetic constructor
+        Itr() {}
+
         public boolean hasNext() {
             return cursor != size;
         }
--- a/jdk/src/java.base/share/classes/java/util/Locale.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Locale.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1027,7 +1027,7 @@
      * not contain ALL valid codes that can be used to create Locales.
      * </ul>
      *
-     * @return Am array of ISO 639 two-letter language codes.
+     * @return An array of ISO 639 two-letter language codes.
      */
     public static String[] getISOLanguages() {
         if (isoLanguages == null) {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java	Tue Oct 18 17:14:09 2016 +0000
@@ -108,10 +108,18 @@
      * if the current value {@code == expectedValue},
      * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
      *
+     * @deprecated This method has plain memory effects but the method
+     * name implies volatile memory effects (see methods such as
+     * {@link #compareAndExchange} and {@link #compareAndSet}).  To avoid
+     * confusion over plain or volatile memory effects it is recommended that
+     * the method {@link #weakCompareAndSetPlain} be used instead.
+     *
      * @param expectedValue the expected value
      * @param newValue the new value
      * @return {@code true} if successful
+     * @see #weakCompareAndSetPlain
      */
+    @Deprecated(since="9")
     public boolean weakCompareAndSet(boolean expectedValue, boolean newValue) {
         return VALUE.weakCompareAndSetPlain(this,
                                             (expectedValue ? 1 : 0),
@@ -119,6 +127,22 @@
     }
 
     /**
+     * Possibly atomically sets the value to {@code newValue}
+     * if the current value {@code == expectedValue},
+     * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+     *
+     * @param expectedValue the expected value
+     * @param newValue the new value
+     * @return {@code true} if successful
+     * @since 9
+     */
+    public boolean weakCompareAndSetPlain(boolean expectedValue, boolean newValue) {
+        return VALUE.weakCompareAndSetPlain(this,
+                                            (expectedValue ? 1 : 0),
+                                            (newValue ? 1 : 0));
+    }
+
+    /**
      * Sets the value to {@code newValue},
      * with memory effects as specified by {@link VarHandle#setVolatile}.
      *
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java	Tue Oct 18 17:14:09 2016 +0000
@@ -148,15 +148,37 @@
      * if the current value {@code == expectedValue},
      * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
      *
+     * @deprecated This method has plain memory effects but the method
+     * name implies volatile memory effects (see methods such as
+     * {@link #compareAndExchange} and {@link #compareAndSet}).  To avoid
+     * confusion over plain or volatile memory effects it is recommended that
+     * the method {@link #weakCompareAndSetPlain} be used instead.
+     *
      * @param expectedValue the expected value
      * @param newValue the new value
      * @return {@code true} if successful
+     * @see #weakCompareAndSetPlain
      */
+    @Deprecated(since="9")
     public final boolean weakCompareAndSet(int expectedValue, int newValue) {
         return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue);
     }
 
     /**
+     * Possibly atomically sets the value to {@code newValue}
+     * if the current value {@code == expectedValue},
+     * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+     *
+     * @param expectedValue the expected value
+     * @param newValue the new value
+     * @return {@code true} if successful
+     * @since 9
+     */
+    public final boolean weakCompareAndSetPlain(int expectedValue, int newValue) {
+        return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue);
+    }
+
+    /**
      * Atomically increments the current value,
      * with memory effects as specified by {@link VarHandle#getAndAdd}.
      *
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java	Tue Oct 18 17:14:09 2016 +0000
@@ -151,16 +151,39 @@
      * {@code newValue} if the element's current value {@code == expectedValue},
      * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
      *
+     * @deprecated This method has plain memory effects but the method
+     * name implies volatile memory effects (see methods such as
+     * {@link #compareAndExchange} and {@link #compareAndSet}).  To avoid
+     * confusion over plain or volatile memory effects it is recommended that
+     * the method {@link #weakCompareAndSetPlain} be used instead.
+     *
      * @param i the index
      * @param expectedValue the expected value
      * @param newValue the new value
      * @return {@code true} if successful
+     * @see #weakCompareAndSetPlain
      */
+    @Deprecated(since="9")
     public final boolean weakCompareAndSet(int i, int expectedValue, int newValue) {
         return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
     }
 
     /**
+     * Possibly atomically sets the element at index {@code i} to
+     * {@code newValue} if the element's current value {@code == expectedValue},
+     * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+     *
+     * @param i the index
+     * @param expectedValue the expected value
+     * @param newValue the new value
+     * @return {@code true} if successful
+     * @since 9
+     */
+    public final boolean weakCompareAndSetPlain(int i, int expectedValue, int newValue) {
+        return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
+    }
+
+    /**
      * Atomically increments the value of the element at index {@code i},
      * with memory effects as specified by {@link VarHandle#getAndAdd}.
      *
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java	Tue Oct 18 17:14:09 2016 +0000
@@ -164,15 +164,37 @@
      * if the current value {@code == expectedValue},
      * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
      *
+     * @deprecated This method has plain memory effects but the method
+     * name implies volatile memory effects (see methods such as
+     * {@link #compareAndExchange} and {@link #compareAndSet}).  To avoid
+     * confusion over plain or volatile memory effects it is recommended that
+     * the method {@link #weakCompareAndSetPlain} be used instead.
+     *
      * @param expectedValue the expected value
      * @param newValue the new value
      * @return {@code true} if successful
+     * @see #weakCompareAndSetPlain
      */
+    @Deprecated(since="9")
     public final boolean weakCompareAndSet(long expectedValue, long newValue) {
         return U.weakCompareAndSwapLong(this, VALUE, expectedValue, newValue);
     }
 
     /**
+     * Possibly atomically sets the value to {@code newValue}
+     * if the current value {@code == expectedValue},
+     * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+     *
+     * @param expectedValue the expected value
+     * @param newValue the new value
+     * @return {@code true} if successful
+     * @since 9
+     */
+    public final boolean weakCompareAndSetPlain(long expectedValue, long newValue) {
+        return U.weakCompareAndSwapLong(this, VALUE, expectedValue, newValue);
+    }
+
+    /**
      * Atomically increments the current value,
      * with memory effects as specified by {@link VarHandle#getAndAdd}.
      *
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java	Tue Oct 18 17:14:09 2016 +0000
@@ -151,16 +151,39 @@
      * {@code newValue} if the element's current value {@code == expectedValue},
      * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
      *
+     * @deprecated This method has plain memory effects but the method
+     * name implies volatile memory effects (see methods such as
+     * {@link #compareAndExchange} and {@link #compareAndSet}).  To avoid
+     * confusion over plain or volatile memory effects it is recommended that
+     * the method {@link #weakCompareAndSetPlain} be used instead.
+     *
      * @param i the index
      * @param expectedValue the expected value
      * @param newValue the new value
      * @return {@code true} if successful
+     * @see #weakCompareAndSetPlain
      */
+    @Deprecated(since="9")
     public final boolean weakCompareAndSet(int i, long expectedValue, long newValue) {
         return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
     }
 
     /**
+     * Possibly atomically sets the element at index {@code i} to
+     * {@code newValue} if the element's current value {@code == expectedValue},
+     * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+     *
+     * @param i the index
+     * @param expectedValue the expected value
+     * @param newValue the new value
+     * @return {@code true} if successful
+     * @since 9
+     */
+    public final boolean weakCompareAndSetPlain(int i, long expectedValue, long newValue) {
+        return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
+    }
+
+    /**
      * Atomically increments the value of the element at index {@code i},
      * with memory effects as specified by {@link VarHandle#getAndAdd}.
      *
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java	Tue Oct 18 17:14:09 2016 +0000
@@ -127,15 +127,37 @@
      * if the current value {@code == expectedValue},
      * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
      *
+     * @deprecated This method has plain memory effects but the method
+     * name implies volatile memory effects (see methods such as
+     * {@link #compareAndExchange} and {@link #compareAndSet}).  To avoid
+     * confusion over plain or volatile memory effects it is recommended that
+     * the method {@link #weakCompareAndSetPlain} be used instead.
+     *
      * @param expectedValue the expected value
      * @param newValue the new value
      * @return {@code true} if successful
+     * @see #weakCompareAndSetPlain
      */
+    @Deprecated(since="9")
     public final boolean weakCompareAndSet(V expectedValue, V newValue) {
         return VALUE.weakCompareAndSetPlain(this, expectedValue, newValue);
     }
 
     /**
+     * Possibly atomically sets the value to {@code newValue}
+     * if the current value {@code == expectedValue},
+     * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+     *
+     * @param expectedValue the expected value
+     * @param newValue the new value
+     * @return {@code true} if successful
+     * @since 9
+     */
+    public final boolean weakCompareAndSetPlain(V expectedValue, V newValue) {
+        return VALUE.weakCompareAndSetPlain(this, expectedValue, newValue);
+    }
+
+    /**
      * Atomically sets the value to {@code newValue} and returns the old value,
      * with memory effects as specified by {@link VarHandle#getAndSet}.
      *
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java	Tue Oct 18 17:14:09 2016 +0000
@@ -157,16 +157,39 @@
      * {@code newValue} if the element's current value {@code == expectedValue},
      * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
      *
+     * @deprecated This method has plain memory effects but the method
+     * name implies volatile memory effects (see methods such as
+     * {@link #compareAndExchange} and {@link #compareAndSet}).  To avoid
+     * confusion over plain or volatile memory effects it is recommended that
+     * the method {@link #weakCompareAndSetPlain} be used instead.
+     *
      * @param i the index
      * @param expectedValue the expected value
      * @param newValue the new value
      * @return {@code true} if successful
+     * @see #weakCompareAndSetPlain
      */
+    @Deprecated(since="9")
     public final boolean weakCompareAndSet(int i, E expectedValue, E newValue) {
         return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
     }
 
     /**
+     * Possibly atomically sets the element at index {@code i} to
+     * {@code newValue} if the element's current value {@code == expectedValue},
+     * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+     *
+     * @param i the index
+     * @param expectedValue the expected value
+     * @param newValue the new value
+     * @return {@code true} if successful
+     * @since 9
+     */
+    public final boolean weakCompareAndSetPlain(int i, E expectedValue, E newValue) {
+        return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue);
+    }
+
+    /**
      * Atomically updates the element at index {@code i} with the results
      * of applying the given function, returning the previous value. The
      * function should be side-effect-free, since it may be re-applied
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/util/spi/ToolProvider.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,165 @@
+/*
+ * 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 java.util.spi;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.ServiceLoader;
+import java.util.stream.StreamSupport;
+
+/**
+ * An interface for command-line tools to provide a way to
+ * be invoked without necessarily starting a new VM.
+ *
+ * <p>Tool providers are normally located using the service-provider
+ * loading facility defined by {@link ServiceLoader}.
+ * Each provider must provide a name, and a method to run
+ * an instance of the corresponding tool. When a tool is run,
+ * it will be provided with an array of string arguments, and a
+ * pair of streams: one for normal (or expected) output and the other
+ * for reporting any errors that may occur.
+ * The interpretation of the string arguments will normally be defined by
+ * each individual tool provider, but will generally correspond to the
+ * arguments that could be provided to the tool when invoking the tool
+ * from the command line.
+ *
+ * @since 9
+ */
+public interface ToolProvider {
+    /**
+     * Returns the name of this tool provider.
+     *
+     * @apiNote It is recommended that the name be the same as would be used on
+     *      the command line: for example, "javac", "jar", "jlink".
+     *
+     * @return the name of this tool provider
+     */
+    String name();
+
+    /**
+     * Runs an instance of the tool, returning zero for a successful run.
+     * Any non-zero return value indicates a tool-specific error during the
+     * execution.
+     * Two streams should be provided, for "expected" output, and for any
+     * error messages. If it is not necessary to distinguish the output,
+     * the same stream may be used for both.
+     *
+     * @apiNote The interpretation of the arguments will be specific to
+     *      each tool.
+     *
+     * @param out a stream to which "expected" output should be written
+     *
+     * @param err a stream to which any error messages should be written
+     *
+     * @param args the command-line arguments for the tool
+     *
+     * @return the result of executing the tool.
+     *      A return value of 0 means the tool did not encounter any errors;
+     *      any other value indicates that at least one error occurred during
+     *      execution.
+     *
+     * @throws NullPointerException if any of the arguments are {@code null},
+     *      or if there are any {@code null} values in the {@code args} array
+     */
+    int run(PrintWriter out, PrintWriter err, String... args);
+
+    /**
+     * Runs an instance of the tool, returning zero for a successful run.
+     * Any non-zero return value indicates a tool-specific error during the
+     * execution.
+     * Two streams should be provided, for "expected" output, and for any
+     * error messages. If it is not necessary to distinguish the output,
+     * the same stream may be used for both.
+     *
+     * @apiNote The interpretation of the arguments will be specific to
+     *      each tool.
+     *
+     * @implNote This implementation wraps the {@code out} and {@code err}
+     *      streams within {@link PrintWriter}s, and then calls
+     *      {@link run(PrintWriter, PrintWriter, String[])}.
+     *
+     * @param out a stream to which "expected" output should be written
+     *
+     * @param err a stream to which any error messages should be written
+     *
+     * @param args the command-line arguments for the tool
+     *
+     * @return the result of executing the tool.
+     *      A return value of 0 means the tool did not encounter any errors;
+     *      any other value indicates that at least one error occurred during
+     *      execution.
+     *
+     * @throws NullPointerException if any of the arguments are {@code null},
+     *      or if there are any {@code null} values in the {@code args} array
+     */
+    default int run(PrintStream out, PrintStream err, String... args) {
+        Objects.requireNonNull(out);
+        Objects.requireNonNull(err);
+        for (String arg : args) {
+            Objects.requireNonNull(args);
+        }
+
+        PrintWriter outWriter = new PrintWriter(out);
+        PrintWriter errWriter = new PrintWriter(err);
+        try {
+            try {
+                return run(outWriter, errWriter, args);
+            } finally {
+                outWriter.flush();
+            }
+        } finally {
+            errWriter.flush();
+        }
+    }
+
+    /**
+     * Returns the first instance of a {@code ToolProvider} with the given name,
+     * as loaded by {@link ServiceLoader} using the system class loader.
+     *
+     * @param name the name of the desired tool provider
+     *
+     * @return an {@code Optional<ToolProvider>} of the first instance found
+     *
+     * @throws NullPointerException if {@code name} is {@code null}
+     */
+    static Optional<ToolProvider> findFirst(String name) {
+        Objects.requireNonNull(name);
+        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
+        return AccessController.doPrivileged(
+            (PrivilegedAction<Optional<ToolProvider>>) () -> {
+                ServiceLoader<ToolProvider> sl =
+                    ServiceLoader.load(ToolProvider.class, systemClassLoader);
+                return StreamSupport.stream(sl.spliterator(), false)
+                    .filter(p -> p.name().equals(name))
+                    .findFirst();
+            });
+    }
+}
+
--- a/jdk/src/java.base/share/classes/java/util/stream/Stream.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/stream/Stream.java	Tue Oct 18 17:14:09 2016 +0000
@@ -282,7 +282,7 @@
      */
     <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper);
 
-    /**
+    /**:
      * Returns an {@code IntStream} consisting of the results of replacing each
      * element of this stream with the contents of a mapped stream produced by
      * applying the provided mapping function to each element.  Each mapped
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/jmod/JmodFile.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,206 @@
+/*
+ * 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.internal.jmod;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.stream.Stream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * Helper class to read JMOD file
+ */
+public class JmodFile implements AutoCloseable {
+    // jmod magic number and version number
+    public static final int JMOD_MAJOR_VERSION = 0x01;
+    public static final int JMOD_MINOR_VERSION = 0x00;
+    public static final byte[] JMOD_MAGIC_NUMBER = {
+        0x4A, 0x4D, /* JM */
+        JMOD_MAJOR_VERSION, JMOD_MINOR_VERSION, /* version 1.0 */
+    };
+
+    public static void checkMagic(Path file) throws IOException {
+        try (InputStream in = Files.newInputStream(file);
+             BufferedInputStream bis = new BufferedInputStream(in)) {
+            // validate the header
+            byte[] magic = new byte[4];
+            bis.read(magic);
+            if (magic[0] != JMOD_MAGIC_NUMBER[0] ||
+                magic[1] != JMOD_MAGIC_NUMBER[1]) {
+                throw new IOException("Invalid jmod file: " + file.toString());
+            }
+            if (magic[2] > JMOD_MAJOR_VERSION ||
+                (magic[2] == JMOD_MAJOR_VERSION && magic[3] > JMOD_MINOR_VERSION)) {
+                throw new IOException("Unsupported jmod version: " +
+                    magic[2] + "." + magic[3] + " in " + file.toString());
+            }
+        }
+    }
+
+    /**
+     * JMOD sections
+     */
+    public static enum Section {
+        NATIVE_LIBS("native"),
+        NATIVE_CMDS("bin"),
+        CLASSES("classes"),
+        CONFIG("conf");
+
+        private final String jmodDir;
+        private Section(String jmodDir) {
+            this.jmodDir = jmodDir;
+        }
+
+        /**
+         * Returns the directory name in the JMOD file corresponding to
+         * this section
+         */
+        public String jmodDir() { return jmodDir; }
+
+    }
+
+    /**
+     * JMOD file entry.
+     *
+     * Each entry corresponds to a ZipEntry whose name is:
+     *   Section::jmodDir + '/' + name
+     */
+    public static class Entry {
+        private final ZipEntry zipEntry;
+        private final Section section;
+        private final String name;
+
+        private Entry(ZipEntry e) {
+            String name = e.getName();
+            int i = name.indexOf('/');
+            if (i <= 1) {
+                throw new RuntimeException("invalid jmod entry: " + name);
+            }
+
+            this.zipEntry = e;
+            this.section = section(name);
+            this.name = name.substring(i+1);
+        }
+
+        /**
+         * Returns the section of this entry.
+         */
+        public Section section() {
+            return section;
+        }
+
+        /**
+         * Returns the name of this entry.
+         */
+        public String name() {
+            return name;
+        }
+
+        /**
+         * Returns the size of this entry.
+         */
+        public long size() {
+            return zipEntry.getSize();
+        }
+
+        public ZipEntry zipEntry() {
+            return zipEntry;
+        }
+
+        @Override
+        public String toString() {
+            return section.jmodDir() + "/" + name;
+        }
+
+        static Section section(String name) {
+            int i = name.indexOf('/');
+            String s = name.substring(0, i);
+            switch (s) {
+                case "native":
+                    return Section.NATIVE_LIBS;
+                case "bin":
+                    return Section.NATIVE_CMDS;
+                case "classes":
+                    return Section.CLASSES;
+                case "conf":
+                    return Section.CONFIG;
+                default:
+                    throw new IllegalArgumentException("invalid section: " + s);
+            }
+        }
+    }
+
+    private final Path file;
+    private final ZipFile zipfile;
+
+    /**
+     * Constructs a {@code JmodFile} from a given path.
+     */
+    public JmodFile(Path file) throws IOException {
+        checkMagic(file);
+        this.file = file;
+        this.zipfile = new ZipFile(file.toFile());
+    }
+
+    /**
+     * Opens an {@code InputStream} for reading the named entry of the given
+     * section in this jmod file.
+     *
+     * @throws IOException if the named entry is not found, or I/O error
+     *         occurs when reading it
+     */
+    public InputStream getInputStream(Section section, String name)
+        throws IOException
+    {
+
+        String entry = section.jmodDir() + "/" + name;
+        ZipEntry e = zipfile.getEntry(entry);
+        if (e == null) {
+            throw new IOException(name + " not found: " + file);
+        }
+        return zipfile.getInputStream(e);
+    }
+
+    /**
+     * Returns a stream of non-directory entries in this jmod file.
+     */
+    public Stream<Entry> stream() {
+        return zipfile.stream()
+                      .filter(e -> !e.isDirectory())
+                      .map(Entry::new);
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (zipfile != null) {
+            zipfile.close();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaIOFilePermissionAccess.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,48 @@
+/*
+ * 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.internal.misc;
+
+import java.io.FilePermission;
+
+public interface JavaIOFilePermissionAccess {
+
+    /**
+     * Returns a new FilePermission plus an alternative path.
+     *
+     * @param input the input
+     * @return the new FilePermission plus the alt path (as npath2)
+     *         or the input itself if no alt path is available.
+     */
+    FilePermission newPermPlusAltPath(FilePermission input);
+
+    /**
+     * Returns a new FilePermission using an alternative path.
+     *
+     * @param input the input
+     * @return the new FilePermission using the alt path (as npath)
+     *         or null if no alt path is available
+     */
+    FilePermission newPermUsingAltPath(FilePermission input);
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java	Tue Oct 18 17:14:09 2016 +0000
@@ -29,6 +29,7 @@
 import java.util.jar.JarFile;
 import java.io.Console;
 import java.io.FileDescriptor;
+import java.io.FilePermission;
 import java.io.ObjectInputStream;
 import java.io.RandomAccessFile;
 import java.security.ProtectionDomain;
@@ -58,6 +59,7 @@
     private static JavaNetSocketAccess javaNetSocketAccess;
     private static JavaNioAccess javaNioAccess;
     private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
+    private static JavaIOFilePermissionAccess javaIOFilePermissionAccess;
     private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess;
     private static JavaSecurityAccess javaSecurityAccess;
     private static JavaUtilZipFileAccess javaUtilZipFileAccess;
@@ -201,6 +203,17 @@
         javaIOFileDescriptorAccess = jiofda;
     }
 
+    public static JavaIOFilePermissionAccess getJavaIOFilePermissionAccess() {
+        if (javaIOFilePermissionAccess == null)
+            unsafe.ensureClassInitialized(FilePermission.class);
+
+        return javaIOFilePermissionAccess;
+    }
+
+    public static void setJavaIOFilePermissionAccess(JavaIOFilePermissionAccess jiofpa) {
+        javaIOFilePermissionAccess = jiofpa;
+    }
+
     public static JavaIOFileDescriptorAccess getJavaIOFileDescriptorAccess() {
         if (javaIOFileDescriptorAccess == null)
             unsafe.ensureClassInitialized(FileDescriptor.class);
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Tue Oct 18 17:14:09 2016 +0000
@@ -430,22 +430,23 @@
             // the key is $MODULE
             String mn = e.getKey();
             Optional<Module> om = bootLayer.findModule(mn);
-            if (!om.isPresent())
-                fail("Unknown module: " + mn);
+            if (!om.isPresent()) {
+                warn("Unknown module: " + mn);
+                continue;
+            }
             Module m = om.get();
 
             // the value is the set of other modules (by name)
             for (String name : e.getValue()) {
-
-                Module other;
                 if (ALL_UNNAMED.equals(name)) {
                     Modules.addReadsAllUnnamed(m);
                 } else {
                     om = bootLayer.findModule(name);
-                    if (!om.isPresent())
-                        fail("Unknown module: " + name);
-                    other = om.get();
-                    Modules.addReads(m, other);
+                    if (om.isPresent()) {
+                        Modules.addReads(m, om.get());
+                    } else {
+                        warn("Unknown module: " + name);
+                    }
                 }
 
             }
@@ -472,14 +473,24 @@
 
             String mn = s[0];
             String pn = s[1];
+            if (mn.isEmpty() || pn.isEmpty())
+                fail("Module and package name must be specified:" + key);
 
             // The exporting module is in the boot layer
             Module m;
             Optional<Module> om = bootLayer.findModule(mn);
-            if (!om.isPresent())
-                fail("Unknown module: " + mn);
+            if (!om.isPresent()) {
+                warn("Unknown module: " + mn);
+                continue;
+            }
+
             m = om.get();
 
+            if (!m.getDescriptor().packages().contains(pn)) {
+                warn("package " + pn + " not in " + mn);
+                continue;
+            }
+
             // the value is the set of modules to export to (by name)
             for (String name : e.getValue()) {
                 boolean allUnnamed = false;
@@ -491,10 +502,10 @@
                     if (om.isPresent()) {
                         other = om.get();
                     } else {
-                        fail("Unknown module: " + name);
+                        warn("Unknown module: " + name);
+                        continue;
                     }
                 }
-
                 if (allUnnamed) {
                     Modules.addExportsToAllUnnamed(m, pn);
                 } else {
@@ -534,13 +545,7 @@
             if (rhs.isEmpty())
                 fail("Unable to parse: " + value);
 
-
-            // value is <module>(,<module>)*
-            if (map.containsKey(key))
-                 fail(key + " specified more than once");
-
-            Set<String> values = new HashSet<>();
-            map.put(key, values);
+            Set<String> values = map.computeIfAbsent(key, k -> new HashSet<>());
             for (String s : rhs.split(",")) {
                 if (s.length() > 0) values.add(s);
             }
@@ -566,6 +571,10 @@
         throw new RuntimeException(m);
     }
 
+    static void warn(String m) {
+        System.err.println("WARNING: " + m);
+    }
+
     static class PerfCounters {
 
         static PerfCounter systemModulesTime
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java	Tue Oct 18 17:14:09 2016 +0000
@@ -163,6 +163,16 @@
      * be discarded.
      */
     public void write(OutputStream out) throws IOException {
+        // emit to the output stream
+        out.write(toByteArray());
+    }
+
+    /**
+     * Returns the bytes of the modified module-info.class.
+     * Once this method has been called then the Extender object should
+     * be discarded.
+     */
+    public byte[] toByteArray() throws IOException {
         ClassWriter cw
             = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
 
@@ -197,8 +207,7 @@
         // add any attributes that didn't replace previous attributes
         cv.finish();
 
-        // emit to the output stream
-        out.write(cw.toByteArray());
+        return cw.toByteArray();
     }
 
     /**
--- a/jdk/src/java.base/share/classes/module-info.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -108,6 +108,7 @@
     uses java.util.spi.ResourceBundleControlProvider;
     uses java.util.spi.ResourceBundleProvider;
     uses java.util.spi.TimeZoneNameProvider;
+    uses java.util.spi.ToolProvider;
     uses javax.security.auth.spi.LoginModule;
 
 
@@ -124,6 +125,9 @@
         jdk.jlink;
     exports jdk.internal.jimage.decompressor to
         jdk.jlink;
+    exports jdk.internal.jmod to
+        jdk.compiler,
+        jdk.jlink;
     exports jdk.internal.logger to
         java.logging;
     exports jdk.internal.org.objectweb.asm to
--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/file/FileURLConnection.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/file/FileURLConnection.java	Tue Oct 18 17:14:09 2016 +0000
@@ -41,10 +41,6 @@
 import java.util.*;
 import java.text.SimpleDateFormat;
 
-import sun.security.action.GetPropertyAction;
-import sun.security.action.GetIntegerAction;
-import sun.security.action.GetBooleanAction;
-
 public class FileURLConnection extends URLConnection {
 
     static String CONTENT_LENGTH = "content-length";
@@ -224,8 +220,13 @@
             if (File.separatorChar == '/') {
                 permission = new FilePermission(decodedPath, "read");
             } else {
+                // decode could return /c:/x/y/z.
+                if (decodedPath.length() > 2 && decodedPath.charAt(0) == '/'
+                        && decodedPath.charAt(2) == ':') {
+                    decodedPath = decodedPath.substring(1);
+                }
                 permission = new FilePermission(
-                        decodedPath.replace('/',File.separatorChar), "read");
+                        decodedPath.replace('/', File.separatorChar), "read");
             }
         }
         return permission;
--- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java	Tue Oct 18 17:14:09 2016 +0000
@@ -45,11 +45,7 @@
 import jdk.internal.misc.JavaSecurityProtectionDomainAccess;
 import static jdk.internal.misc.JavaSecurityProtectionDomainAccess.ProtectionDomainCache;
 import jdk.internal.misc.SharedSecrets;
-import sun.security.util.PolicyUtil;
-import sun.security.util.PropertyExpander;
-import sun.security.util.Debug;
-import sun.security.util.ResourcesMgr;
-import sun.security.util.SecurityConstants;
+import sun.security.util.*;
 import sun.net.www.ParseUtil;
 
 /**
@@ -534,8 +530,6 @@
     /**
      * Reads a policy configuration into the Policy object using a
      * Reader object.
-     *
-     * @param policyFile the policy Reader object.
      */
     private boolean init(URL policy, PolicyInfo newInfo, boolean defPolicy) {
 
@@ -1099,7 +1093,7 @@
             synchronized (pc) {
                 Enumeration<Permission> e = pc.elements();
                 while (e.hasMoreElements()) {
-                    perms.add(e.nextElement());
+                    perms.add(FilePermCompat.newPermPlusAltPath(e.nextElement()));
                 }
             }
         }
@@ -1127,7 +1121,7 @@
      * object with additional permissions granted to the specified
      * ProtectionDomain.
      *
-     * @param perm the Permissions to populate
+     * @param perms the Permissions to populate
      * @param pd the ProtectionDomain associated with the caller.
      *
      * @return the set of Permissions according to the policy.
@@ -1157,8 +1151,8 @@
      * object with additional permissions granted to the specified
      * CodeSource.
      *
-     * @param permissions the permissions to populate
-     * @param codesource the codesource associated with the caller.
+     * @param perms the permissions to populate
+     * @param cs the codesource associated with the caller.
      * This encapsulates the original location of the code (where the code
      * came from) and the public key(s) of its signer.
      *
@@ -1386,7 +1380,7 @@
                         accPs,
                         perms);
             } else {
-                perms.add(p);
+                perms.add(FilePermCompat.newPermPlusAltPath(p));
             }
         }
     }
@@ -1458,9 +1452,9 @@
         }
         try {
             // first try to instantiate the permission
-            perms.add(getInstance(sp.getSelfType(),
+            perms.add(FilePermCompat.newPermPlusAltPath(getInstance(sp.getSelfType(),
                                   sb.toString(),
-                                  sp.getSelfActions()));
+                                  sp.getSelfActions())));
         } catch (ClassNotFoundException cnfe) {
             // ok, the permission is not in the bootclasspath.
             // before we add an UnresolvedPermission, check to see
--- a/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -182,14 +182,15 @@
     }
 
     // verify the data and return the result. See JCA doc
+    // should be reset to the state after engineInitVerify call.
     protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
-        if (sigBytes.length != RSACore.getByteLength(publicKey)) {
-            throw new SignatureException("Signature length not correct: got " +
+        try {
+            if (sigBytes.length != RSACore.getByteLength(publicKey)) {
+                throw new SignatureException("Signature length not correct: got " +
                     sigBytes.length + " but was expecting " +
                     RSACore.getByteLength(publicKey));
-        }
-        byte[] digest = getDigestValue();
-        try {
+            }
+            byte[] digest = getDigestValue();
             byte[] decrypted = RSACore.rsa(sigBytes, publicKey);
             byte[] unpadded = padding.unpad(decrypted);
             byte[] decodedDigest = decodeSignature(digestOID, unpadded);
@@ -202,6 +203,8 @@
             return false;
         } catch (IOException e) {
             throw new SignatureException("Signature encoding error", e);
+        } finally {
+            resetDigest();
         }
     }
 
--- a/jdk/src/java.base/share/classes/sun/security/util/AnchorCertificates.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/AnchorCertificates.java	Tue Oct 18 17:14:09 2016 +0000
@@ -31,8 +31,10 @@
 import java.security.KeyStore;
 import java.security.PrivilegedAction;
 import java.security.cert.X509Certificate;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
+import java.util.Set;
 
 import sun.security.x509.X509CertImpl;
 
@@ -44,7 +46,7 @@
 
     private static final Debug debug = Debug.getInstance("certpath");
     private static final String HASH = "SHA-256";
-    private static HashSet<String> certs;
+    private static Set<String> certs = Collections.emptySet();
 
     static  {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
--- a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java	Tue Oct 18 17:14:09 2016 +0000
@@ -543,7 +543,7 @@
      private static class DenyAfterConstraint extends Constraint {
          private Date denyAfterDate;
          private static final SimpleDateFormat dateFormat =
-                 new SimpleDateFormat("EEE, MMM d HH:mm:ss z YYYY");
+                 new SimpleDateFormat("EEE, MMM d HH:mm:ss z yyyy");
 
          DenyAfterConstraint(String algo, int year, int month, int day) {
              Calendar c;
@@ -593,13 +593,17 @@
          public void permits(CertConstraintParameters cp)
                  throws CertPathValidatorException {
              Date currentDate;
+             String errmsg;
 
              if (cp.getJARTimestamp() != null) {
                  currentDate = cp.getJARTimestamp().getTimestamp();
+                 errmsg = "JAR Timestamp date: ";
              } else if (cp.getPKIXParamDate() != null) {
                  currentDate = cp.getPKIXParamDate();
+                 errmsg = "PKIXParameter date: ";
              } else {
                  currentDate = new Date();
+                 errmsg = "Certificate date: ";
              }
 
              if (!denyAfterDate.after(currentDate)) {
@@ -609,10 +613,9 @@
                  throw new CertPathValidatorException(
                          "denyAfter constraint check failed.  " +
                                  "Constraint date: " +
-                                 dateFormat.format(denyAfterDate) +
-                                 "; Cert date: " +
-                                 dateFormat.format(currentDate),
-                          null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+                                 dateFormat.format(denyAfterDate) + "; "
+                                 + errmsg + dateFormat.format(currentDate),
+                         null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
              }
          }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/FilePermCompat.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,77 @@
+/*
+ * 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 sun.security.action.GetPropertyAction;
+
+import java.io.FilePermission;
+import java.security.Permission;
+import jdk.internal.misc.SharedSecrets;
+
+/**
+ * Take care of FilePermission compatibility after JDK-8164705.
+ */
+public class FilePermCompat {
+    /**
+     * New behavior? Keep compatibility? Both default true.
+     */
+    public static final boolean nb;
+    public static final boolean compat;
+
+    static {
+        String flag = GetPropertyAction.privilegedGetProperty(
+                "jdk.io.permissionsUseCanonicalPath", "false");
+        switch (flag) {
+            case "true":
+                nb = false;
+                compat = false;
+                break;
+            case "false":
+                nb = true;
+                compat = true;
+                break;
+            default:
+                throw new RuntimeException(
+                        "Invalid jdk.io.permissionsUseCanonicalPath: " + flag);
+        }
+    }
+
+    public static Permission newPermPlusAltPath(Permission input) {
+        if (compat && input instanceof FilePermission) {
+            return SharedSecrets.getJavaIOFilePermissionAccess()
+                    .newPermPlusAltPath((FilePermission) input);
+        }
+        return input;
+    }
+
+    public static Permission newPermUsingAltPath(Permission input) {
+        if (input instanceof FilePermission) {
+            return SharedSecrets.getJavaIOFilePermissionAccess()
+                    .newPermUsingAltPath((FilePermission) input);
+        }
+        return null;
+    }
+}
--- a/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java	Tue Oct 18 17:14:09 2016 +0000
@@ -188,6 +188,9 @@
         String MHT[] = new String[] {"Marshall Islands Time", "MHT",
                                      "Marshall Islands Summer Time", "MHST",
                                      "Marshall Islands Time", "MHT"};
+        String MMT[] = new String[] {"Myanmar Time", "MMT",
+                                     "Myanmar Summer Time", "MMST",
+                                     "Myanmar Time", "MMT"};
         String MSK[] = new String[] {"Moscow Standard Time", "MSK",
                                      "Moscow Daylight Time", "MSD",
                                      "Moscow Time", "MT"};
@@ -683,9 +686,7 @@
             {"Asia/Qyzylorda", new String[] {"Qyzylorda Time", "QYZT",
                                              "Qyzylorda Summer Time", "QYZST",
                                              "Qyzylorda Time", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"Myanmar Time", "MMT",
-                                           "Myanmar Summer Time", "MMST",
-                                           "Myanmar Time", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"Sakhalin Time", "SAKT",
@@ -718,6 +719,7 @@
                                                "Vladivostok Summer Time", "VLAST",
                                                "Vladivostok Time", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"Yekaterinburg Time", "YEKT",
                                                  "Yekaterinburg Summer Time", "YEKST",
                                                  "Yekaterinburg Time", "YEKT"}},
--- a/jdk/src/java.base/share/conf/security/java.policy	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/conf/security/java.policy	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,18 @@
+//
+// This system policy file grants a set of default permissions to all domains
+// and can be configured to grant additional permissions to modules and other
+// code sources. The code source URL scheme for modules linked into a
+// run-time image is "jrt".
+//
+// For example, to grant permission to read the "foo" property to the module
+// "com.greetings", the grant entry is:
+//
+// grant codeBase "jrt:/com.greetings" {
+//     permission java.util.PropertyPermission "foo", "read";
+// };
+//
+
 // default permissions granted to all domains
-
 grant {
     // allows anyone to listen on dynamic ports
     permission java.net.SocketPermission "localhost:0", "listen";
--- a/jdk/src/java.base/share/conf/security/java.security	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/conf/security/java.security	Tue Oct 18 17:14:09 2016 +0000
@@ -894,3 +894,44 @@
     disallowReferenceUriSchemes file http https,\
     noDuplicateIds,\
     noRetrievalMethodLoops
+
+#
+# Serialization process-wide filter
+#
+# A filter, if configured, is used by java.io.ObjectInputStream during
+# deserialization to check the contents of the stream.
+# A filter is configured as a sequence of patterns, each pattern is either
+# matched against the name of a class in the stream or defines a limit.
+# Patterns are separated by ";" (semicolon).
+# Whitespace is significant and is considered part of the pattern.
+#
+# If a pattern includes a "=", it sets a limit.
+# If a limit appears more than once the last value is used.
+# Limits are checked before classes regardless of the order in the sequence of patterns.
+# If any of the limits are exceeded, the filter status is REJECTED.
+#
+#   maxdepth=value - the maximum depth of a graph
+#   maxrefs=value  - the maximum number of internal references
+#   maxbytes=value - the maximum number of bytes in the input stream
+#   maxarray=value - the maximum array length allowed
+#
+# Other patterns, from left to right, match the class or package name as
+# returned from Class.getName.
+# If the class is an array type, the class or package to be matched is the element type.
+# Arrays of any number of dimensions are treated the same as the element type.
+# For example, a pattern of "!example.Foo", rejects creation of any instance or
+# array of example.Foo.
+#
+# If the pattern starts with "!", the status is REJECTED if the remaining pattern
+#   is matched; otherwise the status is ALLOWED if the pattern matches.
+# If the pattern contains "/", the non-empty prefix up to the "/" is the module name;
+#   if the module name matches the module name of the class then
+#   the remaining pattern is matched with the class name.
+#   If there is no "/", the module name is not compared.
+# If the pattern ends with ".**" it matches any class in the package and all subpackages.
+# If the pattern ends with ".*" it matches any class in the package.
+# If the pattern ends with "*", it matches any class with the pattern as a prefix.
+# If the pattern is equal to the class name, it matches.
+# Otherwise, the status is UNDECIDED.
+#
+#jdk.serialFilter=pattern;pattern
--- a/jdk/src/java.base/share/native/libnet/net_util.h	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/native/libnet/net_util.h	Tue Oct 18 17:14:09 2016 +0000
@@ -42,6 +42,10 @@
 #define NET_ERROR(env, ex, msg) \
 { if (!(*env)->ExceptionOccurred(env)) JNU_ThrowByName(env, ex, msg); }
 
+#define NET_WAIT_READ    0x01
+#define NET_WAIT_WRITE   0x02
+#define NET_WAIT_CONNECT 0x04
+
 /************************************************************************
  * Cached field IDs
  *
@@ -133,9 +137,6 @@
 
 JNIEXPORT jint JNICALL reuseport_available() ;
 
-void
-NET_AllocSockaddr(struct sockaddr **him, int *len);
-
 JNIEXPORT int JNICALL
 NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr *him, int *len, jboolean v4MappedAddress);
 
@@ -196,4 +197,6 @@
 
 unsigned short in_cksum(unsigned short *addr, int len);
 
+jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
+
 #endif /* NET_UTILS_H */
--- a/jdk/src/java.base/share/native/libzip/zip_util.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/native/libzip/zip_util.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1094,7 +1094,7 @@
  * jzentry for each zip.  This optimizes a common access pattern.
  */
 
-void
+void JNICALL
 ZIP_FreeEntry(jzfile *jz, jzentry *ze)
 {
     jzentry *last;
--- a/jdk/src/java.base/share/native/libzip/zip_util.h	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/share/native/libzip/zip_util.h	Tue Oct 18 17:14:09 2016 +0000
@@ -270,7 +270,8 @@
 void ZIP_Lock(jzfile *zip);
 void ZIP_Unlock(jzfile *zip);
 jint ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len);
-void ZIP_FreeEntry(jzfile *zip, jzentry *ze);
+void JNICALL
+ZIP_FreeEntry(jzfile *zip, jzentry *ze);
 jlong ZIP_GetEntryDataOffset(jzfile *zip, jzentry *entry);
 jzentry * ZIP_GetEntry2(jzfile *zip, char *name, jint ulen, jboolean addSlash);
 
--- a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixDirectoryStream.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixDirectoryStream.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -116,7 +116,7 @@
         synchronized (this) {
             if (iterator != null)
                 throw new IllegalStateException("Iterator already obtained");
-            iterator = new UnixDirectoryIterator(ds);
+            iterator = new UnixDirectoryIterator();
             return iterator;
         }
     }
@@ -130,17 +130,14 @@
      * Iterator implementation
      */
     private class UnixDirectoryIterator implements Iterator<Path> {
-        private final DirectoryStream<Path> stream;
-
         // true when at EOF
         private boolean atEof;
 
         // next entry to return
         private Path nextEntry;
 
-        UnixDirectoryIterator(DirectoryStream<Path> stream) {
+        UnixDirectoryIterator() {
             atEof = false;
-            this.stream = stream;
         }
 
         // Return true if file name is "." or ".."
--- a/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -788,9 +788,9 @@
         case ENETUNREACH: /* Network Unreachable */
         case EAFNOSUPPORT: /* Address Family not supported */
         case EADDRNOTAVAIL: /* address is not available on  the  remote machine */
-#ifdef __linux__
+#if defined(__linux__) || defined(_AIX)
         case EINVAL:
-        case EHOSTUNREACH:
+        case EHOSTUNREACH: /* No route to host */
           /*
            * On some Linux versions, when a socket is bound to the loopback
            * interface, connect will fail and errno will be set to EINVAL
--- a/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -775,9 +775,9 @@
         case ENETUNREACH: /* Network Unreachable */
         case EAFNOSUPPORT: /* Address Family not supported */
         case EADDRNOTAVAIL: /* address is not available on  the  remote machine */
-#ifdef __linux__
+#if defined(__linux__) || defined(_AIX)
         case EINVAL:
-        case EHOSTUNREACH:
+        case EHOSTUNREACH: /* No route to host */
           /*
            * On some Linux versions, when  a socket is bound to the
            * loopback interface, connect will fail and errno will
@@ -804,7 +804,7 @@
                          &optlen) <0) {
             connect_rv = errno;
           }
-          if (connect_rv == 0 || ECONNREFUSED) {
+          if (connect_rv == 0 || connect_rv == ECONNREFUSED) {
             close(fd);
             return JNI_TRUE;
           }
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -193,8 +193,8 @@
     /* fd is an int field on fdObj */
     int fd;
     int len = 0;
-    SOCKADDR him;
-    socklen_t slen = sizeof(him);
+    SOCKETADDRESS him;
+    socklen_t slen = sizeof(SOCKETADDRESS);
 
     if (IS_NULL(fdObj)) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -210,12 +210,12 @@
     }
 
     /* bind */
-    if (NET_InetAddressToSockaddr(env, iaObj, localport, (struct sockaddr *)&him, &len, JNI_TRUE) != 0) {
+    if (NET_InetAddressToSockaddr(env, iaObj, localport, &him.sa, &len, JNI_TRUE) != 0) {
       return;
     }
-    setDefaultScopeID(env, (struct sockaddr *)&him);
+    setDefaultScopeID(env, &him.sa);
 
-    if (NET_Bind(fd, (struct sockaddr *)&him, len) < 0)  {
+    if (NET_Bind(fd, &him.sa, len) < 0)  {
         if (errno == EADDRINUSE || errno == EADDRNOTAVAIL ||
             errno == EPERM || errno == EACCES) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
@@ -232,13 +232,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, (struct sockaddr *)&him, &slen) == -1) {
+        if (getsockname(fd, &him.sa, &slen) == -1) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return;
         }
 
-        localport = NET_GetPortFromSockaddr((struct sockaddr *)&him);
+        localport = NET_GetPortFromSockaddr(&him.sa);
 
         (*env)->SetIntField(env, this, pdsi_localPortID, localport);
     } else {
@@ -259,7 +259,7 @@
     /* The fdObj'fd */
     jint fd;
     /* The packetAddress address, family and port */
-    SOCKADDR rmtaddr;
+    SOCKETADDRESS rmtaddr;
     int len = 0;
 
     if (IS_NULL(fdObj)) {
@@ -274,18 +274,16 @@
         return;
     }
 
-    if (NET_InetAddressToSockaddr(env, address, port, (struct sockaddr *)&rmtaddr, &len, JNI_TRUE) != 0) {
+    if (NET_InetAddressToSockaddr(env, address, port, &rmtaddr.sa, &len, JNI_TRUE) != 0) {
       return;
     }
 
-    setDefaultScopeID(env, (struct sockaddr *)&rmtaddr);
+    setDefaultScopeID(env, &rmtaddr.sa);
 
-    if (NET_Connect(fd, (struct sockaddr *)&rmtaddr, len) == -1) {
+    if (NET_Connect(fd, &rmtaddr.sa, len) == -1) {
         NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
                         "Connect failed");
-        return;
     }
-
 }
 
 /*
@@ -301,7 +299,7 @@
     jint fd;
 
 #if defined(__linux__) || defined(_ALLBSD_SOURCE)
-    SOCKADDR addr;
+    SOCKETADDRESS addr;
     socklen_t len;
 #endif
 
@@ -314,36 +312,34 @@
         memset(&addr, 0, sizeof(addr));
 #ifdef AF_INET6
         if (ipv6_available()) {
-            struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)&addr;
-            him6->sin6_family = AF_UNSPEC;
+            addr.sa6.sin6_family = AF_UNSPEC;
             len = sizeof(struct sockaddr_in6);
         } else
 #endif
         {
-            struct sockaddr_in *him4 = (struct sockaddr_in*)&addr;
-            him4->sin_family = AF_UNSPEC;
+            addr.sa4.sin_family = AF_UNSPEC;
             len = sizeof(struct sockaddr_in);
         }
-        NET_Connect(fd, (struct sockaddr *)&addr, len);
+        NET_Connect(fd, &addr.sa, len);
 
 #ifdef __linux__
         int localPort = 0;
-        if (getsockname(fd, (struct sockaddr *)&addr, &len) == -1)
+        if (getsockname(fd, &addr.sa, &len) == -1)
             return;
 
-        localPort = NET_GetPortFromSockaddr((struct sockaddr *)&addr);
+        localPort = NET_GetPortFromSockaddr(&addr.sa);
         if (localPort == 0) {
             localPort = (*env)->GetIntField(env, this, pdsi_localPortID);
 #ifdef AF_INET6
-            if (((struct sockaddr*)&addr)->sa_family == AF_INET6) {
-                ((struct sockaddr_in6*)&addr)->sin6_port = htons(localPort);
+            if (addr.sa.sa_family == AF_INET6) {
+                addr.sa6.sin6_port = htons(localPort);
             } else
 #endif /* AF_INET6 */
             {
-                ((struct sockaddr_in*)&addr)->sin_port = htons(localPort);
+                addr.sa4.sin_port = htons(localPort);
             }
 
-            NET_Bind(fd, (struct sockaddr *)&addr, len);
+            NET_Bind(fd, &addr.sa, len);
         }
 
 #endif
@@ -376,7 +372,7 @@
     /* The fdObj'fd */
     jint fd;
 
-    SOCKADDR rmtaddr, *rmtaddrP=&rmtaddr;
+    SOCKETADDRESS rmtaddr, *rmtaddrP = &rmtaddr;
     int len;
 
     if (IS_NULL(fdObj)) {
@@ -409,11 +405,11 @@
         rmtaddrP = 0;
     } else {
         packetPort = (*env)->GetIntField(env, packet, dp_portID);
-        if (NET_InetAddressToSockaddr(env, packetAddress, packetPort, (struct sockaddr *)&rmtaddr, &len, JNI_TRUE) != 0) {
-          return;
+        if (NET_InetAddressToSockaddr(env, packetAddress, packetPort, &rmtaddr.sa, &len, JNI_TRUE) != 0) {
+            return;
         }
     }
-    setDefaultScopeID(env, (struct sockaddr *)&rmtaddr);
+    setDefaultScopeID(env, &rmtaddr.sa);
 
     if (packetBufferLen > MAX_BUFFER_LEN) {
         /* When JNI-ifying the JDK's IO routines, we turned
@@ -449,7 +445,7 @@
                                (jbyte *)fullPacket);
 #ifdef AF_INET6
     if (trafficClass != 0 && ipv6_available()) {
-        NET_SetTrafficClass((struct sockaddr *)&rmtaddr, trafficClass);
+        NET_SetTrafficClass(&rmtaddr.sa, trafficClass);
     }
 #endif /* AF_INET6 */
 
@@ -492,8 +488,8 @@
     jint timeout = (*env)->GetIntField(env, this, pdsi_timeoutID);
     jint fd;
     ssize_t n;
-    SOCKADDR remote_addr;
-    socklen_t slen = SOCKADDR_LEN;
+    SOCKETADDRESS rmtaddr;
+    socklen_t slen = sizeof(SOCKETADDRESS);
     char buf[1];
     jint family;
     jobject iaObj;
@@ -527,7 +523,7 @@
         }
     }
 
-    n = NET_RecvFrom(fd, buf, 1, MSG_PEEK, (struct sockaddr *)&remote_addr, &slen);
+    n = NET_RecvFrom(fd, buf, 1, MSG_PEEK, &rmtaddr.sa, &slen);
 
     if (n == -1) {
 
@@ -552,7 +548,7 @@
         return 0;
     }
 
-    iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&remote_addr, &port);
+    iaObj = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port);
 #ifdef AF_INET6
     family = getInetAddress_family(env, iaObj) == IPv4? AF_INET : AF_INET6;
 #else
@@ -574,16 +570,13 @@
     int mallocedPacket = JNI_FALSE;
     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
     jint timeout = (*env)->GetIntField(env, this, pdsi_timeoutID);
-
     jbyteArray packetBuffer;
     jint packetBufferOffset, packetBufferLen;
-
     int fd;
-
     int n;
-    SOCKADDR remote_addr;
-    socklen_t slen = SOCKADDR_LEN;
-    int port;
+    SOCKETADDRESS rmtaddr;
+    socklen_t slen = sizeof(SOCKETADDRESS);
+    int port = -1;
 
     if (IS_NULL(fdObj)) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -661,7 +654,7 @@
     }
 
     n = NET_RecvFrom(fd, fullPacket, packetBufferLen, MSG_PEEK,
-                     (struct sockaddr *)&remote_addr, &slen);
+                     &rmtaddr.sa, &slen);
     /* truncate the data if the packet's length is too small */
     if (n > packetBufferLen) {
         n = packetBufferLen;
@@ -706,18 +699,18 @@
          */
         packetAddress = (*env)->GetObjectField(env, packet, dp_addressID);
         if (packetAddress != NULL) {
-            if (!NET_SockaddrEqualsInetAddress(env, (struct sockaddr *)&remote_addr, packetAddress)) {
+            if (!NET_SockaddrEqualsInetAddress(env, &rmtaddr.sa, packetAddress)) {
                 /* force a new InetAddress to be created */
                 packetAddress = NULL;
             }
         }
         if (packetAddress == NULL) {
-            packetAddress = NET_SockaddrToInetAddress(env, (struct sockaddr *)&remote_addr, &port);
+            packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &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((struct sockaddr *)&remote_addr);
+            port = NET_GetPortFromSockaddr(&rmtaddr.sa);
         }
         /* and fill in the data, remote address/port and such */
         (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n,
@@ -753,8 +746,8 @@
     int fd;
 
     int n;
-    SOCKADDR remote_addr;
-    socklen_t slen = SOCKADDR_LEN;
+    SOCKETADDRESS rmtaddr;
+    socklen_t slen = sizeof(SOCKETADDRESS);
     jboolean retry;
 #ifdef __linux__
     jboolean connected = JNI_FALSE;
@@ -849,7 +842,7 @@
         }
 
         n = NET_RecvFrom(fd, fullPacket, packetBufferLen, 0,
-                         (struct sockaddr *)&remote_addr, &slen);
+                         &rmtaddr.sa, &slen);
         /* truncate the data if the packet's length is too small */
         if (n > packetBufferLen) {
             n = packetBufferLen;
@@ -887,18 +880,18 @@
              */
             packetAddress = (*env)->GetObjectField(env, packet, dp_addressID);
             if (packetAddress != NULL) {
-                if (!NET_SockaddrEqualsInetAddress(env, (struct sockaddr *)&remote_addr, packetAddress)) {
+                if (!NET_SockaddrEqualsInetAddress(env, &rmtaddr.sa, packetAddress)) {
                     /* force a new InetAddress to be created */
                     packetAddress = NULL;
                 }
             }
             if (packetAddress == NULL) {
-                packetAddress = NET_SockaddrToInetAddress(env, (struct sockaddr *)&remote_addr, &port);
+                packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &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((struct sockaddr *)&remote_addr);
+                port = NET_GetPortFromSockaddr(&rmtaddr.sa);
             }
             /* and fill in the data, remote address/port and such */
             (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n,
@@ -1302,7 +1295,7 @@
  * Sets the multicast loopback mode.
  */
 static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd,
-                                  jint opt, jobject value) {
+                                     jint opt, jobject value) {
 #ifdef AF_INET6
 #ifdef __linux__
     mcast_set_loop_v4(env, this, fd, value);
@@ -1330,10 +1323,9 @@
  * Signature: (ILjava/lang/Object;)V
  */
 JNIEXPORT void JNICALL
-Java_java_net_PlainDatagramSocketImpl_socketSetOption0(JNIEnv *env,
-                                                      jobject this,
-                                                      jint opt,
-                                                      jobject value) {
+Java_java_net_PlainDatagramSocketImpl_socketSetOption0
+  (JNIEnv *env, jobject this, jint opt, jobject value)
+{
     int fd;
     int level, optname, optlen;
     int optval;
@@ -1380,7 +1372,7 @@
      * level and option name.
      */
     if (NET_MapSocketOption(opt, &level, &optname)) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return;
     }
 
@@ -1699,8 +1691,9 @@
  * Signature: (I)Ljava/lang/Object;
  */
 JNIEXPORT jobject JNICALL
-Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this,
-                                                      jint opt) {
+Java_java_net_PlainDatagramSocketImpl_socketGetOption
+  (JNIEnv *env, jobject this, jint opt)
+{
     int fd;
     int level, optname, optlen;
     union {
@@ -1729,19 +1722,17 @@
      */
     if (opt == java_net_SocketOptions_SO_BINDADDR) {
         /* find out local IP address */
-        SOCKADDR him;
-        socklen_t len = 0;
+        SOCKETADDRESS him;
+        socklen_t len = sizeof(SOCKETADDRESS);
         int port;
         jobject iaObj;
 
-        len = SOCKADDR_LEN;
-
-        if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
+        if (getsockname(fd, &him.sa, &len) == -1) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return NULL;
         }
-        iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
+        iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port);
 
         return iaObj;
     }
@@ -1751,7 +1742,7 @@
      * level and option name.
      */
     if (NET_MapSocketOption(opt, &level, &optname)) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return NULL;
     }
 
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -274,7 +274,7 @@
     /* fd is an int field on iaObj */
     jint fd;
 
-    SOCKADDR him;
+    SOCKETADDRESS him;
     /* The result of the connection */
     int connect_rv = -1;
 
@@ -290,18 +290,18 @@
     }
 
     /* connect */
-    if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&him, &len, JNI_TRUE) != 0) {
-      return;
+    if (NET_InetAddressToSockaddr(env, iaObj, port, &him.sa, &len, JNI_TRUE) != 0) {
+        return;
     }
-    setDefaultScopeID(env, (struct sockaddr *)&him);
+    setDefaultScopeID(env, &him.sa);
 
 #ifdef AF_INET6
     if (trafficClass != 0 && ipv6_available()) {
-        NET_SetTrafficClass((struct sockaddr *)&him, trafficClass);
+        NET_SetTrafficClass(&him.sa, trafficClass);
     }
 #endif /* AF_INET6 */
     if (timeout <= 0) {
-        connect_rv = NET_Connect(fd, (struct sockaddr *)&him, len);
+        connect_rv = NET_Connect(fd, &him.sa, len);
 #ifdef __solaris__
         if (connect_rv == -1 && errno == EINPROGRESS ) {
 
@@ -350,7 +350,7 @@
         SET_NONBLOCKING(fd);
 
         /* no need to use NET_Connect as non-blocking */
-        connect_rv = connect(fd, (struct sockaddr *)&him, len);
+        connect_rv = connect(fd, &him.sa, len);
 
         /* connection not established immediately */
         if (connect_rv != 0) {
@@ -497,12 +497,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.
          */
-        socklen_t slen = SOCKADDR_LEN;
-        if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
+        socklen_t slen = sizeof(SOCKETADDRESS);
+        if (getsockname(fd, &him.sa, &slen) == -1) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
         } else {
-            localport = NET_GetPortFromSockaddr((struct sockaddr *)&him);
+            localport = NET_GetPortFromSockaddr(&him.sa);
             (*env)->SetIntField(env, this, psi_localportID, localport);
         }
     }
@@ -522,7 +522,7 @@
     /* fd is an int field on fdObj */
     int fd;
     int len;
-    SOCKADDR him;
+    SOCKETADDRESS him;
 
     if (IS_NULL(fdObj)) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -537,13 +537,13 @@
     }
 
     /* bind */
-    if (NET_InetAddressToSockaddr(env, iaObj, localport, (struct sockaddr *)&him,
+    if (NET_InetAddressToSockaddr(env, iaObj, localport, &him.sa,
                                   &len, JNI_TRUE) != 0) {
         return;
     }
-    setDefaultScopeID(env, (struct sockaddr *)&him);
+    setDefaultScopeID(env, &him.sa);
 
-    if (NET_Bind(fd, (struct sockaddr *)&him, len) < 0) {
+    if (NET_Bind(fd, &him.sa, len) < 0) {
         if (errno == EADDRINUSE || errno == EADDRNOTAVAIL ||
             errno == EPERM || errno == EACCES) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
@@ -560,16 +560,16 @@
 
     /* initialize the local port */
     if (localport == 0) {
-        socklen_t slen = sizeof(him);
+        socklen_t slen = sizeof(SOCKETADDRESS);
         /* 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, (struct sockaddr *)&him, &slen) == -1) {
+        if (getsockname(fd, &him.sa, &slen) == -1) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return;
         }
-        localport = NET_GetPortFromSockaddr((struct sockaddr *)&him);
+        localport = NET_GetPortFromSockaddr(&him.sa);
         (*env)->SetIntField(env, this, psi_localportID, localport);
     } else {
         (*env)->SetIntField(env, this, psi_localportID, localport);
@@ -637,8 +637,8 @@
     /* accepted fd */
     jint newfd;
 
-    SOCKADDR him;
-    socklen_t slen = SOCKADDR_LEN;
+    SOCKETADDRESS him;
+    socklen_t slen = sizeof(SOCKETADDRESS);
 
     if (IS_NULL(fdObj)) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -692,7 +692,7 @@
             return;
         }
 
-        newfd = NET_Accept(fd, (struct sockaddr *)&him, &slen);
+        newfd = NET_Accept(fd, &him.sa, &slen);
 
         /* connection accepted */
         if (newfd >= 0) {
@@ -740,7 +740,7 @@
     /*
      * fill up the remote peer port and address in the new socket structure.
      */
-    socketAddressObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
+    socketAddressObj = NET_SockaddrToInetAddress(env, &him.sa, &port);
     if (socketAddressObj == NULL) {
         /* should be pending exception */
         close(newfd);
@@ -855,9 +855,9 @@
  * Signature: (IZLjava/lang/Object;)V
  */
 JNIEXPORT void JNICALL
-Java_java_net_PlainSocketImpl_socketSetOption0(JNIEnv *env, jobject this,
-                                              jint cmd, jboolean on,
-                                              jobject value) {
+Java_java_net_PlainSocketImpl_socketSetOption0
+  (JNIEnv *env, jobject this, jint cmd, jboolean on, jobject value)
+{
     int fd;
     int level, optname, optlen;
     union {
@@ -887,7 +887,7 @@
      * level and option name.
      */
     if (NET_MapSocketOption(cmd, &level, &optname)) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return;
     }
 
@@ -951,9 +951,9 @@
  * Signature: (I)I
  */
 JNIEXPORT jint JNICALL
-Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this,
-                                              jint cmd, jobject iaContainerObj) {
-
+Java_java_net_PlainSocketImpl_socketGetOption
+  (JNIEnv *env, jobject this, jint cmd, jobject iaContainerObj)
+{
     int fd;
     int level, optname, optlen;
     union {
@@ -975,21 +975,19 @@
      * SO_BINDADDR isn't a socket option
      */
     if (cmd == java_net_SocketOptions_SO_BINDADDR) {
-        SOCKADDR him;
-        socklen_t len = 0;
+        SOCKETADDRESS him;
+        socklen_t len = sizeof(SOCKETADDRESS);
         int port;
         jobject iaObj;
         jclass iaCntrClass;
         jfieldID iaFieldID;
 
-        len = SOCKADDR_LEN;
-
-        if (getsockname(fd, (struct sockaddr *)&him, &len) < 0) {
+        if (getsockname(fd, &him.sa, &len) < 0) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return -1;
         }
-        iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
+        iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port);
         CHECK_NULL_RETURN(iaObj, -1);
 
         iaCntrClass = (*env)->GetObjectClass(env, iaContainerObj);
@@ -1004,7 +1002,7 @@
      * level and option name.
      */
     if (NET_MapSocketOption(cmd, &level, &optname)) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return -1;
     }
 
--- a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c	Tue Oct 18 17:14:09 2016 +0000
@@ -58,15 +58,15 @@
         result = NET_TimeoutWithCurrentTime(fd, timeout, prevtime);
         if (result <= 0) {
             if (result == 0) {
-                JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", "Read timed out");
+                JNU_ThrowByName(env, "java/net/SocketTimeoutException", "Read timed out");
             } else if (result == -1) {
                 if (errno == EBADF) {
-                    JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+                    JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
                 } else if (errno == ENOMEM) {
                     JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
                 } else {
                     JNU_ThrowByNameWithMessageAndLastError
-                            (env, JNU_JAVANETPKG "SocketException", "select/poll failed");
+                            (env, "java/net/SocketException", "select/poll failed");
                 }
             }
             return -1;
@@ -100,19 +100,14 @@
     jint fd, nread;
 
     if (IS_NULL(fdObj)) {
-        /* shouldn't this be a NullPointerException? -br */
-        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
+        JNU_ThrowByName(env, "java/net/SocketException",
                         "Socket closed");
         return -1;
-    } else {
-        fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
-        /* Bug 4086704 - If the Socket associated with this file descriptor
-         * was closed (sysCloseFD), then the file descriptor is set to -1.
-         */
-        if (fd == -1) {
-            JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
-            return -1;
-        }
+    }
+    fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
+    if (fd == -1) {
+        JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
+        return -1;
     }
 
     /*
@@ -154,17 +149,17 @@
                     break;
 
                 case EBADF:
-                    JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
+                    JNU_ThrowByName(env, "java/net/SocketException",
                         "Socket closed");
                     break;
 
                 case EINTR:
-                     JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
+                     JNU_ThrowByName(env, "java/io/InterruptedIOException",
                            "Operation interrupted");
                      break;
                 default:
                     JNU_ThrowByNameWithMessageAndLastError
-                        (env, JNU_JAVANETPKG "SocketException", "Read failed");
+                        (env, "java/net/SocketException", "Read failed");
             }
         }
     } else {
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c	Tue Oct 18 17:14:09 2016 +0000
@@ -334,8 +334,8 @@
 #ifdef AF_INET6
     int fd;
     void *ipv6_fn;
-    SOCKADDR sa;
-    socklen_t sa_len = sizeof(sa);
+    SOCKETADDRESS sa;
+    socklen_t sa_len = sizeof(SOCKETADDRESS);
 
     fd = socket(AF_INET6, SOCK_STREAM, 0) ;
     if (fd < 0) {
@@ -351,9 +351,8 @@
      * xinetd. If it's a socket then check the family - if it's an
      * IPv4 socket then we need to disable IPv6.
      */
-    if (getsockname(0, (struct sockaddr *)&sa, &sa_len) == 0) {
-        struct sockaddr *saP = (struct sockaddr *)&sa;
-        if (saP->sa_family != AF_INET6) {
+    if (getsockname(0, &sa.sa, &sa_len) == 0) {
+        if (sa.sa.sa_family != AF_INET6) {
             close(fd);
             return JNI_FALSE;
         }
@@ -488,25 +487,8 @@
     }
 }
 
-void
-NET_AllocSockaddr(struct sockaddr **him, int *len) {
-#ifdef AF_INET6
-    if (ipv6_available()) {
-        struct sockaddr_in6 *him6 = (struct sockaddr_in6*)malloc(sizeof(struct sockaddr_in6));
-        *him = (struct sockaddr*)him6;
-        *len = sizeof(struct sockaddr_in6);
-    } else
-#endif /* AF_INET6 */
-        {
-            struct sockaddr_in *him4 = (struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
-            *him = (struct sockaddr*)him4;
-            *len = sizeof(struct sockaddr_in);
-        }
-}
-
 #if defined(__linux__) && defined(AF_INET6)
 
-
 /* following code creates a list of addresses from the kernel
  * routing table that are routed via the loopback address.
  * We check all destination addresses against this table
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h	Tue Oct 18 17:14:09 2016 +0000
@@ -60,9 +60,9 @@
 void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
                                   const char *defaultDetail);
 
-#define NET_WAIT_READ    0x01
-#define NET_WAIT_WRITE   0x02
-#define NET_WAIT_CONNECT 0x04
+/************************************************************************
+ * Macros and constants
+ */
 
 /* Defines SO_REUSEPORT */
 #ifndef SO_REUSEPORT
@@ -77,12 +77,6 @@
 #endif
 #endif
 
-jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
-
-/************************************************************************
- * Macros and constants
- */
-
 /*
  * On 64-bit JDKs we use a much larger stack and heap buffer.
  */
@@ -95,20 +89,16 @@
 #endif
 
 #ifdef AF_INET6
-
-#define SOCKADDR        union { \
-                            struct sockaddr_in him4; \
-                            struct sockaddr_in6 him6; \
-                        }
-
-#define SOCKADDR_LEN    (ipv6_available() ? sizeof(SOCKADDR) : \
-                         sizeof(struct sockaddr_in))
-
+typedef union {
+    struct sockaddr     sa;
+    struct sockaddr_in  sa4;
+    struct sockaddr_in6 sa6;
+} SOCKETADDRESS;
 #else
-
-#define SOCKADDR        union { struct sockaddr_in him4; }
-#define SOCKADDR_LEN    sizeof(SOCKADDR)
-
+typedef union {
+    struct sockaddr     sa;
+    struct sockaddr_in  sa4;
+} SOCKETADDRESS;
 #endif
 
 /************************************************************************
--- a/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -87,58 +87,50 @@
     jint fd = fdval(env, fdo);
     int rv;
 
-#ifdef __solaris__
+#if defined(__solaris__)
     rv = connect(fd, 0, 0);
-#endif
+#else
+    int len;
+    SOCKETADDRESS sa;
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(_AIX)
-    {
-        int len;
-        SOCKADDR sa;
-
-        memset(&sa, 0, sizeof(sa));
+    memset(&sa, 0, sizeof(sa));
 
 #ifdef AF_INET6
-        if (isIPv6) {
-            struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)&sa;
+    if (isIPv6) {
 #if defined(_ALLBSD_SOURCE)
-            him6->sin6_family = AF_INET6;
+        sa.sa6.sin6_family = AF_INET6;
 #else
-            him6->sin6_family = AF_UNSPEC;
+        sa.sa6.sin6_family = AF_UNSPEC;
 #endif
-            len = sizeof(struct sockaddr_in6);
-        } else
+        len = sizeof(struct sockaddr_in6);
+    } else
 #endif
-        {
-            struct sockaddr_in *him4 = (struct sockaddr_in*)&sa;
+    {
 #if defined(_ALLBSD_SOURCE)
-            him4->sin_family = AF_INET;
+        sa.sa4.sin_family = AF_INET;
 #else
-            him4->sin_family = AF_UNSPEC;
+        sa.sa4.sin_family = AF_UNSPEC;
 #endif
-            len = sizeof(struct sockaddr_in);
-        }
+        len = sizeof(struct sockaddr_in);
+    }
 
-        rv = connect(fd, (struct sockaddr *)&sa, len);
+    rv = connect(fd, &sa.sa, len);
 
 #if defined(_ALLBSD_SOURCE)
-        if (rv < 0 && errno == EADDRNOTAVAIL)
-                rv = errno = 0;
+    if (rv < 0 && errno == EADDRNOTAVAIL)
+        rv = errno = 0;
+#elif defined(_AIX)
+    /* See W. Richard Stevens, "UNIX Network Programming, Volume 1", p. 254:
+     * 'Setting the address family to AF_UNSPEC might return EAFNOSUPPORT
+     * but that is acceptable.
+     */
+    if (rv < 0 && errno == EAFNOSUPPORT)
+        rv = errno = 0;
 #endif
-#if defined(_AIX)
-        /* See W. Richard Stevens, "UNIX Network Programming, Volume 1", p. 254:
-         * 'Setting the address family to AF_UNSPEC might return EAFNOSUPPORT
-         * but that is acceptable.
-         */
-        if (rv < 0 && errno == EAFNOSUPPORT)
-            rv = errno = 0;
-#endif
-    }
 #endif
 
     if (rv < 0)
         handleSocketError(env, errno);
-
 }
 
 JNIEXPORT jint JNICALL
@@ -148,8 +140,8 @@
 {
     jint fd = fdval(env, fdo);
     void *buf = (void *)jlong_to_ptr(address);
-    SOCKADDR sa;
-    socklen_t sa_len = SOCKADDR_LEN;
+    SOCKETADDRESS sa;
+    socklen_t sa_len = sizeof(SOCKETADDRESS);
     jboolean retry = JNI_FALSE;
     jint n = 0;
     jobject senderAddr;
@@ -160,7 +152,7 @@
 
     do {
         retry = JNI_FALSE;
-        n = recvfrom(fd, buf, len, 0, (struct sockaddr *)&sa, &sa_len);
+        n = recvfrom(fd, buf, len, 0, &sa.sa, &sa_len);
         if (n < 0) {
             if (errno == EWOULDBLOCK) {
                 return IOS_UNAVAILABLE;
@@ -189,12 +181,11 @@
      */
     senderAddr = (*env)->GetObjectField(env, this, dci_senderAddrID);
     if (senderAddr != NULL) {
-        if (!NET_SockaddrEqualsInetAddress(env, (struct sockaddr *)&sa,
-                                           senderAddr)) {
+        if (!NET_SockaddrEqualsInetAddress(env, &sa.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.sa)) {
                 senderAddr = NULL;
             }
         }
@@ -202,7 +193,7 @@
     if (senderAddr == NULL) {
         jobject isa = NULL;
         int port = 0;
-        jobject ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
+        jobject ia = NET_SockaddrToInetAddress(env, &sa.sa, &port);
         if (ia != NULL) {
             isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port);
         }
@@ -210,7 +201,7 @@
 
         (*env)->SetObjectField(env, this, dci_senderAddrID, ia);
         (*env)->SetIntField(env, this, dci_senderPortID,
-                            NET_GetPortFromSockaddr((struct sockaddr *)&sa));
+                            NET_GetPortFromSockaddr(&sa.sa));
         (*env)->SetObjectField(env, this, dci_senderID, isa);
     }
     return n;
@@ -223,21 +214,20 @@
 {
     jint fd = fdval(env, fdo);
     void *buf = (void *)jlong_to_ptr(address);
-    SOCKADDR sa;
-    int sa_len = SOCKADDR_LEN;
+    SOCKETADDRESS sa;
+    int sa_len = sizeof(SOCKETADDRESS);
     jint n = 0;
 
     if (len > MAX_PACKET_LEN) {
         len = MAX_PACKET_LEN;
     }
 
-    if (NET_InetAddressToSockaddr(env, destAddress, destPort,
-                                  (struct sockaddr *)&sa,
+    if (NET_InetAddressToSockaddr(env, destAddress, destPort, &sa.sa,
                                   &sa_len, preferIPv6) != 0) {
       return IOS_THROWN;
     }
 
-    n = sendto(fd, buf, len, 0, (struct sockaddr *)&sa, sa_len);
+    n = sendto(fd, buf, len, 0, &sa.sa, sa_len);
     if (n < 0) {
         if (errno == EAGAIN) {
             return IOS_UNAVAILABLE;
--- a/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,18 +57,16 @@
 JNIEXPORT jobject JNICALL
 Java_sun_nio_ch_InheritedChannel_peerAddress0(JNIEnv *env, jclass cla, jint fd)
 {
-    struct sockaddr *sa;
-    socklen_t sa_len;
+    SOCKETADDRESS sa;
+    socklen_t len = sizeof(SOCKETADDRESS);
     jobject remote_ia = NULL;
     jint remote_port;
 
-    NET_AllocSockaddr(&sa, (int *)&sa_len);
-    if (getpeername(fd, sa, &sa_len) == 0) {
-        if (matchFamily(sa)) {
-            remote_ia = NET_SockaddrToInetAddress(env, sa, (int *)&remote_port);
+    if (getpeername(fd, &sa.sa, &len) == 0) {
+        if (matchFamily(&sa.sa)) {
+            remote_ia = NET_SockaddrToInetAddress(env, &sa.sa, (int *)&remote_port);
         }
     }
-    free((void *)sa);
 
     return remote_ia;
 }
@@ -77,17 +75,15 @@
 JNIEXPORT jint JNICALL
 Java_sun_nio_ch_InheritedChannel_peerPort0(JNIEnv *env, jclass cla, jint fd)
 {
-    struct sockaddr *sa;
-    socklen_t sa_len;
+    SOCKETADDRESS sa;
+    socklen_t len = sizeof(SOCKETADDRESS);
     jint remote_port = -1;
 
-    NET_AllocSockaddr(&sa, (int *)&sa_len);
-    if (getpeername(fd, sa, &sa_len) == 0) {
-        if (matchFamily(sa)) {
-            NET_SockaddrToInetAddress(env, sa, (int *)&remote_port);
+    if (getpeername(fd, &sa.sa, &len) == 0) {
+        if (matchFamily(&sa.sa)) {
+            NET_SockaddrToInetAddress(env, &sa.sa, (int *)&remote_port);
         }
     }
-    free((void *)sa);
 
     return remote_port;
 }
--- a/jdk/src/java.base/unix/native/libnio/ch/NativeThread.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnio/ch/NativeThread.c	Tue Oct 18 17:14:09 2016 +0000
@@ -37,6 +37,11 @@
   #include <sys/signal.h>
   /* Also defined in net/linux_close.c */
   #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
+#elif _AIX
+  #include <pthread.h>
+  #include <sys/signal.h>
+  /* Also defined in net/aix_close.c */
+  #define INTERRUPT_SIGNAL (SIGRTMAX - 1)
 #elif __solaris__
   #include <thread.h>
   #include <signal.h>
@@ -59,7 +64,7 @@
 Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
 {
     /* Install the null handler for INTERRUPT_SIGNAL.  This might overwrite the
-     * handler previously installed by java/net/linux_close.c, but that's okay
+     * handler previously installed by <platform>_close.c, but that's okay
      * since neither handler actually does anything.  We install our own
      * handler here simply out of paranoia; ultimately the two mechanisms
      * should somehow be unified, perhaps within the VM.
--- a/jdk/src/java.base/unix/native/libnio/ch/Net.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnio/ch/Net.c	Tue Oct 18 17:14:09 2016 +0000
@@ -273,15 +273,16 @@
 Java_sun_nio_ch_Net_bind0(JNIEnv *env, jclass clazz, jobject fdo, jboolean preferIPv6,
                           jboolean useExclBind, jobject iao, int port)
 {
-    SOCKADDR sa;
-    int sa_len = SOCKADDR_LEN;
+    SOCKETADDRESS sa;
+    int sa_len = sizeof(SOCKETADDRESS);
     int rv = 0;
 
-    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *)&sa, &sa_len, preferIPv6) != 0) {
-      return;
+    if (NET_InetAddressToSockaddr(env, iao, port, &sa.sa, &sa_len,
+                                  preferIPv6) != 0) {
+        return;
     }
 
-    rv = NET_Bind(fdval(env, fdo), (struct sockaddr *)&sa, sa_len);
+    rv = NET_Bind(fdval(env, fdo), &sa.sa, sa_len);
     if (rv != 0) {
         handleSocketError(env, errno);
     }
@@ -298,17 +299,16 @@
 Java_sun_nio_ch_Net_connect0(JNIEnv *env, jclass clazz, jboolean preferIPv6,
                              jobject fdo, jobject iao, jint port)
 {
-    SOCKADDR sa;
-    int sa_len = SOCKADDR_LEN;
+    SOCKETADDRESS sa;
+    int sa_len = sizeof(SOCKETADDRESS);
     int rv;
 
-    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa,
-                                  &sa_len, preferIPv6) != 0)
-    {
-      return IOS_THROWN;
+    if (NET_InetAddressToSockaddr(env, iao, port, &sa.sa, &sa_len,
+                                  preferIPv6) != 0) {
+        return IOS_THROWN;
     }
 
-    rv = connect(fdval(env, fdo), (struct sockaddr *)&sa, sa_len);
+    rv = connect(fdval(env, fdo), &sa.sa, sa_len);
     if (rv != 0) {
         if (errno == EINPROGRESS) {
             return IOS_UNAVAILABLE;
@@ -323,9 +323,9 @@
 JNIEXPORT jint JNICALL
 Java_sun_nio_ch_Net_localPort(JNIEnv *env, jclass clazz, jobject fdo)
 {
-    SOCKADDR sa;
-    socklen_t sa_len = SOCKADDR_LEN;
-    if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) {
+    SOCKETADDRESS sa;
+    socklen_t sa_len = sizeof(SOCKETADDRESS);
+    if (getsockname(fdval(env, fdo), &sa.sa, &sa_len) < 0) {
 #ifdef _ALLBSD_SOURCE
         /*
          * XXXBSD:
@@ -335,13 +335,11 @@
          * it shouldn't fail. As such, we just fill in generic Linux-compatible values.
          */
         if (errno == ECONNRESET) {
-            struct sockaddr_in *sin;
-            sin = (struct sockaddr_in *) &sa;
-            bzero(sin, sizeof(*sin));
-            sin->sin_len  = sizeof(struct sockaddr_in);
-            sin->sin_family = AF_INET;
-            sin->sin_port = htonl(0);
-            sin->sin_addr.s_addr = INADDR_ANY;
+            bzero(&sa.sa4, sizeof(sa));
+            sa.sa4.sin_len = sizeof(struct sockaddr_in);
+            sa.sa4.sin_family = AF_INET;
+            sa.sa4.sin_port = htonl(0);
+            sa.sa4.sin_addr.s_addr = INADDR_ANY;
         } else {
             handleSocketError(env, errno);
             return -1;
@@ -351,16 +349,16 @@
         return -1;
 #endif /* _ALLBSD_SOURCE */
     }
-    return NET_GetPortFromSockaddr((struct sockaddr *)&sa);
+    return NET_GetPortFromSockaddr(&sa.sa);
 }
 
 JNIEXPORT jobject JNICALL
 Java_sun_nio_ch_Net_localInetAddress(JNIEnv *env, jclass clazz, jobject fdo)
 {
-    SOCKADDR sa;
-    socklen_t sa_len = SOCKADDR_LEN;
+    SOCKETADDRESS sa;
+    socklen_t sa_len = sizeof(SOCKETADDRESS);
     int port;
-    if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) {
+    if (getsockname(fdval(env, fdo), &sa.sa, &sa_len) < 0) {
 #ifdef _ALLBSD_SOURCE
         /*
          * XXXBSD:
@@ -370,13 +368,11 @@
          * it shouldn't fail. As such, we just fill in generic Linux-compatible values.
          */
         if (errno == ECONNRESET) {
-            struct sockaddr_in *sin;
-            sin = (struct sockaddr_in *) &sa;
-            bzero(sin, sizeof(*sin));
-            sin->sin_len  = sizeof(struct sockaddr_in);
-            sin->sin_family = AF_INET;
-            sin->sin_port = htonl(0);
-            sin->sin_addr.s_addr = INADDR_ANY;
+            bzero(&sa.sa4, sizeof(sa));
+            sa.sa4.sin_len  = sizeof(struct sockaddr_in);
+            sa.sa4.sin_family = AF_INET;
+            sa.sa4.sin_port = htonl(0);
+            sa.sa4.sin_addr.s_addr = INADDR_ANY;
         } else {
             handleSocketError(env, errno);
             return NULL;
@@ -386,7 +382,7 @@
         return NULL;
 #endif /* _ALLBSD_SOURCE */
     }
-    return NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
+    return NET_SockaddrToInetAddress(env, &sa.sa, &port);
 }
 
 JNIEXPORT jint JNICALL
--- a/jdk/src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -80,26 +80,19 @@
 {
     jint ssfd = (*env)->GetIntField(env, ssfdo, fd_fdID);
     jint newfd;
-    struct sockaddr *sa;
-    int alloc_len;
+    SOCKETADDRESS sa;
+    socklen_t sa_len = sizeof(SOCKETADDRESS);
     jobject remote_ia = 0;
     jobject isa;
     jint remote_port = 0;
 
-    NET_AllocSockaddr(&sa, &alloc_len);
-    if (sa == NULL) {
-        JNU_ThrowOutOfMemoryError(env, NULL);
-        return IOS_THROWN;
-    }
-
     /*
      * accept connection but ignore ECONNABORTED indicating that
      * a connection was eagerly accepted but was reset before
      * accept() was called.
      */
     for (;;) {
-        socklen_t sa_len = alloc_len;
-        newfd = accept(ssfd, sa, &sa_len);
+        newfd = accept(ssfd, &sa.sa, &sa_len);
         if (newfd >= 0) {
             break;
         }
@@ -110,7 +103,6 @@
     }
 
     if (newfd < 0) {
-        free((void *)sa);
         if (errno == EAGAIN)
             return IOS_UNAVAILABLE;
         if (errno == EINTR)
@@ -120,8 +112,7 @@
     }
 
     (*env)->SetIntField(env, newfdo, fd_fdID, newfd);
-    remote_ia = NET_SockaddrToInetAddress(env, sa, (int *)&remote_port);
-    free((void *)sa);
+    remote_ia = NET_SockaddrToInetAddress(env, &sa.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/native/libnet/DualStackPlainDatagramSocketImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -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.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -475,13 +475,14 @@
  * Method:    socketSetIntOption
  * Signature: (III)V
  */
-JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketSetIntOption
-  (JNIEnv *env, jclass clazz, jint fd , jint cmd, jint value) {
+JNIEXPORT void JNICALL
+Java_java_net_DualStackPlainDatagramSocketImpl_socketSetIntOption
+  (JNIEnv *env, jclass clazz, jint fd, jint cmd, jint value)
+{
     int level = 0, opt = 0;
 
     if (NET_MapSocketOption(cmd, &level, &opt) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "Invalid option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return;
     }
 
@@ -495,14 +496,15 @@
  * Method:    socketGetIntOption
  * Signature: (II)I
  */
-JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketGetIntOption
-  (JNIEnv *env, jclass clazz, jint fd, jint cmd) {
-    int level = 0, opt = 0, result=0;
+JNIEXPORT jint JNICALL
+Java_java_net_DualStackPlainDatagramSocketImpl_socketGetIntOption
+  (JNIEnv *env, jclass clazz, jint fd, jint cmd)
+{
+    int level = 0, opt = 0, result = 0;
     int result_len = sizeof(result);
 
     if (NET_MapSocketOption(cmd, &level, &opt) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "Invalid option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return -1;
     }
 
@@ -519,8 +521,10 @@
  * Method:    dataAvailable
  * Signature: ()I
  */
-JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_dataAvailable
-(JNIEnv *env, jobject this) {
+JNIEXPORT jint JNICALL
+Java_java_net_DualStackPlainDatagramSocketImpl_dataAvailable
+  (JNIEnv *env, jobject this)
+{
     SOCKET fd;
     int  rv = -1;
     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
--- a/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -369,18 +369,17 @@
  * Method:    setIntOption
  * Signature: (III)V
  */
-JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_setIntOption
-  (JNIEnv *env, jclass clazz, jint fd, jint cmd, jint value) {
-
+JNIEXPORT void JNICALL
+Java_java_net_DualStackPlainSocketImpl_setIntOption
+  (JNIEnv *env, jclass clazz, jint fd, jint cmd, jint value)
+{
     int level = 0, opt = 0;
     struct linger linger = {0, 0};
     char *parg;
     int arglen;
 
     if (NET_MapSocketOption(cmd, &level, &opt) < 0) {
-        JNU_ThrowByNameWithLastError(env,
-                                     JNU_JAVANETPKG "SocketException",
-                                     "Invalid option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return;
     }
 
@@ -410,8 +409,8 @@
  * Signature: (II)I
  */
 JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_getIntOption
-  (JNIEnv *env, jclass clazz, jint fd, jint cmd) {
-
+  (JNIEnv *env, jclass clazz, jint fd, jint cmd)
+{
     int level = 0, opt = 0;
     int result=0;
     struct linger linger = {0, 0};
@@ -419,9 +418,7 @@
     int arglen;
 
     if (NET_MapSocketOption(cmd, &level, &opt) < 0) {
-        JNU_ThrowByNameWithLastError(env,
-                                     JNU_JAVANETPKG "SocketException",
-                                     "Unsupported socket option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return -1;
     }
 
--- a/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -83,7 +83,7 @@
     jboolean preferIPv6Address;
 
     int error=0;
-    struct addrinfo hints, *res, *resNew = NULL;
+    struct addrinfo hints, *res = NULL, *resNew = NULL;
 
     initInetAddressIDs(env);
     JNU_CHECK_EXCEPTION_RETURN(env, NULL);
@@ -223,7 +223,7 @@
               setInetAddress_addr(env, iaObj, ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
               setInetAddress_hostName(env, iaObj, host);
               (*env)->SetObjectArrayElement(env, ret, (inetIndex | originalIndex), iaObj);
-                inetIndex ++;
+              inetIndex ++;
             } else if (iterator->ai_family == AF_INET6) {
               jint scope = 0;
               jboolean ret1;
--- a/jdk/src/java.base/windows/native/libnet/NetworkInterface.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/windows/native/libnet/NetworkInterface.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -429,8 +429,8 @@
                 return -1;
             }
 
-            curr->addr.him4.sin_family = AF_INET;
-            curr->addr.him4.sin_addr.s_addr = tableP->table[i].dwAddr;
+            curr->addr.sa4.sin_family = AF_INET;
+            curr->addr.sa4.sin_addr.s_addr = tableP->table[i].dwAddr;
             /*
              * Get netmask / broadcast address
              */
@@ -447,11 +447,11 @@
                * to 0 or 1.
                * Yes, I know it's stupid, but what can I say, it's MSFTs API.
                */
-              curr->brdcast.him4.sin_family = AF_INET;
+              curr->brdcast.sa4.sin_family = AF_INET;
               if (tableP->table[i].dwBCastAddr == 1)
-                curr->brdcast.him4.sin_addr.s_addr = (tableP->table[i].dwAddr & tableP->table[i].dwMask) | (0xffffffff ^ tableP->table[i].dwMask);
+                curr->brdcast.sa4.sin_addr.s_addr = (tableP->table[i].dwAddr & tableP->table[i].dwMask) | (0xffffffff ^ tableP->table[i].dwMask);
               else
-                curr->brdcast.him4.sin_addr.s_addr = (tableP->table[i].dwAddr & tableP->table[i].dwMask);
+                curr->brdcast.sa4.sin_addr.s_addr = (tableP->table[i].dwAddr & tableP->table[i].dwMask);
               mask = ntohl(tableP->table[i].dwMask);
               curr->mask = 0;
               while (mask) {
@@ -584,7 +584,7 @@
     while (addrs != NULL) {
         jobject iaObj, ia2Obj;
         jobject ibObj = NULL;
-        if (addrs->addr.him.sa_family == AF_INET) {
+        if (addrs->addr.sa.sa_family == AF_INET) {
             iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
             if (iaObj == NULL) {
                 free_netaddr(netaddrP);
@@ -592,7 +592,7 @@
             }
             /* default ctor will set family to AF_INET */
 
-            setInetAddress_addr(env, iaObj, ntohl(addrs->addr.him4.sin_addr.s_addr));
+            setInetAddress_addr(env, iaObj, ntohl(addrs->addr.sa4.sin_addr.s_addr));
             if (addrs->mask != -1) {
               ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
               if (ibObj == NULL) {
@@ -605,7 +605,7 @@
                 free_netaddr(netaddrP);
                 return NULL;
               }
-              setInetAddress_addr(env, ia2Obj, ntohl(addrs->brdcast.him4.sin_addr.s_addr));
+              setInetAddress_addr(env, ia2Obj, ntohl(addrs->brdcast.sa4.sin_addr.s_addr));
               (*env)->SetObjectField(env, ibObj, ni_ibbroadcastID, ia2Obj);
               (*env)->SetShortField(env, ibObj, ni_ibmaskID, addrs->mask);
               (*env)->SetObjectArrayElement(env, bindsArr, bind_index++, ibObj);
@@ -614,12 +614,12 @@
             int scope;
             iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
             if (iaObj) {
-                jboolean ret = setInet6Address_ipaddress(env, iaObj,  (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr));
+                jboolean ret = setInet6Address_ipaddress(env, iaObj,  (jbyte *)&(addrs->addr.sa6.sin6_addr.s6_addr));
                 if (ret == JNI_FALSE) {
                     return NULL;
                 }
 
-                scope = addrs->addr.him6.sin6_scope_id;
+                scope = addrs->addr.sa6.sin6_scope_id;
                 if (scope != 0) { /* zero is default value, no need to set */
                     setInet6Address_scopeid(env, iaObj, scope);
                     setInet6Address_scopeifname(env, iaObj, netifObj);
@@ -795,7 +795,7 @@
         addrP = addrList;
 
         while (addrP != NULL) {
-            if ((unsigned long)addr == ntohl(addrP->addr.him4.sin_addr.s_addr)) {
+            if ((unsigned long)addr == ntohl(addrP->addr.sa4.sin_addr.s_addr)) {
                 break;
             }
             addrP = addrP->next;
--- a/jdk/src/java.base/windows/native/libnet/NetworkInterface_winXP.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/windows/native/libnet/NetworkInterface_winXP.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -595,14 +595,14 @@
     while (addrs != NULL) {
         jobject iaObj, ia2Obj;
         jobject ibObj = NULL;
-        if (addrs->addr.him.sa_family == AF_INET) {
+        if (addrs->addr.sa.sa_family == AF_INET) {
             iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
             if (iaObj == NULL) {
                 return NULL;
             }
             /* default ctor will set family to AF_INET */
 
-            setInetAddress_addr(env, iaObj, ntohl(addrs->addr.him4.sin_addr.s_addr));
+            setInetAddress_addr(env, iaObj, ntohl(addrs->addr.sa4.sin_addr.s_addr));
 
             ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
             if (ibObj == NULL) {
@@ -615,7 +615,7 @@
               free_netaddr(netaddrP);
               return NULL;
             }
-            setInetAddress_addr(env, ia2Obj, ntohl(addrs->brdcast.him4.sin_addr.s_addr));
+            setInetAddress_addr(env, ia2Obj, ntohl(addrs->brdcast.sa4.sin_addr.s_addr));
             (*env)->SetObjectField(env, ibObj, ni_ibbroadcastID, ia2Obj);
             (*env)->SetShortField(env, ibObj, ni_ibmaskID, addrs->mask);
             (*env)->SetObjectArrayElement(env, bindsArr, bind_index++, ibObj);
@@ -623,11 +623,11 @@
             int scope;
             iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
             if (iaObj) {
-                jboolean ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr));
+                jboolean ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.sa6.sin6_addr.s6_addr));
                 if (ret == JNI_FALSE) {
                     return NULL;
                 }
-                scope = addrs->addr.him6.sin6_scope_id;
+                scope = addrs->addr.sa6.sin6_scope_id;
                 if (scope != 0) { /* zero is default value, no need to set */
                     setInet6Address_scopeid(env, iaObj, scope);
                     setInet6Address_scopeifname(env, iaObj, netifObj);
--- a/jdk/src/java.base/windows/native/libnet/SocketInputStream.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/windows/native/libnet/SocketInputStream.c	Tue Oct 18 17:14:09 2016 +0000
@@ -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
@@ -62,18 +62,18 @@
                                             jobject fdObj, jbyteArray data,
                                             jint off, jint len, jint timeout)
 {
+    char BUF[MAX_BUFFER_LEN];
     char *bufP;
-    char BUF[MAX_BUFFER_LEN];
-    jint fd, newfd;
-    jint nread;
+    jint fd, newfd, nread;
 
     if (IS_NULL(fdObj)) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "socket closed");
+        JNU_ThrowByName(env, "java/net/SocketException",
+                        "Socket closed");
         return -1;
     }
     fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
     if (fd == -1) {
-        NET_ThrowSocketException(env, "Socket closed");
+        JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
         return -1;
     }
 
@@ -103,10 +103,10 @@
 
             if (ret <= 0) {
                 if (ret == 0) {
-                    JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
+                    JNU_ThrowByName(env, "java/net/SocketTimeoutException",
                                     "Read timed out");
                 } else if (ret == -1) {
-                    JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "socket closed");
+                    JNU_ThrowByName(env, "java/net/SocketException", "socket closed");
                 }
                 if (bufP != BUF) {
                     free(bufP);
@@ -117,7 +117,7 @@
             /*check if the socket has been closed while we were in timeout*/
             newfd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
             if (newfd == -1) {
-                NET_ThrowSocketException(env, "Socket Closed");
+                JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
                 if (bufP != BUF) {
                     free(bufP);
                 }
@@ -134,11 +134,11 @@
             // Check if the socket has been closed since we last checked.
             // This could be a reason for recv failing.
             if ((*env)->GetIntField(env, fdObj, IO_fd_fdID) == -1) {
-                NET_ThrowSocketException(env, "Socket closed");
+                JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
             } else {
                 switch (WSAGetLastError()) {
                     case WSAEINTR:
-                        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
+                        JNU_ThrowByName(env, "java/net/SocketException",
                             "socket closed");
                         break;
 
@@ -153,7 +153,7 @@
                         break;
 
                     case WSAETIMEDOUT :
-                        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
+                        JNU_ThrowByName(env, "java/net/SocketTimeoutException",
                                        "Read timed out");
                         break;
 
--- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -51,6 +51,8 @@
 #define IN_CLASSD(i)    (((long)(i) & 0xf0000000) == 0xe0000000)
 #define IN_MULTICAST(i) IN_CLASSD(i)
 
+extern int getAllInterfacesAndAddresses(JNIEnv *env, netif **netifPP);
+
 /************************************************************************
  * TwoStacksPlainDatagramSocketImpl
  */
@@ -88,7 +90,7 @@
  * Returns a java.lang.Integer based on 'i'
  */
 jobject createInteger(JNIEnv *env, int i) {
-    static jclass i_class;
+    static jclass i_class = NULL;
     static jmethodID i_ctrID;
     static jfieldID i_valueID;
 
@@ -101,14 +103,14 @@
         CHECK_NULL_RETURN(i_class, NULL);
     }
 
-    return ( (*env)->NewObject(env, i_class, i_ctrID, i) );
+    return (*env)->NewObject(env, i_class, i_ctrID, i);
 }
 
 /*
  * Returns a java.lang.Boolean based on 'b'
  */
 jobject createBoolean(JNIEnv *env, int b) {
-    static jclass b_class;
+    static jclass b_class = NULL;
     static jmethodID b_ctrID;
     static jfieldID b_valueID;
 
@@ -121,10 +123,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));
 }
 
-
 static int getFD(JNIEnv *env, jobject this) {
     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
 
@@ -333,7 +334,7 @@
     fd_set tbl;
     struct timeval t = { 0, 0 };
     SOCKETADDRESS rmtaddr;
-    int addrlen = sizeof(rmtaddr);
+    int addrlen = sizeof(SOCKETADDRESS);
 
     memset((char *)&rmtaddr, 0, sizeof(rmtaddr));
 
@@ -354,8 +355,7 @@
         if (select(/*ignored*/fd+1, &tbl, 0, 0, &t) <= 0) {
             break;
         }
-        if (recvfrom(fd, buf, 1, MSG_PEEK,
-                         (struct sockaddr *)&rmtaddr, &addrlen) != SOCKET_ERROR) {
+        if (recvfrom(fd, buf, 1, MSG_PEEK, &rmtaddr.sa, &addrlen) != SOCKET_ERROR) {
             break;
         }
         if (WSAGetLastError() != WSAECONNRESET) {
@@ -363,7 +363,7 @@
             break;
         }
 
-        recvfrom(fd, buf, 1, 0,  (struct sockaddr *)&rmtaddr, &addrlen);
+        recvfrom(fd, buf, 1, 0, &rmtaddr.sa, &addrlen);
         got_icmp = JNI_TRUE;
     }
 
@@ -429,11 +429,11 @@
     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
     jobject fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
 
-    int fd, fd1, family;
+    int fd, fd1 = -1, family;
     int ipv6_supported = ipv6_available();
 
     SOCKETADDRESS lcladdr;
-    int lcladdrlen = sizeof(lcladdr);
+    int lcladdrlen = sizeof(SOCKETADDRESS);
     int address;
 
     memset((char *)&lcladdr, 0, sizeof(lcladdr));
@@ -461,8 +461,9 @@
         address = getInetAddress_addr(env, addressObj);
     }
 
-    if (NET_InetAddressToSockaddr(env, addressObj, port, (struct sockaddr *)&lcladdr, &lcladdrlen, JNI_FALSE) != 0) {
-      return;
+    if (NET_InetAddressToSockaddr(env, addressObj, port, &lcladdr.sa,
+                                  &lcladdrlen, JNI_FALSE) != 0) {
+        return;
     }
 
     if (ipv6_supported) {
@@ -500,7 +501,7 @@
             return;
         }
     } else {
-        if (NET_WinBind(fd, (struct sockaddr *)&lcladdr, lcladdrlen, exclBind) == -1) {
+        if (NET_WinBind(fd, &lcladdr.sa, lcladdrlen, exclBind) == -1) {
             if (WSAGetLastError() == WSAEACCES) {
                 WSASetLastError(WSAEADDRINUSE);
             }
@@ -510,11 +511,7 @@
     }
 
     if (port == 0) {
-        if (fd == -1) {
-            /* must be an IPV6 only socket. */
-            fd = fd1;
-        }
-        if (getsockname(fd, (struct sockaddr *)&lcladdr, &lcladdrlen) == -1) {
+        if (getsockname(fd == -1 ? fd1 : fd, &lcladdr.sa, &lcladdrlen) == -1) {
             NET_ThrowCurrent(env, "getsockname");
             return;
         }
@@ -583,11 +580,12 @@
         res = WSAIoctl(fdc,SIO_UDP_CONNRESET,&t,sizeof(t),&x1,sizeof(x1),&x2,0,0);
     }
 
-    if (NET_InetAddressToSockaddr(env, address, port,(struct sockaddr *)&rmtaddr, &rmtaddrlen, JNI_FALSE) != 0) {
-      return;
+    if (NET_InetAddressToSockaddr(env, address, port, &rmtaddr.sa,
+                                  &rmtaddrlen, JNI_FALSE) != 0) {
+        return;
     }
 
-    if (connect(fdc, (struct sockaddr *)&rmtaddr, sizeof(rmtaddr)) == -1) {
+    if (connect(fdc, &rmtaddr.sa, sizeof(rmtaddr)) == -1) {
         NET_ThrowCurrent(env, "connect");
         return;
     }
@@ -622,7 +620,7 @@
     fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
 
     memset((char *)&addr, 0, len);
-    connect(fd, (struct sockaddr *)&addr, len);
+    connect(fd, &addr.sa, len);
 
     /*
      * use SIO_UDP_CONNRESET
@@ -657,8 +655,7 @@
     jbyteArray packetBuffer;
     jboolean connected;
 
-    SOCKETADDRESS rmtaddr;
-    SOCKETADDRESS *addrp = &rmtaddr;
+    SOCKETADDRESS rmtaddr, *addrp = &rmtaddr;
     int addrlen = 0;
 
     memset((char *)&rmtaddr, 0, sizeof(rmtaddr));
@@ -711,9 +708,10 @@
         addrp = 0; /* arg to sendto () null in this case */
         addrlen = 0;
     } else {
-      if (NET_InetAddressToSockaddr(env, iaObj, packetPort, (struct sockaddr *)&rmtaddr, &addrlen, JNI_FALSE) != 0) {
-        return;
-      }
+        if (NET_InetAddressToSockaddr(env, iaObj, packetPort, &rmtaddr.sa,
+                                      &addrlen, JNI_FALSE) != 0) {
+            return;
+        }
     }
 
     if (packetBufferLen > MAX_BUFFER_LEN) {
@@ -732,7 +730,7 @@
             if (connected) {
                 address = getInetAddress_addr(env, iaObj);
             } else {
-                address = ntohl(rmtaddr.him4.sin_addr.s_addr);
+                address = ntohl(rmtaddr.sa4.sin_addr.s_addr);
             }
 
             if (exceedSizeLimit(env, fd, address, packetBufferLen)) {
@@ -813,8 +811,8 @@
     jint address, family;
 
     int n;
-    struct sockaddr_in remote_addr;
-    jint remote_addrsize = sizeof (remote_addr);
+    SOCKETADDRESS remote_addr;
+    jint remote_addrsize = sizeof(SOCKETADDRESS);
     char buf[1];
     BOOL retry;
     jlong prevTime = 0;
@@ -860,8 +858,7 @@
         }
 
         /* now try the peek */
-        n = recvfrom(fd, buf, 1, MSG_PEEK,
-                         (struct sockaddr *)&remote_addr, &remote_addrsize);
+        n = recvfrom(fd, buf, 1, MSG_PEEK, &remote_addr.sa, &remote_addrsize);
 
         if (n == SOCKET_ERROR) {
             if (WSAGetLastError() == WSAECONNRESET) {
@@ -907,11 +904,11 @@
         NET_ThrowCurrent(env, "Datagram peek failed");
         return 0;
     }
-    setInetAddress_addr(env, addressObj, ntohl(remote_addr.sin_addr.s_addr));
+    setInetAddress_addr(env, addressObj, ntohl(remote_addr.sa4.sin_addr.s_addr));
     setInetAddress_family(env, addressObj, IPv4);
 
     /* return port */
-    return ntohs(remote_addr.sin_port);
+    return ntohs(remote_addr.sa4.sin_port);
 }
 
 JNIEXPORT jint JNICALL
@@ -927,13 +924,13 @@
     jbyteArray packetBuffer;
     jint packetBufferOffset, packetBufferLen;
 
-    int fd, fd1, fduse, nsockets=0, errorCode;
+    int fd = -1, fd1 = -1, fduse, nsockets = 0, errorCode;
     int port;
 
     int checkBoth = 0;
     int n;
     SOCKETADDRESS remote_addr;
-    jint remote_addrsize=sizeof(remote_addr);
+    jint remote_addrsize = sizeof(SOCKETADDRESS);
     BOOL retry;
     jlong prevTime = 0;
 
@@ -1063,7 +1060,7 @@
 
         /* receive the packet */
         n = recvfrom(fduse, fullPacket, packetBufferLen, MSG_PEEK,
-                         (struct sockaddr *)&remote_addr, &remote_addrsize);
+                     &remote_addr.sa, &remote_addrsize);
         port = (int) ntohs ((u_short) GET_PORT((SOCKETADDRESS *)&remote_addr));
         if (n == SOCKET_ERROR) {
             if (WSAGetLastError() == WSAECONNRESET) {
@@ -1145,15 +1142,15 @@
          */
         packetAddress = (*env)->GetObjectField(env, packet, dp_addressID);
         if (packetAddress != NULL) {
-            if (!NET_SockaddrEqualsInetAddress(env, (struct sockaddr *)
-                                                &remote_addr, packetAddress)) {
+            if (!NET_SockaddrEqualsInetAddress(env, &remote_addr.sa,
+                                               packetAddress)) {
                 /* force a new InetAddress to be created */
                 packetAddress = NULL;
             }
         }
         if (packetAddress == NULL) {
-            packetAddress = NET_SockaddrToInetAddress(env, (struct sockaddr *)
-                                &remote_addr, &port);
+            packetAddress = NET_SockaddrToInetAddress(env, &remote_addr.sa,
+                                                      &port);
             /* stuff the new Inetaddress in the packet */
             (*env)->SetObjectField(env, packet, dp_addressID, packetAddress);
         }
@@ -1195,11 +1192,11 @@
     /* as a result of the changes for ipv6, peek() or peekData()
      * must be called prior to receive() so that fduse can be set.
      */
-    int fd, fd1, fduse, errorCode;
+    int fd = -1, fd1 = -1, fduse, errorCode;
 
     int n, nsockets=0;
     SOCKETADDRESS remote_addr;
-    jint remote_addrsize=sizeof(remote_addr);
+    jint remote_addrsize = sizeof(SOCKETADDRESS);
     BOOL retry;
     jlong prevTime = 0, selectTime=0;
     jboolean connected;
@@ -1327,8 +1324,8 @@
         retry = FALSE;
 
         /* receive the packet */
-        n = recvfrom(fduse, fullPacket, packetBufferLen, 0,
-                         (struct sockaddr *)&remote_addr, &remote_addrsize);
+        n = recvfrom(fduse, fullPacket, packetBufferLen, 0, &remote_addr.sa,
+                     &remote_addrsize);
 
         if (n == SOCKET_ERROR) {
             if (WSAGetLastError() == WSAECONNRESET) {
@@ -1431,18 +1428,18 @@
         packetAddress = (*env)->GetObjectField(env, packet, dp_addressID);
 
         if (packetAddress != NULL) {
-            if (!NET_SockaddrEqualsInetAddress(env, (struct sockaddr *)&remote_addr, packetAddress)) {
+            if (!NET_SockaddrEqualsInetAddress(env, &remote_addr.sa, packetAddress)) {
                 /* force a new InetAddress to be created */
                 packetAddress = NULL;
             }
         }
         if (packetAddress == NULL) {
-            packetAddress = NET_SockaddrToInetAddress(env, (struct sockaddr *)&remote_addr, &port);
+            packetAddress = NET_SockaddrToInetAddress(env, &remote_addr.sa, &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((struct sockaddr *)&remote_addr);
+            port = NET_GetPortFromSockaddr(&remote_addr.sa);
         }
         /* populate the packet */
         (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n,
@@ -1612,7 +1609,7 @@
 /* Get the multicasting index from the interface */
 
 static int getIndexFromIf (JNIEnv *env, jobject nif) {
-    static jfieldID ni_indexID;
+    static jfieldID ni_indexID = NULL;
 
     if (ni_indexID == NULL) {
         jclass c = (*env)->FindClass(env, "java/net/NetworkInterface");
@@ -1625,10 +1622,9 @@
 }
 
 static int isAdapterIpv6Enabled(JNIEnv *env, int index) {
-  extern int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP);
   netif *ifList, *curr;
   int ipv6Enabled = 0;
-  if (getAllInterfacesAndAddresses (env, &ifList) < 0) {
+  if (getAllInterfacesAndAddresses(env, &ifList) < 0) {
       return ipv6Enabled;
   }
 
@@ -1689,7 +1685,7 @@
          * option instead of IP_MULTICAST_IF
          */
         if (ipv6_supported) {
-            static jclass ni_class;
+            static jclass ni_class = NULL;
             if (ni_class == NULL) {
                 jclass c = (*env)->FindClass(env, "java/net/NetworkInterface");
                 CHECK_NULL(c);
@@ -1729,7 +1725,7 @@
          * option. For IPv6 both must be done.
          */
         if (ipv6_supported) {
-            static jfieldID ni_indexID;
+            static jfieldID ni_indexID = NULL;
             struct in_addr in;
             int index;
 
@@ -1795,9 +1791,9 @@
  * Signature: (ILjava/lang/Object;)V
  */
 JNIEXPORT void JNICALL
-Java_java_net_TwoStacksPlainDatagramSocketImpl_socketNativeSetOption(JNIEnv *env,jobject this,
-                                                      jint opt,jobject value) {
-
+Java_java_net_TwoStacksPlainDatagramSocketImpl_socketNativeSetOption
+  (JNIEnv *env,jobject this, jint opt,jobject value)
+{
     int fd=-1, fd1=-1;
     int levelv4 = 0, levelv6 = 0, optnamev4 = 0, optnamev6 = 0, optlen = 0;
     union {
@@ -1828,13 +1824,13 @@
      */
     if (fd1 != -1) {
         if (NET_MapSocketOptionV6(opt, &levelv6, &optnamev6)) {
-            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
+            JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
             return;
         }
     }
     if (fd != -1) {
         if (NET_MapSocketOption(opt, &levelv4, &optnamev4)) {
-            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
+            JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
             return;
         }
     }
@@ -2163,9 +2159,9 @@
  * Signature: (I)Ljava/lang/Object;
  */
 JNIEXPORT jobject JNICALL
-Java_java_net_TwoStacksPlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this,
-                                                      jint opt) {
-
+Java_java_net_TwoStacksPlainDatagramSocketImpl_socketGetOption
+  (JNIEnv *env, jobject this, jint opt)
+{
     int fd=-1, fd1=-1;
     int level, optname, optlen;
     union {
@@ -2197,13 +2193,13 @@
      * level and option name.
      */
     if (NET_MapSocketOption(opt, &level, &optname)) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return NULL;
     }
 
     if (fd == -1) {
         if (NET_MapSocketOptionV6(opt, &level, &optname)) {
-            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
+            JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
             return NULL;
         }
         fd = fd1; /* must be IPv6 only */
@@ -2250,10 +2246,10 @@
  * Signature: (I)Ljava/lang/Object;
  */
 JNIEXPORT jobject JNICALL
-Java_java_net_TwoStacksPlainDatagramSocketImpl_socketLocalAddress(JNIEnv *env, jobject this,
-                                                      jint family) {
-
-    int fd=-1, fd1=-1;
+Java_java_net_TwoStacksPlainDatagramSocketImpl_socketLocalAddress
+  (JNIEnv *env, jobject this, jint family)
+{
+    int fd = -1, fd1 = -1;
     SOCKETADDRESS him;
     int len = 0;
     int port;
@@ -2273,7 +2269,7 @@
 
     /* find out local IP address */
 
-    len = sizeof (struct sockaddr_in);
+    len = sizeof(struct sockaddr_in);
 
     /* family==-1 when socket is not connected */
     if ((family == IPv6) || (family == -1 && fd == -1)) {
@@ -2287,12 +2283,12 @@
         return NULL;
     }
 
-    if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
+    if (getsockname(fd, &him.sa, &len) == -1) {
         JNU_ThrowByNameWithMessageAndLastError
             (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
         return NULL;
     }
-    iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
+    iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port);
 
     return iaObj;
 }
@@ -2450,17 +2446,17 @@
         return;
     }
 
-    if (NET_InetAddressToSockaddr(env, iaObj, 0, (struct sockaddr *)&name, &len, JNI_FALSE) != 0) {
+    if (NET_InetAddressToSockaddr(env, iaObj, 0, &name.sa, &len, JNI_FALSE) != 0) {
       return;
     }
 
     /* Set the multicast group address in the ip_mreq field
      * eventually this check should be done by the security manager
      */
-    family = name.him.sa_family;
+    family = name.sa.sa_family;
 
     if (family == AF_INET) {
-        int address = name.him4.sin_addr.s_addr;
+        int address = name.sa4.sin_addr.s_addr;
         if (!IN_MULTICAST(ntohl(address))) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "not in multicast");
             return;
@@ -2499,7 +2495,7 @@
     } else /* AF_INET6 */ {
         if (ipv6_supported) {
             struct in6_addr *address;
-            address = &name.him6.sin6_addr;
+            address = &name.sa6.sin6_addr;
             if (!IN6_IS_ADDR_MULTICAST(address)) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "not in6 multicast");
                 return;
--- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -192,7 +192,7 @@
 
     /* family and localport are int fields of iaObj */
     int family;
-    jint fd, fd1=-1;
+    jint fd = -1, fd1 = -1;
     jint len;
     int  ipv6_supported = ipv6_available();
 
@@ -222,11 +222,11 @@
         return;
     }
 
-    if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&him, &len, JNI_FALSE) != 0) {
+    if (NET_InetAddressToSockaddr(env, iaObj, port, &him.sa, &len, JNI_FALSE) != 0) {
       return;
     }
 
-    family = him.him.sa_family;
+    family = him.sa.sa_family;
     if (family == AF_INET6) {
         if (!ipv6_supported) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -258,7 +258,7 @@
     (*env)->SetObjectField(env, this, psi_fd1ID, NULL);
 
     if (timeout <= 0) {
-        connect_res = connect(fd, (struct sockaddr *) &him, SOCKETADDRESS_LEN(&him));
+        connect_res = connect(fd, &him.sa, sizeof(SOCKETADDRESS));
         if (connect_res == SOCKET_ERROR) {
             connect_res = WSAGetLastError();
         }
@@ -268,10 +268,10 @@
 
         /* make socket non-blocking */
         optval = 1;
-        ioctlsocket( fd, FIONBIO, &optval );
+        ioctlsocket(fd, FIONBIO, &optval);
 
         /* initiate the connect */
-        connect_res = connect(fd, (struct sockaddr *) &him, SOCKETADDRESS_LEN(&him));
+        connect_res = connect(fd, &him.sa, sizeof(SOCKETADDRESS));
         if (connect_res == SOCKET_ERROR) {
             if (WSAGetLastError() != WSAEWOULDBLOCK) {
                 connect_res = WSAGetLastError();
@@ -371,18 +371,17 @@
          * that the system chose for us and store it in the Socket object.
          */
         u_short port;
-        int len = SOCKETADDRESS_LEN(&him);
-        if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
-
+        int len = sizeof(SOCKETADDRESS);
+        if (getsockname(fd, &him.sa, &len) == -1) {
             if (WSAGetLastError() == WSAENOTSOCK) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
-                        "Socket closed");
+                                "Socket closed");
             } else {
                 NET_ThrowCurrent(env, "getsockname failed");
             }
             return;
         }
-        port = ntohs ((u_short)GET_PORT(&him));
+        port = ntohs((u_short)GET_PORT(&him));
         (*env)->SetIntField(env, this, psi_localportID, (int) port);
     }
 }
@@ -400,7 +399,7 @@
     /* fdObj is the FileDescriptor field on this */
     jobject fdObj, fd1Obj;
     /* fd is an int field on fdObj */
-    int fd, fd1, len = 0;
+    int fd, fd1 = -1, len = 0;
     int ipv6_supported = ipv6_available();
 
     /* family is an int field of iaObj */
@@ -435,9 +434,9 @@
         return;
     }
 
-    if (NET_InetAddressToSockaddr(env, iaObj, localport,
-                          (struct sockaddr *)&him, &len, JNI_FALSE) != 0) {
-      return;
+    if (NET_InetAddressToSockaddr(env, iaObj, localport, &him.sa, &len,
+                                  JNI_FALSE) != 0) {
+        return;
     }
     if (ipv6_supported) {
         struct ipv6bind v6bind;
@@ -473,7 +472,7 @@
             (*env)->SetObjectField(env, this, psi_fd1ID, NULL);
         }
     } else {
-        rv = NET_WinBind(fd, (struct sockaddr *)&him, len, exclBind);
+        rv = NET_WinBind(fd, &him.sa, len, exclBind);
     }
 
     if (rv == -1) {
@@ -489,17 +488,16 @@
         /* Now that we're a bound socket, let's extract the port number
          * that the system chose for us and store it in the Socket object.
          */
-        int len = SOCKETADDRESS_LEN(&him);
+        int len = sizeof(SOCKETADDRESS);
         u_short port;
-        fd = him.him.sa_family == AF_INET? fd: fd1;
 
-        if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
+        if (getsockname(him.sa.sa_family == AF_INET ? fd: fd1, &him.sa, &len) == -1) {
             NET_ThrowCurrent(env, "getsockname in plain socketBind");
             return;
         }
-        port = ntohs ((u_short) GET_PORT (&him));
+        port = ntohs((u_short) GET_PORT (&him));
 
-        (*env)->SetIntField(env, this, psi_localportID, (int) port);
+        (*env)->SetIntField(env, this, psi_localportID, (int)port);
     } else {
         (*env)->SetIntField(env, this, psi_localportID, localport);
     }
@@ -511,16 +509,17 @@
  * Signature: (I)V
  */
 JNIEXPORT void JNICALL
-Java_java_net_TwoStacksPlainSocketImpl_socketListen (JNIEnv *env, jobject this,
-                                            jint count)
+Java_java_net_TwoStacksPlainSocketImpl_socketListen
+  (JNIEnv *env, jobject this, jint count)
 {
     /* this FileDescriptor fd field */
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
     jobject fd1Obj = (*env)->GetObjectField(env, this, psi_fd1ID);
     jobject address;
     /* fdObj's int fd field */
-    int fd, fd1;
-    SOCKETADDRESS addr; int addrlen;
+    int fd = INVALID_SOCKET, fd1 = INVALID_SOCKET;
+    SOCKETADDRESS addr;
+    int addrlen;
 
     if (IS_NULL(fdObj) && IS_NULL(fd1Obj)) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -540,12 +539,12 @@
         JNU_ThrowNullPointerException(env, "socket address");
         return;
     }
-    if (NET_InetAddressToSockaddr(env, address, 0, (struct sockaddr *)&addr,
-                                  &addrlen, JNI_FALSE) != 0) {
-      return;
+    if (NET_InetAddressToSockaddr(env, address, 0, &addr.sa, &addrlen,
+                                  JNI_FALSE) != 0) {
+        return;
     }
 
-    if (addr.him.sa_family == AF_INET || IN6ADDR_ISANY(&addr.him6)) {
+    if (addr.sa.sa_family == AF_INET || IN6ADDR_ISANY(&addr.sa6)) {
         /* listen on v4 */
         if (listen(fd, count) == -1) {
             NET_ThrowCurrent(env, "listen failed");
@@ -556,7 +555,7 @@
     }
     if (ipv6_available() && !IS_NULL(fd1Obj)) {
         fd1 = (*env)->GetIntField(env, fd1Obj, IO_fd_fdID);
-        if (addr.him.sa_family == AF_INET6 || addr.him4.sin_addr.s_addr == INADDR_ANY) {
+        if (addr.sa.sa_family == AF_INET6 || addr.sa4.sin_addr.s_addr == INADDR_ANY) {
             /* listen on v6 */
             if (listen(fd1, count) == -1) {
                 NET_ThrowCurrent(env, "listen failed");
@@ -687,7 +686,7 @@
             }
         }
     }
-    fd = accept(fd, (struct sockaddr *)&him, &len);
+    fd = accept(fd, &him.sa, &len);
     if (fd < 0) {
         /* REMIND: SOCKET CLOSED PROBLEM */
         if (fd == -2) {
@@ -702,7 +701,7 @@
     SetHandleInformation((HANDLE)(UINT_PTR)fd, HANDLE_FLAG_INHERIT, 0);
     (*env)->SetIntField(env, socketFdObj, IO_fd_fdID, fd);
 
-    if (him.him.sa_family == AF_INET) {
+    if (him.sa.sa_family == AF_INET) {
         if (inet4Cls == NULL) {
             jclass c = (*env)->FindClass(env, "java/net/Inet4Address");
             if (c != NULL) {
@@ -728,7 +727,7 @@
             return;
         }
 
-        setInetAddress_addr(env, socketAddressObj, ntohl(him.him4.sin_addr.s_addr));
+        setInetAddress_addr(env, socketAddressObj, ntohl(him.sa4.sin_addr.s_addr));
         setInetAddress_family(env, socketAddressObj, IPv4);
         (*env)->SetObjectField(env, socket, psi_addressID, socketAddressObj);
     } else {
@@ -754,9 +753,9 @@
             NET_SocketClose(fd);
             return;
         }
-        setInet6Address_ipaddress(env, socketAddressObj, (char *)&him.him6.sin6_addr);
+        setInet6Address_ipaddress(env, socketAddressObj, (char *)&him.sa6.sin6_addr);
         setInetAddress_family(env, socketAddressObj, IPv6);
-        setInet6Address_scopeid(env, socketAddressObj, him.him6.sin6_scope_id);
+        setInet6Address_scopeid(env, socketAddressObj, him.sa6.sin6_scope_id);
 
     }
     /* fields common to AF_INET and AF_INET6 */
@@ -838,10 +837,9 @@
  * Signature: (IZLjava/lang/Object;)V
  */
 JNIEXPORT void JNICALL
-Java_java_net_TwoStacksPlainSocketImpl_socketNativeSetOption(JNIEnv *env,
-                                              jobject this,
-                                              jint cmd, jboolean on,
-                                              jobject value) {
+Java_java_net_TwoStacksPlainSocketImpl_socketNativeSetOption
+  (JNIEnv *env, jobject this, jint cmd, jboolean on, jobject value)
+{
     int fd, fd1;
     int level = 0, optname = 0, optlen = 0;
     union {
@@ -923,11 +921,10 @@
 
     /*
      * Map the Java level socket option to the platform specific
-     * level
+     * level and option name.
      */
     if (NET_MapSocketOption(cmd, &level, &optname)) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
-                        "Invalid option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return;
     }
 
@@ -1006,15 +1003,16 @@
  * Signature: (I)I
  */
 JNIEXPORT jint JNICALL
-Java_java_net_TwoStacksPlainSocketImpl_socketGetOption(JNIEnv *env, jobject this,
-                                              jint opt, jobject iaContainerObj) {
-
+Java_java_net_TwoStacksPlainSocketImpl_socketGetOption
+  (JNIEnv *env, jobject this, jint opt, jobject iaContainerObj)
+{
     int fd, fd1;
     int level = 0, optname = 0, optlen = 0;
     union {
         int i;
         struct linger ling;
     } optval;
+
     /*
      * Get SOCKET and check it hasn't been closed
      */
@@ -1037,13 +1035,12 @@
      */
     if (opt == java_net_SocketOptions_SO_BINDADDR) {
         SOCKETADDRESS him;
-        int len;
+        int len = sizeof(SOCKETADDRESS);
         int port;
         jobject iaObj;
         jclass iaCntrClass;
         jfieldID iaFieldID;
 
-        len = sizeof(him);
         memset((char *)&him, 0, len);
 
         if (fd == -1) {
@@ -1053,12 +1050,12 @@
             fd = getFD1 (env, this);
         }
 
-        if (getsockname(fd, (struct sockaddr *)&him, &len) < 0) {
+        if (getsockname(fd, &him.sa, &len) < 0) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return -1;
         }
-        iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
+        iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port);
         CHECK_NULL_RETURN(iaObj, -1);
 
         iaCntrClass = (*env)->GetObjectClass(env, iaContainerObj);
@@ -1073,7 +1070,7 @@
      * level and option name.
      */
     if (NET_MapSocketOption(opt, &level, &optname)) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
+        JNU_ThrowByName(env, "java/net/SocketException", "Invalid option");
         return -1;
     }
 
--- a/jdk/src/java.base/windows/native/libnet/net_util_md.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/windows/native/libnet/net_util_md.c	Tue Oct 18 17:14:09 2016 +0000
@@ -203,19 +203,6 @@
 }
 
 void
-NET_ThrowSocketException(JNIEnv *env, char* msg)
-{
-    static jclass cls = NULL;
-    if (cls == NULL) {
-        cls = (*env)->FindClass(env, "java/net/SocketException");
-        CHECK_NULL(cls);
-        cls = (*env)->NewGlobalRef(env, cls);
-        CHECK_NULL(cls);
-    }
-    (*env)->ThrowNew(env, cls, msg);
-}
-
-void
 NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
                    const char *defaultDetail) {
     char errmsg[255];
@@ -681,21 +668,21 @@
  */
 
 JNIEXPORT int JNICALL
-NET_BindV6(struct ipv6bind* b, jboolean exclBind) {
+NET_BindV6(struct ipv6bind *b, jboolean exclBind) {
     int fd=-1, ofd=-1, rv, len;
     /* need to defer close until new sockets created */
     int close_fd=-1, close_ofd=-1;
     SOCKETADDRESS oaddr; /* other address to bind */
-    int family = b->addr->him.sa_family;
+    int family = b->addr->sa.sa_family;
     int ofamily;
     u_short port; /* requested port parameter */
     u_short bound_port;
 
-    if (family == AF_INET && (b->addr->him4.sin_addr.s_addr != INADDR_ANY)) {
+    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 (struct sockaddr_in), exclBind);
+        ret = NET_WinBind((int)b->ipv4_fd, (struct sockaddr *)b->addr,
+                                sizeof(SOCKETADDRESS), exclBind);
         if (ret == SOCKET_ERROR) {
             CLOSE_SOCKETS_AND_RETURN;
         }
@@ -703,11 +690,11 @@
         b->ipv6_fd = -1;
         return 0;
     }
-    if (family == AF_INET6 && (!IN6_IS_ADDR_ANY(&b->addr->him6.sin6_addr))) {
+    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,
-                                sizeof (struct SOCKADDR_IN6), exclBind);
+        ret = NET_WinBind((int)b->ipv6_fd, (struct sockaddr *)b->addr,
+                          sizeof(SOCKETADDRESS), exclBind);
         if (ret == SOCKET_ERROR) {
             CLOSE_SOCKETS_AND_RETURN;
         }
@@ -724,32 +711,32 @@
         fd = (int)b->ipv4_fd;
         ofd = (int)b->ipv6_fd;
         port = (u_short)GET_PORT (b->addr);
-        IN6ADDR_SETANY (&oaddr.him6);
-        oaddr.him6.sin6_port = port;
+        IN6ADDR_SETANY(&oaddr.sa6);
+        oaddr.sa6.sin6_port = port;
     } else {
         ofamily = AF_INET;
         ofd = (int)b->ipv4_fd;
         fd = (int)b->ipv6_fd;
         port = (u_short)GET_PORT (b->addr);
-        oaddr.him4.sin_family = AF_INET;
-        oaddr.him4.sin_port = port;
-        oaddr.him4.sin_addr.s_addr = INADDR_ANY;
+        oaddr.sa4.sin_family = AF_INET;
+        oaddr.sa4.sin_port = port;
+        oaddr.sa4.sin_addr.s_addr = INADDR_ANY;
     }
 
-    rv = NET_WinBind(fd, (struct sockaddr *)b->addr, SOCKETADDRESS_LEN(b->addr), exclBind);
+    rv = NET_WinBind(fd, (struct sockaddr *)b->addr, sizeof(SOCKETADDRESS), exclBind);
     if (rv == SOCKET_ERROR) {
         CLOSE_SOCKETS_AND_RETURN;
     }
 
     /* get the port and set it in the other address */
-    len = SOCKETADDRESS_LEN(b->addr);
+    len = sizeof(SOCKETADDRESS);
     if (getsockname(fd, (struct sockaddr *)b->addr, &len) == -1) {
         CLOSE_SOCKETS_AND_RETURN;
     }
     bound_port = GET_PORT (b->addr);
     SET_PORT (&oaddr, bound_port);
-    if ((rv=NET_WinBind (ofd, (struct sockaddr *) &oaddr,
-                         SOCKETADDRESS_LEN (&oaddr), exclBind)) == SOCKET_ERROR) {
+    if ((rv = NET_WinBind(ofd, &oaddr.sa,
+                          sizeof(SOCKETADDRESS), exclBind)) == SOCKET_ERROR) {
         int retries;
         int sotype, arglen=sizeof(sotype);
 
@@ -785,8 +772,7 @@
 
             /* bind random port on first socket */
             SET_PORT (&oaddr, 0);
-            rv = NET_WinBind (ofd, (struct sockaddr *)&oaddr, SOCKETADDRESS_LEN(&oaddr),
-                              exclBind);
+            rv = NET_WinBind(ofd, &oaddr.sa, sizeof(SOCKETADDRESS), exclBind);
             if (rv == SOCKET_ERROR) {
                 CLOSE_SOCKETS_AND_RETURN;
             }
@@ -796,14 +782,14 @@
             close_fd = close_ofd = -1;
 
             /* bind new port on second socket */
-            len = SOCKETADDRESS_LEN(&oaddr);
-            if (getsockname(ofd, (struct sockaddr *)&oaddr, &len) == -1) {
+            len = sizeof(SOCKETADDRESS);
+            if (getsockname(ofd, &oaddr.sa, &len) == -1) {
                 CLOSE_SOCKETS_AND_RETURN;
             }
             bound_port = GET_PORT (&oaddr);
             SET_PORT (b->addr, bound_port);
-            rv = NET_WinBind (fd, (struct sockaddr *)b->addr, SOCKETADDRESS_LEN(b->addr),
-                              exclBind);
+            rv = NET_WinBind(fd, (struct sockaddr *)b->addr,
+                             sizeof(SOCKETADDRESS), exclBind);
 
             if (rv != SOCKET_ERROR) {
                 if (family == AF_INET) {
@@ -839,9 +825,9 @@
     }
 
     ret = WSAIoctl(fd, SIO_ROUTING_INTERFACE_QUERY,
-                    (void *)target_addr, sizeof(struct sockaddr_in6),
-                    (void *)&route, sizeof(struct sockaddr_in6),
-                    &b, 0, 0);
+                   (void *)target_addr, sizeof(struct sockaddr_in6),
+                   (void *)&route, sizeof(struct sockaddr_in6),
+                   &b, 0, 0);
     if (ret == SOCKET_ERROR) {
         // error
         closesocket(fd);
@@ -922,13 +908,13 @@
         him6->sin6_scope_id = scopeid != 0 ? scopeid : cached_scope_id;
         *len = sizeof(struct SOCKADDR_IN6) ;
     } else {
-        struct sockaddr_in *him4 = (struct sockaddr_in*)him;
+        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;
         }
-        memset((char *) him4, 0, sizeof(struct sockaddr_in));
+        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);
@@ -941,9 +927,9 @@
 JNIEXPORT jint JNICALL
 NET_GetPortFromSockaddr(struct sockaddr *him) {
     if (him->sa_family == AF_INET6) {
-        return ntohs(((struct sockaddr_in6*)him)->sin6_port);
+        return ntohs(((struct sockaddr_in6 *)him)->sin6_port);
     } else {
-        return ntohs(((struct sockaddr_in*)him)->sin_port);
+        return ntohs(((struct sockaddr_in *)him)->sin_port);
     }
 }
 
@@ -979,12 +965,12 @@
     return 1;
 }
 
-int getScopeID (struct sockaddr *him) {
+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) {
+int cmpScopeID(unsigned int scope, struct sockaddr *him) {
     struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
     return him6->sin6_scope_id == scope;
 }
--- a/jdk/src/java.base/windows/native/libnet/net_util_md.h	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.base/windows/native/libnet/net_util_md.h	Tue Oct 18 17:14:09 2016 +0000
@@ -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
@@ -247,9 +247,9 @@
 int NET_GetDefaultTOS(void);
 
 typedef union {
-    struct sockaddr     him;
-    struct sockaddr_in  him4;
-    struct SOCKADDR_IN6 him6;
+    struct sockaddr     sa;
+    struct sockaddr_in  sa4;
+    struct SOCKADDR_IN6 sa6;
 } SOCKETADDRESS;
 
 /*
@@ -257,15 +257,11 @@
  * sockets. On return they may refer to different sockets.
  */
 struct ipv6bind {
-    SOCKETADDRESS       *addr;
-    SOCKET               ipv4_fd;
-    SOCKET               ipv6_fd;
+    SOCKETADDRESS      *addr;
+    SOCKET              ipv4_fd;
+    SOCKET              ipv6_fd;
 };
 
-#define SOCKETADDRESS_LEN(X)    \
-        (((X)->him.sa_family==AF_INET6)? sizeof(struct SOCKADDR_IN6) : \
-                         sizeof(struct sockaddr_in))
-
 #define SOCKETADDRESS_COPY(DST,SRC) {                           \
     if ((SRC)->sa_family == AF_INET6) {                         \
         memcpy ((DST), (SRC), sizeof (struct SOCKADDR_IN6));    \
@@ -274,20 +270,20 @@
     }                                                           \
 }
 
-#define SET_PORT(X,Y) {                         \
-    if ((X)->him.sa_family == AF_INET) {        \
-        (X)->him4.sin_port = (Y);               \
-    } else {                                    \
-        (X)->him6.sin6_port = (Y);              \
-    }                                           \
+#define SET_PORT(X,Y) {                    \
+    if ((X)->sa.sa_family == AF_INET) {    \
+        (X)->sa4.sin_port = (Y);           \
+    } else {                               \
+        (X)->sa6.sin6_port = (Y);          \
+    }                                      \
 }
 
-#define GET_PORT(X) ((X)->him.sa_family==AF_INET ?(X)->him4.sin_port: (X)->him6.sin6_port)
+#define GET_PORT(X) ((X)->sa.sa_family == AF_INET ? (X)->sa4.sin_port : (X)->sa6.sin6_port)
 
 #define IS_LOOPBACK_ADDRESS(x) ( \
-    ((x)->him.sa_family == AF_INET) ? \
-        (ntohl((x)->him4.sin_addr.s_addr)==INADDR_LOOPBACK) : \
-        (IN6ADDR_ISLOOPBACK (x)) \
+    ((x)->sa.sa_family == AF_INET) ? \
+        (ntohl((x)->sa4.sin_addr.s_addr) == INADDR_LOOPBACK) : \
+        (IN6ADDR_ISLOOPBACK(x)) \
 )
 
 JNIEXPORT int JNICALL NET_SocketClose(int fd);
@@ -297,9 +293,7 @@
 int NET_Socket(int domain, int type, int protocol);
 
 void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
-         const char *defaultDetail);
-
-void NET_ThrowSocketException(JNIEnv *env, char* msg);
+                                  const char *defaultDetail);
 
 /*
  * differs from NET_Timeout() as follows:
@@ -314,46 +308,39 @@
  */
 JNIEXPORT int JNICALL NET_Timeout2(int fd, int fd1, long timeout, int *fdret);
 
-JNIEXPORT int JNICALL NET_BindV6(struct ipv6bind* b, jboolean exclBind);
-
-#define NET_WAIT_READ   0x01
-#define NET_WAIT_WRITE  0x02
-#define NET_WAIT_CONNECT        0x04
-
-extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
+JNIEXPORT int JNICALL NET_BindV6(struct ipv6bind *b, jboolean exclBind);
 
 JNIEXPORT int JNICALL NET_WinBind(int s, struct sockaddr *him, int len,
-                                   jboolean exclBind);
+                                  jboolean exclBind);
 
 /* XP versions of the native routines */
 
 JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0_XP
-    (JNIEnv *env, jclass cls, jstring name);
+  (JNIEnv *env, jclass cls, jstring name);
 
 JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0_XP
   (JNIEnv *env, jclass cls, jint index);
 
 JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0_XP
-    (JNIEnv *env, jclass cls, jobject iaObj);
+  (JNIEnv *env, jclass cls, jobject iaObj);
 
 JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll_XP
-    (JNIEnv *env, jclass cls);
+  (JNIEnv *env, jclass cls);
 
 JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_supportsMulticast0_XP
-(JNIEnv *env, jclass cls, jstring name, jint index);
+  (JNIEnv *env, jclass cls, jstring name, jint index);
 
 JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isUp0_XP
-(JNIEnv *env, jclass cls, jstring name, jint index);
+  (JNIEnv *env, jclass cls, jstring name, jint index);
 
 JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isP2P0_XP
-(JNIEnv *env, jclass cls, jstring name, jint index);
+  (JNIEnv *env, jclass cls, jstring name, jint index);
 
 JNIEXPORT jbyteArray JNICALL Java_java_net_NetworkInterface_getMacAddr0_XP
-(JNIEnv *env, jclass cls, jstring name, jint index);
+  (JNIEnv *env, jclass cls, jstring name, jint index);
 
 JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0_XP
-(JNIEnv *env, jclass class, jstring name, jint index);
+  (JNIEnv *env, jclass class, jstring name, jint index);
 
 JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isLoopback0_XP
-(JNIEnv *env, jclass cls, jstring name, jint index);
-
+  (JNIEnv *env, jclass cls, jstring name, jint index);
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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
@@ -56,8 +56,6 @@
 import sun.java2d.pipe.hw.ContextCapabilities;
 import static sun.java2d.opengl.OGLSurfaceData.*;
 import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
-import sun.java2d.pipe.hw.AccelDeviceEventListener;
-import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
 
 import sun.lwawt.LWComponentPeer;
 import sun.lwawt.macosx.CPlatformView;
@@ -408,17 +406,6 @@
     }
 
     @Override
-    public void addDeviceEventListener(AccelDeviceEventListener l) {
-        int displayID = getDevice().getCGDisplayID();
-        AccelDeviceEventNotifier.addListener(l, displayID);
-    }
-
-    @Override
-    public void removeDeviceEventListener(AccelDeviceEventListener l) {
-        AccelDeviceEventNotifier.removeListener(l);
-    }
-
-    @Override
     public int getMaxTextureWidth() {
         return Math.max(maxTextureSize / getDevice().getScaleFactor(),
                         getBounds().width);
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java	Tue Oct 18 17:14:09 2016 +0000
@@ -86,6 +86,15 @@
         return null;
     }
 
+    static <T> T invokeAndWait(final Callable<T> callable, final Component c, final T defValue) {
+        T value = null;
+        try {
+            value = LWCToolkit.invokeAndWait(callable, c);
+        } catch (final Exception e) { e.printStackTrace(); }
+
+        return value != null ? value : defValue;
+    }
+
     static void invokeLater(final Runnable runnable, final Component c) {
         try {
             LWCToolkit.invokeLater(runnable, c);
@@ -181,7 +190,7 @@
 
                 return as.isAccessibleChildSelected(index);
             }
-        }, c);
+        }, c, false);
     }
 
     public static AccessibleStateSet getAccessibleStateSet(final AccessibleContext ac, final Component c) {
@@ -203,7 +212,7 @@
                 if (ass == null) return null;
                 return ass.contains(as);
             }
-        }, c);
+        }, c, false);
     }
 
     static String getAccessibleRoleFor(final Accessible a) {
@@ -248,7 +257,7 @@
             public Integer call() throws Exception {
                 return at.getCharCount();
             }
-        }, c);
+        }, c, 0);
     }
 
     // Accessibility Threadsafety for JavaComponentAccessibility.m
@@ -273,7 +282,7 @@
                 if (ac == null) return null;
                 return ac.getAccessibleIndexInParent();
             }
-        }, c);
+        }, c, -1);
     }
 
     public static AccessibleComponent getAccessibleComponent(final Accessible a, final Component c) {
@@ -369,7 +378,7 @@
 
                 return aComp.isFocusTraversable();
             }
-        }, c);
+        }, c, false);
     }
 
     public static Accessible accessibilityHitTest(final Container parent, final float hitPointX, final float hitPointY) {
@@ -428,7 +437,7 @@
 
                 return aComp.isEnabled();
             }
-        }, c);
+        }, c, false);
     }
 
     // KCH - can we make this a postEvent instead?
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m	Tue Oct 18 17:14:09 2016 +0000
@@ -323,11 +323,15 @@
 
 + (JavaComponentAccessibility *)createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view
 {
+    JavaComponentAccessibility *ret = nil;
     jobject jcomponent = [(AWTView *)view awtComponent:env];
     jint index = JNFCallStaticIntMethod(env, sjm_getAccessibleIndexInParent, jaccessible, jcomponent);
-    NSString *javaRole = getJavaRole(env, jaccessible, jcomponent);
+    if (index >= 0) {
+      NSString *javaRole = getJavaRole(env, jaccessible, jcomponent);
+      ret = [self createWithAccessible:jaccessible role:javaRole index:index withEnv:env withView:view];
+    }
     (*env)->DeleteLocalRef(env, jcomponent);
-    return [self createWithAccessible:jaccessible role:javaRole index:index withEnv:env withView:view];
+    return ret;
 }
 
 + (JavaComponentAccessibility *) createWithAccessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m	Tue Oct 18 17:14:09 2016 +0000
@@ -117,7 +117,7 @@
 }
 
 - (void)dealloc {
-    JNIEnv *env = [ThreadUtilities getJNIEnv];
+    JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
     if (self.runnable) {
         (*env)->DeleteGlobalRef(env, self.runnable);
     }
@@ -125,7 +125,7 @@
 }
 
 - (void)perform {
-    JNIEnv* env = [ThreadUtilities getJNIEnv];
+    JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
     static JNF_CLASS_CACHE(sjc_Runnable, "java/lang/Runnable");
     static JNF_MEMBER_CACHE(jm_Runnable_run, sjc_Runnable, "run", "()V");
     JNFCallVoidMethod(env, self.runnable, jm_Runnable_run);
--- a/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m	Tue Oct 18 17:14:09 2016 +0000
@@ -376,7 +376,6 @@
 {
     void (^copy)() = [block copy];
     NSInteger encode = (NSInteger) copy;
-    [copy retain];
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined
                                         location: NSMakePoint(0,0)
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -156,6 +156,10 @@
 
         clearAbortRequest();
         processImageStarted(0);
+        if (abortRequested()) {
+            processWriteAborted();
+            return;
+        }
         if (param == null)
             param = getDefaultWriteParam();
 
@@ -583,12 +587,8 @@
             stream.write(embedded_stream.toByteArray());
             embedded_stream = null;
 
-            if (abortRequested()) {
-                processWriteAborted();
-            } else {
-                processImageComplete();
-                stream.flushBefore(stream.getStreamPosition());
-            }
+            processImageComplete();
+            stream.flushBefore(stream.getStreamPosition());
 
             return;
         }
@@ -606,9 +606,6 @@
             destScanlineLength = destScanlineBytes / (DataBuffer.getDataTypeSize(dataType)>>3);
         }
         for (int i = 0; i < h; i++) {
-            if (abortRequested()) {
-                break;
-            }
 
             int row = minY + i;
 
@@ -724,6 +721,9 @@
             }
 
             processImageProgress(100.0f * (((float)i) / ((float)h)));
+            if (abortRequested()) {
+                break;
+            }
         }
 
         if (compressionType == BI_RLE4 ||
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -574,7 +574,6 @@
                        IIOMetadata sm,
                        IIOImage iioimage,
                        ImageWriteParam p) throws IOException {
-        clearAbortRequest();
 
         RenderedImage image = iioimage.getRenderedImage();
 
@@ -829,11 +828,11 @@
             image.getTile(0, 0) : image.getData();
         for (int y = dy; y < dh; y += ddy) {
             if (numRowsWritten % progressReportRowPeriod == 0) {
+                processImageProgress((numRowsWritten*100.0F)/dh);
                 if (abortRequested()) {
                     processWriteAborted();
                     return;
                 }
-                processImageProgress((numRowsWritten*100.0F)/dh);
             }
 
             raster.getSamples(sx, sy, sw, 1, 0, sbuf);
@@ -857,11 +856,11 @@
         lineStride *= ddy;
         for (int y = dy; y < dh; y += ddy) {
             if (numRowsWritten % progressReportRowPeriod == 0) {
+                processImageProgress((numRowsWritten*100.0F)/dh);
                 if (abortRequested()) {
                     processWriteAborted();
                     return;
                 }
-                processImageProgress((numRowsWritten*100.0F)/dh);
             }
 
             compressor.compress(data, offset, dw);
@@ -924,7 +923,12 @@
 
         int progressReportRowPeriod = Math.max(destHeight/20, 1);
 
+        clearAbortRequest();
         processImageStarted(imageIndex);
+        if (abortRequested()) {
+            processWriteAborted();
+            return;
+        }
 
         if (interlaceFlag) {
             if (DEBUG) System.out.println("Writing interlaced");
@@ -973,6 +977,9 @@
                 writeRowsOpt(data, offset, lineStride, compressor,
                              1, 2, destWidth, destHeight,
                              numRowsWritten, progressReportRowPeriod);
+                if (abortRequested()) {
+                    return;
+                }
             } else {
                 writeRows(image, compressor,
                           sourceXOffset, periodX,
@@ -1016,6 +1023,9 @@
                           sourceWidth,
                           1, 2, destWidth, destHeight,
                           numRowsWritten, progressReportRowPeriod);
+                if (abortRequested()) {
+                    return;
+                }
             }
         } else {
             if (DEBUG) System.out.println("Writing non-interlaced");
@@ -1031,6 +1041,9 @@
                 writeRowsOpt(data, offset, lineStride, compressor,
                              0, 1, destWidth, destHeight,
                              numRowsWritten, progressReportRowPeriod);
+                if (abortRequested()) {
+                    return;
+                }
             } else {
                 writeRows(image, compressor,
                           sourceXOffset, periodX,
@@ -1038,15 +1051,12 @@
                           sourceWidth,
                           0, 1, destWidth, destHeight,
                           numRowsWritten, progressReportRowPeriod);
+                if (abortRequested()) {
+                    return;
+                }
             }
         }
 
-        if (abortRequested()) {
-            return;
-        }
-
-        processImageProgress(100.0F);
-
         compressor.flush();
 
         stream.write(0x00);
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -1234,43 +1234,46 @@
         clearAbortRequest();
 
         processImageStarted(0);
-
-        try {
-            write_magic();
-            write_IHDR();
+        if (abortRequested()) {
+            processWriteAborted();
+        } else {
+            try {
+                write_magic();
+                write_IHDR();
 
-            write_cHRM();
-            write_gAMA();
-            write_iCCP();
-            write_sBIT();
-            write_sRGB();
+                write_cHRM();
+                write_gAMA();
+                write_iCCP();
+                write_sBIT();
+                write_sRGB();
 
-            write_PLTE();
+                write_PLTE();
 
-            write_hIST();
-            write_tRNS();
-            write_bKGD();
+                write_hIST();
+                write_tRNS();
+                write_bKGD();
 
-            write_pHYs();
-            write_sPLT();
-            write_tIME();
-            write_tEXt();
-            write_iTXt();
-            write_zTXt();
+                write_pHYs();
+                write_sPLT();
+                write_tIME();
+                write_tEXt();
+                write_iTXt();
+                write_zTXt();
 
-            writeUnknownChunks();
+                writeUnknownChunks();
+
+                write_IDAT(im, deflaterLevel);
 
-            write_IDAT(im, deflaterLevel);
-
-            if (abortRequested()) {
-                processWriteAborted();
-            } else {
-                // Finish up and inform the listeners we are done
-                writeIEND();
-                processImageComplete();
+                if (abortRequested()) {
+                    processWriteAborted();
+                } else {
+                    // Finish up and inform the listeners we are done
+                    writeIEND();
+                    processImageComplete();
+                }
+            } catch (IOException e) {
+                throw new IIOException("I/O error writing PNG file!", e);
             }
-        } catch (IOException e) {
-            throw new IIOException("I/O error writing PNG file!", e);
         }
     }
 }
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -2437,6 +2437,10 @@
 
         clearAbortRequest();
         processImageStarted(0);
+        if (abortRequested()) {
+            processWriteAborted();
+            return;
+        }
 
         // Optionally write the header.
         if (writeHeader) {
@@ -2587,9 +2591,6 @@
                         nextSpace = pos + byteCount;
                     }
 
-                    pixelsDone += tileRect.width*tileRect.height;
-                    processImageProgress(100.0F*pixelsDone/totalPixels);
-
                     // Fill in the offset and byte count for the file
                     stream.mark();
                     stream.seek(stripOrTileOffsetsPosition);
@@ -2600,14 +2601,16 @@
                     stream.writeInt(byteCount);
                     stripOrTileByteCountsPosition += 4;
                     stream.reset();
+
+                    pixelsDone += tileRect.width*tileRect.height;
+                    processImageProgress(100.0F*pixelsDone/totalPixels);
+                    if (abortRequested()) {
+                        processWriteAborted();
+                        return;
+                    }
                 } catch (IOException e) {
                     throw new IIOException("I/O error writing TIFF file!", e);
                 }
-
-                if (abortRequested()) {
-                    processWriteAborted();
-                    return;
-                }
             }
         }
 
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java	Tue Oct 18 17:14:09 2016 +0000
@@ -586,8 +586,8 @@
      * Convenience method that delegates to finishPainting() with
      * caching enabled.
      */
-    public void finishPainting() {
-        finishPainting(true);
+    public BufferedImage finishPainting() {
+        return finishPainting(true);
     }
 
     /**
@@ -595,7 +595,7 @@
      * BufferedImage from the offscreen buffer, (optionally) cache it,
      * and paint it.
      */
-    public void finishPainting(boolean useCache) {
+    public BufferedImage finishPainting(boolean useCache) {
         DataBufferInt dataBuffer = new DataBufferInt(w0 * h0);
         // Note that stealData() requires a markDirty() afterwards
         // since we modify the data in it.
@@ -609,11 +609,12 @@
                 dataBuffer, w0, h0, w0, bands, null);
 
         ColorModel cm = COLOR_MODELS[transparency - 1];
-        Image img = new BufferedImage(cm, raster, false, null);
+        BufferedImage img = new BufferedImage(cm, raster, false, null);
         if (useCache) {
             cache.setImage(getClass(), null, w0, h0, cacheArgs, img);
         }
         graphics.drawImage(img, x0, y0, null);
+        return img;
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -24,6 +24,8 @@
  */
 package com.sun.java.swing.plaf.gtk;
 
+import sun.awt.ModalExclude;
+import sun.awt.SunToolkit;
 import sun.awt.UNIXToolkit;
 
 import javax.swing.plaf.synth.*;
@@ -36,6 +38,7 @@
 import com.sun.java.swing.plaf.gtk.GTKConstants.Orientation;
 import com.sun.java.swing.plaf.gtk.GTKConstants.PositionType;
 import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType;
+import java.awt.image.BufferedImage;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
@@ -567,8 +570,10 @@
         Region id = context.getRegion();
         int gtkState = GTKLookAndFeel.synthStateToGTKState(
                 id, context.getComponentState());
+        boolean isHW = SunToolkit.getHeavyweightComponent(
+                context.getComponent()) instanceof ModalExclude;
         synchronized (UNIXToolkit.GTK_LOCK) {
-            if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState)) {
+            if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, isHW)) {
                 return;
             }
             ENGINE.startPainting(g, x, y, w, h, id, gtkState);
@@ -581,7 +586,25 @@
                 style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),
                 x + insets.left, y + insets.top, w - insets.left - insets.right,
                 h - insets.top - insets.bottom);
-            ENGINE.finishPainting();
+            BufferedImage img = ENGINE.finishPainting();
+            if(!isHW) {
+                int border = img.getRGB(0, h / 2);
+                if (img != null && border == img.getRGB(w / 2, h / 2)) {
+                    // fix no menu borders in Adwaita theme
+                    Graphics g2 = img.getGraphics();
+                    Color c = new Color(border);
+                    g2.setColor(new Color(Math.max((int) (c.getRed() * 0.8), 0),
+                            Math.max((int) (c.getGreen() * 0.8), 0),
+                            Math.max((int) (c.getBlue() * 0.8), 0)));
+                    g2.drawLine(0, 0, w - 1, 0);
+                    g2.drawLine(w - 1, 0, w - 1, h - 1);
+                    g2.drawLine(0, h - 1, 0, 1);
+                    g2.setColor(c.darker());
+                    g2.drawLine(w - 1, h - 1, 0, h - 1);
+                    g2.dispose();
+                    g.drawImage(img, x, y, null);
+                }
+            }
         }
     }
 
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifCheckBoxMenuItemUI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifCheckBoxMenuItemUI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -33,6 +33,7 @@
 
 import java.awt.*;
 import java.awt.event.*;
+import sun.swing.SwingUtilities2;
 
 
 /**
@@ -89,7 +90,8 @@
             Point p = e.getPoint();
             if(p.x >= 0 && p.x < menuItem.getWidth() &&
                p.y >= 0 && p.y < menuItem.getHeight()) {
-                if (UIManager.getBoolean("CheckBoxMenuItem.closeOnMouseClick")) {
+                String property = "CheckBoxMenuItem.doNotCloseOnMouseClick";
+                if (!SwingUtilities2.getBoolean(menuItem, property)) {
                     manager.clearSelectedPath();
                 }
                 menuItem.doClick(0);
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonMenuItemUI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonMenuItemUI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -33,6 +33,7 @@
 import java.awt.*;
 import java.awt.event.*;
 import java.io.Serializable;
+import sun.swing.SwingUtilities2;
 
 
 /**
@@ -97,8 +98,8 @@
             Point p = e.getPoint();
             if(p.x >= 0 && p.x < menuItem.getWidth() &&
                p.y >= 0 && p.y < menuItem.getHeight()) {
-                String property = "RadioButtonMenuItem.closeOnMouseClick";
-                if (UIManager.getBoolean(property)) {
+                String property = "RadioButtonMenuItem.doNotCloseOnMouseClick";
+                if (!SwingUtilities2.getBoolean(menuItem, property)) {
                     manager.clearSelectedPath();
                 }
                 menuItem.doClick(0);
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java	Tue Oct 18 17:14:09 2016 +0000
@@ -36,6 +36,7 @@
 import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
 
 import sun.swing.MenuItemCheckIconFactory;
+import sun.swing.SwingUtilities2;
 
 /**
  * Factory object that can vend Icons appropriate for the Windows {@literal L & F}.
@@ -400,15 +401,24 @@
 
                 // paint check
                 if (model.isSelected()) {
-                    g.drawLine(x+9, y+3, x+9, y+3);
-                    g.drawLine(x+8, y+4, x+9, y+4);
-                    g.drawLine(x+7, y+5, x+9, y+5);
-                    g.drawLine(x+6, y+6, x+8, y+6);
-                    g.drawLine(x+3, y+7, x+7, y+7);
-                    g.drawLine(x+4, y+8, x+6, y+8);
-                    g.drawLine(x+5, y+9, x+5, y+9);
-                    g.drawLine(x+3, y+5, x+3, y+5);
-                    g.drawLine(x+3, y+6, x+4, y+6);
+                    if (SwingUtilities2.isScaledGraphics(g)) {
+                        int[] xPoints = {3, 5, 9, 9, 5, 3};
+                        int[] yPoints = {5, 7, 3, 5, 9, 7};
+                        g.translate(x, y);
+                        g.fillPolygon(xPoints, yPoints, 6);
+                        g.drawPolygon(xPoints, yPoints, 6);
+                        g.translate(-x, -y);
+                    } else {
+                        g.drawLine(x + 9, y + 3, x + 9, y + 3);
+                        g.drawLine(x + 8, y + 4, x + 9, y + 4);
+                        g.drawLine(x + 7, y + 5, x + 9, y + 5);
+                        g.drawLine(x + 6, y + 6, x + 8, y + 6);
+                        g.drawLine(x + 3, y + 7, x + 7, y + 7);
+                        g.drawLine(x + 4, y + 8, x + 6, y + 8);
+                        g.drawLine(x + 5, y + 9, x + 5, y + 9);
+                        g.drawLine(x + 3, y + 5, x + 3, y + 5);
+                        g.drawLine(x + 3, y + 6, x + 4, y + 6);
+                    }
                 }
             }
         }
@@ -475,54 +485,94 @@
                 g.fillRect(x+2, y+2, 8, 8);
 
 
+                boolean isScaledGraphics = SwingUtilities2.isScaledGraphics(g);
+
+                if (isScaledGraphics) {
+
+                    Graphics2D g2d = (Graphics2D) g;
+                    Stroke oldStroke = g2d.getStroke();
+                    g2d.setStroke(new BasicStroke(1.03f, BasicStroke.CAP_ROUND,
+                                                  BasicStroke.JOIN_ROUND));
+                    Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                                         RenderingHints.VALUE_ANTIALIAS_ON);
+
                     // outter left arc
-                g.setColor(UIManager.getColor("RadioButton.shadow"));
-                g.drawLine(x+4, y+0, x+7, y+0);
-                g.drawLine(x+2, y+1, x+3, y+1);
-                g.drawLine(x+8, y+1, x+9, y+1);
-                g.drawLine(x+1, y+2, x+1, y+3);
-                g.drawLine(x+0, y+4, x+0, y+7);
-                g.drawLine(x+1, y+8, x+1, y+9);
+                    g.setColor(UIManager.getColor("RadioButton.shadow"));
+                    g.drawArc(x, y, 11, 11, 45, 180);
+                    // outter right arc
+                    g.setColor(UIManager.getColor("RadioButton.highlight"));
+                    g.drawArc(x, y, 11, 11, 45, -180);
+                    // inner left arc
+                    g.setColor(UIManager.getColor("RadioButton.darkShadow"));
+                    g.drawArc(x + 1, y + 1, 9, 9, 45, 180);
+                    // inner right arc
+                    g.setColor(UIManager.getColor("RadioButton.light"));
+                    g.drawArc(x + 1, y + 1, 9, 9, 45, -180);
+
+                    g2d.setStroke(oldStroke);
 
-                // outter right arc
-                g.setColor(UIManager.getColor("RadioButton.highlight"));
-                g.drawLine(x+2, y+10, x+3, y+10);
-                g.drawLine(x+4, y+11, x+7, y+11);
-                g.drawLine(x+8, y+10, x+9, y+10);
-                g.drawLine(x+10, y+9, x+10, y+8);
-                g.drawLine(x+11, y+7, x+11, y+4);
-                g.drawLine(x+10, y+3, x+10, y+2);
+                    if (model.isSelected()) {
+                        if (model.isEnabled()) {
+                            g.setColor(UIManager.getColor("RadioButton.foreground"));
+                        } else {
+                            g.setColor(UIManager.getColor("RadioButton.shadow"));
+                        }
+                        g.fillOval(x + 3, y + 3, 5, 5);
+                    }
+                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);
+
+                } else {
+
+                    // outter left arc
+                    g.setColor(UIManager.getColor("RadioButton.shadow"));
+                    g.drawLine(x+4, y+0, x+7, y+0);
+                    g.drawLine(x+2, y+1, x+3, y+1);
+                    g.drawLine(x+8, y+1, x+9, y+1);
+                    g.drawLine(x+1, y+2, x+1, y+3);
+                    g.drawLine(x+0, y+4, x+0, y+7);
+                    g.drawLine(x+1, y+8, x+1, y+9);
+
+                    // outter right arc
+                    g.setColor(UIManager.getColor("RadioButton.highlight"));
+                    g.drawLine(x+2, y+10, x+3, y+10);
+                    g.drawLine(x+4, y+11, x+7, y+11);
+                    g.drawLine(x+8, y+10, x+9, y+10);
+                    g.drawLine(x+10, y+9, x+10, y+8);
+                    g.drawLine(x+11, y+7, x+11, y+4);
+                    g.drawLine(x+10, y+3, x+10, y+2);
 
 
-                // inner left arc
-                g.setColor(UIManager.getColor("RadioButton.darkShadow"));
-                g.drawLine(x+4, y+1, x+7, y+1);
-                g.drawLine(x+2, y+2, x+3, y+2);
-                g.drawLine(x+8, y+2, x+9, y+2);
-                g.drawLine(x+2, y+3, x+2, y+3);
-                g.drawLine(x+1, y+4, x+1, y+7);
-                g.drawLine(x+2, y+8, x+2, y+8);
+                    // inner left arc
+                    g.setColor(UIManager.getColor("RadioButton.darkShadow"));
+                    g.drawLine(x+4, y+1, x+7, y+1);
+                    g.drawLine(x+2, y+2, x+3, y+2);
+                    g.drawLine(x+8, y+2, x+9, y+2);
+                    g.drawLine(x+2, y+3, x+2, y+3);
+                    g.drawLine(x+1, y+4, x+1, y+7);
+                    g.drawLine(x+2, y+8, x+2, y+8);
 
 
-                // inner right arc
-                g.setColor(UIManager.getColor("RadioButton.light"));
-                g.drawLine(x+2,  y+9,  x+3,  y+9);
-                g.drawLine(x+4,  y+10, x+7,  y+10);
-                g.drawLine(x+8,  y+9,  x+9,  y+9);
-                g.drawLine(x+9,  y+8,  x+9,  y+8);
-                g.drawLine(x+10, y+7,  x+10, y+4);
-                g.drawLine(x+9,  y+3,  x+9,  y+3);
+                    // inner right arc
+                    g.setColor(UIManager.getColor("RadioButton.light"));
+                    g.drawLine(x+2,  y+9,  x+3,  y+9);
+                    g.drawLine(x+4,  y+10, x+7,  y+10);
+                    g.drawLine(x+8,  y+9,  x+9,  y+9);
+                    g.drawLine(x+9,  y+8,  x+9,  y+8);
+                    g.drawLine(x+10, y+7,  x+10, y+4);
+                    g.drawLine(x+9,  y+3,  x+9,  y+3);
 
 
-                 // indicate whether selected or not
-                if (model.isSelected()) {
-                    if (model.isEnabled()) {
-                        g.setColor(UIManager.getColor("RadioButton.foreground"));
-                    } else {
-                        g.setColor(UIManager.getColor("RadioButton.shadow"));
+                     // indicate whether selected or not
+                    if (model.isSelected()) {
+                        if (model.isEnabled()) {
+                            g.setColor(UIManager.getColor("RadioButton.foreground"));
+                        } else {
+                            g.setColor(UIManager.getColor("RadioButton.shadow"));
+                        }
+                        g.fillRect(x+4, y+5, 4, 2);
+                        g.fillRect(x+5, y+4, 2, 4);
                     }
-                    g.fillRect(x+4, y+5, 4, 2);
-                    g.fillRect(x+5, y+4, 2, 4);
                 }
             }
         }
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -44,7 +44,7 @@
 public final class AuFileReader extends SunFileReader {
 
     @Override
-    public StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
         final DataInputStream dis = new DataInputStream(stream);
         final int magic = dis.readInt();
@@ -55,9 +55,15 @@
         }
 
         final int headerSize = dis.readInt();
+        if (headerSize < AuFileFormat.AU_HEADERSIZE) {
+            throw new UnsupportedAudioFileException("Invalid header size");
+        }
         final long /* unsigned int */ dataSize = dis.readInt() & 0xffffffffL;
         final int auType = dis.readInt();
         final int sampleRate = dis.readInt();
+        if (sampleRate <= 0) {
+            throw new UnsupportedAudioFileException("Invalid sample rate");
+        }
         final int channels = dis.readInt();
         if (channels <= 0) {
             throw new UnsupportedAudioFileException("Invalid number of channels");
@@ -119,10 +125,19 @@
                 // unsupported filetype, throw exception
                 throw new UnsupportedAudioFileException("not a valid AU file");
         }
-        // now seek past the header
+
+        // Skip the variable-length annotation field. The content of this field
+        // is currently undefined by AU specification and is unsupported by
+        // JavaSound, so seek past the header
         dis.skipBytes(headerSize - AuFileFormat.AU_HEADERSIZE);
 
+        // Even if the sampleSizeInBits and channels are supported we can get an
+        // unsupported frameSize because of overflow
         final int frameSize = calculatePCMFrameSize(sampleSizeInBits, channels);
+        if (frameSize <= 0) {
+            throw new UnsupportedAudioFileException("Invalid frame size");
+        }
+
         //$$fb 2002-11-02: fix for 4629669: AU file reader: problems with empty files
         //$$fb 2003-10-20: fix for 4940459: AudioInputStream.getFrameLength() returns 0 instead of NOT_SPECIFIED
         long frameLength = AudioSystem.NOT_SPECIFIED;
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -252,6 +252,10 @@
      * @return the size of a PCM frame in bytes.
      */
     static final int calculatePCMFrameSize(int sampleSizeInBits, int channels) {
-        return ((sampleSizeInBits + 7) / 8) * channels;
+        try {
+            return Math.multiplyExact((sampleSizeInBits + 7) / 8, channels);
+        } catch (final ArithmeticException ignored) {
+            return 0;
+        }
     }
 }
--- a/jdk/src/java.desktop/share/classes/java/awt/Desktop.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Desktop.java	Tue Oct 18 17:14:09 2016 +0000
@@ -271,6 +271,14 @@
         }
     }
 
+    private void checkEventsProcessingPermission() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(new RuntimePermission(
+                    "canProcessApplicationEvents"));
+        }
+    }
+
     /**
      * Returns the {@code Desktop} instance of the current
      * desktop context. On some platforms the Desktop API may not be
@@ -662,7 +670,7 @@
      *
      * @throws SecurityException if a security manager exists and it
      * denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")}
+     * {@code RuntimePermission("canProcessApplicationEvents")}
      * permission
      *
      * @see java.awt.desktop.AppForegroundListener
@@ -674,7 +682,7 @@
      * @since 9
      */
     public void addAppEventListener(final SystemEventListener listener) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         peer.addAppEventListener(listener);
     }
 
@@ -689,7 +697,7 @@
      *
      * @throws SecurityException if a security manager exists and it
      * denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")}
+     * {@code RuntimePermission("canProcessApplicationEvents")}
      * permission
      *
      * @see java.awt.desktop.AppForegroundListener
@@ -701,7 +709,7 @@
      * @since 9
      */
     public void removeAppEventListener(final SystemEventListener listener) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         peer.removeAppEventListener(listener);
     }
 
@@ -716,7 +724,7 @@
      *
      * @throws SecurityException if a security manager exists and it
      * denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")}
+     * {@code RuntimePermission("canProcessApplicationEvents")}
      * permission
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Desktop.Action#APP_ABOUT} action
@@ -724,7 +732,7 @@
      * @since 9
      */
     public void setAboutHandler(final AboutHandler aboutHandler) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkActionSupport(Action.APP_ABOUT);
         peer.setAboutHandler(aboutHandler);
     }
@@ -741,14 +749,13 @@
      *
      * @throws SecurityException if a security manager exists and it
      * denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")}
-     * permission
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Desktop.Action#APP_PREFERENCES} action
      * @since 9
      */
     public void setPreferencesHandler(final PreferencesHandler preferencesHandler) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkActionSupport(Action.APP_PREFERENCES);
         peer.setPreferencesHandler(preferencesHandler);
     }
@@ -770,7 +777,7 @@
      * @throws SecurityException if a security manager exists and its
      * {@link java.lang.SecurityManager#checkRead(java.lang.String)}
      * method denies read access to the files, or it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")}
+     * {@code RuntimePermission("canProcessApplicationEvents")}
      * permission, or the calling thread is not allowed to create a
      * subprocess
      * @throws UnsupportedOperationException if the current platform
@@ -778,7 +785,7 @@
      * @since 9
      */
     public void setOpenFileHandler(final OpenFilesHandler openFileHandler) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkExec();
         checkRead();
         checkActionSupport(Action.APP_OPEN_FILE);
@@ -800,12 +807,14 @@
      * @param printFileHandler handler
      * @throws SecurityException if a security manager exists and its
      * {@link java.lang.SecurityManager#checkPrintJobAccess()} method denies
-     * the permission to print.
+     * the permission to print or it denies the
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Desktop.Action#APP_PRINT_FILE} action
      * @since 9
      */
     public void setPrintFileHandler(final PrintFilesHandler printFileHandler) {
+        checkEventsProcessingPermission();
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
             sm.checkPrintJobAccess();
@@ -832,7 +841,7 @@
      *
      * @param openURIHandler handler
      *
-     * {@code AWTPermission("showWindowWithoutWarningBanner")}
+     * {@code RuntimePermission("canProcessApplicationEvents")}
      * permission, or the calling thread is not allowed to create a
      * subprocess
      * @throws UnsupportedOperationException if the current platform
@@ -840,7 +849,7 @@
      * @since 9
      */
     public void setOpenURIHandler(final OpenURIHandler openURIHandler) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkExec();
         checkActionSupport(Action.APP_OPEN_URI);
         peer.setOpenURIHandler(openURIHandler);
@@ -856,12 +865,14 @@
      * asked to quit
      *
      * @throws SecurityException if a security manager exists and it
-     * will not allow the caller to invoke {@code System.exit}
+     * will not allow the caller to invoke {@code System.exit} or it denies the
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Desktop.Action#APP_QUIT_HANDLER} action
      * @since 9
      */
     public void setQuitHandler(final QuitHandler quitHandler) {
+        checkEventsProcessingPermission();
         checkQuitPermission();
         checkActionSupport(Action.APP_QUIT_HANDLER);
         peer.setQuitHandler(quitHandler);
@@ -874,13 +885,15 @@
      * @param strategy the way this application should be shutdown
      *
      * @throws SecurityException if a security manager exists and it
-     * will not allow the caller to invoke {@code System.exit}
+     * will not allow the caller to invoke {@code System.exit} or it denies the
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Desktop.Action#APP_QUIT_STRATEGY} action
      * @see QuitStrategy
      * @since 9
      */
     public void setQuitStrategy(final QuitStrategy strategy) {
+        checkEventsProcessingPermission();
         checkQuitPermission();
         checkActionSupport(Action.APP_QUIT_STRATEGY);
         peer.setQuitStrategy(strategy);
@@ -901,13 +914,15 @@
      * effectively "kill -KILL" your application.
      *
      * @throws SecurityException if a security manager exists and it
-     * will not allow the caller to invoke {@code System.exit}
+     * will not allow the caller to invoke {@code System.exit} or it denies the
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Desktop.Action#APP_SUDDEN_TERMINATION} action
      * @see #disableSuddenTermination()
      * @since 9
      */
     public void enableSuddenTermination() {
+        checkEventsProcessingPermission();
         checkQuitPermission();
         checkActionSupport(Action.APP_SUDDEN_TERMINATION);
         peer.enableSuddenTermination();
@@ -920,13 +935,15 @@
      * may not be terminated without notification.
      *
      * @throws SecurityException if a security manager exists and it
-     * will not allow the caller to invoke {@code System.exit}
+     * will not allow the caller to invoke {@code System.exit} or it denies the
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Desktop.Action#APP_SUDDEN_TERMINATION} action
      * @see #enableSuddenTermination()
      * @since 9
      */
     public void disableSuddenTermination() {
+        checkEventsProcessingPermission();
         checkQuitPermission();
         checkActionSupport(Action.APP_SUDDEN_TERMINATION);
         peer.disableSuddenTermination();
@@ -938,13 +955,13 @@
      * @param allWindows if all windows of this application should be moved to
      * the foreground, or only the foremost one
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Desktop.Action#APP_REQUEST_FOREGROUND} action
      * @since 9
      */
     public void requestForeground(final boolean allWindows) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkActionSupport(Action.APP_REQUEST_FOREGROUND);
         peer.requestForeground(allWindows);
     }
@@ -957,13 +974,13 @@
      * and registered in the Info.plist with CFBundleHelpBookFolder
      *
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Desktop.Action#APP_HELP_VIEWER} action
      * @since 9
      */
     public void openHelpViewer() {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkActionSupport(Action.APP_HELP_VIEWER);
         peer.openHelpViewer();
     }
@@ -975,13 +992,13 @@
      *
      * @param menuBar to use when no other frames are active
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Desktop.Action#APP_MENU_BAR} action
      * @since 9
      */
     public void setDefaultMenuBar(final JMenuBar menuBar) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkActionSupport(Action.APP_MENU_BAR);
         peer.setDefaultMenuBar(menuBar);
     }
--- a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java	Tue Oct 18 17:14:09 2016 +0000
@@ -179,14 +179,13 @@
 
     /**
      *  Calls to the security manager's {@code checkPermission} method with
-     *  an {@code AWTPermission("showWindowWithoutWarningBanner")}
-     *  permission.
+     *  an {@code RuntimePermission("canProcessApplicationEvents")} permissions.
      */
-    private void checkAWTPermission(){
+    private void checkEventsProcessingPermission(){
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            sm.checkPermission(new AWTPermission(
-                    "showWindowWithoutWarningBanner"));
+            sm.checkPermission(new RuntimePermission(
+                    "canProcessApplicationEvents"));
         }
     }
 
@@ -262,12 +261,12 @@
      * @param enabled disables this request if false
      * @param critical if this is an important request
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#USER_ATTENTION} feature
      */
     public void requestUserAttention(final boolean enabled, final boolean critical) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.USER_ATTENTION);
         peer.requestUserAttention(enabled, critical);
     }
@@ -277,12 +276,12 @@
      *
      * @param w window
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#USER_ATTENTION_WINDOW} feature
      */
     public void requestWindowUserAttention(Window w) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.USER_ATTENTION_WINDOW);
         peer.requestWindowUserAttention(w);
     }
@@ -293,12 +292,12 @@
      *
      * @param menu the PopupMenu to attach to this application
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#MENU} feature
      */
     public void setMenu(final PopupMenu menu) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.MENU);
         peer.setMenu(menu);
     }
@@ -308,12 +307,12 @@
      *
      * @return the PopupMenu
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#MENU} feature
      */
     public PopupMenu getMenu() {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.MENU);
         return peer.getMenu();
     }
@@ -323,12 +322,12 @@
      *
      * @param image to change
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#ICON_IMAGE} feature
      */
     public void setIconImage(final Image image) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.ICON_IMAGE);
         peer.setIconImage(image);
     }
@@ -338,12 +337,12 @@
      *
      * @return an image of this application's icon
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#ICON_IMAGE} feature
      */
     public Image getIconImage() {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.ICON_IMAGE);
         return peer.getIconImage();
     }
@@ -360,13 +359,13 @@
      * Passing {@code null} as parameter hides the badge.
      * @param badge label to affix to the icon
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#ICON_BADGE_NUMBER}
      * or {@link Taskbar.Feature#ICON_BADGE_TEXT} feature
      */
     public void setIconBadge(final String badge) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.ICON_BADGE_NUMBER);
         peer.setIconBadge(badge);
     }
@@ -379,12 +378,12 @@
      * @param w window to update
      * @param badge image to affix to the icon
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#ICON_BADGE_IMAGE_WINDOW} feature
      */
     public void setWindowIconBadge(Window w, final Image badge) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.ICON_BADGE_IMAGE_WINDOW);
         if (w != null) {
             peer.setWindowIconBadge(w, badge);
@@ -396,11 +395,13 @@
      * Affixes a small system-provided progress bar to this application's icon.
      *
      * @param value from 0 to 100, other to disable progress indication
+     * @throws SecurityException if a security manager exists and it denies the
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#PROGRESS_VALUE} feature
      */
     public void setProgressValue(int value) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.PROGRESS_VALUE);
         peer.setProgressValue(value);
     }
@@ -411,12 +412,12 @@
      * @param w window to update
      * @param value from 0 to 100, other to disable progress indication
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#PROGRESS_VALUE_WINDOW} feature
      */
     public void setWindowProgressValue(Window w, int value) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.PROGRESS_VALUE_WINDOW);
         if (w != null) {
             peer.setWindowProgressValue(w, value);
@@ -434,12 +435,12 @@
      * @see State#INDETERMINATE
      * @see State#ERROR
      * @throws SecurityException if a security manager exists and it denies the
-     * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
+     * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
      * does not support the {@link Taskbar.Feature#PROGRESS_STATE_WINDOW} feature
      */
     public void setWindowProgressState(Window w, State state) {
-        checkAWTPermission();
+        checkEventsProcessingPermission();
         checkFeatureSupport(Feature.PROGRESS_STATE_WINDOW);
         if (w != null) {
             peer.setWindowProgressState(w, state);
--- a/jdk/src/java.desktop/share/classes/java/awt/TextField.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/TextField.java	Tue Oct 18 17:14:09 2016 +0000
@@ -159,8 +159,8 @@
      * @param      text       the text to be displayed. If
      *             {@code text} is {@code null}, the empty
      *             string {@code ""} will be displayed.
-     *             If {@code text} contains EOL character, then
-     *             it will be replaced by space character.
+     *             If {@code text} contains EOL and/or LF characters, then
+     *             each will be replaced by space character.
      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
      * returns true.
      * @see java.awt.GraphicsEnvironment#isHeadless
@@ -192,8 +192,8 @@
      * @param      text       the text to be displayed. If
      *             {@code text} is {@code null}, the empty
      *             string {@code ""} will be displayed.
-     *             If {@code text} contains EOL character, then
-     *             it will be replaced by space character.
+     *             If {@code text} contains EOL and/or LF characters, then
+     *             each will be replaced by space character.
      * @param      columns     the number of columns.  If
      *             {@code columns} is less than {@code 0},
      *             {@code columns} is set to {@code 0}.
@@ -300,8 +300,8 @@
      * @param      t       the new text. If
      *             {@code t} is {@code null}, the empty
      *             string {@code ""} will be displayed.
-     *             If {@code t} contains EOL character, then
-     *             it will be replaced by space character.
+     *             If {@code t} contains EOL and/or LF characters, then
+     *             each will be replaced by space character.
      * @see         java.awt.TextComponent#getText
      */
     public void setText(String t) {
--- a/jdk/src/java.desktop/share/classes/java/awt/Window.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Window.java	Tue Oct 18 17:14:09 2016 +0000
@@ -678,6 +678,10 @@
      * Depending on the platform capabilities one or several images
      * of different dimensions will be used as the window's icon.
      * <p>
+     * The {@code icons} list can contain {@code MultiResolutionImage} images also.
+     * Suitable image depending on screen resolution is extracted from
+     * base {@code MultiResolutionImage} image and added to the icons list
+     * while base resolution image is removed from list.
      * The {@code icons} list is scanned for the images of most
      * appropriate dimensions from the beginning. If the list contains
      * several images of the same size, the first will be used.
--- a/jdk/src/java.desktop/share/classes/java/beans/MetaData.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/beans/MetaData.java	Tue Oct 18 17:14:09 2016 +0000
@@ -510,102 +510,6 @@
             return new Expression(oldInstance, Collections.class, "synchronizedSortedMap", new Object[]{map});
         }
     }
-
-    static final class CheckedCollection_PersistenceDelegate extends java_util_Collections {
-        protected Expression instantiate(Object oldInstance, Encoder out) {
-            Object type = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedCollection.type");
-            List<?> list = new ArrayList<>((Collection<?>) oldInstance);
-            return new Expression(oldInstance, Collections.class, "checkedCollection", new Object[]{list, type});
-        }
-    }
-
-    static final class CheckedList_PersistenceDelegate extends java_util_Collections {
-        protected Expression instantiate(Object oldInstance, Encoder out) {
-            Object type = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedCollection.type");
-            List<?> list = new LinkedList<>((Collection<?>) oldInstance);
-            return new Expression(oldInstance, Collections.class, "checkedList", new Object[]{list, type});
-        }
-    }
-
-    static final class CheckedRandomAccessList_PersistenceDelegate extends java_util_Collections {
-        protected Expression instantiate(Object oldInstance, Encoder out) {
-            Object type = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedCollection.type");
-            List<?> list = new ArrayList<>((Collection<?>) oldInstance);
-            return new Expression(oldInstance, Collections.class, "checkedList", new Object[]{list, type});
-        }
-    }
-
-    static final class CheckedSet_PersistenceDelegate extends java_util_Collections {
-        protected Expression instantiate(Object oldInstance, Encoder out) {
-            Object type = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedCollection.type");
-            Set<?> set = new HashSet<>((Set<?>) oldInstance);
-            return new Expression(oldInstance, Collections.class, "checkedSet", new Object[]{set, type});
-        }
-    }
-
-    static final class CheckedSortedSet_PersistenceDelegate extends java_util_Collections {
-        protected Expression instantiate(Object oldInstance, Encoder out) {
-            Object type = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedCollection.type");
-            SortedSet<?> set = new TreeSet<>((SortedSet<?>) oldInstance);
-            return new Expression(oldInstance, Collections.class, "checkedSortedSet", new Object[]{set, type});
-        }
-    }
-
-    static final class CheckedMap_PersistenceDelegate extends java_util_Collections {
-        protected Expression instantiate(Object oldInstance, Encoder out) {
-            Object keyType   = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedMap.keyType");
-            Object valueType = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedMap.valueType");
-            Map<?,?> map = new HashMap<>((Map<?,?>) oldInstance);
-            return new Expression(oldInstance, Collections.class, "checkedMap", new Object[]{map, keyType, valueType});
-        }
-    }
-
-    static final class CheckedSortedMap_PersistenceDelegate extends java_util_Collections {
-        protected Expression instantiate(Object oldInstance, Encoder out) {
-            Object keyType   = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedMap.keyType");
-            Object valueType = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedMap.valueType");
-            SortedMap<?,?> map = new TreeMap<>((SortedMap<?,?>) oldInstance);
-            return new Expression(oldInstance, Collections.class, "checkedSortedMap", new Object[]{map, keyType, valueType});
-        }
-    }
-}
-
-/**
- * The persistence delegate for {@code java.util.EnumMap} classes.
- *
- * @author Sergey A. Malenkov
- */
-static final class java_util_EnumMap_PersistenceDelegate extends PersistenceDelegate {
-    protected boolean mutatesTo(Object oldInstance, Object newInstance) {
-        return super.mutatesTo(oldInstance, newInstance) && (getType(oldInstance) == getType(newInstance));
-    }
-
-    protected Expression instantiate(Object oldInstance, Encoder out) {
-        return new Expression(oldInstance, EnumMap.class, "new", new Object[] {getType(oldInstance)});
-    }
-
-    private static Object getType(Object instance) {
-        return MetaData.getPrivateFieldValue(instance, "java.util.EnumMap.keyType");
-    }
-}
-
-/**
- * The persistence delegate for {@code java.util.EnumSet} classes.
- *
- * @author Sergey A. Malenkov
- */
-static final class java_util_EnumSet_PersistenceDelegate extends PersistenceDelegate {
-    protected boolean mutatesTo(Object oldInstance, Object newInstance) {
-        return super.mutatesTo(oldInstance, newInstance) && (getType(oldInstance) == getType(newInstance));
-    }
-
-    protected Expression instantiate(Object oldInstance, Encoder out) {
-        return new Expression(oldInstance, EnumSet.class, "noneOf", new Object[] {getType(oldInstance)});
-    }
-
-    private static Object getType(Object instance) {
-        return MetaData.getPrivateFieldValue(instance, "java.util.EnumSet.elementType");
-    }
 }
 
 // Collection
@@ -1313,9 +1217,6 @@
 
         internalPersistenceDelegates.put("java.sql.Date", new java_util_Date_PersistenceDelegate());
         internalPersistenceDelegates.put("java.sql.Time", new java_util_Date_PersistenceDelegate());
-
-        internalPersistenceDelegates.put("java.util.JumboEnumSet", new java_util_EnumSet_PersistenceDelegate());
-        internalPersistenceDelegates.put("java.util.RegularEnumSet", new java_util_EnumSet_PersistenceDelegate());
     }
 
     @SuppressWarnings("rawtypes")
--- a/jdk/src/java.desktop/share/classes/javax/swing/JCheckBoxMenuItem.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JCheckBoxMenuItem.java	Tue Oct 18 17:14:09 2016 +0000
@@ -58,10 +58,13 @@
  * <p>
  * Some times it is required to select several check box menu items from a menu.
  * In this case it is useful that clicking on one check box menu item does not
- * close the menu. Such behavior can be controlled by the Look and Feel property
- * named {@code "CheckBoxMenuItem.closeOnMouseClick"}. The default value is
- * {@code true}. Setting the property to {@code false} prevents the menu from
- * closing when it is clicked by the mouse.
+ * close the menu. Such behavior can be controlled either by client
+ * {@link JComponent#putClientProperty} or the Look and Feel
+ * {@link UIManager#put} property named
+ * {@code "CheckBoxMenuItem.doNotCloseOnMouseClick"}. The default value is
+ * {@code false}. Setting the property to {@code true} prevents the menu from
+ * closing when it is clicked by the mouse. If the client property is set its
+ * value is always used; otherwise the {@literal L&F} property is queried.
  * Note: some {@code L&F}s may ignore this property. All built-in {@code L&F}s
  * inherit this behaviour.
  * <p>
--- a/jdk/src/java.desktop/share/classes/javax/swing/JRadioButtonMenuItem.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JRadioButtonMenuItem.java	Tue Oct 18 17:14:09 2016 +0000
@@ -52,10 +52,13 @@
  * <p>
  * Some menus can have several button groups with radio button menu items. In
  * this case it is useful that clicking on one radio button menu item does not
- * close the menu. Such behavior can be controlled by the Look and Feel property
- * named {@code "RadioButtonMenuItem.closeOnMouseClick"}. The default value is
- * {@code true}. Setting the property to {@code false} prevents the menu from
- * closing when it is clicked by the mouse.
+ * close the menu. Such behavior can be controlled either by client
+ * {@link JComponent#putClientProperty} or the Look and Feel
+ * {@link UIManager#put} property named
+ * {@code "RadioButtonMenuItem.doNotCloseOnMouseClick"}. The default value is
+ * {@code false}. Setting the property to {@code true} prevents the menu from
+ * closing when it is clicked by the mouse. If the client property is set its
+ * value is always used; otherwise the {@literal L&F} property is queried.
  * Note: some {@code L&F}s may ignore this property. All built-in {@code L&F}s
  * inherit this behaviour.
  * <p>
--- a/jdk/src/java.desktop/share/classes/javax/swing/LayoutFocusTraversalPolicy.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/LayoutFocusTraversalPolicy.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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,9 +26,9 @@
 
 import java.awt.Component;
 import java.awt.Container;
-import java.awt.ComponentOrientation;
 import java.util.Comparator;
 import java.io.*;
+import java.util.Enumeration;
 import sun.awt.SunToolkit;
 
 
@@ -236,6 +236,31 @@
             JComboBox<?> box = (JComboBox)aComponent;
             return box.getUI().isFocusTraversable(box);
         } else if (aComponent instanceof JComponent) {
+            if (SunToolkit.isInstanceOf(aComponent,
+                                                 "javax.swing.JToggleButton")) {
+                JToggleButton.ToggleButtonModel model =
+                        (JToggleButton.ToggleButtonModel) ((JToggleButton)
+                                aComponent).getModel();
+                if (model != null) {
+                    ButtonGroup group = model.getGroup();
+                    if (group != null) {
+                        Enumeration<AbstractButton> elements =
+                                                            group.getElements();
+                        int idx = 0;
+                        while (elements.hasMoreElements()) {
+                            AbstractButton member = elements.nextElement();
+                            if (member.isVisible() && member.isDisplayable() &&
+                                   member.isEnabled() && member.isFocusable()) {
+                                if (member == aComponent) {
+                                    return idx == 0;
+                                }
+                                idx++;
+                            }
+                        }
+                    }
+                }
+            }
+
             JComponent jComponent = (JComponent)aComponent;
             InputMap inputMap = jComponent.getInputMap(JComponent.WHEN_FOCUSED,
                                                        false);
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicArrowButton.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicArrowButton.java	Tue Oct 18 17:14:09 2016 +0000
@@ -27,9 +27,13 @@
 import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Path2D;
 
 import javax.swing.*;
 import javax.swing.plaf.UIResource;
+import sun.swing.SwingUtilities2;
 
 /**
  * JButton object that draws a scaled Arrow in one of the cardinal directions.
@@ -236,6 +240,16 @@
          */
         public void paintTriangle(Graphics g, int x, int y, int size,
                                         int direction, boolean isEnabled) {
+            if (SwingUtilities2.isScaledGraphics(g)) {
+                paintScaledTriangle(g, x, y, size, direction, isEnabled);
+            } else {
+                paintUnscaledTriangle(g, x, y, size, direction, isEnabled);
+            }
+        }
+
+        private void paintUnscaledTriangle(Graphics g, int x, int y, int size,
+                                           int direction, boolean isEnabled)
+        {
             Color oldColor = g.getColor();
             int mid, i, j;
 
@@ -309,4 +323,32 @@
             g.setColor(oldColor);
         }
 
+    private void paintScaledTriangle(Graphics g, double x, double y, double size,
+                                     int direction, boolean isEnabled) {
+        size = Math.max(size, 2);
+        Path2D.Double path = new Path2D.Double();
+        path.moveTo(-size, size / 2);
+        path.lineTo(size, size / 2);
+        path.lineTo(0, -size / 2);
+        path.closePath();
+        AffineTransform affineTransform = new AffineTransform();
+        affineTransform.rotate(Math.PI * (direction - 1) / 4);
+        path.transform(affineTransform);
+
+        Graphics2D g2d = (Graphics2D) g;
+        double tx = x + size / 2;
+        double ty = y + size / 2;
+        g2d.translate(tx, ty);
+        Color oldColor = g.getColor();
+        if (!isEnabled) {
+            g2d.translate(1, 0);
+            g2d.setColor(highlight);
+            g2d.fill(path);
+            g2d.translate(-1, 0);
+        }
+        g2d.setColor(isEnabled ? darkShadow : shadow);
+        g2d.fill(path);
+        g2d.translate(-tx, -ty);
+        g2d.setColor(oldColor);
+    }
 }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1055,7 +1055,6 @@
             "RadioButtonMenuItem.checkIcon", radioButtonMenuItemIcon,
             "RadioButtonMenuItem.arrowIcon", menuItemArrowIcon,
             "RadioButtonMenuItem.commandSound", null,
-            "RadioButtonMenuItem.closeOnMouseClick", Boolean.TRUE,
 
             "CheckBoxMenuItem.font", dialogPlain12,
             "CheckBoxMenuItem.acceleratorFont", dialogPlain12,
@@ -1072,7 +1071,6 @@
             "CheckBoxMenuItem.checkIcon", checkBoxMenuItemIcon,
             "CheckBoxMenuItem.arrowIcon", menuItemArrowIcon,
             "CheckBoxMenuItem.commandSound", null,
-            "CheckBoxMenuItem.closeOnMouseClick", Boolean.TRUE,
 
             "Menu.font", dialogPlain12,
             "Menu.acceleratorFont", dialogPlain12,
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -936,13 +936,15 @@
         }
     }
 
-    boolean closeOnMouseClick() {
+    boolean doNotCloseOnMouseClick() {
         if (menuItem instanceof JCheckBoxMenuItem) {
-            return UIManager.getBoolean("CheckBoxMenuItem.closeOnMouseClick");
+            String property = "CheckBoxMenuItem.doNotCloseOnMouseClick";
+            return SwingUtilities2.getBoolean(menuItem, property);
         } else if (menuItem instanceof JRadioButtonMenuItem) {
-            return UIManager.getBoolean("RadioButtonMenuItem.closeOnMouseClick");
+            String property = "RadioButtonMenuItem.doNotCloseOnMouseClick";
+            return SwingUtilities2.getBoolean(menuItem, property);
         }
-        return true;
+        return false;
     }
 
     /**
@@ -967,7 +969,7 @@
             BasicLookAndFeel.playSound(menuItem, getPropertyPrefix() +
                                        ".commandSound");
         }
-        if (closeOnMouseClick()) {
+        if (!doNotCloseOnMouseClick()) {
             // Visual feedback
             if (msm == null) {
                 msm = MenuSelectionManager.defaultManager();
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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
@@ -438,21 +438,7 @@
         // Check if the next object to gain focus belongs
         // to the button group or not
         Component getFocusTransferBaseComponent(boolean next){
-            Component focusBaseComp = activeBtn;
-            Container container = focusBaseComp.getFocusCycleRootAncestor();
-            if (container != null) {
-                FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
-                Component comp = next ? policy.getComponentAfter(container, activeBtn)
-                                      : policy.getComponentBefore(container, activeBtn);
-
-                // If next component in the button group, use last/first button as base focus
-                // otherwise, use the activeBtn as the base focus
-                if (containsInGroup(comp)) {
-                    focusBaseComp = next ? lastBtn : firstBtn;
-                }
-            }
-
-            return focusBaseComp;
+            return firstBtn;
         }
 
         boolean getButtonGroupInfo() {
--- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Tue Oct 18 17:14:09 2016 +0000
@@ -46,6 +46,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.security.AccessController;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Locale;
@@ -887,12 +888,21 @@
         if (width == 0 || height == 0) {
             return null;
         }
+        java.util.List<Image> multiResAndnormalImages = new ArrayList<>(imageList.size());
+        for (Image image : imageList) {
+            if ((image instanceof MultiResolutionImage)) {
+                Image im = ((MultiResolutionImage) image).getResolutionVariant(width, height);
+                multiResAndnormalImages.add(im);
+            } else {
+                multiResAndnormalImages.add(image);
+            }
+        }
         Image bestImage = null;
         int bestWidth = 0;
         int bestHeight = 0;
         double bestSimilarity = 3; //Impossibly high value
         double bestScaleFactor = 0;
-        for (Iterator<Image> i = imageList.iterator();i.hasNext();) {
+        for (Iterator<Image> i = multiResAndnormalImages.iterator();i.hasNext();) {
             //Iterate imageList looking for best matching image.
             //'Similarity' measure is defined as good scale factor and small insets.
             //best possible similarity is 0 (no scale, no insets).
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelDeviceEventListener.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute 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.java2d.pipe.hw;
-
-/**
- * An interface for receiving notifications about imminent accelerated device's
- * events. Upon receiving such event appropriate actions can be taken (for
- * example, resources associated with the device can be freed).
- */
-public interface AccelDeviceEventListener {
-    /**
-     * Called when the device is about to be reset.
-     *
-     * One must release all native resources associated with the device which
-     * prevent the device from being reset (such as Default Pool resources for
-     * the D3D pipeline).
-     *
-     * It is safe to remove the listener while in the call back.
-     *
-     * Note: this method is called on the rendering thread,
-     * do not call into user code, do not take RQ lock!
-     */
-    public void onDeviceReset();
-
-    /**
-     * Called when the device is about to be disposed of.
-     *
-     * One must release all native resources associated with the device.
-     *
-     * It is safe to remove the listener while in the call back.
-     *
-     * Note: this method is called on the rendering thread,
-     * do not call into user code, do not take RQ lock!
-     */
-    public void onDeviceDispose();
-}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 2007, 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.  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.java2d.pipe.hw;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.lang.annotation.Native;
-
-
-/**
- * This class is used to notify listeners about accelerated device's
- * events such as device reset or dispose that are about to occur.
- */
-public class AccelDeviceEventNotifier {
-
-    private static AccelDeviceEventNotifier theInstance;
-
-    /**
-     * A device is about to be reset. The listeners have to release all
-     * resources associated with the device which are required for the device
-     * to be reset.
-     */
-    @Native public static final int DEVICE_RESET = 0;
-
-    /**
-     * A device is about to be disposed. The listeners have to release all
-     * resources associated with the device.
-     */
-    @Native public static final int DEVICE_DISPOSED = 1;
-
-    private final Map<AccelDeviceEventListener, Integer> listeners;
-
-    private AccelDeviceEventNotifier() {
-        listeners = Collections.synchronizedMap(
-            new HashMap<AccelDeviceEventListener, Integer>(1));
-    }
-
-    /**
-     * Returns a singleton of AccelDeviceEventNotifier if it exists. If the
-     * passed boolean is false and singleton doesn't exist yet, null is
-     * returned. If the passed boolean is {@code true} and singleton doesn't
-     * exist it will be created and returned.
-     *
-     * @param create whether to create a singleton instance if doesn't yet
-     * exist
-     * @return a singleton instance or null
-     */
-    private static synchronized
-        AccelDeviceEventNotifier getInstance(boolean create)
-    {
-        if (theInstance == null && create) {
-            theInstance = new AccelDeviceEventNotifier();
-        }
-        return theInstance;
-    }
-
-    /**
-     * Called to indicate that a device event had occurred.
-     * If a singleton exists, the listeners (those associated with
-     * the device) will be notified.
-     *
-     * @param screen a screen number of the device which is a source of
-     * the event
-     * @param eventType a type of the event
-     * @see #DEVICE_DISPOSED
-     * @see #DEVICE_RESET
-     */
-    public static final void eventOccured(int screen, int eventType) {
-        AccelDeviceEventNotifier notifier = getInstance(false);
-        if (notifier != null) {
-            notifier.notifyListeners(eventType, screen);
-        }
-    }
-
-    /**
-     * Adds the listener associated with a device on particular screen.
-     *
-     * Note: the listener must be removed as otherwise it will forever
-     * be referenced by the notifier.
-     *
-     * @param l the listener
-     * @param screen the screen number indicating which device the listener is
-     * interested in.
-     */
-    public static final void addListener(AccelDeviceEventListener l,int screen){
-        getInstance(true).add(l, screen);
-    }
-
-    /**
-     * Removes the listener.
-     *
-     * @param l the listener
-     */
-    public static final void removeListener(AccelDeviceEventListener l) {
-        getInstance(true).remove(l);
-    }
-
-    private final void add(AccelDeviceEventListener theListener, int screen) {
-        listeners.put(theListener, screen);
-    }
-    private final void remove(AccelDeviceEventListener theListener) {
-        listeners.remove(theListener);
-    }
-
-    /**
-     * Notifies the listeners associated with the screen's device about the
-     * event.
-     *
-     * Implementation note: the current list of listeners is first duplicated
-     * which allows the listeners to remove themselves during the iteration.
-     *
-     * @param screen a screen number with which the device which is a source of
-     * the event is associated with
-     * @param deviceEventType a type of the event
-     * @see #DEVICE_DISPOSED
-     * @see #DEVICE_RESET
-     */
-    private final void notifyListeners(int deviceEventType, int screen) {
-        HashMap<AccelDeviceEventListener, Integer> listClone;
-        Set<AccelDeviceEventListener> cloneSet;
-
-        synchronized(listeners) {
-            listClone =
-                new HashMap<AccelDeviceEventListener, Integer>(listeners);
-        }
-
-        cloneSet = listClone.keySet();
-        Iterator<AccelDeviceEventListener> itr = cloneSet.iterator();
-        while (itr.hasNext()) {
-            AccelDeviceEventListener current = itr.next();
-            Integer i = listClone.get(current);
-            // only notify listeners which are interested in this device
-            if (i != null && i.intValue() != screen) {
-                continue;
-            }
-            if (deviceEventType == DEVICE_RESET) {
-                current.onDeviceReset();
-            } else if (deviceEventType == DEVICE_DISPOSED) {
-                current.onDeviceDispose();
-            }
-        }
-    }
-}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelGraphicsConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelGraphicsConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,26 +70,4 @@
      * @see ContextCapabilities
      */
     public ContextCapabilities getContextCapabilities();
-
-    /**
-     * Adds an {@code AccelDeviceEventListener} to listen to accelerated
-     * device's (which is associated with this {@code AccelGraphicsConfig})
-     * events.
-     *
-     * Note: a hard link to the listener may be kept so it must be explicitly
-     * removed via {@link #removeDeviceEventListener}.
-     *
-     * @param l the listener
-     * @see AccelDeviceEventListener
-     */
-    public void addDeviceEventListener(AccelDeviceEventListener l);
-
-    /**
-     * Removes an {@code AccelDeviceEventListener} from the list of listeners
-     * for this device's events.
-     *
-     * @param l the listener
-     * @see AccelDeviceEventListener
-     */
-    public void removeDeviceEventListener(AccelDeviceEventListener l);
 }
--- a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1282,12 +1282,6 @@
         JobSheets jobSheets = (JobSheets)attributes.get(JobSheets.class);
         if (jobSheets != null) {
             noJobSheet = jobSheets == JobSheets.NONE;
-        } else {
-            JobSheets js = (JobSheets)getPrintService().
-                                      getDefaultAttributeValue(JobSheets.class);
-            if (js != null && js.equals(JobSheets.NONE)) {
-                noJobSheet = true;
-            }
         }
 
         JobName jobName = (JobName)attributes.get(JobName.class);
@@ -1487,6 +1481,22 @@
             throw new PrinterException("Printer is not accepting job.");
         }
 
+        /*
+         * Check the default job-sheet value on underlying platform. If IPP
+         * reports job-sheets=none, then honour that and modify noJobSheet since
+         * by default, noJobSheet is false which mean jdk will print banner page.
+         * This is because if "attributes" is null (if user directly calls print()
+         * without specifying any attributes and without showing printdialog) then
+         * setAttribute will return without changing noJobSheet value.
+         * Also, we do this before setAttributes() call so as to allow the user
+         * to override this via explicitly adding JobSheets attributes to
+         * PrintRequestAttributeSet while calling print(attributes)
+         */
+        JobSheets js = (JobSheets)psvc.getDefaultAttributeValue(JobSheets.class);
+        if (js != null && js.equals(JobSheets.NONE)) {
+            noJobSheet = true;
+        }
+
         if ((psvc instanceof SunPrinterJobService) &&
             ((SunPrinterJobService)psvc).usesClass(getClass())) {
             setAttributes(attributes);
--- a/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -25,7 +25,6 @@
 package sun.swing;
 
 import java.awt.*;
-import java.awt.geom.AffineTransform;
 import java.awt.image.*;
 import java.util.*;
 
@@ -60,7 +59,11 @@
         synchronized(CachedPainter.class) {
             ImageCache cache = cacheMap.get(key);
             if (cache == null) {
-                cache = new ImageCache(1);
+                if (key == PainterMultiResolutionCachedImage.class) {
+                    cache = new ImageCache(32);
+                } else {
+                    cache = new ImageCache(1);
+                }
                 cacheMap.put(key, cache);
             }
             return cache;
@@ -271,7 +274,8 @@
         public Image getResolutionVariant(double destWidth, double destHeight) {
             int w = (int) Math.ceil(destWidth);
             int h = (int) Math.ceil(destHeight);
-            return getImage(this, c, baseWidth, baseHeight, w, h, args);
+            return getImage(PainterMultiResolutionCachedImage.class,
+                    c, baseWidth, baseHeight, w, h, args);
         }
 
         @Override
--- a/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java	Tue Oct 18 17:14:09 2016 +0000
@@ -31,6 +31,8 @@
 import java.awt.event.*;
 import java.awt.font.*;
 import java.awt.geom.AffineTransform;
+import static java.awt.geom.AffineTransform.TYPE_FLIP;
+import static java.awt.geom.AffineTransform.TYPE_TRANSLATION;
 import java.awt.print.PrinterGraphics;
 import java.text.BreakIterator;
 import java.text.CharacterIterator;
@@ -2036,6 +2038,33 @@
         return path;
     }
 
+    public static boolean isScaledGraphics(Graphics g) {
+        if (g instanceof Graphics2D) {
+            AffineTransform tx = ((Graphics2D) g).getTransform();
+            return (tx.getType() & ~(TYPE_TRANSLATION | TYPE_FLIP)) != 0;
+        }
+        return false;
+    }
+
+    /**
+     * Returns the client property for the given key if it is set; otherwise
+     * returns the {@L&F} property.
+     *
+     * @param component the component
+     * @param key an {@code String} specifying the key for the desired boolean value
+     * @return the boolean value of the client property if it is set or the {@L&F}
+     *         property in other case.
+     */
+    public static boolean getBoolean(JComponent component, String key) {
+        Object clientProperty = component.getClientProperty(key);
+
+        if (clientProperty instanceof Boolean) {
+            return Boolean.TRUE.equals(clientProperty);
+        }
+
+        return UIManager.getBoolean(key);
+    }
+
     /**
      * Used to listen to "blit" repaints in RepaintManager.
      */
--- a/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -553,30 +553,43 @@
 METHODDEF(void)
 sun_jpeg_output_message (j_common_ptr cinfo)
 {
-  char buffer[JMSG_LENGTH_MAX];
-  jstring string;
-  imageIODataPtr data = (imageIODataPtr) cinfo->client_data;
-  JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-  jobject theObject;
-
-  /* Create the message */
-  (*cinfo->err->format_message) (cinfo, buffer);
-
-  // Create a new java string from the message
-  string = (*env)->NewStringUTF(env, buffer);
-  CHECK_NULL(string);
-
-  theObject = data->imageIOobj;
-
-  if (cinfo->is_decompressor) {
-      (*env)->CallVoidMethod(env, theObject,
-                             JPEGImageReader_warningWithMessageID,
-                             string);
-  } else {
-      (*env)->CallVoidMethod(env, theObject,
-                             JPEGImageWriter_warningWithMessageID,
-                             string);
-  }
+    char buffer[JMSG_LENGTH_MAX];
+    jstring string;
+    imageIODataPtr data = (imageIODataPtr) cinfo->client_data;
+    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+    jobject theObject;
+
+    /* Create the message */
+    (*cinfo->err->format_message) (cinfo, buffer);
+
+    // Create a new java string from the message
+    string = (*env)->NewStringUTF(env, buffer);
+    CHECK_NULL(string);
+
+    theObject = data->imageIOobj;
+
+    if (cinfo->is_decompressor) {
+        struct jpeg_source_mgr *src = ((j_decompress_ptr)cinfo)->src;
+        RELEASE_ARRAYS(env, data, src->next_input_byte);
+        (*env)->CallVoidMethod(env, theObject,
+            JPEGImageReader_warningWithMessageID,
+            string);
+        if ((*env)->ExceptionOccurred(env)
+            || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+            cinfo->err->error_exit(cinfo);
+        }
+    } else {
+        struct jpeg_destination_mgr *dest = ((j_compress_ptr)cinfo)->dest;
+        RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte));
+        (*env)->CallVoidMethod(env, theObject,
+            JPEGImageWriter_warningWithMessageID,
+            string);
+        if ((*env)->ExceptionOccurred(env)
+            || !GET_ARRAYS(env, data,
+            (const JOCTET **)(&dest->next_output_byte))) {
+            cinfo->err->error_exit(cinfo);
+        }
+    }
 }
 
 /* End of verbatim copy from jpegdecoder.c */
@@ -1043,6 +1056,7 @@
         if (!GET_ARRAYS(env, data, &(src->next_input_byte))) {
             cinfo->err->error_exit((j_common_ptr) cinfo);
         }
+        RELEASE_ARRAYS(env, data, src->next_input_byte);
         return;
     }
 
@@ -1798,9 +1812,14 @@
                                cinfo->out_color_space,
                                cinfo->num_components,
                                profileData);
+        if ((*env)->ExceptionOccurred(env)
+            || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+            cinfo->err->error_exit((j_common_ptr) cinfo);
+        }
         if (reset) {
             jpeg_abort_decompress(cinfo);
         }
+        RELEASE_ARRAYS(env, data, src->next_input_byte);
     }
 
     return retval;
@@ -2010,6 +2029,7 @@
     jpeg_start_decompress(cinfo);
 
     if (numBands !=  cinfo->output_components) {
+        RELEASE_ARRAYS(env, data, src->next_input_byte);
         JNU_ThrowByName(env, "javax/imageio/IIOException",
                         "Invalid argument to native readImage");
         return data->abortFlag;
@@ -2018,6 +2038,7 @@
     if (cinfo->output_components <= 0 ||
         cinfo->image_width > (0xffffffffu / (unsigned int)cinfo->output_components))
     {
+        RELEASE_ARRAYS(env, data, src->next_input_byte);
         JNU_ThrowByName(env, "javax/imageio/IIOException",
                         "Invalid number of output components");
         return data->abortFlag;
@@ -2041,15 +2062,24 @@
             // the first interesting pass.
             jpeg_start_output(cinfo, cinfo->input_scan_number);
             if (wantUpdates) {
+                RELEASE_ARRAYS(env, data, src->next_input_byte);
                 (*env)->CallVoidMethod(env, this,
                                        JPEGImageReader_passStartedID,
                                        cinfo->input_scan_number-1);
+                if ((*env)->ExceptionOccurred(env)
+                    || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+                    cinfo->err->error_exit((j_common_ptr) cinfo);
+                }
             }
         } else if (wantUpdates) {
+            RELEASE_ARRAYS(env, data, src->next_input_byte);
             (*env)->CallVoidMethod(env, this,
                                    JPEGImageReader_passStartedID,
                                    0);
-
+            if ((*env)->ExceptionOccurred(env)
+                || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+                cinfo->err->error_exit((j_common_ptr) cinfo);
+            }
         }
 
         // Skip until the first interesting line
@@ -2137,8 +2167,13 @@
             done = TRUE;
         }
         if (wantUpdates) {
+            RELEASE_ARRAYS(env, data, src->next_input_byte);
             (*env)->CallVoidMethod(env, this,
                                    JPEGImageReader_passCompleteID);
+            if ((*env)->ExceptionOccurred(env)
+                || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+                cinfo->err->error_exit((j_common_ptr) cinfo);
+            }
         }
 
     }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java	Tue Oct 18 17:14:09 2016 +0000
@@ -308,6 +308,19 @@
         super.handlePropertyNotify(xev);
 
         XPropertyEvent ev = xev.get_xproperty();
+        if( !insets_corrected && isReparented() &&
+                                         XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
+            int state = XWM.getWM().getState(this);
+            if ((state & Frame.MAXIMIZED_BOTH) ==  Frame.MAXIMIZED_BOTH) {
+                // Stop ignoring ConfigureNotify because no extents will be sent
+                // by WM for initially maximized decorated window.
+                // Re-request window bounds to ensure actual dimensions and
+                // notify the target with the initial size.
+                insets_corrected = true;
+                XlibWrapper.XConfigureWindow(XToolkit.getDisplay(),
+                                                             getWindow(), 0, 0);
+            }
+        }
         if (ev.get_atom() == XWM.XA_KDE_NET_WM_FRAME_STRUT.getAtom()
             || ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom())
         {
@@ -326,9 +339,29 @@
                     lastKnownInsets.put(getClass(), in);
                 }
                 if (!in.equals(dimensions.getInsets())) {
-                    handleCorrectInsets(in);
+                    if (insets_corrected || isMaximized()) {
+                        currentInsets = in;
+                        insets_corrected = true;
+                        // insets were changed by WM. To handle this situation
+                        // re-request window bounds because the current
+                        // dimensions may be not actual as well.
+                        XlibWrapper.XConfigureWindow(XToolkit.getDisplay(),
+                                                             getWindow(), 0, 0);
+                    } else {
+                        // recalculate dimensions when window is just created
+                        // and the initially guessed insets were wrong
+                        handleCorrectInsets(in);
+                    }
+                } else if (!dimensions.isClientSizeSet()) {
+                    insets_corrected = true;
+                    // initial insets were guessed correctly. Re-request
+                    // frame bounds because they may be changed by WM if the
+                    // initial window position overlapped desktop's toolbars.
+                    // This should initiate the final ConfigureNotify upon which
+                    // the target will be notified with the final size.
+                    XlibWrapper.XConfigureWindow(XToolkit.getDisplay(),
+                                                             getWindow(), 0, 0);
                 }
-                insets_corrected = true;
             }
         }
     }
@@ -374,6 +407,9 @@
             } else { /* reparented to WM frame, figure out our insets */
                 setReparented(true);
                 insets_corrected = false;
+                if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
+                    return;
+                }
 
                 // Check if we have insets provided by the WM
                 Insets correctWM = getWMSetInsets(null);
@@ -405,7 +441,7 @@
                     }
                 }
 
-                if (correctWM != null && XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
+                if (correctWM != null) {
                     handleCorrectInsets(correctWM);
                 }
             }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,6 +26,8 @@
 
 import java.awt.*;
 import java.awt.peer.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
@@ -38,7 +40,8 @@
     static final boolean tryGtk;
     static {
         loadNativeLibraries();
-        tryGtk = Boolean.getBoolean("awt.robot.gtk");
+        tryGtk = AccessController.doPrivileged((PrivilegedAction<Boolean>)()
+                -> Boolean.getBoolean("awt.robot.gtk"));
     }
 
     private static boolean isGtkSupported =  false;
--- a/jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXGraphicsConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXGraphicsConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 import java.awt.AWTException;
 import java.awt.BufferCapabilities;
-import java.awt.BufferCapabilities.FlipContents;
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Graphics;
@@ -59,8 +58,6 @@
 import static sun.java2d.opengl.OGLContext.*;
 import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
 import sun.java2d.opengl.GLXSurfaceData.GLXVSyncOffScreenSurfaceData;
-import sun.java2d.pipe.hw.AccelDeviceEventListener;
-import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
 
 public class GLXGraphicsConfig
     extends X11GraphicsConfig
@@ -426,14 +423,4 @@
     public ContextCapabilities getContextCapabilities() {
         return oglCaps;
     }
-
-    @Override
-    public void addDeviceEventListener(AccelDeviceEventListener l) {
-        AccelDeviceEventNotifier.addListener(l, screen.getScreen());
-    }
-
-    @Override
-    public void removeDeviceEventListener(AccelDeviceEventListener l) {
-        AccelDeviceEventNotifier.removeListener(l);
-    }
 }
--- a/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRPaints.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRPaints.java	Tue Oct 18 17:14:09 2016 +0000
@@ -95,15 +95,15 @@
         private XRGradient() {
         }
 
-        /**
-         * There are no restrictions for accelerating GradientPaint, so this
-         * method always returns true.
-         */
         @Override
         boolean isPaintValid(SunGraphics2D sg2d) {
-            return true;
+            GradientPaint paint = (GradientPaint) sg2d.paint;
+
+            return XRUtils.isPointCoordInShortRange(paint.getPoint1())
+                    && XRUtils.isPointCoordInShortRange(paint.getPoint2());
         }
 
+        @Override
         void setXRPaint(SunGraphics2D sg2d, Paint pt) {
             GradientPaint paint = (GradientPaint) pt;
 
@@ -130,24 +130,27 @@
 
         @Override
         boolean isPaintValid(SunGraphics2D sg2d) {
-            return ((LinearGradientPaint) sg2d.getPaint()).getColorSpace() == ColorSpaceType.SRGB;
+            LinearGradientPaint paint = (LinearGradientPaint) sg2d.getPaint();
+
+            return paint.getColorSpace() == ColorSpaceType.SRGB
+                    && XRUtils.isPointCoordInShortRange(paint.getStartPoint())
+                    && XRUtils.isPointCoordInShortRange(paint.getEndPoint())
+                    && paint.getTransform().getDeterminant() != 0.0;
         }
 
         @Override
         void setXRPaint(SunGraphics2D sg2d, Paint pt) {
             LinearGradientPaint paint = (LinearGradientPaint) pt;
-
             Color[] colors = paint.getColors();
             Point2D pt1 = paint.getStartPoint();
             Point2D pt2 = paint.getEndPoint();
-
             int repeat = XRUtils.getRepeatForCycleMethod(paint.getCycleMethod());
             float[] fractions = paint.getFractions();
             int[] pixels = convertToIntArgbPixels(colors);
+            AffineTransform at = paint.getTransform();
 
-            AffineTransform at = paint.getTransform();
             try {
-                at.invert();
+               at.invert();
             } catch (NoninvertibleTransformException ex) {
                 ex.printStackTrace();
             }
@@ -165,8 +168,12 @@
         @Override
         boolean isPaintValid(SunGraphics2D sg2d) {
             RadialGradientPaint grad = (RadialGradientPaint) sg2d.paint;
-            return grad.getFocusPoint().equals(grad.getCenterPoint())
-                   && grad.getColorSpace() == ColorSpaceType.SRGB;
+
+            return grad.getColorSpace() == ColorSpaceType.SRGB
+                   && grad.getFocusPoint().equals(grad.getCenterPoint())
+                   && XRUtils.isPointCoordInShortRange(grad.getCenterPoint())
+                   && grad.getRadius() <= Short.MAX_VALUE
+                   && grad.getTransform().getDeterminant() != 0.0;
         }
 
         @Override
@@ -174,18 +181,17 @@
             RadialGradientPaint paint = (RadialGradientPaint) pt;
             Color[] colors = paint.getColors();
             Point2D center = paint.getCenterPoint();
+            float cx = (float) center.getX();
+            float cy = (float) center.getY();
 
+            AffineTransform at = paint.getTransform();
             int repeat = XRUtils.getRepeatForCycleMethod(paint.getCycleMethod());
             float[] fractions = paint.getFractions();
             int[] pixels = convertToIntArgbPixels(colors);
             float radius = paint.getRadius();
 
-            float cx = (float) center.getX();
-            float cy = (float) center.getY();
-
-            AffineTransform at = paint.getTransform();
             try {
-                at.invert();
+               at.invert();
             } catch (NoninvertibleTransformException ex) {
                 ex.printStackTrace();
             }
--- a/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRUtils.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRUtils.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,6 +26,7 @@
 package sun.java2d.xr;
 
 import java.awt.*;
+import java.awt.geom.Point2D;
 import java.awt.MultipleGradientPaint.*;
 import java.awt.geom.AffineTransform;
 import java.awt.image.*;
@@ -260,6 +261,15 @@
         return (x > 65535 ? 65535 : (x < 0) ? 0 : x);
     }
 
+    public static boolean isDoubleInShortRange(double dbl) {
+         return dbl <= Short.MAX_VALUE && dbl >= Short.MIN_VALUE;
+    }
+
+    public static boolean isPointCoordInShortRange(Point2D p) {
+        return isDoubleInShortRange(p.getX()) && isDoubleInShortRange(p.getY());
+    }
+
+
     public static boolean isTransformQuadrantRotated(AffineTransform tr) {
         return ((tr.getType() & (AffineTransform.TYPE_GENERAL_ROTATION |
                  AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0);
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java	Tue Oct 18 17:14:09 2016 +0000
@@ -28,16 +28,19 @@
 import java.awt.Graphics2D;
 import java.awt.AWTEvent;
 import java.awt.Frame;
+import java.awt.GraphicsEnvironment;
 import java.awt.PopupMenu;
 import java.awt.Point;
 import java.awt.TrayIcon;
 import java.awt.Image;
+import java.awt.geom.AffineTransform;
 import java.awt.peer.TrayIconPeer;
 import java.awt.image.*;
 
 import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
 import sun.awt.image.IntegerComponentRaster;
+import sun.java2d.pipe.Region;
 
 final class WTrayIconPeer extends WObjectPeer implements TrayIconPeer {
     static final int TRAY_ICON_WIDTH = 16;
@@ -123,16 +126,22 @@
             return;
 
         boolean autosize = ((TrayIcon)target).isImageAutoSize();
-
-        BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT,
-                                                   BufferedImage.TYPE_INT_ARGB);
+        AffineTransform tx = GraphicsEnvironment.getLocalGraphicsEnvironment().
+                getDefaultScreenDevice().getDefaultConfiguration().
+                getDefaultTransform();
+        int w = Region.clipScale(TRAY_ICON_WIDTH, tx.getScaleX());
+        int h = Region.clipScale(TRAY_ICON_HEIGHT, tx.getScaleY());
+        int imgWidth = Region.clipScale(image.getWidth(observer), tx.getScaleX());
+        int imgHeight = Region.clipScale(image.getHeight(observer), tx.getScaleY());
+        BufferedImage bufImage = new BufferedImage(w,
+                h, BufferedImage.TYPE_INT_ARGB);
         Graphics2D gr = bufImage.createGraphics();
         if (gr != null) {
             try {
                 gr.setPaintMode();
 
-                gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)),
-                             (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer);
+                gr.drawImage(image, 0, 0, (autosize ? w : imgWidth),
+                             (autosize ? h : imgHeight), observer);
 
                 createNativeImage(bufImage);
 
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java	Tue Oct 18 17:14:09 2016 +0000
@@ -34,7 +34,7 @@
 import java.util.*;
 import java.util.List;
 import sun.util.logging.PlatformLogger;
-
+import java.awt.geom.AffineTransform;
 import sun.awt.*;
 
 import sun.java2d.pipe.Region;
@@ -391,6 +391,11 @@
             int h = getSysIconHeight();
             int smw = getSysSmIconWidth();
             int smh = getSysSmIconHeight();
+            AffineTransform tx = getGraphicsConfiguration().getDefaultTransform();
+            w = Region.clipScale(w, tx.getScaleX());
+            h = Region.clipScale(h, tx.getScaleY());
+            smw = Region.clipScale(smw, tx.getScaleX());
+            smh = Region.clipScale(smh, tx.getScaleY());
             DataBufferInt iconData = SunToolkit.getScaledIconData(imageList,
                                                                   w, h);
             DataBufferInt iconSmData = SunToolkit.getScaledIconData(imageList,
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 import java.awt.AWTException;
 import java.awt.BufferCapabilities;
-import java.awt.BufferCapabilities.FlipContents;
 import java.awt.Component;
 import java.awt.Graphics;
 import java.awt.ImageCapabilities;
@@ -43,14 +42,12 @@
 import sun.awt.windows.WComponentPeer;
 import sun.java2d.Surface;
 import sun.java2d.SurfaceData;
-import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
 import sun.java2d.pipe.hw.AccelTypedVolatileImage;
 import sun.java2d.pipe.hw.AccelGraphicsConfig;
 import sun.java2d.pipe.hw.AccelSurface;
 import sun.java2d.pipe.hw.ContextCapabilities;
 import static sun.java2d.pipe.hw.AccelSurface.*;
 import static sun.java2d.d3d.D3DContext.D3DContextCaps.*;
-import sun.java2d.pipe.hw.AccelDeviceEventListener;
 
 public class D3DGraphicsConfig
     extends Win32GraphicsConfig
@@ -315,14 +312,4 @@
     public ContextCapabilities getContextCapabilities() {
         return device.getContextCapabilities();
     }
-
-    @Override
-    public void addDeviceEventListener(AccelDeviceEventListener l) {
-        AccelDeviceEventNotifier.addListener(l, device.getScreen());
-    }
-
-    @Override
-    public void removeDeviceEventListener(AccelDeviceEventListener l) {
-        AccelDeviceEventNotifier.removeListener(l);
-    }
 }
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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
@@ -54,8 +54,6 @@
 import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
 import static sun.java2d.opengl.WGLSurfaceData.*;
 import sun.java2d.opengl.OGLContext.OGLContextCaps;
-import sun.java2d.pipe.hw.AccelDeviceEventListener;
-import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
 import sun.java2d.windows.GDIWindowSurfaceData;
 
 public class WGLGraphicsConfig
@@ -92,8 +90,7 @@
         // add a record to the Disposer so that we destroy the native
         // WGLGraphicsConfigInfo data when this object goes away
         Disposer.addRecord(disposerReferent,
-                           new WGLGCDisposerRecord(pConfigInfo,
-                                                   device.getScreen()));
+                           new WGLGCDisposerRecord(pConfigInfo));
     }
 
     public Object getProxyKey() {
@@ -198,27 +195,10 @@
 
     private static class WGLGCDisposerRecord implements DisposerRecord {
         private long pCfgInfo;
-        private int screen;
-        public WGLGCDisposerRecord(long pCfgInfo, int screen) {
+        public WGLGCDisposerRecord(long pCfgInfo) {
             this.pCfgInfo = pCfgInfo;
         }
         public void dispose() {
-            OGLRenderQueue rq = OGLRenderQueue.getInstance();
-            rq.lock();
-            try {
-                rq.flushAndInvokeNow(new Runnable() {
-                    public void run() {
-                        AccelDeviceEventNotifier.
-                            eventOccured(screen,
-                                AccelDeviceEventNotifier.DEVICE_RESET);
-                        AccelDeviceEventNotifier.
-                            eventOccured(screen,
-                                AccelDeviceEventNotifier.DEVICE_DISPOSED);
-                    }
-                });
-            } finally {
-                rq.unlock();
-            }
             if (pCfgInfo != 0) {
                 OGLRenderQueue.disposeGraphicsConfig(pCfgInfo);
                 pCfgInfo = 0;
@@ -455,14 +435,4 @@
     public ContextCapabilities getContextCapabilities() {
         return oglCaps;
     }
-
-    @Override
-    public void addDeviceEventListener(AccelDeviceEventListener l) {
-        AccelDeviceEventNotifier.addListener(l, screen.getScreen());
-    }
-
-    @Override
-    public void removeDeviceEventListener(AccelDeviceEventListener l) {
-        AccelDeviceEventNotifier.removeListener(l);
-    }
 }
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -253,9 +253,6 @@
 
     EndScene();
 
-    D3DPipelineManager::NotifyAdapterEventListeners(devCaps.AdapterOrdinal,
-                                                    DEVICE_RESET);
-
     contextCaps = CAPS_EMPTY;
 
     SAFE_RELEASE(pSyncQuery);
@@ -292,9 +289,6 @@
 
     ReleaseDefPoolResources();
 
-    D3DPipelineManager::NotifyAdapterEventListeners(devCaps.AdapterOrdinal,
-                                                    DEVICE_DISPOSED);
-
     // dispose shader lists
     ShaderList_Dispose(&convolvePrograms);
     ShaderList_Dispose(&rescalePrograms);
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.h	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.h	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
 #include "sun_java2d_pipe_BufferedContext.h"
 #include "sun_java2d_d3d_D3DContext_D3DContextCaps.h"
 #include "sun_java2d_d3d_D3DSurfaceData.h"
-#include "sun_java2d_pipe_hw_AccelDeviceEventNotifier.h"
 
 #include "ShaderList.h"
 #include "D3DPipeline.h"
@@ -413,9 +412,4 @@
 #define CAPS_PS30           \
     sun_java2d_d3d_D3DContext_D3DContextCaps_CAPS_PS30
 
-#define DEVICE_RESET    \
-    sun_java2d_pipe_hw_AccelDeviceEventNotifier_DEVICE_RESET
-#define DEVICE_DISPOSED \
-    sun_java2d_pipe_hw_AccelDeviceEventNotifier_DEVICE_DISPOSED
-
 #endif // D3DCONTEXT_H
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipelineManager.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipelineManager.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -173,41 +173,6 @@
     return S_OK;
 }
 
-// static
-void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter,
-                                                     jint eventType)
-{
-    HMONITOR hMon;
-    int gdiScreen;
-    D3DPipelineManager *pMgr;
-
-    // fix for 6946559: if d3d preloading fails jmv may be NULL
-    if (jvm == NULL) {
-        return;
-    }
-
-    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    RETURN_IF_NULL(env);
-
-    pMgr = D3DPipelineManager::GetInstance();
-    RETURN_IF_NULL(pMgr);
-    hMon = pMgr->pd3d9->GetAdapterMonitor(adapter);
-
-    /*
-     * If we don't have devices initialized yet, no sense to clear them.
-     */
-    if (!Devices::GetInstance()){
-         return;
-    }
-
-    gdiScreen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(hMon);
-
-    JNU_CallStaticMethodByName(env, NULL,
-        "sun/java2d/pipe/hw/AccelDeviceEventNotifier",
-        "eventOccured", "(II)V",
-        gdiScreen, eventType);
-}
-
 UINT D3DPipelineManager::GetAdapterOrdinalForScreen(jint gdiScreen)
 {
     HMONITOR mHnd = AwtWin32GraphicsDevice::GetMonitor(gdiScreen);
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipelineManager.h	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipelineManager.h	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -78,11 +78,6 @@
     // these may differ depending on which display is primary
     UINT GetAdapterOrdinalForScreen(jint gdiScreen);
 
-    // notifies adapter event listeners by calling
-    // AccelDeviceEventNotifier.eventOccured()
-    static
-    void NotifyAdapterEventListeners(UINT adapter, jint eventType);
-
 private:
     D3DPipelineManager(void);
    ~D3DPipelineManager(void);
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DnDDS.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DnDDS.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, 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
@@ -266,11 +266,14 @@
 
     dragSource->Signal();
 
+    AwtToolkit &toolkit = AwtToolkit::GetInstance();
+    toolkit.isInDoDragDropLoop = TRUE;
     res = ::DoDragDrop(dragSource,
                        dragSource,
                        convertActionsToDROPEFFECT(dragSource->m_actions),
                        &effects
           );
+    toolkit.isInDoDragDropLoop = FALSE;
 
     if (effects == DROPEFFECT_NONE && dragSource->m_dwPerformedDropEffect != DROPEFFECT_NONE) {
         effects = dragSource->m_dwPerformedDropEffect;
@@ -626,6 +629,7 @@
  */
 
 HRESULT __stdcall  AwtDragSource::QueryContinueDrag(BOOL fEscapeKeyPressed, DWORD grfKeyState) {
+    AwtToolkit::GetInstance().eventNumber++;
     TRY;
 
     JNIEnv* env       = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -681,6 +685,7 @@
  */
 
 HRESULT __stdcall  AwtDragSource::GiveFeedback(DWORD dwEffect) {
+    AwtToolkit::GetInstance().eventNumber++;
     TRY;
 
     JNIEnv* env       = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -760,6 +765,7 @@
 
 HRESULT __stdcall AwtDragSource::GetData(FORMATETC __RPC_FAR *pFormatEtc,
                                          STGMEDIUM __RPC_FAR *pmedium) {
+    AwtToolkit::GetInstance().eventNumber++;
     TRY;
     STGMEDIUM *pPicMedia = PictureDragHelper::FindData(*pFormatEtc);
     if (NULL != pPicMedia) {
@@ -934,6 +940,7 @@
 
 HRESULT __stdcall AwtDragSource::GetDataHere(FORMATETC __RPC_FAR *pFormatEtc,
                                              STGMEDIUM __RPC_FAR *pmedium) {
+    AwtToolkit::GetInstance().eventNumber++;
     TRY;
 
     if (pmedium->pUnkForRelease != (IUnknown *)NULL) {
@@ -1036,6 +1043,7 @@
  */
 
 HRESULT __stdcall  AwtDragSource::QueryGetData(FORMATETC __RPC_FAR *pFormatEtc) {
+    AwtToolkit::GetInstance().eventNumber++;
     TRY;
 
     return MatchFormatEtc(pFormatEtc, (FORMATETC *)NULL);
@@ -1049,6 +1057,7 @@
  */
 
 HRESULT __stdcall  AwtDragSource::GetCanonicalFormatEtc(FORMATETC __RPC_FAR *pFormatEtcIn, FORMATETC __RPC_FAR *pFormatEtcOut) {
+    AwtToolkit::GetInstance().eventNumber++;
     TRY;
 
     HRESULT   res = MatchFormatEtc(pFormatEtcIn, (FORMATETC *)NULL);
@@ -1069,6 +1078,7 @@
  */
 
 HRESULT __stdcall AwtDragSource::SetData(FORMATETC __RPC_FAR *pFormatEtc, STGMEDIUM __RPC_FAR *pmedium, BOOL fRelease) {
+    AwtToolkit::GetInstance().eventNumber++;
     if (pFormatEtc->cfFormat == CF_PERFORMEDDROPEFFECT && pmedium->tymed == TYMED_HGLOBAL) {
         m_dwPerformedDropEffect = *(DWORD*)::GlobalLock(pmedium->hGlobal);
         ::GlobalUnlock(pmedium->hGlobal);
@@ -1091,6 +1101,7 @@
  */
 
 HRESULT __stdcall  AwtDragSource::EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC *__RPC_FAR *ppenumFormatEtc) {
+    AwtToolkit::GetInstance().eventNumber++;
     TRY;
 
     *ppenumFormatEtc = new ADSIEnumFormatEtc(this);
@@ -1104,6 +1115,7 @@
  */
 
 HRESULT __stdcall  AwtDragSource::DAdvise(FORMATETC __RPC_FAR *pFormatEtc, DWORD advf, IAdviseSink __RPC_FAR *pAdvSink, DWORD __RPC_FAR *pdwConnection) {
+    AwtToolkit::GetInstance().eventNumber++;
     return E_NOTIMPL;
 }
 
@@ -1112,6 +1124,7 @@
  */
 
 HRESULT __stdcall  AwtDragSource::DUnadvise(DWORD dwConnection) {
+    AwtToolkit::GetInstance().eventNumber++;
     return OLE_E_ADVISENOTSUPPORTED;
 }
 
@@ -1120,6 +1133,7 @@
  */
 
 HRESULT __stdcall  AwtDragSource::EnumDAdvise(IEnumSTATDATA __RPC_FAR *__RPC_FAR *ppenumAdvise) {
+    AwtToolkit::GetInstance().eventNumber++;
     return OLE_E_ADVISENOTSUPPORTED;
 }
 
@@ -1127,7 +1141,7 @@
     ::RegisterClipboardFormat(TEXT("_SUNW_JAVA_AWT_PROCESS_ID"));
 
 HRESULT __stdcall AwtDragSource::GetProcessId(FORMATETC __RPC_FAR *pFormatEtc, STGMEDIUM __RPC_FAR *pmedium) {
-
+    AwtToolkit::GetInstance().eventNumber++;
     if ((pFormatEtc->tymed & TYMED_HGLOBAL) == 0) {
         return DV_E_TYMED;
     } else if (pFormatEtc->lindex != -1) {
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -334,6 +334,7 @@
     ::GetKeyboardState(m_lastKeyboardState);
 
     m_waitEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL);
+    isInDoDragDropLoop = FALSE;
     eventNumber = 0;
 }
 
@@ -2752,7 +2753,12 @@
     AwtToolkit & tk = AwtToolkit::GetInstance();
     DWORD eventNumber = tk.eventNumber;
     tk.PostMessage(WM_SYNC_WAIT, 0, 0);
-    ::WaitForSingleObject(tk.m_waitEvent, INFINITE);
+    for(long t = 2; t < timeout &&
+               WAIT_TIMEOUT == ::WaitForSingleObject(tk.m_waitEvent, 2); t+=2) {
+        if (tk.isInDoDragDropLoop) {
+            break;
+        }
+    }
     DWORD newEventNumber = tk.eventNumber;
     return (newEventNumber - eventNumber) > 2;
 }
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h	Tue Oct 18 17:14:09 2016 +0000
@@ -388,7 +388,8 @@
     static BOOL activateKeyboardLayout(HKL hkl);
 
     HANDLE m_waitEvent;
-    DWORD eventNumber;
+    volatile DWORD eventNumber;
+    volatile BOOL isInDoDragDropLoop;
 private:
     HWND CreateToolkitWnd(LPCTSTR name);
 
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp	Tue Oct 18 17:14:09 2016 +0000
@@ -46,11 +46,16 @@
 #include "sun_awt_windows_WCanvasPeer.h"
 
 #include <windowsx.h>
-
+#include <math.h>
 #if !defined(__int3264)
 typedef __int32 LONG_PTR;
 #endif // __int3264
 
+#if defined(_MSC_VER) && _MSC_VER >= 1800
+#  define ROUND_TO_INT(num)    ((int) round(num))
+#else
+#  define ROUND_TO_INT(num)    ((int) floor((num) + 0.5))
+#endif
 // Used for Swing's Menu/Tooltip animation Support
 const int UNSPECIFIED = 0;
 const int TOOLTIP = 1;
@@ -3097,7 +3102,7 @@
 
     env->DeleteGlobalRef(self);
 }
-
+extern "C" int getSystemMetricValue(int msgType);
 extern "C" {
 
 /*
@@ -3407,7 +3412,7 @@
 {
     TRY;
 
-    return ::GetSystemMetrics(SM_CYICON);
+    return getSystemMetricValue(SM_CYICON);
 
     CATCH_BAD_ALLOC_RET(0);
 }
@@ -3422,7 +3427,7 @@
 {
     TRY;
 
-    return ::GetSystemMetrics(SM_CXICON);
+    return getSystemMetricValue(SM_CXICON);
 
     CATCH_BAD_ALLOC_RET(0);
 }
@@ -3437,7 +3442,7 @@
 {
     TRY;
 
-    return ::GetSystemMetrics(SM_CYSMICON);
+    return getSystemMetricValue(SM_CYSMICON);
 
     CATCH_BAD_ALLOC_RET(0);
 }
@@ -3452,11 +3457,44 @@
 {
     TRY;
 
-    return ::GetSystemMetrics(SM_CXSMICON);
+    return getSystemMetricValue(SM_CXSMICON);
 
     CATCH_BAD_ALLOC_RET(0);
 }
 
+int getSystemMetricValue(int msgType) {
+    int value = 1;
+    int logPixels = LOGPIXELSX;
+    switch (msgType) {
+        case SM_CXICON:
+            value = ::GetSystemMetrics(SM_CXICON);
+            break;
+        case SM_CYICON:
+            value = ::GetSystemMetrics(SM_CYICON);
+            logPixels = LOGPIXELSY;
+            break;
+        case SM_CXSMICON:
+            value = ::GetSystemMetrics(SM_CXSMICON);
+            break;
+        case SM_CYSMICON:
+            value = ::GetSystemMetrics(SM_CYSMICON);
+            logPixels = LOGPIXELSY;
+            break;
+    }
+    static int dpi = -1;
+    if (dpi == -1) {
+        HWND hWnd = ::GetDesktopWindow();
+        HDC hDC = ::GetDC(hWnd);
+        dpi = GetDeviceCaps(hDC, logPixels);
+        ::ReleaseDC(hWnd, hDC);
+    }
+    if(dpi != 0 && dpi != 96) {
+        float invScaleX = 96.0f / dpi;
+        value = (int) ROUND_TO_INT(value * invScaleX);
+    }
+    return value;
+}
+
 /*
  * Class:     sun_awt_windows_WWindowPeer
  * Method:    setIconImagesData
--- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c	Tue Oct 18 17:14:09 2016 +0000
@@ -790,9 +790,10 @@
     pkg_name_buf[len] = '\0';
 
     err = (*jvmti)->GetNamedModule(jvmti, loaderObject, pkg_name_buf, &moduleObject);
+    free((void*)pkg_name_buf);
+    check_phase_ret_blob(err, NULL);
     jplis_assert_msg(err == JVMTI_ERROR_NONE, "error in the JVMTI GetNamedModule");
 
-    free((void*)pkg_name_buf);
     return moduleObject;
 }
 
--- a/jdk/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java	Tue Oct 18 17:14:09 2016 +0000
@@ -24,9 +24,11 @@
  */
 package java.rmi.server;
 
+import java.io.ObjectInputFilter;
 import java.rmi.*;
 import sun.rmi.server.UnicastServerRef;
 import sun.rmi.server.UnicastServerRef2;
+import sun.rmi.transport.LiveRef;
 
 /**
  * Used for exporting a remote object with JRMP and obtaining a stub
@@ -38,11 +40,11 @@
  * generated stubs is deprecated. This includes the API in this class that
  * requires the use of static stubs, as well as the runtime support for
  * loading static stubs.  Generating stubs dynamically is preferred, using one
- * of the five non-deprecated ways of exporting objects as listed below. Do
+ * of the non-deprecated ways of exporting objects as listed below. Do
  * not run {@code rmic} to generate static stub classes. It is unnecessary, and
  * it is also deprecated.</em>
  *
- * <p>There are six ways to export remote objects:
+ * <p>There are eight ways to export remote objects:
  *
  * <ol>
  *
@@ -67,12 +69,19 @@
  * {@link #exportObject(Remote, int, RMIClientSocketFactory, RMIServerSocketFactory)
  * exportObject(Remote, port, csf, ssf)} method.
  *
+ * <li>Calling the
+ * {@link #exportObject(Remote, int, ObjectInputFilter) exportObject(Remote, port, filter)} method.
+ *
+ * <li>Calling the
+ * {@link #exportObject(Remote, int, RMIClientSocketFactory, RMIServerSocketFactory, ObjectInputFilter)
+ * exportObject(Remote, port, csf, ssf, filter)} method.
+ *
  * </ol>
  *
  * <p>The fourth technique, {@link #exportObject(Remote)},
  * always uses statically generated stubs and is deprecated.
  *
- * <p>The other five techniques all use the following approach: if the
+ * <p>The other techniques all use the following approach: if the
  * {@code java.rmi.server.ignoreStubClasses} property is {@code true}
  * (case insensitive) or if a static stub cannot be found, stubs are generated
  * dynamically using {@link java.lang.reflect.Proxy Proxy} objects. Otherwise,
@@ -130,6 +139,22 @@
  *
  * </ul>
  *
+ * <p>
+ * Exported remote objects receive method invocations from the stubs
+ * as described in the RMI specification. Each invocation's operation and
+ * parameters are unmarshaled using a custom {@link java.io.ObjectInputStream}.
+ * If an {@link ObjectInputFilter} is provided and is not {@code null} when the object
+ * is exported, it is used to filter the parameters as they are unmarshaled from the stream.
+ * The filter is used for all invocations and all parameters regardless of
+ * the method being invoked or the parameter values.
+ * If no filter is provided or is {@code null} for the exported object then the
+ * {@code ObjectInputStream} default filter, if any, is used. The default filter is
+ * configured with {@link ObjectInputFilter.Config#setSerialFilter(ObjectInputFilter)
+ * ObjectInputFilter.Config.setSerialFilter}.
+ * If the filter rejects any of the parameters, the {@code InvalidClassException}
+ * thrown by {@code ObjectInputStream} is reported as the cause of an
+ * {@link UnmarshalException}.
+ *
  * @implNote
  * Depending upon which constructor or static method is used for exporting an
  * object, {@link RMISocketFactory} may be used for creating sockets.
@@ -347,6 +372,58 @@
     }
 
     /**
+     * Exports the remote object to make it available to receive incoming
+     * calls, using the particular supplied port
+     * and {@linkplain ObjectInputFilter filter}.
+     *
+     * <p>The object is exported with a server socket
+     * created using the {@link RMISocketFactory} class.
+     *
+     * @param obj the remote object to be exported
+     * @param port the port to export the object on
+     * @param filter an ObjectInputFilter applied when deserializing invocation arguments;
+     *               may be {@code null}
+     * @return remote object stub
+     * @exception RemoteException if export fails
+     * @since 9
+     */
+    public static Remote exportObject(Remote obj, int port,
+                                      ObjectInputFilter filter)
+            throws RemoteException
+    {
+        return exportObject(obj, new UnicastServerRef(new LiveRef(port), filter));
+    }
+
+    /**
+     * Exports the remote object to make it available to receive incoming
+     * calls, using a transport specified by the given socket factory
+     * and {@linkplain ObjectInputFilter filter}.
+     *
+     * <p>Either socket factory may be {@code null}, in which case
+     * the corresponding client or server socket creation method of
+     * {@link RMISocketFactory} is used instead.
+     *
+     * @param obj the remote object to be exported
+     * @param port the port to export the object on
+     * @param csf the client-side socket factory for making calls to the
+     * remote object
+     * @param ssf the server-side socket factory for receiving remote calls
+     * @param filter an ObjectInputFilter applied when deserializing invocation arguments;
+     *               may be {@code null}
+     * @return remote object stub
+     * @exception RemoteException if export fails
+     * @since 9
+     */
+    public static Remote exportObject(Remote obj, int port,
+                                      RMIClientSocketFactory csf,
+                                      RMIServerSocketFactory ssf,
+                                      ObjectInputFilter filter)
+        throws RemoteException
+    {
+        return exportObject(obj, new UnicastServerRef2(port, csf, ssf, filter));
+    }
+
+    /**
      * Removes the remote object, obj, from the RMI runtime. If
      * successful, the object can no longer accept incoming RMI calls.
      * If the force parameter is true, the object is forcibly unexported
--- a/jdk/src/java.rmi/share/classes/sun/rmi/server/UnicastServerRef.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/server/UnicastServerRef.java	Tue Oct 18 17:14:09 2016 +0000
@@ -27,6 +27,8 @@
 
 import java.io.IOException;
 import java.io.ObjectInput;
+import java.io.ObjectInputFilter;
+import java.io.ObjectInputStream;
 import java.io.ObjectOutput;
 import java.io.ObjectStreamClass;
 import java.lang.reflect.InvocationTargetException;
@@ -62,6 +64,10 @@
  * UnicastServerRef implements the remote reference layer server-side
  * behavior for remote objects exported with the "UnicastRef" reference
  * type.
+ * If an {@link ObjectInputFilter ObjectInputFilter} is supplied it is
+ * invoked during deserialization to filter the arguments,
+ * otherwise the default filter of {@link ObjectInputStream ObjectInputStream}
+ * applies.
  *
  * @author  Ann Wollrath
  * @author  Roger Riggs
@@ -103,6 +109,9 @@
      */
     private transient Skeleton skel;
 
+    // The ObjectInputFilter for checking the invocation arguments
+    private final transient ObjectInputFilter filter;
+
     /** maps method hash to Method object for each remote method */
     private transient Map<Long,Method> hashToMethod_Map = null;
 
@@ -121,16 +130,29 @@
 
     /**
      * Create a new (empty) Unicast server remote reference.
+     * The filter is null to defer to the  default ObjectInputStream filter, if any.
      */
     public UnicastServerRef() {
+        this.filter = null;
     }
 
     /**
      * Construct a Unicast server remote reference for a specified
      * liveRef.
+     * The filter is null to defer to the  default ObjectInputStream filter, if any.
      */
     public UnicastServerRef(LiveRef ref) {
         super(ref);
+        this.filter = null;
+    }
+
+    /**
+     * Construct a Unicast server remote reference for a specified
+     * liveRef and filter.
+     */
+    public UnicastServerRef(LiveRef ref, ObjectInputFilter filter) {
+        super(ref);
+        this.filter = filter;
     }
 
     /**
@@ -139,6 +161,7 @@
      */
     public UnicastServerRef(int port) {
         super(new LiveRef(port));
+        this.filter = null;
     }
 
     /**
@@ -363,9 +386,23 @@
         }
     }
 
+    /**
+     * Sets a filter for invocation arguments, if a filter has been set.
+     * Called by dispatch before the arguments are read.
+     */
     protected void unmarshalCustomCallData(ObjectInput in)
-        throws IOException, ClassNotFoundException
-    {}
+            throws IOException, ClassNotFoundException {
+        if (filter != null &&
+                in instanceof ObjectInputStream) {
+            // Set the filter on the stream
+            ObjectInputStream ois = (ObjectInputStream) in;
+
+            AccessController.doPrivileged((PrivilegedAction<Void>)() -> {
+                ois.setObjectInputFilter(filter);
+                return null;
+            });
+        }
+    }
 
     /**
      * Handle server-side dispatch using the RMI 1.1 stub/skeleton
--- a/jdk/src/java.rmi/share/classes/sun/rmi/server/UnicastServerRef2.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/server/UnicastServerRef2.java	Tue Oct 18 17:14:09 2016 +0000
@@ -25,12 +25,13 @@
 
 package sun.rmi.server;
 
-import java.io.IOException;
+import java.io.ObjectInputFilter;
 import java.io.ObjectOutput;
-import java.rmi.*;
-import java.rmi.server.*;
-import sun.rmi.transport.*;
-import sun.rmi.transport.tcp.*;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.RemoteRef;
+
+import sun.rmi.transport.LiveRef;
 
 /**
  * Server-side ref for a remote impl that uses a custom socket factory.
@@ -59,6 +60,16 @@
     }
 
     /**
+     * Construct a Unicast server remote reference for a specified
+     * liveRef and filter.
+     */
+    public UnicastServerRef2(LiveRef ref,
+                             ObjectInputFilter filter)
+    {
+        super(ref, filter);
+    }
+
+    /**
      * Construct a Unicast server remote reference to be exported
      * on the specified port.
      */
@@ -70,6 +81,18 @@
     }
 
     /**
+     * Construct a Unicast server remote reference to be exported
+     * on the specified port.
+     */
+    public UnicastServerRef2(int port,
+                             RMIClientSocketFactory csf,
+                             RMIServerSocketFactory ssf,
+                             ObjectInputFilter filter)
+    {
+        super(new LiveRef(port, csf, ssf), filter);
+    }
+
+    /**
      * Returns the class of the ref type to be serialized
      */
     public String getRefClass(ObjectOutput out)
--- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11Cipher.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11Cipher.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -344,7 +344,7 @@
     private void implInit(int opmode, Key key, byte[] iv,
             SecureRandom random)
             throws InvalidKeyException, InvalidAlgorithmParameterException {
-        cancelOperation();
+        reset(true);
         if (fixedKeySize != -1 && key.getEncoded().length != fixedKeySize) {
             throw new InvalidKeyException("Key size is invalid");
         }
@@ -404,23 +404,26 @@
         if (initialized == false) {
             return;
         }
-        initialized = false;
+
         if ((session == null) || (token.explicitCancel == false)) {
             return;
         }
-        // cancel operation by finishing it
-        int bufLen = doFinalLength(0);
-        byte[] buffer = new byte[bufLen];
         try {
-            if (encrypt) {
-                token.p11.C_EncryptFinal(session.id(), 0, buffer, 0, bufLen);
+            if (session.hasObjects() == false) {
+                session = token.killSession(session);
+                return;
             } else {
-                token.p11.C_DecryptFinal(session.id(), 0, buffer, 0, bufLen);
+                // cancel operation by finishing it
+                int bufLen = doFinalLength(0);
+                byte[] buffer = new byte[bufLen];
+                if (encrypt) {
+                    token.p11.C_EncryptFinal(session.id(), 0, buffer, 0, bufLen);
+                } else {
+                    token.p11.C_DecryptFinal(session.id(), 0, buffer, 0, bufLen);
+                }
             }
         } catch (PKCS11Exception e) {
             throw new ProviderException("Cancel failed", e);
-        } finally {
-            reset();
         }
     }
 
@@ -483,7 +486,9 @@
     }
 
     // reset the states to the pre-initialized values
-    private void reset() {
+    private void reset(boolean doCancel) {
+        if (doCancel) cancelOperation();
+
         initialized = false;
         bytesBuffered = 0;
         padBufferLen = 0;
@@ -610,7 +615,7 @@
                 throw (ShortBufferException)
                         (new ShortBufferException().initCause(e));
             }
-            reset();
+            reset(false);
             throw new ProviderException("update() failed", e);
         }
     }
@@ -728,7 +733,7 @@
                 throw (ShortBufferException)
                         (new ShortBufferException().initCause(e));
             }
-            reset();
+            reset(false);
             throw new ProviderException("update() failed", e);
         }
     }
@@ -740,6 +745,7 @@
         if (outLen < requiredOutLen) {
             throw new ShortBufferException();
         }
+        boolean doCancel = true;
         try {
             ensureInitialized();
             int k = 0;
@@ -753,7 +759,12 @@
                 }
                 k += token.p11.C_EncryptFinal(session.id(),
                         0, out, (outOfs + k), (outLen - k));
+                doCancel = false;
             } else {
+                // Special handling to match SunJCE provider behavior
+                if (bytesBuffered == 0 && padBufferLen == 0) {
+                    return 0;
+                }
                 if (paddingObj != null) {
                     if (padBufferLen != 0) {
                         k = token.p11.C_DecryptUpdate(session.id(), 0,
@@ -762,20 +773,24 @@
                     }
                     k += token.p11.C_DecryptFinal(session.id(), 0, padBuffer, k,
                             padBuffer.length - k);
+                    doCancel = false;
+
                     int actualPadLen = paddingObj.unpad(padBuffer, k);
                     k -= actualPadLen;
                     System.arraycopy(padBuffer, 0, out, outOfs, k);
                 } else {
                     k = token.p11.C_DecryptFinal(session.id(), 0, out, outOfs,
                             outLen);
+                    doCancel = false;
                 }
             }
             return k;
         } catch (PKCS11Exception e) {
+            doCancel = false;
             handleException(e);
             throw new ProviderException("doFinal() failed", e);
         } finally {
-            reset();
+            reset(doCancel);
         }
     }
 
@@ -788,6 +803,7 @@
             throw new ShortBufferException();
         }
 
+        boolean doCancel = true;
         try {
             ensureInitialized();
 
@@ -818,7 +834,13 @@
                 }
                 k += token.p11.C_EncryptFinal(session.id(),
                         outAddr, outArray, (outOfs + k), (outLen - k));
+                doCancel = false;
             } else {
+                // Special handling to match SunJCE provider behavior
+                if (bytesBuffered == 0 && padBufferLen == 0) {
+                    return 0;
+                }
+
                 if (paddingObj != null) {
                     if (padBufferLen != 0) {
                         k = token.p11.C_DecryptUpdate(session.id(),
@@ -828,6 +850,8 @@
                     }
                     k += token.p11.C_DecryptFinal(session.id(),
                             0, padBuffer, k, padBuffer.length - k);
+                    doCancel = false;
+
                     int actualPadLen = paddingObj.unpad(padBuffer, k);
                     k -= actualPadLen;
                     outArray = padBuffer;
@@ -835,6 +859,7 @@
                 } else {
                     k = token.p11.C_DecryptFinal(session.id(),
                             outAddr, outArray, outOfs, outLen);
+                    doCancel = false;
                 }
             }
             if ((!encrypt && paddingObj != null) ||
@@ -846,10 +871,11 @@
             }
             return k;
         } catch (PKCS11Exception e) {
+            doCancel = false;
             handleException(e);
             throw new ProviderException("doFinal() failed", e);
         } finally {
-            reset();
+            reset(doCancel);
         }
     }
 
--- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11Signature.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11Signature.java	Tue Oct 18 17:14:09 2016 +0000
@@ -616,8 +616,11 @@
                     return dsaToASN1(signature);
                 }
             }
-        } catch (PKCS11Exception e) {
-            throw new ProviderException(e);
+        } catch (PKCS11Exception pe) {
+            throw new ProviderException(pe);
+        } catch (SignatureException | ProviderException e) {
+            cancelOperation();
+            throw e;
         } finally {
             initialized = false;
             session = token.releaseSession(session);
@@ -669,8 +672,8 @@
                 }
             }
             return true;
-        } catch (PKCS11Exception e) {
-            long errorCode = e.getErrorCode();
+        } catch (PKCS11Exception pe) {
+            long errorCode = pe.getErrorCode();
             if (errorCode == CKR_SIGNATURE_INVALID) {
                 return false;
             }
@@ -682,10 +685,11 @@
             if (errorCode == CKR_DATA_LEN_RANGE) {
                 return false;
             }
-            throw new ProviderException(e);
+            throw new ProviderException(pe);
+        }  catch (SignatureException | ProviderException e) {
+            cancelOperation();
+            throw e;
         } finally {
-            // XXX we should not release the session if we abort above
-            // before calling C_Verify
             initialized = false;
             session = token.releaseSession(session);
         }
--- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Secmod.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Secmod.java	Tue Oct 18 17:14:09 2016 +0000
@@ -743,6 +743,7 @@
         Map<Bytes,TrustAttributes> trustMap = new HashMap<Bytes,TrustAttributes>();
         Token token = provider.getToken();
         Session session = null;
+        boolean exceptionOccurred = true;
         try {
             session = token.getOpSession();
             int MAX_NUM = 8192;
@@ -762,8 +763,13 @@
                     // skip put on pkcs11 error
                 }
             }
+            exceptionOccurred = false;
         } finally {
-            token.releaseSession(session);
+            if (exceptionOccurred) {
+                token.killSession(session);
+            } else {
+                token.releaseSession(session);
+            }
         }
         return trustMap;
     }
--- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -160,8 +160,11 @@
                 ShortBufferException {
             int tbSize = (trailingBytes == null? 0:trailingBytes.position());
             int dataLen = tbSize + lastData.length;
-            // check total length
-            if ((dataLen < 1) || (dataLen % blockSize != 0)) {
+
+            // Special handling to match SunJCE provider behavior
+            if (dataLen <= 0) {
+                return 0;
+            } else if (dataLen % blockSize != 0) {
                 UcryptoProvider.debug("PKCS5Padding: unpad, buffered " + tbSize +
                                  " bytes, last block " + lastData.length + " bytes");
 
@@ -402,7 +405,6 @@
         throws ShortBufferException, IllegalBlockSizeException,
                BadPaddingException {
         int estimatedOutLen = engineGetOutputSize(inLen);
-
         if (out.length - outOfs < estimatedOutLen) {
             throw new ShortBufferException("Actual: " + (out.length - outOfs) +
                 ". Estimated Out Length: " + estimatedOutLen);
--- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -258,27 +258,38 @@
 
     @Override
     protected synchronized byte[] engineSign() throws SignatureException {
-        byte[] sig = new byte[sigLength];
-        int rv = doFinal(sig, 0, sigLength);
-        if (rv < 0) {
-            throw new SignatureException(new UcryptoException(-rv));
+        try {
+            byte[] sig = new byte[sigLength];
+            int rv = doFinal(sig, 0, sigLength);
+            if (rv < 0) {
+                throw new SignatureException(new UcryptoException(-rv));
+            }
+            return sig;
+        } finally {
+            // doFinal should already be called, no need to cancel
+            reset(false);
         }
-        return sig;
     }
 
     @Override
     protected synchronized int engineSign(byte[] outbuf, int offset, int len)
         throws SignatureException {
-        if (outbuf == null || (offset < 0) || (outbuf.length < (offset + sigLength))
-            || (len < sigLength)) {
-            throw new SignatureException("Invalid output buffer. offset: " +
-                offset + ". len: " + len + ". sigLength: " + sigLength);
+        boolean doCancel = true;
+        try {
+            if (outbuf == null || (offset < 0) || (outbuf.length < (offset + sigLength))
+                || (len < sigLength)) {
+                throw new SignatureException("Invalid output buffer. offset: " +
+                    offset + ". len: " + len + ". sigLength: " + sigLength);
+            }
+            int rv = doFinal(outbuf, offset, sigLength);
+            doCancel = false;
+            if (rv < 0) {
+                throw new SignatureException(new UcryptoException(-rv));
+            }
+            return sigLength;
+        } finally {
+            reset(doCancel);
         }
-        int rv = doFinal(outbuf, offset, sigLength);
-        if (rv < 0) {
-            throw new SignatureException(new UcryptoException(-rv));
-        }
-        return sigLength;
     }
 
     @Override
@@ -329,19 +340,25 @@
     @Override
     protected synchronized boolean engineVerify(byte[] sigBytes, int sigOfs, int sigLen)
         throws SignatureException {
-        if (sigBytes == null || (sigOfs < 0) || (sigBytes.length < (sigOfs + this.sigLength))
-            || (sigLen != this.sigLength)) {
-            throw new SignatureException("Invalid signature length: got " +
-                sigLen + " but was expecting " + this.sigLength);
-        }
+        boolean doCancel = true;
+        try {
+            if (sigBytes == null || (sigOfs < 0) || (sigBytes.length < (sigOfs + this.sigLength))
+                || (sigLen != this.sigLength)) {
+                throw new SignatureException("Invalid signature length: got " +
+                    sigLen + " but was expecting " + this.sigLength);
+            }
 
-        int rv = doFinal(sigBytes, sigOfs, sigLen);
-        if (rv == 0) {
-            return true;
-        } else {
-            UcryptoProvider.debug("Signature: " + mech + " verification error " +
+            int rv = doFinal(sigBytes, sigOfs, sigLen);
+            doCancel = false;
+            if (rv == 0) {
+                return true;
+            } else {
+                UcryptoProvider.debug("Signature: " + mech + " verification error " +
                              new UcryptoException(-rv).getMessage());
-            return false;
+                return false;
+            }
+        } finally {
+            reset(doCancel);
         }
     }
 
@@ -432,13 +449,9 @@
 
     // returns 0 (success) or negative (ucrypto error occurred)
     private int doFinal(byte[] sigBytes, int sigOfs, int sigLen) {
-        try {
-            ensureInitialized();
-            int k = nativeFinal(pCtxt.id, sign, sigBytes, sigOfs, sigLen);
-            return k;
-        } finally {
-            reset(false);
-        }
+        ensureInitialized();
+        int k = nativeFinal(pCtxt.id, sign, sigBytes, sigOfs, sigLen);
+        return k;
     }
 
     // check and return RSA key size in number of bytes
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java	Tue Oct 18 17:14:09 2016 +0000
@@ -48,7 +48,9 @@
     private History currentDelegate;
 
     protected EditingHistory(ConsoleReader in, Iterable<? extends String> originalHistory) {
-        this.fullHistory = new MemoryHistory();
+        MemoryHistory fullHistory = new MemoryHistory();
+        fullHistory.setIgnoreDuplicates(false);
+        this.fullHistory = fullHistory;
         this.currentDelegate = fullHistory;
         bind(in, CTRL_UP,
              (Runnable) () -> moveHistoryToSnippet(in, ((EditingHistory) in.getHistory())::previousSnippet));
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Tue Oct 18 17:14:09 2016 +0000
@@ -103,6 +103,18 @@
             basename = en.baseName;
             entryname = en.entryName;
         }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) return true;
+            if (!(o instanceof Entry)) return false;
+            return this.file.equals(((Entry)o).file);
+        }
+
+        @Override
+        public int hashCode() {
+            return file.hashCode();
+        }
     }
 
     class EntryName {
@@ -124,10 +136,10 @@
             if (name.startsWith("./")) {
                 name = name.substring(2);
             }
-            this.baseName = name;
-            this.entryName = (version > BASE_VERSION)
-                    ? VERSIONS_DIR + version + "/" + this.baseName
-                    : this.baseName;
+            baseName = name;
+            entryName = (version > BASE_VERSION)
+                    ? VERSIONS_DIR + version + "/" + baseName
+                    : baseName;
         }
     }
 
@@ -137,7 +149,7 @@
     Map<String, Entry> entryMap = new HashMap<>();
 
     // All entries need to be added/updated.
-    Map<String, Entry> entries = new LinkedHashMap<>();
+    Set<Entry> entries = new LinkedHashSet<>();
 
     // All packages.
     Set<String> packages = new HashSet<>();
@@ -855,8 +867,7 @@
                     moduleInfoPaths.put(entryName, f.toPath());
                     if (isUpdate)
                         entryMap.put(entryName, entry);
-                } else if (!entries.containsKey(entryName)) {
-                    entries.put(entryName, entry);
+                } else if (entries.add(entry)) {
                     jarEntries.add(entryName);
                     if (entry.basename.endsWith(".class") && !entryName.startsWith(VERSIONS_DIR))
                         packages.add(toPackageName(entry.basename));
@@ -864,8 +875,7 @@
                         entryMap.put(entryName, entry);
                 }
             } else if (f.isDirectory()) {
-                if (!entries.containsKey(entryName)) {
-                    entries.put(entryName, entry);
+                if (entries.add(entry)) {
                     if (isUpdate) {
                         entryMap.put(entryName, entry);
                     }
@@ -923,8 +933,7 @@
             in.transferTo(zos);
             zos.closeEntry();
         }
-        for (String entryname : entries.keySet()) {
-            Entry entry = entries.get(entryname);
+        for (Entry entry : entries) {
             addFile(zos, entry);
         }
         zos.close();
@@ -1049,7 +1058,7 @@
                     Entry ent = entryMap.get(name);
                     addFile(zos, ent);
                     entryMap.remove(name);
-                    entries.remove(name);
+                    entries.remove(ent);
                 }
 
                 jarEntries.add(name);
@@ -1059,8 +1068,8 @@
         }
 
         // add the remaining new files
-        for (String entryname : entries.keySet()) {
-            addFile(zos, entries.get(entryname));
+        for (Entry entry : entries) {
+            addFile(zos, entry);
         }
         if (!foundManifest) {
             if (newManifest != null) {
@@ -1248,6 +1257,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;
         boolean isDir = entry.isDir;
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -211,6 +211,62 @@
     return error;
 }
 
+/*
+ * Delete saved global references - if any - for:
+ * - a potentially thrown Exception
+ * - a returned refernce/array value
+ * See invoker_doInvoke() and invoke* methods where global references
+ * are being saved.
+ */
+static void
+deletePotentiallySavedGlobalRefs(JNIEnv *env, InvokeRequest *request)
+{
+    /* Delete potentially saved return value */
+    if ((request->invokeType == INVOKE_CONSTRUCTOR) ||
+        (returnTypeTag(request->methodSignature) == JDWP_TAG(OBJECT)) ||
+        (returnTypeTag(request->methodSignature) == JDWP_TAG(ARRAY))) {
+        if (request->returnValue.l != NULL) {
+            tossGlobalRef(env, &(request->returnValue.l));
+        }
+    }
+    /* Delete potentially saved exception */
+    if (request->exception != NULL) {
+        tossGlobalRef(env, &(request->exception));
+    }
+}
+
+/*
+ * Delete global argument references from the request which got put there before a
+ * invoke request was carried out. See fillInvokeRequest().
+ */
+static void
+deleteGlobalArgumentRefs(JNIEnv *env, InvokeRequest *request)
+{
+    void *cursor;
+    jint argIndex = 0;
+    jvalue *argument = request->arguments;
+    jbyte argumentTag = firstArgumentTypeTag(request->methodSignature, &cursor);
+
+    if (request->clazz != NULL) {
+        tossGlobalRef(env, &(request->clazz));
+    }
+    if (request->instance != NULL) {
+        tossGlobalRef(env, &(request->instance));
+    }
+    /* Delete global argument references */
+    while (argIndex < request->argumentCount) {
+        if ((argumentTag == JDWP_TAG(OBJECT)) ||
+            (argumentTag == JDWP_TAG(ARRAY))) {
+            if (argument->l != NULL) {
+                tossGlobalRef(env, &(argument->l));
+            }
+        }
+        argument++;
+        argIndex++;
+        argumentTag = nextArgumentTypeTag(&cursor);
+    }
+}
+
 static jvmtiError
 fillInvokeRequest(JNIEnv *env, InvokeRequest *request,
                   jbyte invokeType, jbyte options, jint id,
@@ -287,6 +343,35 @@
     debugMonitorExit(invokerLock);
 }
 
+/*
+ * Check that method is in the specified clazz or one of its super classes.
+ * We have to enforce this check at the JDWP layer because the JNI layer
+ * has different requirements.
+ */
+static jvmtiError check_methodClass(JNIEnv *env, jclass clazz, jmethodID method)
+{
+    jclass containing_class = NULL;
+    jvmtiError error;
+
+    error = JVMTI_FUNC_PTR(gdata->jvmti,GetMethodDeclaringClass)
+                (gdata->jvmti, method, &containing_class);
+    if (error != JVMTI_ERROR_NONE) {
+        return JVMTI_ERROR_NONE;  /* Bad jmethodID ?  This will be handled elsewhere */
+    }
+
+    if (JNI_FUNC_PTR(env,IsSameObject)(env, clazz, containing_class)) {
+        return JVMTI_ERROR_NONE;
+    }
+
+    // If not the same class then check that containing_class is a superclass of
+    // clazz (not a superinterface).
+    if (JNI_FUNC_PTR(env,IsAssignableFrom)(env, clazz, containing_class) &&
+        referenceTypeTag(containing_class) != JDWP_TYPE_TAG(INTERFACE)) {
+        return JVMTI_ERROR_NONE;
+    }
+    return JVMTI_ERROR_INVALID_METHODID;
+}
+
 jvmtiError
 invoker_requestInvoke(jbyte invokeType, jbyte options, jint id,
                       jthread thread, jclass clazz, jmethodID method,
@@ -297,6 +382,13 @@
     InvokeRequest *request;
     jvmtiError error = JVMTI_ERROR_NONE;
 
+    if (invokeType == INVOKE_STATIC) {
+        error = check_methodClass(env, clazz, method);
+        if (error != JVMTI_ERROR_NONE) {
+            return error;
+        }
+    }
+
     debugMonitorEnter(invokerLock);
     request = threadControl_getInvokeRequest(thread);
     if (request != NULL) {
@@ -322,6 +414,8 @@
 invokeConstructor(JNIEnv *env, InvokeRequest *request)
 {
     jobject object;
+
+    JDI_ASSERT_MSG(request->clazz, "Request clazz null");
     object = JNI_FUNC_PTR(env,NewObjectA)(env, request->clazz,
                                      request->method,
                                      request->arguments);
@@ -338,6 +432,7 @@
         case JDWP_TAG(OBJECT):
         case JDWP_TAG(ARRAY): {
             jobject object;
+            JDI_ASSERT_MSG(request->clazz, "Request clazz null");
             object = JNI_FUNC_PTR(env,CallStaticObjectMethodA)(env,
                                        request->clazz,
                                        request->method,
@@ -426,6 +521,7 @@
         case JDWP_TAG(OBJECT):
         case JDWP_TAG(ARRAY): {
             jobject object;
+            JDI_ASSERT_MSG(request->instance, "Request instance null");
             object = JNI_FUNC_PTR(env,CallObjectMethodA)(env,
                                  request->instance,
                                  request->method,
@@ -513,6 +609,8 @@
         case JDWP_TAG(OBJECT):
         case JDWP_TAG(ARRAY): {
             jobject object;
+            JDI_ASSERT_MSG(request->clazz, "Request clazz null");
+            JDI_ASSERT_MSG(request->instance, "Request instance null");
             object = JNI_FUNC_PTR(env,CallNonvirtualObjectMethodA)(env,
                                            request->instance,
                                            request->clazz,
@@ -609,6 +707,8 @@
     JNIEnv *env;
     jboolean startNow;
     InvokeRequest *request;
+    jbyte options;
+    jbyte invokeType;
 
     JDI_ASSERT(thread);
 
@@ -625,6 +725,9 @@
     if (startNow) {
         request->started = JNI_TRUE;
     }
+    options = request->options;
+    invokeType = request->invokeType;
+
     debugMonitorExit(invokerLock);
 
     if (!startNow) {
@@ -639,7 +742,7 @@
 
         JNI_FUNC_PTR(env,ExceptionClear)(env);
 
-        switch (request->invokeType) {
+        switch (invokeType) {
             case INVOKE_CONSTRUCTOR:
                 invokeConstructor(env, request);
                 break;
@@ -647,7 +750,7 @@
                 invokeStatic(env, request);
                 break;
             case INVOKE_INSTANCE:
-                if (request->options & JDWP_INVOKE_OPTIONS(NONVIRTUAL) ) {
+                if (options & JDWP_INVOKE_OPTIONS(NONVIRTUAL) ) {
                     invokeNonvirtual(env, request);
                 } else {
                     invokeVirtual(env, request);
@@ -725,12 +828,23 @@
     }
 
     /*
+     * At this time, there's no need to retain global references on
+     * arguments since the reply is processed. No one will deal with
+     * this request ID anymore, so we must call deleteGlobalArgumentRefs().
+     *
+     * We cannot delete saved exception or return value references
+     * since otherwise a deleted handle would escape when writing
+     * the response to the stream. Instead, we clean those refs up
+     * after writing the respone.
+     */
+    deleteGlobalArgumentRefs(env, request);
+
+    /*
      * Give up the lock before I/O operation
      */
     debugMonitorExit(invokerLock);
     eventHandler_unlock();
 
-
     if (!detached) {
         outStream_initReply(&out, id);
         (void)outStream_writeValue(env, &out, tag, returnValue);
@@ -738,6 +852,16 @@
         (void)outStream_writeObjectRef(env, &out, exc);
         outStream_sendReply(&out);
     }
+
+    /*
+     * Delete potentially saved global references of return value
+     * and exception
+     */
+    eventHandler_lock(); // for proper lock order
+    debugMonitorEnter(invokerLock);
+    deletePotentiallySavedGlobalRefs(env, request);
+    debugMonitorExit(invokerLock);
+    eventHandler_unlock();
 }
 
 jboolean
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java	Tue Oct 18 17:14:09 2016 +0000
@@ -55,6 +55,13 @@
         private final Archive archive;
         private final String path;
 
+        /**
+         * Constructs an entry of the given archive
+         * @param archive archive
+         * @param path
+         * @param name an entry name that does not contain the module name
+         * @param type
+         */
         public Entry(Archive archive, String path, String name, EntryType type) {
             this.archive = Objects.requireNonNull(archive);
             this.path = Objects.requireNonNull(path);
@@ -62,25 +69,29 @@
             this.type = Objects.requireNonNull(type);
         }
 
-        public Archive archive() {
+        public final Archive archive() {
             return archive;
         }
 
-        public String path() {
-            return path;
-        }
-
-        public EntryType type() {
+        public final EntryType type() {
             return type;
         }
 
-        /*
+        /**
          * Returns the name of this entry.
          */
-        public String name() {
+        public final String name() {
             return name;
         }
 
+        /**
+         * Returns the name representing a ResourcePoolEntry in the form of:
+         *    /$MODULE/$ENTRY_NAME
+         */
+        public final String getResourcePoolEntryName() {
+            return "/" + archive.moduleName() + "/" + name;
+        }
+
         @Override
         public String toString() {
             return "type " + type.name() + " path " + path;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java	Tue Oct 18 17:14:09 2016 +0000
@@ -50,7 +50,7 @@
 
         FileEntry(Path path, String name) {
             super(DirArchive.this, getPathName(path), name,
-                    Archive.Entry.EntryType.CLASS_OR_RESOURCE);
+                  Archive.Entry.EntryType.CLASS_OR_RESOURCE);
             this.path = path;
             try {
                 size = Files.size(path);
@@ -124,13 +124,7 @@
             return null;
         }
         String name = getPathName(p).substring(chop);
-        if (name.startsWith("_")) {
-            return null;
-        }
         log.accept(moduleName + "/" + name);
-        if (name.equals(MODULE_INFO)) {
-            name = moduleName + "/" + MODULE_INFO;
-        }
         return new FileEntry(p, name);
     }
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java	Tue Oct 18 17:14:09 2016 +0000
@@ -40,6 +40,7 @@
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
+
 import jdk.tools.jlink.internal.Archive.Entry;
 import jdk.tools.jlink.internal.Archive.Entry.EntryType;
 import jdk.tools.jlink.internal.ResourcePoolManager.CompressedModuleData;
@@ -122,10 +123,6 @@
         });
     }
 
-    public static boolean isClassPackage(String path) {
-        return path.endsWith(".class") && !path.endsWith("module-info.class");
-    }
-
     public static void recreateJimage(Path jimageFile,
             Set<Archive> archives,
             ImagePluginStack pluginSupport)
@@ -265,26 +262,13 @@
                 return writer.getString(id);
             }
         });
+
         for (Archive archive : archives) {
             String mn = archive.moduleName();
-            for (Entry entry : entriesForModule.get(mn)) {
-                String path;
-                if (entry.type() == EntryType.CLASS_OR_RESOURCE) {
-                    // Removal of "classes/" radical.
-                    path = entry.name();
-                    if (path.endsWith("module-info.class")) {
-                        path = "/" + path;
-                    } else {
-                        path = "/" + mn + "/" + path;
-                    }
-                } else {
-                    // Entry.path() contains the kind of file native, conf, bin, ...
-                    // Keep it to avoid naming conflict (eg: native/jvm.cfg and config/jvm.cfg
-                    path = "/" + mn + "/" + entry.path();
-                }
-
-                resources.add(new ArchiveEntryResourcePoolEntry(mn, path, entry));
-            }
+            entriesForModule.get(mn).stream()
+                .map(e -> new ArchiveEntryResourcePoolEntry(mn,
+                                    e.getResourcePoolEntryName(), e))
+                .forEach(resources::add);
         }
         return resources;
     }
@@ -320,6 +304,20 @@
         return result.toArray(array);
     }
 
+    /**
+     * Returns the path of the resource.
+     */
+    public static String resourceName(String path) {
+        Objects.requireNonNull(path);
+        String s = path.substring(1);
+        int index = s.indexOf("/");
+        return s.substring(index + 1);
+    }
+
+    public static String toPackage(String name) {
+        return toPackage(name, false);
+    }
+
     private static String toPackage(String name, boolean log) {
         int index = name.lastIndexOf('/');
         if (index > 0) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java	Tue Oct 18 17:14:09 2016 +0000
@@ -43,7 +43,7 @@
     /**
      * An entry located in a jar file.
      */
-    private class JarEntry extends Entry {
+    public class JarEntry extends Entry {
 
         private final long size;
         private final ZipEntry entry;
@@ -70,12 +70,10 @@
         }
     }
 
-    private static final String MODULE_INFO = "module-info.class";
-
     private final Path file;
     private final String moduleName;
     // currently processed ZipFile
-    private ZipFile zipFile;
+    protected ZipFile zipFile;
 
     protected JarArchive(String mn, Path file) {
         Objects.requireNonNull(mn);
@@ -110,21 +108,7 @@
 
     abstract String getFileName(String entryName);
 
-    private Entry toEntry(ZipEntry ze) {
-        String name = ze.getName();
-        String fn = getFileName(name);
-
-        if (ze.isDirectory() || fn.startsWith("_")) {
-            return null;
-        }
-
-        EntryType rt = toEntryType(name);
-
-        if (fn.equals(MODULE_INFO)) {
-            fn = moduleName + "/" + MODULE_INFO;
-        }
-        return new JarEntry(ze.getName(), fn, rt, zipFile, ze);
-    }
+    abstract Entry toEntry(ZipEntry ze);
 
     @Override
     public void close() throws IOException {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Tue Oct 18 17:14:09 2016 +0000
@@ -86,6 +86,9 @@
             task.options.help = true;
         }, "--help", "-h"),
         new Option<JlinkTask>(true, (task, opt, arg) -> {
+            // if used multiple times, the last one wins!
+            // So, clear previous values, if any.
+            task.options.modulePath.clear();
             String[] dirs = arg.split(File.pathSeparator);
             int i = 0;
             Arrays.stream(dirs)
@@ -93,6 +96,9 @@
                   .forEach(task.options.modulePath::add);
         }, "--module-path", "-p"),
         new Option<JlinkTask>(true, (task, opt, arg) -> {
+            // if used multiple times, the last one wins!
+            // So, clear previous values, if any.
+            task.options.limitMods.clear();
             for (String mn : arg.split(",")) {
                 if (mn.isEmpty()) {
                     throw taskHelper.newBadArgs("err.mods.must.be.specified",
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java	Tue Oct 18 17:14:09 2016 +0000
@@ -25,34 +25,106 @@
 
 package jdk.tools.jlink.internal;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
 import java.nio.file.Path;
 import java.util.Objects;
+import java.util.stream.Stream;
+
+import jdk.internal.jmod.JmodFile;
 import jdk.tools.jlink.internal.Archive.Entry.EntryType;
 
 /**
  * An Archive backed by a jmod file.
  */
-public class JmodArchive extends JarArchive {
-
+public class JmodArchive implements Archive {
     private static final String JMOD_EXT    = ".jmod";
-    private static final String MODULE_NAME = "module";
-    private static final String MODULE_INFO = "module-info.class";
-    private static final String CLASSES     = "classes";
-    private static final String NATIVE_LIBS = "native";
-    private static final String NATIVE_CMDS = "bin";
-    private static final String CONFIG      = "conf";
+
+    /**
+     * An entry located in a jmod file.
+     */
+    public class JmodEntry extends Entry {
+        private final JmodFile.Entry entry;
+
+        JmodEntry(String path, String name, EntryType type,
+                  JmodFile.Entry entry) {
+            super(JmodArchive.this, path, name, type);
+            this.entry = Objects.requireNonNull(entry);
+        }
+
+        /**
+         * Returns the number of uncompressed bytes for this entry.
+         */
+        @Override
+        public long size() {
+            return entry.size();
+        }
+
+        @Override
+        public InputStream stream() throws IOException {
+            return jmodFile.getInputStream(entry.section(), entry.name());
+        }
+    }
+
+    private final Path file;
+    private final String moduleName;
+    private JmodFile jmodFile;
 
     public JmodArchive(String mn, Path jmod) {
-        super(mn, jmod);
-        String filename = Objects.requireNonNull(jmod.getFileName()).toString();
+        Objects.requireNonNull(mn);
+        Objects.requireNonNull(jmod.getFileName());
+        String filename = jmod.toString();
         if (!filename.endsWith(JMOD_EXT)) {
             throw new UnsupportedOperationException("Unsupported format: " + filename);
         }
+        this.moduleName = mn;
+        this.file = jmod;
+    }
+
+    @Override
+    public String moduleName() {
+        return moduleName;
+    }
+
+    @Override
+    public Path getPath() {
+        return file;
+    }
+
+    @Override
+    public Stream<Entry> entries() {
+        ensureOpen();
+        return jmodFile.stream()
+                       .map(this::toEntry);
     }
 
     @Override
-    EntryType toEntryType(String entryName) {
-        String section = getSection(entryName.replace('\\', '/'));
+    public void open() throws IOException {
+        if (jmodFile != null) {
+            jmodFile.close();
+        }
+        this.jmodFile = new JmodFile(file);
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (jmodFile != null) {
+            jmodFile.close();
+        }
+    }
+
+    private void ensureOpen() {
+        if (jmodFile == null) {
+            try {
+                open();
+            } catch(IOException ioe){
+                throw new UncheckedIOException(ioe);
+            }
+        }
+    }
+
+    private EntryType toEntryType(JmodFile.Section section) {
         switch (section) {
             case CLASSES:
                 return EntryType.CLASS_OR_RESOURCE;
@@ -62,26 +134,23 @@
                 return EntryType.NATIVE_CMD;
             case CONFIG:
                 return EntryType.CONFIG;
-            case MODULE_NAME:
-                return EntryType.MODULE_NAME;
             default:
                 throw new InternalError("unexpected entry: " + section);
         }
     }
 
-    private static String getSection(String entryName) {
-        int i = entryName.indexOf('/');
-        // Unnamed section.
-        String section = "";
-        if (i > 0) {
-            section = entryName.substring(0, entryName.indexOf('/'));
+    private Entry toEntry(JmodFile.Entry entry) {
+        EntryType type = toEntryType(entry.section());
+        String name = entry.name();
+        String path = entry.section().jmodDir() + "/" + name;
+
+        // Entry.path() contains the kind of file native, conf, bin, ...
+        // Keep it to avoid naming conflict (eg: native/jvm.cfg and config/jvm.cfg
+        String resourceName = name;
+        if (type != EntryType.CLASS_OR_RESOURCE) {
+            resourceName = path;
         }
-        return section;
-    }
 
-    @Override
-    String getFileName(String entryName) {
-        entryName = entryName.replace('\\', '/');
-        return entryName.substring(entryName.indexOf('/') + 1);
+        return new JmodEntry(path, resourceName, type, entry);
     }
 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java	Tue Oct 18 17:14:09 2016 +0000
@@ -27,6 +27,8 @@
 
 import java.nio.file.Path;
 import java.util.Objects;
+import java.util.zip.ZipEntry;
+
 import jdk.tools.jlink.internal.Archive.Entry.EntryType;
 
 /**
@@ -35,6 +37,7 @@
 public class ModularJarArchive extends JarArchive {
 
     private static final String JAR_EXT = ".jar";
+    private static final String MODULE_INFO = "module-info.class";
 
     public ModularJarArchive(String mn, Path jmod) {
         super(mn, jmod);
@@ -50,6 +53,17 @@
     }
 
     @Override
+    Entry toEntry(ZipEntry ze) {
+        if (ze.isDirectory()) {
+            return null;
+        }
+
+        String name = ze.getName();
+        EntryType type = toEntryType(name);
+        return new JarEntry(ze.getName(), getFileName(name), type, zipFile, ze);
+    }
+
+    @Override
     String getFileName(String entryName) {
         return entryName;
     }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java	Tue Oct 18 17:14:09 2016 +0000
@@ -27,15 +27,12 @@
 import java.lang.module.ModuleDescriptor;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
-import java.util.function.Function;
 import java.util.stream.Stream;
 import jdk.internal.jimage.decompressor.CompressedResourceHeader;
 import jdk.tools.jlink.plugin.ResourcePool;
@@ -44,7 +41,6 @@
 import jdk.tools.jlink.plugin.ResourcePoolModule;
 import jdk.tools.jlink.plugin.ResourcePoolModuleView;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
 
 /**
  * A manager for pool of resources.
@@ -100,17 +96,17 @@
         @Override
         public Set<String> packages() {
             Set<String> pkgs = new HashSet<>();
-            moduleContent.values().stream().filter(m -> m.type().
-                    equals(ResourcePoolEntry.Type.CLASS_OR_RESOURCE)).forEach(res -> {
-                // Module metadata only contains packages with .class files
-                if (ImageFileCreator.isClassPackage(res.path())) {
-                    String[] split = ImageFileCreator.splitPath(res.path());
-                    String pkg = split[1];
-                    if (pkg != null && !pkg.isEmpty()) {
-                        pkgs.add(pkg);
+            moduleContent.values().stream()
+                .filter(m -> m.type() == ResourcePoolEntry.Type.CLASS_OR_RESOURCE)
+                .forEach(res -> {
+                    String name = ImageFileCreator.resourceName(res.path());
+                    if (name.endsWith(".class") && !name.endsWith("module-info.class")) {
+                        String pkg = ImageFileCreator.toPackage(name);
+                        if (!pkg.isEmpty()) {
+                            pkgs.add(pkg);
+                        }
                     }
-                }
-            });
+                });
             return pkgs;
         }
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java	Tue Oct 18 17:14:09 2016 +0000
@@ -307,9 +307,10 @@
 
     private boolean filterOutUnsupportedTags(byte[] b) {
         List<Locale> locales;
+        List<String> originalTags = Arrays.asList(new String(b).split(" "));
 
         try {
-            locales = Arrays.asList(new String(b).split(" ")).stream()
+            locales = originalTags.stream()
                 .filter(tag -> !tag.isEmpty())
                 .map(IncludeLocalesPlugin::tagToLocale)
                 .collect(Collectors.toList());
@@ -319,6 +320,9 @@
         }
 
         byte[] filteredBytes = filterLocales(locales).stream()
+            // Make sure the filtered language tags do exist in the
+            // original supported tags for compatibility codes, e.g., "iw"
+            .filter(originalTags::contains)
             .collect(Collectors.joining(" "))
             .getBytes();
 
@@ -331,6 +335,11 @@
         return true;
     }
 
+    /*
+     * Filter list of locales according to the secified priorityList. Note
+     * that returned list of language tags may include extra ones, such as
+     * compatibility ones (e.g., "iw" -> "iw", "he").
+     */
     private List<String> filterLocales(List<Locale> locales) {
         List<String> ret =
             Locale.filter(priorityList, locales, Locale.FilteringMode.EXTENDED_FILTERING).stream()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodOutputStream.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,116 @@
+/*
+ * 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.tools.jmod;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import static jdk.internal.jmod.JmodFile.*;
+
+/**
+ * Output stream to write to JMOD file
+ */
+class JmodOutputStream extends OutputStream implements AutoCloseable {
+    /**
+     * This method creates (or overrides, if exists) the JMOD file,
+     * returning the the output stream to write to the JMOD file.
+     */
+    static JmodOutputStream newOutputStream(Path file) throws IOException {
+        OutputStream out = Files.newOutputStream(file);
+        BufferedOutputStream bos = new BufferedOutputStream(out);
+        return new JmodOutputStream(bos);
+    }
+
+    private final ZipOutputStream zos;
+    private JmodOutputStream(OutputStream out) {
+        this.zos = new ZipOutputStream(out);
+        try {
+            out.write(JMOD_MAGIC_NUMBER);
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
+    /**
+     * Writes the input stream to the named entry of the given section.
+     */
+    public void writeEntry(InputStream in, Section section, String name)
+        throws IOException
+    {
+        ZipEntry ze = newEntry(section, name);
+        zos.putNextEntry(ze);
+        in.transferTo(zos);
+        zos.closeEntry();
+    }
+
+    /**
+     * Writes the given bytes to the named entry of the given section.
+     */
+    public void writeEntry(byte[] bytes, Section section, String path)
+        throws IOException
+    {
+        ZipEntry ze = newEntry(section, path);
+        zos.putNextEntry(ze);
+        zos.write(bytes);
+        zos.closeEntry();
+    }
+
+    /**
+     * Writes the given entry to the given input stream.
+     */
+    public void writeEntry(InputStream in, Entry e) throws IOException {
+        zos.putNextEntry(e.zipEntry());
+        zos.write(in.readAllBytes());
+        zos.closeEntry();
+    }
+
+    private ZipEntry newEntry(Section section, String path) {
+        String prefix = section.jmodDir();
+        String name = Paths.get(prefix, path).toString()
+                           .replace(File.separatorChar, '/');
+        return new ZipEntry(name);
+    }
+
+    @Override
+    public void write(int b) throws IOException {
+        zos.write(b);
+    }
+
+    @Override
+    public void close() throws IOException {
+        zos.close();
+    }
+}
+
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Tue Oct 18 17:14:09 2016 +0000
@@ -25,8 +25,6 @@
 
 package jdk.tools.jmod;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -60,7 +58,6 @@
 import java.text.MessageFormat;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
@@ -80,15 +77,16 @@
 import java.util.function.Supplier;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
 import java.util.stream.Collectors;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipException;
 import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
 
+import jdk.internal.jmod.JmodFile;
+import jdk.internal.jmod.JmodFile.Section;
 import jdk.internal.joptsimple.BuiltinHelpFormatter;
 import jdk.internal.joptsimple.NonOptionArgumentSpec;
 import jdk.internal.joptsimple.OptionDescriptor;
@@ -250,23 +248,14 @@
     }
 
     private boolean describe() throws IOException {
-        ZipFile zip = null;
-        try {
-            try {
-                zip = new ZipFile(options.jmodFile.toFile());
-            } catch (IOException x) {
-                throw new IOException("error opening jmod file", x);
+        try (JmodFile jf = new JmodFile(options.jmodFile)) {
+            try (InputStream in = jf.getInputStream(Section.CLASSES, MODULE_INFO)) {
+                ModuleDescriptor md = ModuleDescriptor.read(in);
+                printModuleDescriptor(md);
+                return true;
+            } catch (IOException e) {
+                throw new CommandException("err.module.descriptor.not.found");
             }
-
-            try (InputStream in = Files.newInputStream(options.jmodFile)) {
-                boolean found = printModuleDescriptor(in);
-                if (!found)
-                    throw new CommandException("err.module.descriptor.not.found");
-                return found;
-            }
-        } finally {
-            if (zip != null)
-                zip.close();
         }
     }
 
@@ -278,65 +267,52 @@
 
     private static final JavaLangModuleAccess JLMA = SharedSecrets.getJavaLangModuleAccess();
 
-    private boolean printModuleDescriptor(InputStream in)
+    private void printModuleDescriptor(ModuleDescriptor md)
         throws IOException
     {
-        final String mi = Section.CLASSES.jmodDir() + "/" + MODULE_INFO;
-        try (BufferedInputStream bis = new BufferedInputStream(in);
-             ZipInputStream zis = new ZipInputStream(bis)) {
-
-            ZipEntry e;
-            while ((e = zis.getNextEntry()) != null) {
-                if (e.getName().equals(mi)) {
-                    ModuleDescriptor md = ModuleDescriptor.read(zis);
-                    StringBuilder sb = new StringBuilder();
-                    sb.append("\n").append(md.toNameAndVersion());
+        StringBuilder sb = new StringBuilder();
+        sb.append("\n").append(md.toNameAndVersion());
 
-                    md.requires().stream()
-                        .sorted(Comparator.comparing(Requires::name))
-                        .forEach(r -> {
-                            sb.append("\n  requires ");
-                            if (!r.modifiers().isEmpty())
-                                sb.append(toString(r.modifiers())).append(" ");
-                            sb.append(r.name());
-                        });
+        md.requires().stream()
+            .sorted(Comparator.comparing(Requires::name))
+            .forEach(r -> {
+                sb.append("\n  requires ");
+                if (!r.modifiers().isEmpty())
+                    sb.append(toString(r.modifiers())).append(" ");
+                sb.append(r.name());
+            });
 
-                    md.uses().stream().sorted()
-                        .forEach(s -> sb.append("\n  uses ").append(s));
+        md.uses().stream().sorted()
+            .forEach(s -> sb.append("\n  uses ").append(s));
 
-                    md.exports().stream()
-                        .sorted(Comparator.comparing(Exports::source))
-                        .forEach(p -> sb.append("\n  exports ").append(p));
+        md.exports().stream()
+            .sorted(Comparator.comparing(Exports::source))
+            .forEach(p -> sb.append("\n  exports ").append(p));
+
+        md.conceals().stream().sorted()
+            .forEach(p -> sb.append("\n  conceals ").append(p));
 
-                    md.conceals().stream().sorted()
-                        .forEach(p -> sb.append("\n  conceals ").append(p));
+        md.provides().values().stream()
+            .sorted(Comparator.comparing(Provides::service))
+            .forEach(p -> sb.append("\n  provides ").append(p.service())
+                .append(" with ")
+                .append(toString(p.providers())));
 
-                    md.provides().values().stream()
-                        .sorted(Comparator.comparing(Provides::service))
-                        .forEach(p -> sb.append("\n  provides ").append(p.service())
-                                        .append(" with ")
-                                        .append(toString(p.providers())));
+        md.mainClass().ifPresent(v -> sb.append("\n  main-class " + v));
 
-                    md.mainClass().ifPresent(v -> sb.append("\n  main-class " + v));
-
-                    md.osName().ifPresent(v -> sb.append("\n  operating-system-name " + v));
-
-                    md.osArch().ifPresent(v -> sb.append("\n  operating-system-architecture " + v));
+        md.osName().ifPresent(v -> sb.append("\n  operating-system-name " + v));
 
-                    md.osVersion().ifPresent(v -> sb.append("\n  operating-system-version " + v));
+        md.osArch().ifPresent(v -> sb.append("\n  operating-system-architecture " + v));
+
+        md.osVersion().ifPresent(v -> sb.append("\n  operating-system-version " + v));
 
-                    JLMA.hashes(md).ifPresent(
-                            hashes -> hashes.names().stream().sorted().forEach(
-                                    mod -> sb.append("\n  hashes ").append(mod).append(" ")
-                                             .append(hashes.algorithm()).append(" ")
-                                             .append(hashes.hashFor(mod))));
+        JLMA.hashes(md).ifPresent(
+            hashes -> hashes.names().stream().sorted().forEach(
+                mod -> sb.append("\n  hashes ").append(mod).append(" ")
+                    .append(hashes.algorithm()).append(" ")
+                    .append(hashes.hashFor(mod))));
 
-                    out.println(sb.toString());
-                    return true;
-                }
-            }
-        }
-        return false;
+        out.println(sb.toString());
     }
 
     private boolean create() throws IOException {
@@ -347,9 +323,8 @@
         Path target = options.jmodFile;
         Path tempTarget = target.resolveSibling(target.getFileName() + ".tmp");
         try {
-            try (OutputStream out = Files.newOutputStream(tempTarget);
-                 BufferedOutputStream bos = new BufferedOutputStream(out)) {
-                jmod.write(bos);
+            try (JmodOutputStream jos = JmodOutputStream.newOutputStream(tempTarget)) {
+                jmod.write(jos);
             }
             Files.move(tempTarget, target);
         } catch (Exception e) {
@@ -383,19 +358,16 @@
         /**
          * Writes the jmod to the given output stream.
          */
-        void write(OutputStream out) throws IOException {
-            try (ZipOutputStream zos = new ZipOutputStream(out)) {
-
-                // module-info.class
-                writeModuleInfo(zos, findPackages(classpath));
+        void write(JmodOutputStream out) throws IOException {
+            // module-info.class
+            writeModuleInfo(out, findPackages(classpath));
 
-                // classes
-                processClasses(zos, classpath);
+            // classes
+            processClasses(out, classpath);
 
-                processSection(zos, Section.NATIVE_CMDS, cmds);
-                processSection(zos, Section.NATIVE_LIBS, libs);
-                processSection(zos, Section.CONFIG, configs);
-            }
+            processSection(out, Section.NATIVE_CMDS, cmds);
+            processSection(out, Section.NATIVE_LIBS, libs);
+            processSection(out, Section.CONFIG, configs);
         }
 
         /**
@@ -441,7 +413,7 @@
          * then the corresponding class file attributes are added to the
          * module-info here.
          */
-        void writeModuleInfo(ZipOutputStream zos, Set<String> packages)
+        void writeModuleInfo(JmodOutputStream out, Set<String> packages)
             throws IOException
         {
             Supplier<InputStream> miSupplier = newModuleInfoSupplier();
@@ -492,11 +464,7 @@
                 }
 
                 // write the (possibly extended or modified) module-info.class
-                String e = Section.CLASSES.jmodDir() + "/" + MODULE_INFO;
-                ZipEntry ze = new ZipEntry(e);
-                zos.putNextEntry(ze);
-                extender.write(zos);
-                zos.closeEntry();
+                out.writeEntry(extender.toByteArray(), Section.CLASSES, MODULE_INFO);
             }
         }
 
@@ -627,7 +595,7 @@
                 return "";
         }
 
-        void processClasses(ZipOutputStream zos, List<Path> classpaths)
+        void processClasses(JmodOutputStream zos, List<Path> classpaths)
             throws IOException
         {
             if (classpaths == null)
@@ -645,7 +613,7 @@
             }
         }
 
-        void processSection(ZipOutputStream zos, Section section, List<Path> paths)
+        void processSection(JmodOutputStream zos, Section section, List<Path> paths)
             throws IOException
         {
             if (paths == null)
@@ -655,11 +623,9 @@
                 processSection(zos, section, p);
         }
 
-        void processSection(ZipOutputStream zos, Section section, Path top)
+        void processSection(JmodOutputStream out, Section section, Path top)
             throws IOException
         {
-            final String prefix = section.jmodDir();
-
             Files.walkFileTree(top, new SimpleFileVisitor<Path>() {
                 @Override
                 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
@@ -667,13 +633,19 @@
                 {
                     Path relPath = top.relativize(file);
                     if (relPath.toString().equals(MODULE_INFO)
-                            && !Section.CLASSES.equals(section))
+                        && !Section.CLASSES.equals(section))
                         warning("warn.ignore.entry", MODULE_INFO, section);
 
                     if (!relPath.toString().equals(MODULE_INFO)
-                            && !matches(relPath, excludes)) {
+                        && !matches(relPath, excludes)) {
                         try (InputStream in = Files.newInputStream(file)) {
-                            writeZipEntry(zos, in, prefix, relPath.toString());
+                            out.writeEntry(in, section, relPath.toString());
+                        } catch (IOException x) {
+                            if (x.getMessage().contains("duplicate entry")) {
+                                warning("warn.ignore.duplicate.entry", relPath.toString(), section);
+                                return FileVisitResult.CONTINUE;
+                            }
+                            throw x;
                         }
                     }
                     return FileVisitResult.CONTINUE;
@@ -691,36 +663,17 @@
             return false;
         }
 
-        void writeZipEntry(ZipOutputStream zos, InputStream in, String prefix, String other)
-            throws IOException
-        {
-            String name = Paths.get(prefix, other).toString()
-                               .replace(File.separatorChar, '/');
-            ZipEntry ze = new ZipEntry(name);
-            try {
-                zos.putNextEntry(ze);
-                in.transferTo(zos);
-                zos.closeEntry();
-            } catch (ZipException x) {
-                if (x.getMessage().contains("duplicate entry")) {
-                    warning("warn.ignore.duplicate.entry", name, prefix);
-                    return;
-                }
-                throw x;
-            }
-        }
-
         class JarEntryConsumer implements Consumer<JarEntry>, Predicate<JarEntry> {
-            final ZipOutputStream zos;
+            final JmodOutputStream out;
             final JarFile jarfile;
-            JarEntryConsumer(ZipOutputStream zos, JarFile jarfile) {
-                this.zos = zos;
+            JarEntryConsumer(JmodOutputStream out, JarFile jarfile) {
+                this.out = out;
                 this.jarfile = jarfile;
             }
             @Override
             public void accept(JarEntry je) {
                 try (InputStream in = jarfile.getInputStream(je)) {
-                    writeZipEntry(zos, in, Section.CLASSES.jmodDir(), je.getName());
+                    out.writeEntry(in, Section.CLASSES, je.getName());
                 } catch (IOException e) {
                     throw new UncheckedIOException(e);
                 }
@@ -947,29 +900,11 @@
         {
             Path target = moduleNameToPath.get(name);
             Path tempTarget = target.resolveSibling(target.getFileName() + ".tmp");
-            ZipFile zip = new ZipFile(target.toFile());
             try {
-                try (OutputStream out = Files.newOutputStream(tempTarget);
-                     ZipOutputStream zos = new ZipOutputStream(out)) {
-                    zip.stream().forEach(e -> {
-                        try {
-                            InputStream in = zip.getInputStream(e);
-                            if (e.getName().equals(MODULE_INFO) ||
-                                e.getName().equals(Section.CLASSES.jmodDir() + "/" + MODULE_INFO)) {
-                                ZipEntry ze = new ZipEntry(e.getName());
-                                ze.setTime(System.currentTimeMillis());
-                                zos.putNextEntry(ze);
-                                recordHashes(in, zos, moduleHashes);
-                                zos.closeEntry();
-                            } else {
-                                zos.putNextEntry(e);
-                                zos.write(in.readAllBytes());
-                                zos.closeEntry();
-                            }
-                        } catch (IOException x) {
-                            throw new UncheckedIOException(x);
-                        }
-                    });
+                if (target.getFileName().toString().endsWith(".jmod")) {
+                    updateJmodFile(target, tempTarget, moduleHashes);
+                } else {
+                    updateModularJar(target, tempTarget, moduleHashes);
                 }
             } catch (IOException|RuntimeException e) {
                 if (Files.exists(tempTarget)) {
@@ -980,13 +915,67 @@
                     }
                 }
                 throw e;
-            } finally {
-                zip.close();
             }
+
             out.println(getMessage("module.hashes.recorded", name));
             Files.move(tempTarget, target, StandardCopyOption.REPLACE_EXISTING);
         }
 
+        private void updateModularJar(Path target, Path tempTarget,
+                                      ModuleHashes moduleHashes)
+            throws IOException
+        {
+            try (JarFile jf = new JarFile(target.toFile());
+                 OutputStream out = Files.newOutputStream(tempTarget);
+                 JarOutputStream jos = new JarOutputStream(out))
+            {
+                jf.stream().forEach(e -> {
+                    try (InputStream in = jf.getInputStream(e)) {
+                        if (e.getName().equals(MODULE_INFO)) {
+                            // what about module-info.class in versioned entries?
+                            ZipEntry ze = new ZipEntry(e.getName());
+                            ze.setTime(System.currentTimeMillis());
+                            jos.putNextEntry(ze);
+                            recordHashes(in, jos, moduleHashes);
+                            jos.closeEntry();
+                        } else {
+                            jos.putNextEntry(e);
+                            jos.write(in.readAllBytes());
+                            jos.closeEntry();
+                        }
+                    } catch (IOException x) {
+                        throw new UncheckedIOException(x);
+                    }
+                });
+            }
+        }
+
+        private void updateJmodFile(Path target, Path tempTarget,
+                                    ModuleHashes moduleHashes)
+            throws IOException
+        {
+
+            try (JmodFile jf = new JmodFile(target);
+                 JmodOutputStream jos = JmodOutputStream.newOutputStream(tempTarget))
+            {
+                jf.stream().forEach(e -> {
+                    try (InputStream in = jf.getInputStream(e.section(), e.name())) {
+                        if (e.name().equals(MODULE_INFO)) {
+                            // replace module-info.class
+                            ModuleInfoExtender extender =
+                                ModuleInfoExtender.newExtender(in);
+                            extender.hashes(moduleHashes);
+                            jos.writeEntry(extender.toByteArray(), e.section(), e.name());
+                        } else {
+                            jos.writeEntry(in, e);
+                        }
+                    } catch (IOException x) {
+                        throw new UncheckedIOException(x);
+                    }
+                });
+            }
+        }
+
         private Path moduleToPath(String name) {
             ModuleReference mref = moduleFinder.find(name).orElseThrow(
                 () -> new InternalError("Selected module " + name + " not on module path"));
@@ -1001,22 +990,6 @@
         }
     }
 
-    enum Section {
-        NATIVE_LIBS("native"),
-        NATIVE_CMDS("bin"),
-        CLASSES("classes"),
-        CONFIG("conf"),
-        UNKNOWN("unknown");
-
-        private final String jmodDir;
-
-        Section(String jmodDir) {
-            this.jmodDir = jmodDir;
-        }
-
-        String jmodDir() { return jmodDir; }
-    }
-
     static class ClassPathConverter implements ValueConverter<Path> {
         static final ValueConverter<Path> INSTANCE = new ClassPathConverter();
 
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_de.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_de.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,6 +189,9 @@
         String MHT[] = new String[] {"Marshallinseln Zeit", "MHT",
                                      "Marshallinseln Sommerzeit", "MHST",
                                      "Marshallinseln Zeit", "MHT"};
+        String MMT[] = new String[] {"Myanmar Zeit", "MMT",
+                                     "Myanmar Sommerzeit", "MMST",
+                                     "Myanmar Zeit", "MMT"};
         String MSK[] = new String[] {"Moskauer Normalzeit", "MSK",
                                      "Moskauer Sommerzeit", "MSD",
                                      "Zeitzone f\u00FCr Moskau", "MT"};
@@ -684,9 +687,7 @@
             {"Asia/Qyzylorda", new String[] {"Qyzylorda Zeit", "QYZT",
                                              "Qyzylorda Sommerzeit", "QYZST",
                                              "Qyzylorda Zeit", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"Myanmar Zeit", "MMT",
-                                           "Myanmar Sommerzeit", "MMST",
-                                           "Myanmar Zeit", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"Sakhalin Zeit", "SAKT",
@@ -719,6 +720,7 @@
                                                "Wladiwostok Sommerzeit", "VLAST",
                                                "Wladiwostok Zeit", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"Jekaterinburger Zeit", "YEKT",
                                                  "Jekaterinburger Sommerzeit", "YEKST",
                                                  "Jekaterinburger Zeit", "YEKT"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_es.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_es.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,6 +189,9 @@
         String MHT[] = new String[] {"Hora de las Islas Marshall", "MHT",
                                      "Hora de verano de las Islas Marshall", "MHST",
                                      "Hora de Islas Marshall", "MHT"};
+        String MMT[] = new String[] {"Hora de Myanmar", "MMT",
+                                     "Hora de verano de Myanmar", "MMST",
+                                     "Hora de Myanmar", "MMT"};
         String MSK[] = new String[] {"Hora est\u00e1ndar de Mosc\u00fa", "MSK",
                                      "Hora de verano de Mosc\u00fa", "MSD",
                                      "Hora de Mosc\u00FA", "MT"};
@@ -684,9 +687,7 @@
             {"Asia/Qyzylorda", new String[] {"Hora de Qyzylorda", "QYZT",
                                              "Hora de verano de Qyzylorda", "QYZST",
                                              "Hora de Qyzylorda", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"Hora de Myanmar", "MMT",
-                                           "Hora de verano de Myanmar", "MMST",
-                                           "Hora de Myanmar", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"Hora de Sajalin", "SAKT",
@@ -719,6 +720,7 @@
                                                "Hora de verano de Vladivostok", "VLAST",
                                                "Hora de Vladivostok", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"Hora de Ekaterinburgo", "YEKT",
                                                  "Hora de verano de Ekaterinburgo", "YEKST",
                                                  "Hora de Ekaterinburgo", "YEKT"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_fr.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_fr.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,6 +189,9 @@
         String MHT[] = new String[] {"Heure des Iles Marshall", "MHT",
                                      "Heure d'\u00e9t\u00e9 des Iles Marshall", "MHST",
                                      "Heure des Iles Marshall", "MHT"};
+        String MMT[] = new String[] {"Heure de Myanmar", "MMT",
+                                     "Heure d'\u00e9t\u00e9 de Myanmar", "MMST",
+                                     "Heure de Myanmar", "MMT"};
         String MSK[] = new String[] {"Heure standard de Moscou", "MSK",
                                      "Heure avanc\u00e9e de Moscou", "MSD",
                                      "Moscou", "MT"};
@@ -684,9 +687,7 @@
             {"Asia/Qyzylorda", new String[] {"Heure de Kyzylorda", "QYZT",
                                              "Heure d'\u00e9t\u00e9 de Kyzylorda", "QYZST",
                                              "Heure de Kyzylorda", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"Heure de Myanmar", "MMT",
-                                           "Heure d'\u00e9t\u00e9 de Myanmar", "MMST",
-                                           "Heure de Myanmar", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"Heure de Sakhalin", "SAKT",
@@ -719,6 +720,7 @@
                                                "Heure d'\u00e9t\u00e9 de Vladivostok", "VLAST",
                                                "Heure de Vladivostok", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"Heure de Yekaterinburg", "YEKT",
                                                  "Heure d'\u00e9t\u00e9 de Yekaterinburg", "YEKST",
                                                  "Heure de Yekaterinburg", "YEKT"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_it.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_it.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,6 +189,9 @@
         String MHT[] = new String[] {"Ora delle Isole Marshall", "MHT",
                                      "Ora estiva delle Isole Marshall", "MHST",
                                      "Ora delle Isole Marshall", "MHT"};
+        String MMT[] = new String[] {"Ora della Birmania/Myanmar", "MMT",
+                                     "Ora estiva della Birmania/Myanmar", "MMST",
+                                     "Ora della Birmania/Myanmar", "MMT"};
         String MSK[] = new String[] {"Ora standard di Mosca", "MSK",
                                      "Ora legale di Mosca", "MSD",
                                      "Ora Mosca", "MT"};
@@ -684,9 +687,7 @@
             {"Asia/Qyzylorda", new String[] {"Ora di Qyzylorda", "QYZT",
                                              "Ora estiva di Qyzylorda", "QYZST",
                                              "Ora di Qyzylorda", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"Ora della Birmania/Myanmar", "MMT",
-                                           "Ora estiva della Birmania/Myanmar", "MMST",
-                                           "Ora della Birmania/Myanmar", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"Ora di Sakhalin", "SAKT",
@@ -719,6 +720,7 @@
                                                "Ora estiva di Vladivostok", "VLAST",
                                                "Ora di Vladivostok", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"Ora di Ekaterinburg", "YEKT",
                                                  "Ora estiva di Ekaterinburg", "YEKST",
                                                  "Ora di Ekaterinburg", "YEKT"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ja.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ja.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,6 +189,9 @@
         String MHT[] = new String[] {"\u30de\u30fc\u30b7\u30e3\u30eb\u5cf6\u6642\u9593", "MHT",
                                      "\u30de\u30fc\u30b7\u30e3\u30eb\u5cf6\u590f\u6642\u9593", "MHST",
                                      "\u30DE\u30FC\u30B7\u30E3\u30EB\u8AF8\u5CF6\u6642\u9593", "MHT"};
+        String MMT[] = new String[] {"\u30df\u30e3\u30f3\u30de\u30fc\u6642\u9593", "MMT",
+                                     "\u30df\u30e3\u30f3\u30de\u30fc\u590f\u6642\u9593", "MMST",
+                                     "\u30DF\u30E3\u30F3\u30DE\u30FC\u6642\u9593", "MMT"};
         String MSK[] = new String[] {"\u30e2\u30b9\u30af\u30ef\u6a19\u6e96\u6642", "MSK",
                                      "\u30e2\u30b9\u30af\u30ef\u590f\u6642\u9593", "MSD",
                                      "\u30E2\u30B9\u30AF\u30EF\u6642\u9593", "MT"};
@@ -684,9 +687,7 @@
             {"Asia/Qyzylorda", new String[] {"\u30ad\u30b8\u30eb\u30aa\u30eb\u30c0\u6642\u9593", "QYZT",
                                              "\u30ad\u30b8\u30eb\u30aa\u30eb\u30c0\u590f\u6642\u9593", "QYZST",
                                              "\u30AF\u30BA\u30ED\u30EB\u30C0\u6642\u9593", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"\u30df\u30e3\u30f3\u30de\u30fc\u6642\u9593", "MMT",
-                                           "\u30df\u30e3\u30f3\u30de\u30fc\u590f\u6642\u9593", "MMST",
-                                           "\u30DF\u30E3\u30F3\u30DE\u30FC\u6642\u9593", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"\u6a3a\u592a\u6642\u9593", "SAKT",
@@ -719,6 +720,7 @@
                                                "\u30a6\u30e9\u30b8\u30aa\u30b9\u30c8\u30af\u590f\u6642\u9593", "VLAST",
                                                "\u30A6\u30E9\u30B8\u30AA\u30B9\u30C8\u30AF\u6642\u9593", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"\u30a8\u30ab\u30c6\u30ea\u30f3\u30d6\u30eb\u30b0\u6642\u9593", "YEKT",
                                                  "\u30a8\u30ab\u30c6\u30ea\u30f3\u30d6\u30eb\u30b0\u590f\u6642\u9593", "YEKST",
                                                  "\u30A8\u30AB\u30C6\u30EA\u30F3\u30D6\u30EB\u30AF\u6642\u9593", "YEKT"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ko.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ko.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,6 +189,9 @@
         String MHT[] = new String[] {"\ub9c8\uc15c\uc81c\ub3c4 \uc2dc\uac04", "MHT",
                                      "\ub9c8\uc15c\uc81c\ub3c4 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "MHST",
                                      "\uB9C8\uC15C \uC81C\uB3C4 \uD45C\uC900\uC2DC", "MHT"};
+        String MMT[] = new String[] {"\ubbf8\uc580\ub9c8 \uc2dc\uac04", "MMT",
+                                     "\ubbf8\uc580\ub9c8 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "MMST",
+                                     "\uBBF8\uC580\uB9C8 \uD45C\uC900\uC2DC", "MMT"};
         String MSK[] = new String[] {"\ubaa8\uc2a4\ud06c\ubc14 \ud45c\uc900\uc2dc", "MSK",
                                      "\ubaa8\uc2a4\ud06c\ubc14 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "MSD",
                                      "\uBAA8\uC2A4\uD06C\uBC14 \uD45C\uC900\uC2DC", "MT"};
@@ -684,9 +687,7 @@
             {"Asia/Qyzylorda", new String[] {"Qyzylorda \ud45c\uc900\uc2dc", "QYZT",
                                              "Qyzylorda \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "QYZST",
                                              "\uD0A4\uC9C8\uB85C\uB974\uB2E4 \uD45C\uC900\uC2DC", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"\ubbf8\uc580\ub9c8 \uc2dc\uac04", "MMT",
-                                           "\ubbf8\uc580\ub9c8 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "MMST",
-                                           "\uBBF8\uC580\uB9C8 \uD45C\uC900\uC2DC", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"\uc0ac\ud560\ub9b0 \uc2dc\uac04", "SAKT",
@@ -719,6 +720,7 @@
                                                "\ube14\ub77c\ub514\ubcf4\uc2a4\ud1a1 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "VLAST",
                                                "\uBE14\uB77C\uB514\uBCF4\uC2A4\uD1A1 \uD45C\uC900\uC2DC", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"\uc608\uce74\ud14c\ub9b0\ubc84\uadf8 \uc2dc\uac04", "YEKT",
                                                  "\uc608\uce74\ud14c\ub9b0\ubc84\uadf8 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "YEKST",
                                                  "\uC608\uCE74\uD14C\uB9B0\uBD80\uB974\uD06C \uD45C\uC900\uC2DC", "YEKT"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_pt_BR.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_pt_BR.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,6 +189,9 @@
         String MSK[] = new String[] {"Fuso hor\u00e1rio padr\u00e3o de Moscou", "MSK",
                                      "Hor\u00e1rio de luz natural de Moscou", "MSD",
                                      "Hor\u00E1rio de Moscou", "MT"};
+        String MMT[] = new String[] {"Fuso hor\u00e1rio de Mianmar", "MMT",
+                                     "Fuso hor\u00e1rio de ver\u00e3o de Mianmar", "MMST",
+                                     "Hor\u00E1rio de Mianmar", "MMT"};
         String MST[] = new String[] {"Fuso hor\u00e1rio padr\u00e3o das montanhas", "MST",
                                      "Hor\u00e1rio de luz natural das montanhas", "MDT",
                                      "Hor\u00E1rio das Montanhas Rochosas", "MT"};
@@ -684,9 +687,7 @@
             {"Asia/Qyzylorda", new String[] {"Fuso hor\u00e1rio de Kizil-Orda", "QYZT",
                                              "Fuso hor\u00e1rio de ver\u00e3o de Kizil-Orda", "QYZST",
                                              "Hor\u00E1rio de Qyzylorda", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"Fuso hor\u00e1rio de Mianmar", "MMT",
-                                           "Fuso hor\u00e1rio de ver\u00e3o de Mianmar", "MMST",
-                                           "Hor\u00E1rio de Mianmar", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"Fuso hor\u00e1rio de Sakhalina", "SAKT",
@@ -719,6 +720,7 @@
                                                "Fuso hor\u00e1rio de ver\u00e3o de Vladivostok", "VLAST",
                                                "Hor\u00E1rio de Vladivostok", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"Fuso hor\u00e1rio de Yekaterinburgo", "YEKT",
                                                  "Fuso hor\u00e1rio de ver\u00e3o de Yekaterinburgo", "YEKST",
                                                  "Hor\u00E1rio de Yekaterinburg", "YEKT"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_sv.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_sv.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,6 +189,9 @@
         String MHT[] = new String[] {"Marshall\u00f6arna, normaltid", "MHT",
                                      "Marshall\u00f6arna, sommartid", "MHST",
                                      "Marshall\u00F6arna-tid", "MHT"};
+        String MMT[] = new String[] {"Myanmar, normaltid", "MMT",
+                                     "Myanmar, sommartid", "MMST",
+                                     "Myanmar-tid", "MMT"};
         String MSK[] = new String[] {"Moskva, normaltid", "MSK",
                                      "Moskva, sommartid", "MSD",
                                      "Moskvas tid", "MT"};
@@ -684,9 +687,7 @@
             {"Asia/Qyzylorda", new String[] {"Qyzylorda, normaltid", "QYZT",
                                              "Qyzylorda, sommartid", "QYZST",
                                              "Qyzylorda-tid", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"Myanmar, normaltid", "MMT",
-                                           "Myanmar, sommartid", "MMST",
-                                           "Myanmar-tid", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"Sakhalin, normaltid", "SAKT",
@@ -719,6 +720,7 @@
                                                "Vladivostok, sommartid", "VLAST",
                                                "Vladivostok-tid", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"Jekaterinburg, normaltid", "YEKT",
                                                  "Jekaterinburg, sommartid", "YEKST",
                                                  "Jekaterinburg-tid", "YEKT"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_CN.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_CN.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,6 +189,9 @@
         String MHT[] = new String[] {"\u9a6c\u7ecd\u5c14\u7fa4\u5c9b\u65f6\u95f4", "MHT",
                                      "\u9a6c\u7ecd\u5c14\u7fa4\u5c9b\u590f\u4ee4\u65f6", "MHST",
                                      "\u9A6C\u7ECD\u5C14\u7FA4\u5C9B\u65F6\u95F4", "MHT"};
+        String MMT[] = new String[] {"\u7f05\u7538\u65f6\u95f4", "MMT",
+                                     "\u7f05\u7538\u590f\u4ee4\u65f6", "MMST",
+                                     "\u7F05\u7538\u65F6\u95F4", "MMT"};
         String MSK[] = new String[] {"\u83ab\u65af\u79d1\u6807\u51c6\u65f6\u95f4", "MSK",
                                      "\u83ab\u65af\u79d1\u590f\u4ee4\u65f6", "MSD",
                                      "\u83AB\u65AF\u79D1\u65F6\u95F4", "MT"};
@@ -684,9 +687,7 @@
             {"Asia/Qyzylorda", new String[] {"Qyzylorda \u65f6\u95f4", "QYZT",
                                              "Qyzylorda \u590f\u4ee4\u65f6", "QYZST",
                                              "Qyzylorda \u65F6\u95F4", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"\u7f05\u7538\u65f6\u95f4", "MMT",
-                                           "\u7f05\u7538\u590f\u4ee4\u65f6", "MMST",
-                                           "\u7F05\u7538\u65F6\u95F4", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"\u5e93\u9875\u5c9b\u65f6\u95f4", "SAKT",
@@ -719,6 +720,7 @@
                                                "\u6d77\u53c2\u5d34\u590f\u4ee4\u65f6", "VLAST",
                                                "\u6D77\u53C2\u5D34\u65F6\u95F4", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"Yekaterinburg \u65f6\u95f4", "YEKT",
                                                  "Yekaterinburg \u590f\u4ee4\u65f6", "YEKST",
                                                  "Yekaterinburg \u65F6\u95F4", "YEKT"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_TW.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_TW.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,6 +189,9 @@
         String MHT[] = new String[] {"\u99ac\u7d39\u723e\u7fa4\u5cf6\u6642\u9593", "MHT",
                                      "\u99ac\u7d39\u723e\u7fa4\u5cf6\u590f\u4ee4\u6642\u9593", "MHST",
                                      "\u99AC\u7D39\u723E\u7FA4\u5CF6\u6642\u9593", "MHT"};
+        String MMT[] = new String[] {"\u7dec\u7538\u6642\u9593", "MMT",
+                                     "\u7dec\u7538\u590f\u4ee4\u6642\u9593", "MMST",
+                                     "\u7DEC\u7538\u6642\u9593", "MMT"};
         String MSK[] = new String[] {"\u83ab\u65af\u79d1\u6a19\u6e96\u6642\u9593", "MSK",
                                      "\u83ab\u65af\u79d1\u65e5\u5149\u7bc0\u7d04\u6642\u9593", "MSD",
                                      "\u83AB\u65AF\u79D1\u6642\u9593", "MT"};
@@ -684,9 +687,7 @@
             {"Asia/Qyzylorda", new String[] {"Qyzylorda \u6642\u9593", "QYZT",
                                              "Qyzylorda \u590f\u4ee4\u6642\u9593", "QYZST",
                                              "\u514B\u5B5C\u6D1B\u723E\u9054\u6642\u9593", "QYZT"}},
-            {"Asia/Rangoon", new String[] {"\u7dec\u7538\u6642\u9593", "MMT",
-                                           "\u7dec\u7538\u590f\u4ee4\u6642\u9593", "MMST",
-                                           "\u7DEC\u7538\u6642\u9593", "MMT"}},
+            {"Asia/Rangoon", MMT},
             {"Asia/Riyadh", ARAST},
             {"Asia/Saigon", ICT},
             {"Asia/Sakhalin", new String[] {"\u5eab\u9801\u5cf6\u6642\u9593", "SAKT",
@@ -721,6 +722,7 @@
                                                "\u6d77\u53c3\u5d34\u590f\u4ee4\u6642\u9593", "VLAST",
                                                "\u6D77\u53C3\u5D34\u6642\u9593", "VLAT"}},
             {"Asia/Yakutsk", YAKT},
+            {"Asia/Yangon", MMT},
             {"Asia/Yekaterinburg", new String[] {"Yekaterinburg \u6642\u9593", "YEKT",
                                                  "Yekaterinburg \u590f\u4ee4\u6642\u9593", "YEKST",
                                                  "\u8449\u5361\u6377\u7433\u5821\u6642\u9593", "YEKT"}},
--- a/jdk/src/jdk.management/share/native/libmanagement_ext/DiagnosticCommandImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.management/share/native/libmanagement_ext/DiagnosticCommandImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,13 @@
   return jmm_interface->GetDiagnosticCommands(env);
 }
 
+#define EXCEPTION_CHECK_AND_FREE(x) do { \
+                                        if ((*env)->ExceptionCheck(env)) { \
+                                            free(x); \
+                                            return NULL; \
+                                        } \
+                                    } while(0)
+
 jobject getDiagnosticCommandArgumentInfoArray(JNIEnv *env, jstring command,
                                               int num_arg) {
   int i;
@@ -59,6 +66,7 @@
   dcmd_arg_info_array = (dcmdArgInfo*) malloc(num_arg * sizeof(dcmdArgInfo));
   /* According to ISO C it is perfectly legal for malloc to return zero if called with a zero argument */
   if (dcmd_arg_info_array == NULL && num_arg != 0) {
+    JNU_ThrowOutOfMemoryError(env, 0);
     return NULL;
   }
   jmm_interface->GetDiagnosticCommandArgumentsInfo(env, command,
@@ -76,14 +84,24 @@
     return NULL;
   }
   for (i=0; i<num_arg; i++) {
+    jstring jname, jdesc,jtype,jdefStr;
+
+    jname = (*env)->NewStringUTF(env,dcmd_arg_info_array[i].name);
+    EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
+
+    jdesc = (*env)->NewStringUTF(env,dcmd_arg_info_array[i].description);
+    EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
+
+    jtype = (*env)->NewStringUTF(env,dcmd_arg_info_array[i].type);
+    EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
+
+    jdefStr = (*env)->NewStringUTF(env, dcmd_arg_info_array[i].default_string);
+    EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
     obj = JNU_NewObjectByName(env,
                               "com/sun/management/internal/DiagnosticCommandArgumentInfo",
                               "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZZI)V",
-                              (*env)->NewStringUTF(env,dcmd_arg_info_array[i].name),
-                              (*env)->NewStringUTF(env,dcmd_arg_info_array[i].description),
-                              (*env)->NewStringUTF(env,dcmd_arg_info_array[i].type),
-                              dcmd_arg_info_array[i].default_string == NULL ? NULL:
-                              (*env)->NewStringUTF(env, dcmd_arg_info_array[i].default_string),
+                              jname, jdesc, jtype,
+                              dcmd_arg_info_array[i].default_string == NULL ? NULL: jdefStr,
                               dcmd_arg_info_array[i].mandatory,
                               dcmd_arg_info_array[i].option,
                               dcmd_arg_info_array[i].multiple,
@@ -93,6 +111,7 @@
       return NULL;
     }
     (*env)->SetObjectArrayElement(env, result, i, obj);
+    EXCEPTION_CHECK_AND_FREE(dcmd_arg_info_array);
   }
   free(dcmd_arg_info_array);
   arraysCls = (*env)->FindClass(env, "java/util/Arrays");
@@ -125,6 +144,7 @@
   jint ret = jmm_interface->GetOptionalSupport(env, &mos);
   jsize num_commands;
   dcmdInfo* dcmd_info_array;
+  jstring jname, jdesc, jimpact;
 
   if (commands == NULL) {
       JNU_ThrowNullPointerException(env, "Invalid String Array");
@@ -139,7 +159,6 @@
 
   result = (*env)->NewObjectArray(env, num_commands, dcmdInfoCls, NULL);
   if (result == NULL) {
-      JNU_ThrowOutOfMemoryError(env, 0);
       return NULL;
   }
   if (num_commands == 0) {
@@ -159,15 +178,22 @@
                                                    dcmd_info_array[i].num_arguments);
       if (args == NULL) {
           free(dcmd_info_array);
-          JNU_ThrowOutOfMemoryError(env, 0);
           return NULL;
       }
+
+      jname = (*env)->NewStringUTF(env,dcmd_info_array[i].name);
+      EXCEPTION_CHECK_AND_FREE(dcmd_info_array);
+
+      jdesc = (*env)->NewStringUTF(env,dcmd_info_array[i].description);
+      EXCEPTION_CHECK_AND_FREE(dcmd_info_array);
+
+      jimpact = (*env)->NewStringUTF(env,dcmd_info_array[i].impact);
+      EXCEPTION_CHECK_AND_FREE(dcmd_info_array);
+
       obj = JNU_NewObjectByName(env,
                                 "com/sun/management/internal/DiagnosticCommandInfo",
                                 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/util/List;)V",
-                                (*env)->NewStringUTF(env,dcmd_info_array[i].name),
-                                (*env)->NewStringUTF(env,dcmd_info_array[i].description),
-                                (*env)->NewStringUTF(env,dcmd_info_array[i].impact),
+                                jname, jdesc, jimpact,
                                 dcmd_info_array[i].permission_class==NULL?NULL:(*env)->NewStringUTF(env,dcmd_info_array[i].permission_class),
                                 dcmd_info_array[i].permission_name==NULL?NULL:(*env)->NewStringUTF(env,dcmd_info_array[i].permission_name),
                                 dcmd_info_array[i].permission_action==NULL?NULL:(*env)->NewStringUTF(env,dcmd_info_array[i].permission_action),
@@ -175,10 +201,11 @@
                                 args);
       if (obj == NULL) {
           free(dcmd_info_array);
-          JNU_ThrowOutOfMemoryError(env, 0);
           return NULL;
       }
+
       (*env)->SetObjectArrayElement(env, result, i, obj);
+      EXCEPTION_CHECK_AND_FREE(dcmd_info_array);
   }
   free(dcmd_info_array);
   return result;
--- a/jdk/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -417,8 +417,8 @@
 JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0
   (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj,
    jlong address, jint length, jboolean peek) {
-    SOCKADDR sa;
-    int sa_len = sizeof(sa);
+    SOCKETADDRESS sa;
+    int sa_len = sizeof(SOCKETADDRESS);
     ssize_t rv = 0;
     jlong *addr = jlong_to_ptr(address);
     struct iovec iov[1];
@@ -501,7 +501,7 @@
             snp = (union sctp_notification *) bufp;
             if (handleNotification(env, fd, resultContainerObj, snp, rv,
                                    (msg->msg_flags & MSG_EOR),
-                                   (struct sockaddr*)&sa ) == JNI_TRUE) {
+                                   &sa.sa) == JNI_TRUE) {
                 /* We have received a notification that is of interest
                    to the Java API. The appropriate notification will be
                    set in the result container. */
@@ -524,7 +524,7 @@
     } while (msg->msg_flags & MSG_NOTIFICATION);
 
     handleMessage(env, resultContainerObj, msg, rv,
-            (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa);
+            (msg->msg_flags & MSG_EOR), &sa.sa);
     return rv;
 }
 
@@ -537,8 +537,8 @@
   (JNIEnv *env, jclass klass, jint fd, jlong address, jint length,
    jobject targetAddress, jint targetPort, jint assocId, jint streamNumber,
    jboolean unordered, jint ppid) {
-    SOCKADDR sa;
-    int sa_len = sizeof(sa);
+    SOCKETADDRESS sa;
+    int sa_len = sizeof(SOCKETADDRESS);
     ssize_t rv = 0;
     jlong *addr = jlong_to_ptr(address);
     struct iovec iov[1];
@@ -555,8 +555,7 @@
      *    Association already existing, assocId != -1, targetAddress = preferred addr
      */
     if (targetAddress != NULL /*&& assocId <= 0*/) {
-        if (NET_InetAddressToSockaddr(env, targetAddress, targetPort,
-                                      (struct sockaddr *)&sa,
+        if (NET_InetAddressToSockaddr(env, targetAddress, targetPort, &sa.sa,
                                       &sa_len, JNI_TRUE) != 0) {
             return IOS_THROWN;
         }
--- a/jdk/src/jdk.sctp/unix/native/libsctp/SctpNet.c	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.sctp/unix/native/libsctp/SctpNet.c	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -210,20 +210,20 @@
 JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_bindx
   (JNIEnv *env, jclass klass, jint fd, jobjectArray addrs, jint port,
    jint addrsLength, jboolean add, jboolean preferIPv6) {
-    SOCKADDR *sap, *tmpSap;
-    int i, sa_len = sizeof(SOCKADDR);
+    SOCKETADDRESS *sap, *tmpSap;
+    int i, sa_len = sizeof(SOCKETADDRESS);
     jobject ia;
 
     if (addrsLength < 1)
         return;
 
-    if ((sap = calloc(addrsLength,  sa_len)) == NULL) {
+    if ((sap = calloc(addrsLength, sa_len)) == NULL) {
           JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
         return;
     }
 
     tmpSap = sap;
-    for (i=0; i<addrsLength; i++) {
+    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) {
@@ -233,7 +233,7 @@
         tmpSap++;
     }
 
-    if (nio_sctp_bindx(fd, (void*)sap, addrsLength, add ? SCTP_BINDX_ADD_ADDR :
+    if (nio_sctp_bindx(fd, (void *)sap, addrsLength, add ? SCTP_BINDX_ADD_ADDR :
                        SCTP_BINDX_REM_ADDR) != 0) {
         handleSocketError(env, errno);
     }
@@ -261,16 +261,16 @@
 JNIEXPORT jint JNICALL
 Java_sun_nio_ch_sctp_SctpNet_connect0
   (JNIEnv *env, jclass clazz, int fd, jobject iao, jint port) {
-    SOCKADDR sa;
-    int sa_len = SOCKADDR_LEN;
+    SOCKETADDRESS sa;
+    int sa_len = sizeof(SOCKETADDRESS);
     int rv;
 
-    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa,
+    if (NET_InetAddressToSockaddr(env, iao, port, &sa.sa,
                                   &sa_len, JNI_TRUE) != 0) {
         return IOS_THROWN;
     }
 
-    rv = connect(fd, (struct sockaddr *)&sa, sa_len);
+    rv = connect(fd, &sa.sa, sa_len);
     if (rv != 0) {
         if (errno == EINPROGRESS) {
             return IOS_UNAVAILABLE;
--- a/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/ExtendedGSSContext.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/ExtendedGSSContext.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,8 +26,6 @@
 package com.sun.security.jgss;
 
 import org.ietf.jgss.*;
-import sun.security.jgss.GSSContextImpl;
-import sun.security.krb5.internal.AuthorizationData;
 
 /**
  * The extended GSSContext interface for supporting additional
@@ -36,40 +34,6 @@
  */
 public interface ExtendedGSSContext extends GSSContext {
 
-    // The impl is almost identical to GSSContextImpl with only 2 differences:
-    // 1. It implements the extended interface
-    // 2. It translates result to data types here in inquireSecContext
-    static class ExtendedGSSContextImpl extends GSSContextImpl
-            implements ExtendedGSSContext {
-
-        public ExtendedGSSContextImpl(GSSContextImpl old) {
-            super(old);
-        }
-
-        @Override
-        public Object inquireSecContext(InquireType type) throws GSSException {
-            SecurityManager security = System.getSecurityManager();
-            if (security != null) {
-                security.checkPermission(
-                        new InquireSecContextPermission(type.toString()));
-            }
-            Object output = super.inquireSecContext(type.name());
-            if (output != null) {
-                if (type == InquireType.KRB5_GET_AUTHZ_DATA) {
-                    AuthorizationData ad = (AuthorizationData) output;
-                    AuthorizationDataEntry[] authzData =
-                            new AuthorizationDataEntry[ad.count()];
-                    for (int i = 0; i < ad.count(); i++) {
-                        authzData[i] = new AuthorizationDataEntry(
-                                ad.item(i).adType, ad.item(i).adData);
-                    }
-                    output = authzData;
-                }
-            }
-            return output;
-        }
-    }
-
     /**
      * Return the mechanism-specific attribute associated with {@code type}.
      * <p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/ExtendedGSSContextImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,64 @@
+/*
+ * 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 com.sun.security.jgss;
+
+import org.ietf.jgss.*;
+import sun.security.jgss.GSSContextImpl;
+import sun.security.krb5.internal.AuthorizationData;
+
+// The impl is almost identical to GSSContextImpl with only 2 differences:
+// 1. It implements the extended interface
+// 2. It translates result to data types here in inquireSecContext
+class ExtendedGSSContextImpl extends GSSContextImpl
+        implements ExtendedGSSContext {
+
+    public ExtendedGSSContextImpl(GSSContextImpl old) {
+        super(old);
+    }
+
+    @Override
+    public Object inquireSecContext(InquireType type) throws GSSException {
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
+            security.checkPermission(
+                    new InquireSecContextPermission(type.toString()));
+        }
+        Object output = super.inquireSecContext(type.name());
+        if (output != null) {
+            if (type == InquireType.KRB5_GET_AUTHZ_DATA) {
+                AuthorizationData ad = (AuthorizationData) output;
+                AuthorizationDataEntry[] authzData =
+                        new AuthorizationDataEntry[ad.count()];
+                for (int i = 0; i < ad.count(); i++) {
+                    authzData[i] = new AuthorizationDataEntry(
+                            ad.item(i).adType, ad.item(i).adData);
+                }
+                output = authzData;
+            }
+        }
+        return output;
+    }
+}
--- a/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/ExtendedGSSCredential.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/ExtendedGSSCredential.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,7 +26,6 @@
 package com.sun.security.jgss;
 
 import org.ietf.jgss.*;
-import sun.security.jgss.GSSCredentialImpl;
 
 /**
  * The extended GSSCredential interface for supporting additional
@@ -35,14 +34,6 @@
  */
 public interface ExtendedGSSCredential extends GSSCredential {
 
-    static class ExtendedGSSCredentialImpl extends GSSCredentialImpl
-            implements ExtendedGSSCredential {
-
-        public ExtendedGSSCredentialImpl(GSSCredentialImpl old) {
-            super(old);
-        }
-    }
-
     /**
      * Impersonates a principal. In Kerberos, this can be implemented
      * using the Microsoft S4U2self extension.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/ExtendedGSSCredentialImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,36 @@
+/*
+ * 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 com.sun.security.jgss;
+
+import sun.security.jgss.GSSCredentialImpl;
+
+class ExtendedGSSCredentialImpl extends GSSCredentialImpl
+        implements ExtendedGSSCredential {
+
+    public ExtendedGSSCredentialImpl(GSSCredentialImpl old) {
+        super(old);
+    }
+}
--- a/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/Extender.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/Extender.java	Tue Oct 18 17:14:09 2016 +0000
@@ -39,18 +39,18 @@
     }
 
     public GSSCredential wrap(GSSCredential cred) {
-        if (cred instanceof ExtendedGSSCredential.ExtendedGSSCredentialImpl) {
+        if (cred instanceof ExtendedGSSCredentialImpl) {
             return cred;
         } else {
-            return new ExtendedGSSCredential.ExtendedGSSCredentialImpl((GSSCredentialImpl)cred);
+            return new ExtendedGSSCredentialImpl((GSSCredentialImpl)cred);
         }
     }
 
     public GSSContext wrap(GSSContext ctxt) {
-        if (ctxt instanceof ExtendedGSSContext.ExtendedGSSContextImpl) {
+        if (ctxt instanceof ExtendedGSSContextImpl) {
             return ctxt;
         } else {
-            return new ExtendedGSSContext.ExtendedGSSContextImpl((GSSContextImpl)ctxt);
+            return new ExtendedGSSContextImpl((GSSContextImpl)ctxt);
         }
     }
 }
--- a/jdk/test/ProblemList.txt	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/ProblemList.txt	Tue Oct 18 17:14:09 2016 +0000
@@ -134,7 +134,7 @@
 
 java/lang/instrument/BootClassPath/BootClassPathTest.sh         8072130 macosx-all
 
-java/lang/instrument/DaemonThread/TestDaemonThread.java         8161225 generic-all
+java/lang/instrument/DaemonThread/TestDaemonThread.java         8167001 generic-all
 
 java/lang/management/MemoryMXBean/Pending.java                  8158837 generic-all
 java/lang/management/MemoryMXBean/PendingAllGC.sh               8158760 generic-all
@@ -275,8 +275,6 @@
 
 java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java 8062512 generic-all
 
-java/util/Arrays/ParallelPrefix.java                            8080165,8085982 generic-all
-
 java/util/BitSet/BitSetStreamTest.java                          8079538 generic-all
 
 ############################################################################
--- a/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java	Tue Oct 18 17:14:09 2016 +0000
@@ -36,7 +36,6 @@
  * @author Yun Ke
  * @author Bill Situ
  * @author Yu-Ching (Valerie) PENG
- * @run main TestCipherKeyWrapperPBEKey
  */
 public class TestCipherPBECons {
 
--- a/jdk/test/com/sun/jdi/InterfaceMethodsTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/com/sun/jdi/InterfaceMethodsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -197,14 +197,18 @@
         // invoke interface static method A
         testInvokePos(ifaceClass, null, "staticMethodA", "()I", vm().mirrorOf(RESULT_A));
 
-        // try to invoke static method A on the instance
-        testInvokePos(ifaceClass, ref, "staticMethodA", "()I", vm().mirrorOf(RESULT_A));
+        // invoking static method A on the instance fails because static method A is
+        // not inherited by TargetClass.
+        testInvokeNeg(ifaceClass, ref, "staticMethodA", "()I", vm().mirrorOf(RESULT_A),
+                "Invalid MethodID");
 
         // invoke interface static method B
         testInvokePos(ifaceClass, null, "staticMethodB", "()I", vm().mirrorOf(RESULT_A));
 
-        // try to invoke static method B on the instance
-        testInvokePos(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_A));
+        // invoking static method B on the instance fails because static method B is
+        // not inherited by TargetClass.
+        testInvokeNeg(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_A),
+                "Invalid MethodID");
 
         // try to invoke a virtual method
         testInvokePos(ifaceClass, ref, "implementedMethod", "()I", vm().mirrorOf(RESULT_A), true);
@@ -239,21 +243,25 @@
         testInvokeNeg(ifaceClass, null, "staticMethodA", "()I", vm().mirrorOf(RESULT_A),
                 "Static interface methods are not inheritable");
 
-        // however it is possible to call "staticMethodA" on the actual instance
+        // "staticMethodA" is not inherited by InterfaceB even from an actual instance
         testInvokeNeg(ifaceClass, ref, "staticMethodA", "()I", vm().mirrorOf(RESULT_A),
                 "Static interface methods are not inheritable");
 
-        // "staticMethodB" is overridden in InterfaceB
+        // "staticMethodB" is re-defined in InterfaceB
         testInvokePos(ifaceClass, null, "staticMethodB", "()I", vm().mirrorOf(RESULT_B));
 
-        // the instance invokes the overriden form of "staticMethodB" from InterfaceB
-        testInvokePos(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_B));
+        // the instance fails to invoke the re-defined form of "staticMethodB" from
+        // InterfaceB because staticMethodB is not inherited by TargetClass
+        testInvokeNeg(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_B),
+                "Invalid MethodID");
 
         // "staticMethodC" is present only in InterfaceB
         testInvokePos(ifaceClass, null, "staticMethodC", "()I", vm().mirrorOf(RESULT_B));
 
-        // "staticMethodC" should be reachable from the instance too
-        testInvokePos(ifaceClass, ref, "staticMethodC", "()I", vm().mirrorOf(RESULT_B));
+        // "staticMethodC" is not reachable from the instance because staticMethodC
+        // is not inherited by TargetClass.
+        testInvokeNeg(ifaceClass, ref, "staticMethodC", "()I", vm().mirrorOf(RESULT_B),
+                "Invalid MethodID");
     }
 
     private void testImplementationClass(ReferenceType targetClass, ObjectReference thisObject) {
--- a/jdk/test/com/sun/jdi/InvokeHangTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/com/sun/jdi/InvokeHangTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
  *  @author jjh
  *
  *  @modules jdk.jdi
+ *  @library /test/lib
  *  @run build TestScaffold VMConnection TargetListener TargetAdapter
  *  @run compile -g InvokeHangTest.java
  *  @run driver InvokeHangTest
@@ -133,7 +134,7 @@
     BreakpointRequest request2;
     static volatile int bkpts = 0;
     Thread timerThread;
-    static int waitTime = 20000;
+    static long waitTime = jdk.test.lib.Utils.adjustTimeout(20000);
 
     InvokeHangTest (String args[]) {
         super(args);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/jdi/OomDebugTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,416 @@
+/*
+ * Copyright (c) 2016 Red Hat Inc.
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8153711
+ *  @summary JDWP: Memory Leak (global references not deleted after invokeMethod).
+ *
+ *  @author Severin Gehwolf <sgehwolf@redhat.com>
+ *
+ *  @library ..
+ *  @run build TestScaffold VMConnection TargetListener TargetAdapter
+ *  @run compile -g OomDebugTest.java
+ *  @run main OomDebugTest OomDebugTestTarget test1
+ *  @run main OomDebugTest OomDebugTestTarget test2
+ *  @run main OomDebugTest OomDebugTestTarget test3
+ *  @run main OomDebugTest OomDebugTestTarget test4
+ *  @run main OomDebugTest OomDebugTestTarget test5
+ */
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import com.sun.jdi.ArrayReference;
+import com.sun.jdi.ArrayType;
+import com.sun.jdi.ClassType;
+import com.sun.jdi.Field;
+import com.sun.jdi.InvocationException;
+import com.sun.jdi.Method;
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.StackFrame;
+import com.sun.jdi.VMOutOfMemoryException;
+import com.sun.jdi.Value;
+import com.sun.jdi.event.BreakpointEvent;
+import com.sun.jdi.event.ExceptionEvent;
+
+/***************** Target program **********************/
+
+class OomDebugTestTarget {
+
+    OomDebugTestTarget() {
+        System.out.println("DEBUG: invoked constructor");
+    }
+    static class FooCls {
+        @SuppressWarnings("unused")
+        private byte[] bytes = new byte[3000000];
+    };
+
+    FooCls fooCls = new FooCls();
+    byte[] byteArray = new byte[0];
+
+    void testMethod(FooCls foo) {
+        System.out.println("DEBUG: invoked 'void testMethod(FooCls)', foo == " + foo);
+    }
+
+    void testPrimitive(byte[] foo) {
+        System.out.println("DEBUG: invoked 'void testPrimitive(byte[])', foo == " + foo);
+    }
+
+    byte[] testPrimitiveArrRetval() {
+        System.out.println("DEBUG: invoked 'byte[] testPrimitiveArrRetval()'");
+        return new byte[3000000];
+    }
+
+    FooCls testFooClsRetval() {
+        System.out.println("DEBUG: invoked 'FooCls testFooClsRetval()'");
+        return new FooCls();
+    }
+
+    public void entry() {}
+
+    public static void main(String[] args){
+        System.out.println("DEBUG: OomDebugTestTarget.main");
+        new OomDebugTestTarget().entry();
+    }
+}
+
+/***************** Test program ************************/
+
+public class OomDebugTest extends TestScaffold {
+
+    private static final String[] ALL_TESTS = new String[] {
+            "test1", "test2", "test3", "test4", "test5"
+    };
+    private static final Set<String> ALL_TESTS_SET = new HashSet<String>();
+    static {
+        ALL_TESTS_SET.addAll(Arrays.asList(ALL_TESTS));
+    }
+    private static final String TEST_CLASSES = System.getProperty("test.classes", ".");
+    private static final File RESULT_FILE = new File(TEST_CLASSES, "results.properties");
+    private static final String LAST_TEST = ALL_TESTS[ALL_TESTS.length - 1];
+    private ReferenceType targetClass;
+    private ObjectReference thisObject;
+    private int failedTests;
+    private final String testMethod;
+
+    public OomDebugTest(String[] args) {
+        super(args);
+        if (args.length != 2) {
+            throw new RuntimeException("Test failed unexpectedly.");
+        }
+        this.testMethod = args[1];
+    }
+
+    @Override
+    protected void runTests() throws Exception {
+        try {
+            addListener(new TargetAdapter() {
+
+                @Override
+                public void exceptionThrown(ExceptionEvent event) {
+                    String name = event.exception().referenceType().name();
+                    System.err.println("DEBUG: Exception thrown in debuggee was: " + name);
+                }
+            });
+            /*
+             * Get to the top of entry()
+             * to determine targetClass and mainThread
+             */
+            BreakpointEvent bpe = startTo("OomDebugTestTarget", "entry", "()V");
+            targetClass = bpe.location().declaringType();
+
+            mainThread = bpe.thread();
+
+            StackFrame frame = mainThread.frame(0);
+            thisObject = frame.thisObject();
+            java.lang.reflect.Method m = findTestMethod();
+            m.invoke(this);
+        } catch (NoSuchMethodException e) {
+            e.printStackTrace();
+            failure();
+        } catch (SecurityException e) {
+            e.printStackTrace();
+            failure();
+        }
+        /*
+         * resume the target, listening for events
+         */
+        listenUntilVMDisconnect();
+    }
+
+    private java.lang.reflect.Method findTestMethod()
+            throws NoSuchMethodException, SecurityException {
+        return OomDebugTest.class.getDeclaredMethod(testMethod);
+    }
+
+    private void failure() {
+        failedTests++;
+    }
+
+    /*
+     * Test case: Object reference as method parameter.
+     */
+    @SuppressWarnings("unused") // called via reflection
+    private void test1() throws Exception {
+        System.out.println("DEBUG: ------------> Running test1");
+        try {
+            Field field = targetClass.fieldByName("fooCls");
+            ClassType clsType = (ClassType)field.type();
+            Method constructor = getConstructorForClass(clsType);
+            for (int i = 0; i < 15; i++) {
+                @SuppressWarnings({ "rawtypes", "unchecked" })
+                ObjectReference objRef = clsType.newInstance(mainThread,
+                                                             constructor,
+                                                             new ArrayList(0),
+                                                             ObjectReference.INVOKE_NONVIRTUAL);
+                if (objRef.isCollected()) {
+                    System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP.");
+                    continue;
+                }
+                invoke("testMethod", "(LOomDebugTestTarget$FooCls;)V", objRef);
+            }
+        } catch (InvocationException e) {
+            handleFailure(e);
+        }
+    }
+
+    /*
+     * Test case: Array reference as method parameter.
+     */
+    @SuppressWarnings("unused") // called via reflection
+    private void test2() throws Exception {
+        System.out.println("DEBUG: ------------> Running test2");
+        try {
+            Field field = targetClass.fieldByName("byteArray");
+            ArrayType arrType = (ArrayType)field.type();
+
+            for (int i = 0; i < 15; i++) {
+                ArrayReference byteArrayVal = arrType.newInstance(3000000);
+                if (byteArrayVal.isCollected()) {
+                    System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP.");
+                    continue;
+                }
+                invoke("testPrimitive", "([B)V", byteArrayVal);
+            }
+        } catch (VMOutOfMemoryException e) {
+            defaultHandleOOMFailure(e);
+        }
+    }
+
+    /*
+     * Test case: Array reference as return value.
+     */
+    @SuppressWarnings("unused") // called via reflection
+    private void test3() throws Exception {
+        System.out.println("DEBUG: ------------> Running test3");
+        try {
+            for (int i = 0; i < 15; i++) {
+                invoke("testPrimitiveArrRetval",
+                       "()[B",
+                       Collections.EMPTY_LIST,
+                       vm().mirrorOfVoid());
+            }
+        } catch (InvocationException e) {
+            handleFailure(e);
+        }
+    }
+
+    /*
+     * Test case: Object reference as return value.
+     */
+    @SuppressWarnings("unused") // called via reflection
+    private void test4() throws Exception {
+        System.out.println("DEBUG: ------------> Running test4");
+        try {
+            for (int i = 0; i < 15; i++) {
+                invoke("testFooClsRetval",
+                       "()LOomDebugTestTarget$FooCls;",
+                       Collections.EMPTY_LIST,
+                       vm().mirrorOfVoid());
+            }
+        } catch (InvocationException e) {
+            handleFailure(e);
+        }
+    }
+
+    /*
+     * Test case: Constructor
+     */
+    @SuppressWarnings({ "unused", "unchecked", "rawtypes" }) // called via reflection
+    private void test5() throws Exception {
+        System.out.println("DEBUG: ------------> Running test5");
+        try {
+            ClassType type = (ClassType)thisObject.type();
+            for (int i = 0; i < 15; i++) {
+                type.newInstance(mainThread,
+                                 findMethod(targetClass, "<init>", "()V"),
+                                 new ArrayList(0),
+                                 ObjectReference.INVOKE_NONVIRTUAL);
+            }
+        } catch (InvocationException e) {
+            handleFailure(e);
+        }
+    }
+
+    private Method getConstructorForClass(ClassType clsType) {
+        List<Method> methods = clsType.methodsByName("<init>");
+        if (methods.size() != 1) {
+            throw new RuntimeException("FAIL. Expected only one, the default, constructor");
+        }
+        return methods.get(0);
+    }
+
+    private void handleFailure(InvocationException e) {
+        // There is no good way to see the OOME diagnostic message in the target since the
+        // TestScaffold might throw an exception while trying to print the stack trace. I.e
+        // it might get a a VMDisconnectedException before the stack trace printing finishes.
+        System.err.println("FAILURE: InvocationException thrown. Trying to determine cause...");
+        defaultHandleOOMFailure(e);
+    }
+
+    private void defaultHandleOOMFailure(Exception e) {
+        e.printStackTrace();
+        failure();
+    }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    void invoke(String methodName, String methodSig, Value value)
+            throws Exception {
+        List args = new ArrayList(1);
+        args.add(value);
+        invoke(methodName, methodSig, args, value);
+    }
+
+    void invoke(String methodName,
+                String methodSig,
+                @SuppressWarnings("rawtypes") List args,
+                Value value) throws Exception {
+        Method method = findMethod(targetClass, methodName, methodSig);
+        if ( method == null) {
+            failure("FAILED: Can't find method: "
+                    + methodName  + " for class = " + targetClass);
+            return;
+        }
+        invoke(method, args, value);
+    }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    void invoke(Method method, List args, Value value) throws Exception {
+        thisObject.invokeMethod(mainThread, method, args, 0);
+        System.out.println("DEBUG: Done invoking method via debugger.");
+    }
+
+    Value fieldValue(String fieldName) {
+        Field field = targetClass.fieldByName(fieldName);
+        return thisObject.getValue(field);
+    }
+
+    // Determine the pass/fail status on some heuristic and don't fail the
+    // test if < 3 of the total number of tests (currently 5) fail. This also
+    // has the nice side effect that all tests are first attempted and only
+    // all tests ran an overall pass/fail status is determined.
+    private static void determineOverallTestStatus(OomDebugTest oomTest)
+                                   throws IOException, FileNotFoundException {
+        Properties resultProps = new Properties();
+        if (!RESULT_FILE.exists()) {
+            RESULT_FILE.createNewFile();
+        }
+        FileInputStream fin = null;
+        try {
+            fin = new FileInputStream(RESULT_FILE);
+            resultProps.load(fin);
+            resultProps.put(oomTest.testMethod,
+                            Integer.toString(oomTest.failedTests));
+        } finally {
+            if (fin != null) {
+                fin.close();
+            }
+        }
+        System.out.println("DEBUG: Finished running test '"
+                           + oomTest.testMethod + "'.");
+        if (LAST_TEST.equals(oomTest.testMethod)) {
+            System.out.println("DEBUG: Determining overall test status.");
+            Set<String> actualTestsRun = new HashSet<String>();
+            int totalTests = ALL_TESTS.length;
+            int failedTests = 0;
+            for (Object key: resultProps.keySet()) {
+                actualTestsRun.add((String)key);
+                Object propVal = resultProps.get(key);
+                int value = Integer.parseInt((String)propVal);
+                failedTests += value;
+            }
+            if (!ALL_TESTS_SET.equals(actualTestsRun)) {
+                String errorMsg = "Test failed! Expected to run tests '"
+                        + ALL_TESTS_SET + "', but only these were run '"
+                        + actualTestsRun + "'";
+                throw new RuntimeException(errorMsg);
+            }
+            if (failedTests >= 3) {
+                String errorMsg = "Test failed. Expected < 3 sub-tests to fail "
+                                  + "for a pass. Got " + failedTests
+                                  + " failed tests out of " + totalTests + ".";
+                throw new RuntimeException(errorMsg);
+            }
+            RESULT_FILE.delete();
+            System.out.println("All " + totalTests + " tests passed.");
+        } else {
+            System.out.println("DEBUG: More tests to run. Coninuing.");
+            FileOutputStream fout = null;
+            try {
+                fout = new FileOutputStream(RESULT_FILE);
+                resultProps.store(fout, "Storing results after test "
+                                         + oomTest.testMethod);
+            } finally {
+                if (fout != null) {
+                    fout.close();
+                }
+            }
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.setProperty("test.vm.opts", "-Xmx40m"); // Set debuggee VM option
+        OomDebugTest oomTest = new OomDebugTest(args);
+        try {
+            oomTest.startTests();
+        } catch (Throwable e) {
+            System.out.println("DEBUG: Got exception for test run. " + e);
+            e.printStackTrace();
+            oomTest.failure();
+        }
+        determineOverallTestStatus(oomTest);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/FocusTraversalPolicy/ButtonGroupLayoutTraversal/ButtonGroupLayoutTraversalTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,158 @@
+/*
+ * 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 8154043
+  @summary Fields not reachable anymore by tab-key, because of new tabbing
+  behaviour of radio button groups.
+  @run main ButtonGroupLayoutTraversalTest
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.KeyEvent;
+
+public class ButtonGroupLayoutTraversalTest {
+    static int nx = 3;
+    static int ny = 3;
+
+    static int focusCnt[] = new int[nx * ny];
+    private static JFrame window;
+
+
+    public static void main(String[] args) throws Exception {
+
+        SwingUtilities.invokeAndWait(()->initLayout(nx, ny));
+        Robot robot = new Robot();
+        robot.setAutoDelay(100);
+        robot.waitForIdle();
+        robot.delay(200);
+
+
+        for(int i = 0; i < nx * ny - nx * ny / 2 - 1; i++) {
+            robot.keyPress(KeyEvent.VK_RIGHT);
+            robot.keyRelease(KeyEvent.VK_RIGHT);
+        }
+
+        for(int i = 0; i < nx * ny / 2; i++) {
+            robot.keyPress(KeyEvent.VK_TAB);
+            robot.keyRelease(KeyEvent.VK_TAB);
+        }
+
+        robot.waitForIdle();
+        robot.delay(200);
+
+        for(int i = 0; i < nx * ny; i++) {
+            if(focusCnt[i] < 1) {
+                SwingUtilities.invokeLater(window::dispose);
+                throw new RuntimeException("Component " + i +
+                        " is not reachable in the forward focus cycle");
+            } else if (focusCnt[i] > 1) {
+                SwingUtilities.invokeLater(window::dispose);
+                throw new RuntimeException("Component " + i +
+                        " got focus more than once in the forward focus cycle");
+            }
+        }
+
+        for(int i = 0; i < nx * ny / 2; i++) {
+            robot.keyPress(KeyEvent.VK_SHIFT);
+            robot.keyPress(KeyEvent.VK_TAB);
+            robot.keyRelease(KeyEvent.VK_TAB);
+            robot.keyRelease(KeyEvent.VK_SHIFT);
+        }
+
+        for(int i = 0; i < nx * ny - nx * ny / 2 - 1; i++) {
+            robot.keyPress(KeyEvent.VK_LEFT);
+            robot.keyRelease(KeyEvent.VK_LEFT);
+        }
+
+        robot.keyPress(KeyEvent.VK_SHIFT);
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.keyRelease(KeyEvent.VK_TAB);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+
+        robot.waitForIdle();
+        robot.delay(200);
+
+        for(int i = 0; i < nx * ny; i++) {
+            if(focusCnt[i] < 2) {
+                SwingUtilities.invokeLater(window::dispose);
+                throw new RuntimeException("Component " + i +
+                        " is not reachable in the backward focus cycle");
+            } else if (focusCnt[i] > 2) {
+                SwingUtilities.invokeLater(window::dispose);
+                throw new RuntimeException("Component " + i +
+                        " got focus more than once in the backward focus cycle");
+            }
+        }
+
+        SwingUtilities.invokeLater(window::dispose);
+    }
+
+    public static void initLayout(int nx, int ny)
+    {
+        window = new JFrame("Test");
+        window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        JPanel rootPanel = new JPanel();
+        rootPanel.setLayout(new BorderLayout());
+        JPanel formPanel = new JPanel(new GridLayout(nx, ny));
+        formPanel.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
+        formPanel.setFocusCycleRoot(true);
+        ButtonGroup radioButtonGroup = new ButtonGroup();
+        for(int i = 0; i < nx * ny; i++) {
+            JToggleButton comp;
+            if(i % 2 == 0) {
+                comp = new JRadioButton("Grouped component");
+                radioButtonGroup.add(comp);
+            } else {
+                comp = new JRadioButton("Single component");
+            }
+            formPanel.add(comp);
+            int fi = i;
+            comp.setBackground(Color.red);
+            comp.addFocusListener(new FocusAdapter() {
+                @Override
+                public void focusGained(FocusEvent e) {
+                    focusCnt[fi]++;
+                    if( focusCnt[fi] == 1) {
+                        ((JComponent) e.getSource())
+                                .setBackground(Color.yellow);
+                    } else if(focusCnt[fi] == 2) {
+                        ((JComponent) e.getSource())
+                                .setBackground(Color.green);
+                    } else {
+                        ((JComponent) e.getSource())
+                                .setBackground(Color.red);
+                    }
+                }
+            });
+        }
+        rootPanel.add(formPanel, BorderLayout.CENTER);
+        window.add(rootPanel);
+        window.pack();
+        window.setVisible(true);
+    }
+}
--- a/jdk/test/java/awt/Focus/ModalDialogActivationTest/ModalDialogActivationTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/awt/Focus/ModalDialogActivationTest/ModalDialogActivationTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -23,15 +23,21 @@
  * questions.
  */
 
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.EventQueue;
+import java.awt.Frame;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
 
 /*
   @test
-  @bug       8160570
-  @summary   Tests that a modal dialog receives WINDOW_ACTIVATED & WINDOW_GAINED_FOCUS on first show.
+  @key headful
+  @bug 8160570 8166015
+  @summary Tests that a modal dialog receives WINDOW_ACTIVATED
+            & WINDOW_GAINED_FOCUS on first show.
 */
+
 public class ModalDialogActivationTest {
     static final Object lock = new Object();
     static volatile boolean activated;
@@ -48,7 +54,8 @@
             }
         }
         if (!activated || !focused) {
-            throw new RuntimeException("Test FAILED: activated: " + activated + ", focused: " + focused);
+            throw new RuntimeException("Test FAILED: activated: " + activated
+                                        + ", focused: " + focused);
         }
         System.out.println("Test PASSED");
     }
@@ -79,7 +86,7 @@
     }
 
     static class MyModalDialog extends JDialog {
-        public MyModalDialog(Frame owner, String title)ª {
+        public MyModalDialog(Frame owner, String title) {
             super(owner, title, true);
         }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/DecoratedFrameInsets/DecoratedFrameInsetsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,81 @@
+/*
+ * 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 8165619
+ * @summary Frame is not repainted if created in state=MAXIMIZED_BOTH on Unity
+ * @run main DecoratedFrameInsetsTest
+ */
+
+import java.awt.*;
+
+public class DecoratedFrameInsetsTest {
+    static Robot robot;
+    private static Insets expectedInsets;
+
+    public static void main(String[] args) throws Exception {
+        robot = new Robot();
+        expectedInsets = getExpectedInsets();
+        System.out.println("Normal state insets: " + expectedInsets);
+        testState(Frame.MAXIMIZED_BOTH);
+        testState(Frame.ICONIFIED);
+        testState(Frame.MAXIMIZED_HORIZ);
+        testState(Frame.MAXIMIZED_VERT);
+    }
+
+    private static Insets getExpectedInsets() {
+        Frame frame = new Frame();
+        frame.setVisible(true);
+        robot.waitForIdle();
+        robot.delay(200);
+        Insets expectedInsets = frame.getInsets();
+        frame.dispose();
+        return expectedInsets;
+    }
+
+    static void testState(int state) {
+        Frame frame = new Frame();
+        if( Toolkit.getDefaultToolkit().isFrameStateSupported(state)) {
+            frame.setBounds(150, 150, 200, 200);
+            frame.setExtendedState(state);
+            frame.setVisible(true);
+            robot.waitForIdle();
+            robot.delay(200);
+            System.out.println("State " + state +
+                                               " insets: " + frame.getInsets());
+
+            frame.setExtendedState(Frame.NORMAL);
+            frame.toFront();
+            robot.waitForIdle();
+            robot.delay(200);
+            Insets insets = frame.getInsets();
+            frame.dispose();
+            System.out.println("State " + state +
+                                           " back to normal insets: " + insets);
+            if(!expectedInsets.equals(insets)) {
+                throw new RuntimeException("Insets are wrong " + insets);
+            }
+        }
+    }
+}
--- a/jdk/test/java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 /*
  @test
  @key headful
- @bug 7079254
+ @bug 7079254 8163261
  @summary Toolkit eventListener leaks memory
  @library ../regtesthelpers
  @build Util
@@ -93,8 +93,15 @@
             }
         }
         alloc = null;
+        String leakObjs = "";
         if (button.get() != null) {
-            throw new Exception("Test failed: JButton was not collected");
+            leakObjs = "JButton";
+        }
+        if (p.get() != null) {
+            leakObjs += " JPanel";
+        }
+        if (leakObjs != "") {
+            throw new Exception("Test failed: " + leakObjs + " not collected");
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Robot/SpuriousMouseEvents/SpuriousMouseEvents.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,93 @@
+/*
+ * 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
+  @key headful
+  @bug 5097801 8163270
+  @summary Tests that no mouse events are sent to component if robot is
+           moving mouse on another screen, Xinerama
+  @run main SpuriousMouseEvents
+ */
+import java.awt.AWTException;
+import java.awt.GraphicsEnvironment;
+import java.awt.GraphicsDevice;
+import java.awt.Robot;
+import java.awt.GraphicsConfiguration;
+import java.awt.Frame;
+import java.awt.event.MouseMotionAdapter;
+import java.awt.event.MouseEvent;
+
+public class SpuriousMouseEvents {
+
+    private static volatile boolean testPassed = true;
+
+    public static void main(String args[]) throws AWTException {
+        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+        GraphicsDevice[] gds = ge.getScreenDevices();
+        if (gds.length < 2) {
+            return;
+        }
+
+        Robot r = null;
+        try {
+            r = new Robot();
+        } catch (Exception e) {
+            throw new RuntimeException("Couldn't create AWT robot" + e);
+        }
+
+        for (int i = 1; i >= 0; i--) {
+            GraphicsDevice gd = gds[i];
+            GraphicsDevice gdo = gds[1 - i];
+            GraphicsConfiguration gc = gd.getDefaultConfiguration();
+            GraphicsConfiguration gco = gdo.getDefaultConfiguration();
+            Frame f = new Frame("Frame", gc);
+            f.setBounds(gc.getBounds().x + 100, gc.getBounds().y + 100, 200, 200);
+            f.addMouseMotionListener(new MouseMotionAdapter() {
+                public void mouseMoved(MouseEvent me) {
+                    testPassed = false;
+                }
+            });
+            f.setVisible(true);
+
+            r = new Robot(gdo);
+            int x = (int) gco.getBounds().x;
+            for (int j = x; j < x + 400; j += 10) {
+                r.mouseMove(j, 200);
+                r.delay(10);
+            }
+            r.delay(1000);
+
+            f.setVisible(false);
+            f.dispose();
+
+            if (!testPassed) {
+                break;
+            }
+        }
+
+        if (!testPassed) {
+            throw new RuntimeException("Wrong mouse events are sent");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/MultiResIconTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,198 @@
+/*
+ * 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
+ * @key headful
+ * @bug 8149371
+ * @summary multi-res. image: -Dsun.java2d.uiScale does not work for Window
+ * icons (some ambiguity for Window.setIconImages()?)
+ * @run main/othervm/manual -Dsun.java2d.uiScale=2 MultiResIconTest
+ */
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.image.BaseMultiResolutionImage;
+import java.awt.image.BufferedImage;
+import java.util.concurrent.CountDownLatch;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+public class MultiResIconTest {
+
+    private static GridBagLayout layout;
+    private static JPanel mainControlPanel;
+    private static JPanel resultButtonPanel;
+    private static JLabel instructionText;
+    private static JButton passButton;
+    private static JButton failButton;
+    private static JDialog f;
+    private static CountDownLatch latch;
+    private static TestFrame frame;
+
+    private static BufferedImage generateImage(int x, Color c) {
+
+        BufferedImage img = new BufferedImage(x, x, BufferedImage.TYPE_INT_RGB);
+        Graphics g = img.getGraphics();
+        g.setColor(c);
+        g.fillRect(0, 0, x, x);
+        g.setColor(Color.WHITE);
+        g.fillRect(x / 3, x / 3, x / 3, x / 3);
+        return img;
+    }
+
+    public MultiResIconTest() {
+        try {
+            latch = new CountDownLatch(1);
+            createUI();
+            latch.await();
+        } catch (Exception ex) {
+        }
+    }
+
+    private static void createUI() throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            frame = new TestFrame();
+            f = new JDialog(frame);
+            f.setTitle("Instruction Dialog");
+            layout = new GridBagLayout();
+            mainControlPanel = new JPanel(layout);
+            resultButtonPanel = new JPanel(layout);
+            GridBagConstraints gbc = new GridBagConstraints();
+            String instructions
+                    = "<html>    INSTRUCTIONS:<br><br>"
+                    + "1) Test frame title icon and frame color should be green."
+                    + "<br>"
+                    + "2) Test frame task bar icon should be blue<br>"
+                    + "3) If color are same as mentioned in 1 and 2 press pass<br>"
+                    + "   else press fail.<br><br></html>";
+
+            instructionText = new JLabel();
+            instructionText.setText(instructions);
+
+            gbc.gridx = 0;
+            gbc.gridy = 0;
+            gbc.fill = GridBagConstraints.HORIZONTAL;
+            mainControlPanel.add(instructionText, gbc);
+            passButton = new JButton("Pass");
+            passButton.setActionCommand("Pass");
+            passButton.addActionListener((ActionEvent e) -> {
+                latch.countDown();
+                f.dispose();
+                frame.dispose();
+            });
+            failButton = new JButton("Fail");
+            failButton.setActionCommand("Fail");
+            failButton.addActionListener(new ActionListener() {
+                @Override
+                public void actionPerformed(ActionEvent e) {
+                    latch.countDown();
+                    f.dispose();
+                    frame.dispose();
+                    throw new RuntimeException("Test Failed");
+                }
+            });
+            gbc.gridx = 1;
+            gbc.gridy = 0;
+            resultButtonPanel.add(passButton, gbc);
+            gbc.gridx = 2;
+            gbc.gridy = 0;
+            resultButtonPanel.add(failButton, gbc);
+
+            gbc.gridx = 0;
+            gbc.gridy = 1;
+            mainControlPanel.add(resultButtonPanel, gbc);
+
+            f.add(mainControlPanel);
+            f.setSize(400, 200);
+            f.setLocationRelativeTo(null);
+            f.setVisible(true);
+
+            f.addWindowListener(new WindowAdapter() {
+                @Override
+                public void windowClosing(WindowEvent e) {
+                    latch.countDown();
+                    f.dispose();
+                    frame.dispose();
+                }
+            });
+        });
+    }
+
+    private static class TestFrame extends JFrame {
+
+        private static final int W = 200;
+
+        private static final BaseMultiResolutionImage IMG
+                = new BaseMultiResolutionImage(
+                        new BufferedImage[]{generateImage(W, Color.RED),
+                            generateImage(2 * W, Color.GREEN),
+                            generateImage(4 * W, Color.BLUE)});
+
+        private static final BaseMultiResolutionImage ICON
+                = new BaseMultiResolutionImage(
+                        new BufferedImage[]{generateImage(16, Color.RED),
+                            generateImage(32, Color.GREEN),
+                            generateImage(64, Color.BLUE),
+                            generateImage(128, Color.BLACK),
+                            generateImage(256, Color.GRAY)});
+
+        public TestFrame() {
+            createUI();
+        }
+
+        private void createUI() {
+            setTitle("Test Frame");
+            setIconImage(ICON);
+            addWindowListener(new WindowAdapter() {
+                @Override
+                public void windowClosing(WindowEvent e) {
+                    dispose();
+                }
+            });
+            setSize(W, W);
+            setLocation(50, 50);
+            setResizable(false);
+            setVisible(true);
+        }
+
+        @Override
+        public void paint(Graphics gr) {
+            gr.drawImage(IMG, 0, 0, this);
+        }
+    }
+
+    public static void main(String[] args) {
+        new MultiResIconTest();
+    }
+}
+
--- a/jdk/test/java/awt/image/multiresolution/MultiResolutionTrayIconTest/MultiResolutionTrayIconTest.html	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +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.
--->
-
-<html>
-<head>
-<title> MultiResolutionTrayIconTest </title>
-</head>
-<body>
-<applet code="MultiResolutionTrayIconTest.class" width=100 height=30></applet>
-
-To run test please push "Start" (if system tray is not supported, push "Pass").
-
-Two tray icons will appear (note: sometimes they can go to the tray icons pool).
-
-Please check if both of them have correct size and
-the same colouring (white rectagle in a blue mount). In this case please push "Pass".
-
-Otherwise (if the 2nd red-white small icon appears) please push "Fail".
-
-</body>
-</html>
--- a/jdk/test/java/awt/image/multiresolution/MultiResolutionTrayIconTest/MultiResolutionTrayIconTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/awt/image/multiresolution/MultiResolutionTrayIconTest/MultiResolutionTrayIconTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -22,96 +22,177 @@
  */
 
 
-/*
-  @test
-  @bug 8150176 8151773
-  @summary Check if correct resolution variant is used for tray icon.
-  @author a.stepanov
-  @run applet/manual=yesno MultiResolutionTrayIconTest.html
-*/
-
-
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.image.*;
-
-
-public class MultiResolutionTrayIconTest extends Applet {
-
-    private SystemTray tray;
-    private TrayIcon   icon, iconMRI;
+/**
+ * @test
+ * @key headful
+ * @bug 8150176 8151773 8150176
+ * @summary Check if correct resolution variant is used for tray icon.
+ * @run main/manual/othervm -Dsun.java2d.uiScale=2 MultiResolutionTrayIconTest
+ */
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.SystemTray;
+import java.awt.TrayIcon;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.image.BaseMultiResolutionImage;
+import java.awt.image.BufferedImage;
+import javax.swing.JFrame;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
-    public void init() { this.setLayout(new BorderLayout()); }
-
-    public void start() {
-
-        boolean trayIsSupported = SystemTray.isSupported();
-        Button b = new Button("Start");
-        if (trayIsSupported) {
+public class MultiResolutionTrayIconTest {
+    private static SystemTray tray;
+    private static TrayIcon icon;
+    private static GridBagLayout layout;
+    private static JPanel mainControlPanel;
+    private static JPanel resultButtonPanel;
+    private static JLabel instructionText;
+    private static JButton passButton;
+    private static JButton failButton;
+    private static JButton startButton;
+    private static JFrame mainFrame;
+    private static CountDownLatch latch;
 
-            prepareIcons();
-            b.addActionListener(new ActionListener() {
-                @Override
-                public void actionPerformed(ActionEvent e) { doTest(); }
-            });
-        } else {
-             b.setLabel("not supported");
-             b.setEnabled(false);
-             System.out.println("system tray is not supported");
-        }
-        add(b, BorderLayout.CENTER);
-
-        validate();
-        setVisible(true);
+    public static void main(String[] args) throws Exception {
+        latch = new CountDownLatch(1);
+        createUI();
+        latch.await(200, TimeUnit.SECONDS);
     }
 
-    private BufferedImage generateImage(int w, int h, Color c) {
+    public static void createUI() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                mainFrame = new JFrame("TrayIcon Test");
+                boolean trayIsSupported = SystemTray.isSupported();
+                tray = SystemTray.getSystemTray();
+                Dimension d = tray.getTrayIconSize();
+                icon = new TrayIcon(createIcon(d.width, d.height));
+                icon.setImageAutoSize(true);
+                layout = new GridBagLayout();
+                mainControlPanel = new JPanel(layout);
+                resultButtonPanel = new JPanel(layout);
+
+                GridBagConstraints gbc = new GridBagConstraints();
+                String instructions
+                        = "<html>INSTRUCTIONS:<br>"
+                        + "Press start button to add icon to system tray.<br><br>"
+                        + "If Icon color is green test"
+                        + " passes else failed.<br><br></html>";
+
+                instructionText = new JLabel();
+                instructionText.setText(instructions);
+
+                gbc.gridx = 0;
+                gbc.gridy = 0;
+                gbc.fill = GridBagConstraints.HORIZONTAL;
+                mainControlPanel.add(instructionText, gbc);
+                startButton = new JButton("Start");
+                startButton.setActionCommand("Start");
+                if (trayIsSupported) {
+
+                    startButton.addActionListener((ActionEvent e) -> {
+                        doTest();
+                    });
+                } else {
+                    startButton.setEnabled(false);
+                    System.out.println("system tray is not supported");
+                    latch.countDown();
+                }
+                gbc.gridx = 0;
+                gbc.gridy = 0;
+                resultButtonPanel.add(startButton, gbc);
 
-        BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+                passButton = new JButton("Pass");
+                passButton.setActionCommand("Pass");
+                passButton.addActionListener((ActionEvent e) -> {
+                    latch.countDown();
+                    removeIcon();
+                    mainFrame.dispose();
+                });
+                failButton = new JButton("Fail");
+                failButton.setActionCommand("Fail");
+                failButton.addActionListener(new ActionListener() {
+                    @Override
+                    public void actionPerformed(ActionEvent e) {
+                        removeIcon();
+                        latch.countDown();
+                        mainFrame.dispose();
+                        throw new RuntimeException("Test Failed");
+                    }
+                });
+                gbc.gridx = 1;
+                gbc.gridy = 0;
+                resultButtonPanel.add(passButton, gbc);
+                gbc.gridx = 2;
+                gbc.gridy = 0;
+                resultButtonPanel.add(failButton, gbc);
+
+                gbc.gridx = 0;
+                gbc.gridy = 1;
+                mainControlPanel.add(resultButtonPanel, gbc);
+
+                mainFrame.add(mainControlPanel);
+                mainFrame.setSize(400, 200);
+                mainFrame.setLocationRelativeTo(null);
+                mainFrame.setVisible(true);
+
+                mainFrame.addWindowListener(new WindowAdapter() {
+                    @Override
+                    public void windowClosing(WindowEvent e) {
+                        removeIcon();
+                        latch.countDown();
+                        mainFrame.dispose();
+                    }
+                });
+            }
+        });
+
+    }
+
+    private static BaseMultiResolutionImage createIcon(int w, int h) {
+        return new BaseMultiResolutionImage(
+                new BufferedImage[]{generateImage(w, h, 1, Color.RED),
+                    generateImage(w, h, 2, Color.GREEN)});
+    }
+
+    private static BufferedImage generateImage(int w, int h, int scale, Color c) {
+
+        int x = w * scale, y = h * scale;
+        BufferedImage img = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);
         Graphics g = img.getGraphics();
         g.setColor(c);
-        g.fillRect(0, 0, w, h);
+        g.fillRect(0, 0, x, y);
         g.setColor(Color.WHITE);
-        int r = (Math.min(w, h) >= 8) ? 3 : 1;
-        g.fillRect(r, r, w - 2 * r, h - 2 * r);
+        g.fillRect(x / 3, y / 3, x / 3, y / 3);
         return img;
     }
 
-    private void prepareIcons() {
-
-        tray = SystemTray.getSystemTray();
-        Dimension d = tray.getTrayIconSize();
-        int w = d.width, h = d.height;
+    private static void doTest() {
 
-        BufferedImage img = generateImage(w, h, Color.BLUE);
-        // use wrong icon size for "nok"
-        BufferedImage nok = generateImage(w / 2 + 2, h / 2 + 2, Color.RED);
-        BaseMultiResolutionImage mri =
-            new BaseMultiResolutionImage(new BufferedImage[] {nok, img});
-        icon = new TrayIcon(img);
-        icon.setImageAutoSize(true); // just in case
-        iconMRI = new TrayIcon(mri);
-        iconMRI.setImageAutoSize(true);
-    }
-
-    private void doTest() {
-
-        if (tray.getTrayIcons().length > 0) { return; } // icons were added already
+        if (tray.getTrayIcons().length > 0) {
+            return;
+        }
         try {
             tray.add(icon);
-            tray.add(iconMRI);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
     }
 
-    public void stop() {
-
-        // check for null, just in case
+    private static void removeIcon() {
         if (tray != null) {
             tray.remove(icon);
-            tray.remove(iconMRI);
         }
     }
 }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/TestCheckSystemDefaultBannerOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,172 @@
+/*
+ * 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 8165947
+ * @summary  Verifies System default banner page option is honoured by jdk
+ * @requires (os.family == "linux" | os.family == "solaris")
+ * @run main/manual TestCheckSystemDefaultBannerOption
+ */
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Graphics;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import static java.awt.print.Printable.NO_SUCH_PAGE;
+import static java.awt.print.Printable.PAGE_EXISTS;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import javax.print.attribute.standard.JobSheets;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+
+public class TestCheckSystemDefaultBannerOption implements Printable {
+    private static Thread mainThread;
+    private static boolean testPassed;
+    private static boolean testGeneratedInterrupt;
+    private static boolean noJobSheet = false;
+    private static PrinterJob job = null;
+
+    public static void main (String[] args) throws Exception {
+
+        job = PrinterJob.getPrinterJob();
+        if (job.getPrintService() == null) {
+            System.out.println("No printers. Test cannot continue");
+            return;
+        }
+        // check system default banner option and let user know what to expect
+        JobSheets js = (JobSheets)job.getPrintService().
+                getDefaultAttributeValue(JobSheets.class);
+        if (js != null && js.equals(JobSheets.NONE)) {
+            noJobSheet = true;
+        }
+        SwingUtilities.invokeAndWait(() -> {
+            doTest(TestCheckSystemDefaultBannerOption::printTest);
+        });
+        mainThread = Thread.currentThread();
+        try {
+            Thread.sleep(60000);
+        } catch (InterruptedException e) {
+            if (!testPassed && testGeneratedInterrupt) {
+                String banner = noJobSheet ? "Banner page" : " No Banner page";
+                throw new RuntimeException(banner + " is printed");
+            }
+        }
+        if (!testGeneratedInterrupt) {
+            throw new RuntimeException("user has not executed the test");
+        }
+    }
+
+    private static void printTest() {
+        job.setPrintable(new TestCheckSystemDefaultBannerOption());
+        try {
+            job.print();
+        } catch (PrinterException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static synchronized void pass() {
+        testPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    public static synchronized void fail() {
+        testPassed = false;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    private static void doTest(Runnable action) {
+        String banner = null;
+        if (noJobSheet) {
+            banner = "No Banner page";
+        } else {
+            banner = "Banner page";
+        }
+        String description
+                = " A testpage will be sent to printer. \n"
+                + " Please check if " + banner + " is printed \n"
+                + " along with testpage.\n "
+                + " If " + banner + " is printed, press PASS else press FAIL";
+
+        final JDialog dialog = new JDialog();
+        dialog.setTitle("printSelectionTest");
+        JTextArea textArea = new JTextArea(description);
+        textArea.setEditable(false);
+        final JButton testButton = new JButton("Start Test");
+        final JButton passButton = new JButton("PASS");
+        passButton.setEnabled(false);
+        passButton.addActionListener((e) -> {
+            dialog.dispose();
+            pass();
+        });
+        final JButton failButton = new JButton("FAIL");
+        failButton.setEnabled(false);
+        failButton.addActionListener((e) -> {
+            dialog.dispose();
+            fail();
+        });
+        testButton.addActionListener((e) -> {
+            testButton.setEnabled(false);
+            action.run();
+            passButton.setEnabled(true);
+            failButton.setEnabled(true);
+        });
+        JPanel mainPanel = new JPanel(new BorderLayout());
+        mainPanel.add(textArea, BorderLayout.CENTER);
+        JPanel buttonPanel = new JPanel(new FlowLayout());
+        buttonPanel.add(testButton);
+        buttonPanel.add(passButton);
+        buttonPanel.add(failButton);
+        mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+        dialog.add(mainPanel);
+        dialog.pack();
+        dialog.setVisible(true);
+        dialog.addWindowListener(new WindowAdapter() {
+           @Override
+            public void windowClosing(WindowEvent e) {
+                System.out.println("main dialog closing");
+                testGeneratedInterrupt = false;
+                mainThread.interrupt();
+            }
+        });
+    }
+
+    @Override
+    public int print(Graphics g, PageFormat pf, int pi)
+            throws PrinterException {
+        System.out.println("pi = " + pi);
+        g.drawString("Testing", 100, 100);
+        if (pi == 1)
+            return NO_SUCH_PAGE;
+        return PAGE_EXISTS;
+    }
+}
--- a/jdk/test/java/beans/XMLEncoder/EnumPrivate.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-enum EnumPrivate {
-    A0,B0,C0,D0,E0,F0,G0,H0,I0,J0,K0,L0,M0,N0,O0,P0,Q0,R0,S0,T0,U0,V0,W0,X0,Y0,Z0,
-    A1,B1,C1,D1,E1,F1,G1,H1,I1,J1,K1,L1,M1,N1,O1,P1,Q1,R1,S1,T1,U1,V1,W1,X1,Y1,Z1,
-    A2,B2,C2,D2,E2,F2,G2,H2,I2,J2,K2,L2,M2,N2,O2,P2,Q2,R2,S2,T2,U2,V2,W2,X2,Y2,Z2,
-    A3,B3,C3,D3,E3,F3,G3,H3,I3,J3,K3,L3,M3,N3,O3,P3,Q3,R3,S3,T3,U3,V3,W3,X3,Y3,Z3,
-    A4,B4,C4,D4,E4,F4,G4,H4,I4,J4,K4,L4,M4,N4,O4,P4,Q4,R4,S4,T4,U4,V4,W4,X4,Y4,Z4,
-    A5,B5,C5,D5,E5,F5,G5,H5,I5,J5,K5,L5,M5,N5,O5,P5,Q5,R5,S5,T5,U5,V5,W5,X5,Y5,Z5,
-    A6,B6,C6,D6,E6,F6,G6,H6,I6,J6,K6,L6,M6,N6,O6,P6,Q6,R6,S6,T6,U6,V6,W6,X6,Y6,Z6,
-    A7,B7,C7,D7,E7,F7,G7,H7,I7,J7,K7,L7,M7,N7,O7,P7,Q7,R7,S7,T7,U7,V7,W7,X7,Y7,Z7,
-    A8,B8,C8,D8,E8,F8,G8,H8,I8,J8,K8,L8,M8,N8,O8,P8,Q8,R8,S8,T8,U8,V8,W8,X8,Y8,Z8,
-    A9,B9,C9,D9,E9,F9,G9,H9,I9,J9,K9,L9,M9,N9,O9,P9,Q9,R9,S9,T9,U9,V9,W9,X9,Y9,Z9,
-}
--- a/jdk/test/java/beans/XMLEncoder/EnumPublic.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-public enum EnumPublic {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z}
--- a/jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedCollection.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 6505888
- * @summary Tests CheckedCollection encoding
- * @author Sergey Malenkov
- */
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-public final class java_util_Collections_CheckedCollection extends AbstractTest<Collection<String>> {
-    public static void main(String[] args) {
-        new java_util_Collections_CheckedCollection().test(true);
-    }
-
-    protected Collection<String> getObject() {
-        List<String> list = Collections.singletonList("string");
-        return Collections.checkedCollection(list, String.class);
-    }
-
-    protected Collection<String> getAnotherObject() {
-        List<String> list = Collections.emptyList();
-        return Collections.checkedCollection(list, String.class);
-    }
-}
--- a/jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedList.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 6505888
- * @summary Tests CheckedList encoding
- * @author Sergey Malenkov
- */
-
-import java.util.Collections;
-import java.util.List;
-
-public final class java_util_Collections_CheckedList extends AbstractTest<List<String>> {
-    public static void main(String[] args) {
-        new java_util_Collections_CheckedList().test(true);
-    }
-
-    protected List<String> getObject() {
-        List<String> list = Collections.singletonList("string");
-        return Collections.checkedList(list, String.class);
-    }
-
-    protected List<String> getAnotherObject() {
-        List<String> list = Collections.emptyList();
-        return Collections.checkedList(list, String.class);
-    }
-}
--- a/jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedMap.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 6505888
- * @summary Tests CheckedMap encoding
- * @author Sergey Malenkov
- */
-
-import java.util.Collections;
-import java.util.Map;
-
-public final class java_util_Collections_CheckedMap extends AbstractTest<Map<String, String>> {
-    public static void main(String[] args) {
-        new java_util_Collections_CheckedMap().test(true);
-    }
-
-    protected Map<String, String> getObject() {
-        Map<String, String> map = Collections.singletonMap("key", "value");
-        return Collections.checkedMap(map, String.class, String.class);
-    }
-
-    protected Map<String, String> getAnotherObject() {
-        Map<String, String> map = Collections.emptyMap();
-        return Collections.checkedMap(map, String.class, String.class);
-    }
-}
--- a/jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedRandomAccessList.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 6505888
- * @summary Tests CheckedRandomAccessList encoding
- * @author Sergey Malenkov
- */
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public final class java_util_Collections_CheckedRandomAccessList extends AbstractTest<List<String>> {
-    public static void main(String[] args) {
-        new java_util_Collections_CheckedRandomAccessList().test(true);
-    }
-
-    protected List<String> getObject() {
-        List<String> list = new ArrayList<String>();
-        list.add("string");
-        return Collections.checkedList(list, String.class);
-    }
-
-    protected List<String> getAnotherObject() {
-        List<String> list = new ArrayList<String>();
-        return Collections.checkedList(list, String.class);
-    }
-}
--- a/jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedSet.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 6505888
- * @summary Tests CheckedSet encoding
- * @author Sergey Malenkov
- */
-
-import java.util.Collections;
-import java.util.Set;
-
-public final class java_util_Collections_CheckedSet extends AbstractTest<Set<String>> {
-    public static void main(String[] args) {
-        new java_util_Collections_CheckedSet().test(true);
-    }
-
-    protected Set<String> getObject() {
-        Set<String> set = Collections.singleton("string");
-        return Collections.checkedSet(set, String.class);
-    }
-
-    protected Set<String> getAnotherObject() {
-        Set<String> set = Collections.emptySet();
-        return Collections.checkedSet(set, String.class);
-    }
-}
--- a/jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedSortedMap.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 6505888
- * @summary Tests CheckedSortedMap encoding
- * @author Sergey Malenkov
- */
-
-import java.util.Collections;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-public final class java_util_Collections_CheckedSortedMap extends AbstractTest<SortedMap<String, String>> {
-    public static void main(String[] args) {
-        new java_util_Collections_CheckedSortedMap().test(true);
-    }
-
-    protected SortedMap<String, String> getObject() {
-        SortedMap<String, String> map = new TreeMap<String, String>();
-        map.put("key", "value");
-        return Collections.checkedSortedMap(map, String.class, String.class);
-    }
-
-    protected SortedMap<String, String> getAnotherObject() {
-        SortedMap<String, String> map = new TreeMap<String, String>();
-        return Collections.checkedSortedMap(map, String.class, String.class);
-    }
-}
--- a/jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedSortedSet.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 6505888
- * @summary Tests CheckedSortedSet encoding
- * @author Sergey Malenkov
- */
-
-import java.util.Collections;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-public final class java_util_Collections_CheckedSortedSet extends AbstractTest<SortedSet<String>> {
-    public static void main(String[] args) {
-        new java_util_Collections_CheckedSortedSet().test(true);
-    }
-
-    protected SortedSet<String> getObject() {
-        SortedSet<String> set = new TreeSet<String>();
-        set.add("string");
-        return Collections.checkedSortedSet(set, String.class);
-    }
-
-    protected SortedSet<String> getAnotherObject() {
-        SortedSet<String> set = new TreeSet<String>();
-        return Collections.checkedSortedSet(set, String.class);
-    }
-}
--- a/jdk/test/java/beans/XMLEncoder/java_util_EnumMap.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 6536295
- * @summary Tests EnumMap encoding
- * @author Sergey Malenkov
- */
-
-import java.util.EnumMap;
-import java.util.Map;
-
-public final class java_util_EnumMap extends AbstractTest<Map<EnumPublic, String>> {
-    public static void main(String[] args) {
-        new java_util_EnumMap().test(true);
-    }
-
-    protected Map<EnumPublic, String> getObject() {
-        return new EnumMap<EnumPublic, String>(EnumPublic.class);
-    }
-
-    protected Map<EnumPublic, String> getAnotherObject() {
-        Map<EnumPublic, String> map = new EnumMap<EnumPublic, String>(EnumPublic.class);
-        map.put(EnumPublic.A, "value");
-        map.put(EnumPublic.Z, null);
-        return map;
-    }
-}
--- a/jdk/test/java/beans/XMLEncoder/java_util_JumboEnumSet.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 6536295
- * @summary Tests JumboEnumSet encoding
- * @author Sergey Malenkov
- */
-
-import java.util.EnumSet;
-import java.util.Set;
-
-public final class java_util_JumboEnumSet extends AbstractTest<Set<EnumPrivate>> {
-    public static void main(String[] args) {
-        new java_util_JumboEnumSet().test(true);
-    }
-
-    protected Set<EnumPrivate> getObject() {
-        return EnumSet.noneOf(EnumPrivate.class);
-    }
-
-    protected Set<EnumPrivate> getAnotherObject() {
-        Set<EnumPrivate> set = EnumSet.noneOf(EnumPrivate.class);
-        set.add(EnumPrivate.A0);
-        set.add(EnumPrivate.Z9);
-        return set;
-    }
-}
--- a/jdk/test/java/beans/XMLEncoder/java_util_RegularEnumSet.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 6536295
- * @summary Tests RegularEnumSet encoding
- * @author Sergey Malenkov
- */
-
-import java.util.EnumSet;
-import java.util.Set;
-
-public final class java_util_RegularEnumSet extends AbstractTest<Set<EnumPublic>> {
-    public static void main(String[] args) {
-        new java_util_RegularEnumSet().test(true);
-    }
-
-    protected Set<EnumPublic> getObject() {
-        return EnumSet.noneOf(EnumPublic.class);
-    }
-
-    protected Set<EnumPublic> getAnotherObject() {
-        Set<EnumPublic> set = EnumSet.noneOf(EnumPublic.class);
-        set.add(EnumPublic.A);
-        set.add(EnumPublic.Z);
-        return set;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/FilePermission/Correctness.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,182 @@
+/*
+ * 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 8164705
+ * @summary Remove pathname canonicalization from FilePermission
+ */
+
+import java.io.FilePermission;
+import java.lang.reflect.Method;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class Correctness {
+
+    static boolean err = false;
+    static Method containsMethod;
+    static boolean isWindows =
+            System.getProperty("os.name").contains("Windows");
+    public static void main(String args[]) throws Exception {
+        check("/", "/");
+        checkNo("/", "/x");
+        checkNo("/", "/../x");
+
+        checkNo("/", "x");
+
+        check("/-", "/*");
+        checkNo("/*", "/-");
+
+        check("/*", "/x");
+        check("/-", "/x");
+        check("/-", "/x/*");
+        check("/-", "/x/-");
+        check("/-", "/x/y");
+        checkNo("/*", "/x/y");
+        check("/x/*", "/x/x");
+        checkNo("/x/-", "/x");
+        checkNo("/x/*", "/x");
+        check("/x/-", "/x/x");
+        check("/x/-", "/x/x/y");
+        checkNo("/x/*", "/x/x/y");
+        checkNo("/x/*", "/x");
+
+        check("*", "x");
+        checkNo("", "x");
+        check("-", "x");
+        check("-", "*");
+        check("-", "a/-");
+        check("-", "a/*");
+        checkNo("*", "a/b");
+        check("a/*", "a/b");
+        check("a/-", "a/*");
+        check("a/-", "a/b/c");
+        checkNo("a/*", "a/b/c");
+
+        check("../", "../");
+        check("../-", "../*");
+        check("../../*", "../../a");
+
+        // If we allow .. and abs/rel checks
+        check("../-", "a");
+        check("../../-", "-");
+        checkNo("../../*", "a");
+        //check("/-", "a");
+        //checkNo("/*", "a");
+        //check("/-", "-");
+
+        try {
+            // containsPath is broken on Windows.
+            containsMethod = FilePermission.class.getDeclaredMethod(
+                    "containsPath", Path.class, Path.class);
+            containsMethod.setAccessible(true);
+            System.out.println();
+
+            contains("x", "x", 0);
+            contains("x", "x/y", 1);
+            contains("x", "x/y/z", 2);
+            contains("x", "y", -1);
+            contains("x", "", -1);
+            contains("", "", 0);
+            contains("", "x", 1);
+            contains("", "x/y", 2);
+            contains("/", "/", 0);
+            contains("/", "/x", 1);
+            contains("/", "/x/y", 2);
+            contains("/x", "/x/y", 1);
+            contains("/x", "/y", -1);
+            //contains("/", "..", Integer.MAX_VALUE);
+            //contains("/", "x", Integer.MAX_VALUE);
+            //contains("/", "x/y", Integer.MAX_VALUE);
+            //contains("/", "../x", Integer.MAX_VALUE);
+            contains("/x", "y", -1);
+            contains("x", "/y", -1);
+
+            contains("", "..", -1);
+            contains("", "../x", -1);
+            contains("..", "", 1);
+            contains("..", "x", 2);
+            contains("..", "x/y", 3);
+            contains("../x", "x", -1);
+            contains("../x", "y", -1);
+            contains("../x", "../x/y", 1);
+            contains("../../x", "../../x/y", 1);
+            contains("../../../x", "../../../x/y", 1);
+            contains("../x", "../y", -1);
+        } catch (NoSuchMethodException e) {
+            // Ignored
+        }
+        if (err) throw new Exception("Failed.");
+    }
+
+    // Checks if s2 is inside s1 and depth is expected.
+    static void contains(String s1, String s2, int expected) throws Exception {
+        contains0(s1, s2, expected);
+        if (isWindows) {
+            contains0("C:" + s1, s2, -1);
+            contains0(s1, "C:" + s2, -1);
+            contains0("C:" + s1, "D:" + s2, -1);
+            contains0("C:" + s1, "C:" + s2, expected);
+        }
+    }
+
+    static void contains0(String s1, String s2, int expected) throws Exception {
+        Path p1 = Paths.get(s1);
+        Path p2 = Paths.get(s2);
+        int d = (int)containsMethod.invoke(null, p1, p2);
+        Path p;
+        try {
+            p = p2.relativize(p1);
+        } catch (Exception e) {
+            p = null;
+        }
+        System.out.printf("%-20s -> %-20s: %20s %5d %5d %s\n", s1, s2, p,
+                d, expected, d==expected?"":" WRONG");
+        if (d != expected) {
+            err = true;
+        }
+    }
+
+    static void check(String s1, String s2, boolean expected) {
+        FilePermission fp1 = new FilePermission(s1, "read");
+        FilePermission fp2 = new FilePermission(s2, "read");
+        boolean b = fp1.implies(fp2);
+        System.out.printf("%-30s -> %-30s: %5b %s\n",
+                s1, s2, b, b==expected?"":" WRONG");
+        if (b != expected) {
+            err = true;
+            System.out.println(fp1);
+            System.out.println(fp2);
+        }
+    }
+
+    static void check(String s1, String s2) {
+        check(s1, s2, true);
+    }
+
+    static void checkNo(String s1, String s2) {
+        check(s1, s2, false);
+    }
+}
--- a/jdk/test/java/io/FilePermission/FilePermissionCollection.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/io/FilePermission/FilePermissionCollection.java	Tue Oct 18 17:14:09 2016 +0000
@@ -47,14 +47,14 @@
             ("test 1: add throws IllegalArgExc for wrong perm type");
         try {
             perms.add(new SecurityPermission("createAccessControlContext"));
-            System.err.println("Expected IllegalArgumentException");
+            System.out.println("Expected IllegalArgumentException");
             testFail++;
         } catch (IllegalArgumentException iae) {}
 
         // test 2
         System.out.println("test 2: implies returns false for wrong perm type");
         if (perms.implies(new SecurityPermission("getPolicy"))) {
-            System.err.println("Expected false, returned true");
+            System.out.println("Expected false, returned true");
             testFail++;
         }
 
@@ -63,7 +63,7 @@
                            "name and action");
         perms.add(new FilePermission("/tmp/foo", "read"));
         if (!perms.implies(new FilePermission("/tmp/foo", "read"))) {
-            System.err.println("Expected true, returned false");
+            System.out.println("Expected true, returned false");
             testFail++;
         }
 
@@ -71,7 +71,7 @@
         System.out.println("test 4: implies returns false for match on " +
                            "name but not action");
         if (perms.implies(new FilePermission("/tmp/foo", "write"))) {
-            System.err.println("Expected false, returned true");
+            System.out.println("Expected false, returned true");
             testFail++;
         }
 
@@ -80,7 +80,7 @@
                            "name and subset of actions");
         perms.add(new FilePermission("/tmp/bar", "read, write"));
         if (!perms.implies(new FilePermission("/tmp/bar", "write"))) {
-            System.err.println("Expected true, returned false");
+            System.out.println("Expected true, returned false");
             testFail++;
         }
 
@@ -90,11 +90,11 @@
         perms.add(new FilePermission("/tmp/baz", "read"));
         perms.add(new FilePermission("/tmp/baz", "write"));
         if (!perms.implies(new FilePermission("/tmp/baz", "read"))) {
-            System.err.println("Expected true, returned false");
+            System.out.println("Expected true, returned false");
             testFail++;
         }
         if (!perms.implies(new FilePermission("/tmp/baz", "write,read"))) {
-            System.err.println("Expected true, returned false");
+            System.out.println("Expected true, returned false");
             testFail++;
         }
 
@@ -103,7 +103,7 @@
                            "and match on action");
         perms.add(new FilePermission("/usr/tmp/*", "read"));
         if (!perms.implies(new FilePermission("/usr/tmp/foo", "read"))) {
-            System.err.println("Expected true, returned false");
+            System.out.println("Expected true, returned false");
             testFail++;
         }
 
@@ -111,7 +111,7 @@
         System.out.println
             ("test 8: implies returns false for non-match on wildcard");
         if (perms.implies(new FilePermission("/usr/tmp/bar/foo", "read"))) {
-            System.err.println("Expected false, returned true");
+            System.out.println("Expected false, returned true");
             testFail++;
         }
 
@@ -120,25 +120,25 @@
             ("test 9: implies returns true for deep wildcard match");
         perms.add(new FilePermission("/usr/tmp/-", "read"));
         if (!perms.implies(new FilePermission("/usr/tmp/bar/foo", "read"))) {
-            System.err.println("Expected true, returned false");
+            System.out.println("Expected true, returned false");
             testFail++;
         }
 
         // test 10
-        System.out.println("test 10: implies returns true for relative match");
+        //System.out.println("test 10: implies returns true for relative match");
         perms.add(new FilePermission(".", "read"));
-        if (!perms.implies(new FilePermission(System.getProperty("user.dir"),
-                                              "read"))) {
-            System.err.println("Expected true, returned false");
-            testFail++;
-        }
+        //if (!perms.implies(new FilePermission(System.getProperty("user.dir"),
+        //                                      "read"))) {
+        //    System.out.println("Expected true, returned false");
+        //    testFail++;
+        //}
 
         // test 11
         System.out.println("test 11: implies returns true for all " +
                            "wildcard and match on action");
         perms.add(new FilePermission("<<ALL FILES>>", "read"));
         if (!perms.implies(new FilePermission("/tmp/foobar", "read"))) {
-            System.err.println("Expected true, returned false");
+            System.out.println("Expected true, returned false");
             testFail++;
         }
 
@@ -146,7 +146,7 @@
         System.out.println("test 12: implies returns false for wildcard " +
                            "and non-match on action");
         if (perms.implies(new FilePermission("/tmp/foobar", "write"))) {
-            System.err.println("Expected false, returned true");
+            System.out.println("Expected false, returned true");
             testFail++;
         }
 
@@ -160,7 +160,7 @@
         }
         // the two "/tmp/baz" entries were combined into one
         if (numPerms != 7) {
-            System.err.println("Expected 7, got " + numPerms);
+            System.out.println("Expected 7, got " + numPerms);
             testFail++;
         }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/FilePermission/FilePermissionTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.io.FilePermission;
+import java.util.Arrays;
+import java.util.List;
+
+/*
+ * @test
+ * @bug 8156054
+ * @summary Test some of FilePermission methods when canonicalization property
+ *          set and un-set.
+ * @run main/othervm -Djdk.io.permissionsUseCanonicalPath=true
+ *      FilePermissionTest truetruetruetruetruetrue
+ * @run main/othervm -Djdk.io.permissionsUseCanonicalPath=false
+ *      FilePermissionTest falsefalsefalsefalsefalsefalse
+ * @run main FilePermissionTest falsefalsefalsefalsefalsefalse
+ */
+public class FilePermissionTest {
+
+    public static void main(String[] args) throws Exception {
+
+        final File realFile = new File("exist.file");
+        try {
+            if (!realFile.createNewFile()) {
+                throw new RuntimeException("Unable to create a file.");
+            }
+            check(Arrays.asList(realFile.getName(), "notexist.file"), args[0]);
+        } finally {
+            if (realFile.exists()) {
+                realFile.delete();
+            }
+        }
+    }
+
+    private static void check(List<String> files, String expected) {
+
+        StringBuilder actual = new StringBuilder();
+        files.forEach(f -> {
+            StringBuilder result = new StringBuilder();
+            FilePermission fp1 = new FilePermission(f, "read");
+            FilePermission fp2 = new FilePermission(
+                    new File(f).getAbsolutePath(), "read");
+            result.append(fp1.equals(fp2));
+            result.append(fp1.implies(fp2));
+            result.append(fp1.hashCode() == fp2.hashCode());
+            System.out.println(fp1 + " Vs. " + fp2 + " : Result: " + result);
+            actual.append(result);
+        });
+        if (!expected.equals(actual.toString())) {
+            throw new RuntimeException("Failed: " + expected + "/" + actual);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/FilePermission/ReadFileOnPath.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,82 @@
+/*
+ * 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 8164705
+ * @library /lib/testlibrary /test/lib
+ * @modules java.base/jdk.internal.misc
+ * @run main ReadFileOnPath
+ * @summary Still able to read file on the same path
+ */
+
+import jdk.test.lib.process.ProcessTools;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class ReadFileOnPath {
+
+    private static final Path SRC_DIR    = Paths.get(System.getProperty("test.src"));
+    private static final Path HERE_DIR   = Paths.get(".");
+    private static final Path MODS_DIR   = Paths.get("modules");
+
+    public static void main(String args[]) throws Exception {
+        CompilerUtils.compile(SRC_DIR.resolve("m"), MODS_DIR.resolve("m"));
+        Files.write(MODS_DIR.resolve("m/base"), "base".getBytes());
+        Files.write(MODS_DIR.resolve("m/p/child"), "child".getBytes());
+        JarUtils.createJarFile(HERE_DIR.resolve("old.jar"),
+                MODS_DIR.resolve("m"),
+                "base", "p/App.class", "p/child");
+        JarUtils.createJarFile(HERE_DIR.resolve("new.jar"),
+                MODS_DIR.resolve("m"),
+                "module-info.class", "base", "p/App.class", "p/child");
+
+        // exploded module
+        test("--module-path", "modules", "-m", "m/p.App", "SS+++++");
+
+        // module in jar
+        test("--module-path", "new.jar", "-m", "m/p.App", "SSSS++0");
+
+        // exploded classpath
+        test("-cp", "modules/m", "p.App", "SS+++++");
+
+        // classpath in jar
+        test("-cp", "old.jar", "p.App", "SSSS++0");
+    }
+
+    static void test(String... args) throws Exception {
+        List<String> cmds = new ArrayList<>();
+        cmds.add("-Djava.security.manager");
+        cmds.addAll(Arrays.asList(args));
+        cmds.addAll(List.of(
+                "x", "modules/m", "modules/m/base", "modules/m/p/child",
+                "-", "child", "/base", "../base"));
+        ProcessTools.executeTestJvm(cmds.toArray(new String[cmds.size()]))
+                .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/FilePermission/m/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,3 @@
+module m {
+    exports p;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/FilePermission/m/p/App.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,44 @@
+package p;
+import java.io.InputStream;
+import java.io.FileInputStream;
+public class App {
+    public static void main(String[] args) throws Exception {
+        boolean f = true;
+        StringBuilder sb = new StringBuilder();
+        String expected = null;
+        for (String s: args) {
+            if (expected == null) {
+                expected = s;
+            } else if (s.equals("-")) {
+                f = false;
+            } else if (f) {
+                try (InputStream is = new FileInputStream(s)) {
+                    is.readAllBytes();
+                    sb.append('+');
+                } catch (SecurityException se) {
+                    System.out.println(se);
+                    sb.append('S');
+                } catch (Exception e) {
+                    System.out.println(e);
+                    sb.append('-');
+                }
+            } else {
+                try (InputStream is = App.class.getResourceAsStream(s)) {
+                    is.readAllBytes();
+                    sb.append('+');
+                } catch (NullPointerException npe) {
+                    System.out.println(npe);
+                    sb.append('0');
+                } catch (Exception e) {
+                    System.out.println(e);
+                    sb.append('-');
+                }
+            }
+        }
+        if (!sb.toString().equals(expected)) {
+            throw new Exception("Expected " + expected + ", actually " + sb);
+        } else {
+            System.out.println("OK");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialFilter/CheckInputOrderTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,93 @@
+/*
+ * 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.InvalidClassException;
+import java.io.ObjectInputFilter;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.security.Security;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
+
+/* @test
+ * @build CheckInputOrderTest SerialFilterTest
+ * @run testng/othervm CheckInputOrderTest
+ *
+ * @summary Test that when both global filter and specific filter are set,
+ *          global filter will not affect specific filter.
+ */
+
+public class CheckInputOrderTest implements Serializable {
+    private static final long serialVersionUID = 12345678901L;
+
+    @DataProvider(name="Patterns")
+    Object[][] patterns() {
+        return new Object[][] {
+                new Object[] { SerialFilterTest.genTestObject("maxarray=1", true), "java.**;java.lang.*;java.lang.Long;maxarray=0", false },
+                new Object[] { SerialFilterTest.genTestObject("maxarray=1", true), "java.**;java.lang.*;java.lang.Long", true },
+                new Object[] { Long.MAX_VALUE, "java.**;java.lang.*;java.lang.Long;maxdepth=0", false },
+                new Object[] { Long.MAX_VALUE, "java.**;java.lang.*;java.lang.Long;maxbytes=0", false },
+                new Object[] { Long.MAX_VALUE, "java.**;java.lang.*;java.lang.Long;maxrefs=0", false },
+
+                new Object[] { Long.MAX_VALUE, "java.**;java.lang.*;java.lang.Long", true },
+
+                new Object[] { Long.MAX_VALUE, "!java.**;java.lang.*;java.lang.Long", false },
+                new Object[] { Long.MAX_VALUE, "java.**;!java.lang.*;java.lang.Long", true },
+
+                new Object[] { Long.MAX_VALUE, "!java.lang.*;java.**;java.lang.Long", false },
+                new Object[] { Long.MAX_VALUE, "java.lang.*;!java.**;java.lang.Long", true },
+
+                new Object[] { Long.MAX_VALUE, "!java.lang.Long;java.**;java.lang.*", false },
+                new Object[] { Long.MAX_VALUE, "java.lang.Long;java.**;!java.lang.*", true },
+
+                new Object[] { Long.MAX_VALUE, "java.lang.Long;!java.**;java.lang.*", false },
+                new Object[] { Long.MAX_VALUE, "java.lang.Long;java.lang.Number;!java.**;java.lang.*", true },
+        };
+    }
+
+    /**
+     * Test:
+     *   "global filter reject" + "specific ObjectInputStream filter is empty" => should reject
+     *   "global filter reject" + "specific ObjectInputStream filter allow"    => should allow
+     */
+    @Test(dataProvider="Patterns")
+    public void testRejectedInGlobal(Object toDeserialized, String pattern, boolean allowed) throws Exception {
+        byte[] bytes = SerialFilterTest.writeObjects(toDeserialized);
+        ObjectInputFilter filter = ObjectInputFilter.Config.createFilter(pattern);
+
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                ObjectInputStream ois = new ObjectInputStream(bais)) {
+            ois.setObjectInputFilter(filter);
+            Object o = ois.readObject();
+            assertTrue(allowed, "filter should have thrown an exception");
+        } catch (InvalidClassException ice) {
+            assertFalse(allowed, "filter should have thrown an exception");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialFilter/FilterWithSecurityManagerTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,100 @@
+/*
+ * 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.ObjectInputFilter;
+import java.io.ObjectInputStream;
+import java.security.AccessControlException;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+/* @test
+ * @build FilterWithSecurityManagerTest SerialFilterTest
+ * @run testng/othervm FilterWithSecurityManagerTest
+ * @run testng/othervm/policy=security.policy.without.globalFilter
+ *          -Djava.security.manager=default FilterWithSecurityManagerTest
+ * @run testng/othervm/policy=security.policy
+ *          -Djava.security.manager=default
+ *          -Djdk.serialFilter=java.lang.Integer FilterWithSecurityManagerTest
+ *
+ * @summary Test that setting specific filter is checked by security manager,
+ *          setting process-wide filter is checked by security manager.
+ */
+
+@Test
+public class FilterWithSecurityManagerTest {
+
+    byte[] bytes;
+    boolean setSecurityManager;
+    ObjectInputFilter filter;
+
+    @BeforeClass
+    public void setup() throws Exception {
+        setSecurityManager = System.getSecurityManager() != null;
+        Object toDeserialized = Long.MAX_VALUE;
+        bytes = SerialFilterTest.writeObjects(toDeserialized);
+        filter = ObjectInputFilter.Config.createFilter("java.lang.Long");
+    }
+
+    /**
+     * Test that setting process-wide filter is checked by security manager.
+     */
+    @Test
+    public void testGlobalFilter() throws Exception {
+        if (ObjectInputFilter.Config.getSerialFilter() == null) {
+            return;
+        }
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                ObjectInputStream ois = new ObjectInputStream(bais)) {
+            ObjectInputFilter.Config.setSerialFilter(filter);
+            assertFalse(setSecurityManager,
+                    "When SecurityManager exists, without "
+                    + "java.security.SerializablePermission(serialFilter) Exception should be thrown");
+            Object o = ois.readObject();
+        } catch (AccessControlException ex) {
+            assertTrue(setSecurityManager);
+            assertTrue(ex.getMessage().contains("java.io.SerializablePermission"));
+            assertTrue(ex.getMessage().contains("serialFilter"));
+        }
+    }
+
+    /**
+     * Test that setting specific filter is checked by security manager.
+     */
+    @Test(dependsOnMethods = { "testGlobalFilter" })
+    public void testSpecificFilter() throws Exception {
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                ObjectInputStream ois = new ObjectInputStream(bais)) {
+            ois.setObjectInputFilter(filter);
+            Object o = ois.readObject();
+        } catch (AccessControlException ex) {
+            assertTrue(setSecurityManager);
+            assertTrue(ex.getMessage().contains("java.io.SerializablePermission"));
+            assertTrue(ex.getMessage().contains("serialFilter"));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialFilter/GlobalFilterTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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.
+ */
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InvalidClassException;
+import java.io.ObjectInputFilter;
+import java.io.ObjectInputStream;
+
+import java.io.SerializablePermission;
+import java.security.Security;
+import java.util.Objects;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+
+/* @test
+ * @build GlobalFilterTest SerialFilterTest
+ * @run testng/othervm GlobalFilterTest
+ * @run testng/othervm -Djdk.serialFilter=java.** GlobalFilterTest
+ * @run testng/othervm/policy=security.policy GlobalFilterTest
+ * @run testng/othervm/policy=security.policy
+ *        -Djava.security.properties=${test.src}/java.security-extra1
+ *        -Djava.security.debug=properties GlobalFilterTest
+ *
+ * @summary Test Global Filters
+ */
+@Test
+public class GlobalFilterTest {
+
+    /**
+     * DataProvider of patterns and objects derived from the configured process-wide filter.
+     * @return Array of arrays of pattern, object, allowed boolean, and API factory
+     */
+    @DataProvider(name="globalPatternElements")
+    Object[][] globalPatternElements() {
+        String globalFilter =
+                System.getProperty("jdk.serialFilter",
+                        Security.getProperty("jdk.serialFilter"));
+        if (globalFilter == null) {
+            return new Object[0][];
+        }
+
+        String[] patterns = globalFilter.split(";");
+        Object[][] objects = new Object[patterns.length][];
+
+        for (int i = 0; i < patterns.length; i++) {
+            Object o;
+            boolean allowed;
+            String pattern = patterns[i].trim();
+            if (pattern.contains("=")) {
+                allowed = false;
+                o = SerialFilterTest.genTestObject(pattern, false);
+            } else {
+                allowed = !pattern.startsWith("!");
+                o = (allowed)
+                    ? SerialFilterTest.genTestObject(pattern, true)
+                    : SerialFilterTest.genTestObject(pattern.substring(1), false);
+
+                Assert.assertNotNull(o, "fail generation failed");
+            }
+            objects[i] = new Object[3];
+            objects[i][0] = pattern;
+            objects[i][1] = allowed;
+            objects[i][2] = o;
+        }
+        return objects;
+    }
+
+    /**
+     * Test that the process-wide filter is set when the properties are set
+     * and has the toString matching the configured pattern.
+     */
+    @Test()
+    static void globalFilter() {
+        String pattern =
+                System.getProperty("jdk.serialFilter",
+                        Security.getProperty("jdk.serialFilter"));
+        ObjectInputFilter filter = ObjectInputFilter.Config.getSerialFilter();
+        System.out.printf("global pattern: %s, filter: %s%n", pattern, filter);
+        Assert.assertEquals(pattern, Objects.toString(filter, null),
+                "process-wide filter pattern does not match");
+    }
+
+    /**
+     * If the Global filter is already set, it should always refuse to be
+     * set again.
+     * If there is a security manager, setting the serialFilter should fail
+     * without the appropriate permission.
+     * If there is no security manager then setting it should work.
+     */
+    @Test()
+    static void setGlobalFilter() {
+        SecurityManager sm = System.getSecurityManager();
+        ObjectInputFilter filter = new SerialFilterTest.Validator();
+        ObjectInputFilter global = ObjectInputFilter.Config.getSerialFilter();
+        if (global != null) {
+            // once set, can never be re-set
+            try {
+                ObjectInputFilter.Config.setSerialFilter(filter);
+                Assert.fail("set only once process-wide filter");
+            } catch (IllegalStateException ise) {
+                if (sm != null) {
+                    Assert.fail("wrong exception when security manager is set", ise);
+                }
+            } catch (SecurityException se) {
+                if (sm == null) {
+                    Assert.fail("wrong exception when security manager is not set", se);
+                }
+            }
+        } else {
+            if (sm == null) {
+                // no security manager
+                try {
+                    ObjectInputFilter.Config.setSerialFilter(filter);
+                    // Note once set, it can not be reset; so other tests
+                    System.out.printf("Global Filter set to Validator%n");
+                } catch (SecurityException se) {
+                    Assert.fail("setGlobalFilter should not get SecurityException", se);
+                }
+                try {
+                    // Try to set it again, expecting it to throw
+                    ObjectInputFilter.Config.setSerialFilter(filter);
+                    Assert.fail("set only once process-wide filter");
+                } catch (IllegalStateException ise) {
+                    // Normal case
+                }
+            } else {
+                // Security manager
+                SecurityException expectSE = null;
+                try {
+                    sm.checkPermission(new SerializablePermission("serialFilter"));
+                } catch (SecurityException se1) {
+                    expectSE = se1;
+                }
+                SecurityException actualSE = null;
+                try {
+                    ObjectInputFilter.Config.setSerialFilter(filter);
+                } catch (SecurityException se2) {
+                    actualSE = se2;
+                }
+                if (expectSE == null | actualSE == null) {
+                    Assert.assertEquals(expectSE, actualSE, "SecurityException");
+                } else {
+                    Assert.assertEquals(expectSE.getClass(), actualSE.getClass(),
+                            "SecurityException class");
+                }
+            }
+        }
+    }
+
+    /**
+     * For each pattern in the process-wide filter test a generated object
+     * against the default process-wide filter.
+     *
+     * @param pattern a pattern extracted from the configured global pattern
+     */
+    @Test(dataProvider = "globalPatternElements")
+    static void globalFilterElements(String pattern, boolean allowed,Object obj) {
+        testGlobalPattern(pattern, obj, allowed);
+    }
+
+    /**
+     * Serialize and deserialize an object using the default process-wide filter
+     * and check allowed or reject.
+     *
+     * @param pattern the pattern
+     * @param object the test object
+     * @param allowed the expected result from ObjectInputStream (exception or not)
+     */
+    static void testGlobalPattern(String pattern, Object object, boolean allowed) {
+        try {
+//            System.out.printf("global %s pattern: %s, obj: %s%n", (allowed ? "allowed" : "not allowed"), pattern, object);
+            byte[] bytes = SerialFilterTest.writeObjects(object);
+            try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                 ObjectInputStream ois = new ObjectInputStream(bais)) {
+                Object o = ois.readObject();
+            } catch (EOFException eof) {
+                // normal completion
+            } catch (ClassNotFoundException cnf) {
+                Assert.fail("Deserializing", cnf);
+            }
+            Assert.assertTrue(allowed, "filter should have thrown an exception");
+        } catch (IllegalArgumentException iae) {
+            Assert.fail("bad format pattern", iae);
+        } catch (InvalidClassException ice) {
+            Assert.assertFalse(allowed, "filter should not have thrown an exception: " + ice);
+        } catch (IOException ioe) {
+            Assert.fail("Unexpected IOException", ioe);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialFilter/MixedFiltersTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,137 @@
+/*
+ * 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.InvalidClassException;
+import java.io.ObjectInputFilter;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.security.Security;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+/* @test
+ * @build MixedFiltersTest SerialFilterTest
+ * @run testng/othervm -Djdk.serialFilter=!java.**;!java.lang.Long;maxdepth=5;maxarray=5;maxbytes=90;maxrefs=5          MixedFiltersTest
+ * @run testng/othervm -Djdk.serialFilter=java.**;java.lang.Long;maxdepth=1000;maxarray=1000;maxbytes=1000;maxrefs=1000 MixedFiltersTest
+ *
+ * @summary Test that when both global filter and specific filter are set,
+ *          global filter will not affect specific filter.
+ */
+
+public class MixedFiltersTest implements Serializable {
+
+    private static final long serialVersionUID = 1234567890L;
+
+
+    boolean globalRejected;
+
+    @BeforeClass
+    public void setup() {
+        String pattern = System.getProperty("jdk.serialFilter",
+                Security.getProperty("jdk.serialFilter"));
+        globalRejected = pattern.startsWith("!");
+    }
+
+    @DataProvider(name="RejectedInGlobal")
+    Object[][] rejectedInGlobal() {
+        if (!globalRejected) {
+            return new Object[0][];
+        }
+        return new Object[][] {
+                new Object[] { Long.MAX_VALUE, "java.**" },
+                new Object[] { Long.MAX_VALUE, "java.lang.Long" },
+                new Object[] { SerialFilterTest.genTestObject("java.lang.**", true), "java.lang.**" },
+                new Object[] { SerialFilterTest.genTestObject("maxdepth=10", true), "maxdepth=100" },
+                new Object[] { SerialFilterTest.genTestObject("maxarray=10", true), "maxarray=100" },
+                new Object[] { SerialFilterTest.genTestObject("maxbytes=100", true), "maxbytes=1000" },
+                new Object[] { SerialFilterTest.genTestObject("maxrefs=10", true), "maxrefs=100" },
+        };
+    }
+
+    /**
+     * Test:
+     *   "global filter reject" + "specific ObjectInputStream filter is empty" => should reject
+     *   "global filter reject" + "specific ObjectInputStream filter allow"    => should allow
+     */
+    @Test(dataProvider="RejectedInGlobal")
+    public void testRejectedInGlobal(Object toDeserialized, String pattern) throws Exception {
+        byte[] bytes = SerialFilterTest.writeObjects(toDeserialized);
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                ObjectInputStream ois = new ObjectInputStream(bais)) {
+            Object o = ois.readObject();
+            fail("filter should have thrown an exception");
+        } catch (InvalidClassException expected) { }
+
+        ObjectInputFilter filter = ObjectInputFilter.Config.createFilter(pattern);
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                ObjectInputStream ois = new ObjectInputStream(bais)) {
+            ois.setObjectInputFilter(filter);
+            Object o = ois.readObject();
+        }
+    }
+
+    @DataProvider(name="AllowedInGlobal")
+    Object[][] allowedInGlobal() {
+        if (globalRejected) {
+            return new Object[0][];
+        }
+
+        return new Object[][] {
+                new Object[] { Long.MAX_VALUE, "!java.**" },
+                new Object[] { Long.MAX_VALUE, "!java.lang.Long" },
+                new Object[] { SerialFilterTest.genTestObject("java.lang.**", true), "!java.lang.**" },
+                new Object[] { SerialFilterTest.genTestObject("maxdepth=10", true), "maxdepth=5" },
+                new Object[] { SerialFilterTest.genTestObject("maxarray=10", true), "maxarray=5" },
+                new Object[] { SerialFilterTest.genTestObject("maxbytes=100", true), "maxbytes=5" },
+                new Object[] { SerialFilterTest.genTestObject("maxrefs=10", true), "maxrefs=5" },
+            };
+    }
+
+    /**
+     * Test:
+     *   "global filter allow" + "specific ObjectInputStream filter is empty" => should allow
+     *   "global filter allow" + "specific ObjectInputStream filter reject"   => should reject
+     */
+    @Test(dataProvider="AllowedInGlobal")
+    public void testAllowedInGlobal(Object toDeserialized, String pattern) throws Exception {
+        byte[] bytes = SerialFilterTest.writeObjects(toDeserialized);
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                ObjectInputStream ois = new ObjectInputStream(bais)) {
+            Object o = ois.readObject();
+        }
+
+        ObjectInputFilter filter = ObjectInputFilter.Config.createFilter(pattern);
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                ObjectInputStream ois = new ObjectInputStream(bais)) {
+            ois.setObjectInputFilter(filter);
+            Object o = ois.readObject();
+            assertTrue(false, "filter should have thrown an exception");
+        } catch (InvalidClassException expected) { }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialFilter/SerialFilterTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,752 @@
+/*
+ * 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.EOFException;
+import java.io.IOException;
+import java.io.InvalidClassException;
+import java.io.ObjectInputStream;
+import java.io.ObjectInputFilter;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.invoke.SerializedLambda;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Proxy;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+import java.util.concurrent.atomic.LongAdder;
+
+import javax.lang.model.SourceVersion;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+
+/* @test
+ * @build SerialFilterTest
+ * @run testng/othervm  SerialFilterTest
+ *
+ * @summary Test ObjectInputFilters
+ */
+@Test
+public class SerialFilterTest implements Serializable {
+
+    private static final long serialVersionUID = -6999613679881262446L;
+
+    /**
+     * Enable three arg lambda.
+     * @param <T> The pattern
+     * @param <U> The test object
+     * @param <V> Boolean for if the filter should allow or reject
+     */
+    interface TriConsumer< T, U, V> {
+        void accept(T t, U u, V v);
+    }
+
+    /**
+     * Misc object to use that should always be accepted.
+     */
+    private static final Object otherObject = Integer.valueOf(0);
+
+    /**
+     * DataProvider for the individual patterns to test.
+     * Expand the patterns into cases for each of the Std and Compatibility APIs.
+     * @return an array of arrays of the parameters including factories
+     */
+    @DataProvider(name="Patterns")
+    static Object[][] patterns() {
+        Object[][] patterns = new Object[][]{
+                {"java.util.Hashtable"},
+                {"java.util.Hash*"},
+                {"javax.lang.model.*"},
+                {"javax.lang.**"},
+                {"*"},
+                {"maxarray=47"},
+                {"maxdepth=5"},
+                {"maxrefs=10"},
+                {"maxbytes=100"},
+                {"maxbytes=72"},
+                {"maxbytes=+1024"},
+                {"java.base/java.util.Hashtable"},
+        };
+        return patterns;
+    }
+
+    @DataProvider(name="InvalidPatterns")
+    static Object[][] invalidPatterns() {
+        return new Object [][] {
+                {"maxrefs=-1"},
+                {"maxdepth=-1"},
+                {"maxbytes=-1"},
+                {"maxarray=-1"},
+                {"xyz=0"},
+                {"xyz=-1"},
+                {"maxrefs=0xabc"},
+                {"maxrefs=abc"},
+                {"maxrefs="},
+                {"maxrefs=+"},
+                {".*"},
+                {".**"},
+                {"!"},
+                {"/java.util.Hashtable"},
+                {"java.base/"},
+                {"/"},
+        };
+    }
+
+    @DataProvider(name="Limits")
+    static Object[][] limits() {
+        // The numbers are arbitrary > 1
+        return new Object[][]{
+                {"maxrefs", 10},
+                {"maxdepth", 5},
+                {"maxbytes", 100},
+                {"maxarray", 16},
+        };
+    }
+
+    /**
+     * DataProvider of individual objects. Used to check the information
+     * available to the filter.
+     * @return  Arrays of parameters with objects
+     */
+    @DataProvider(name="Objects")
+    static Object[][] objects() {
+        byte[] byteArray = new byte[0];
+        Object[] objArray = new Object[7];
+        objArray[objArray.length - 1] = objArray;
+
+        Class<?> serClass = null;
+        String className = "java.util.concurrent.atomic.LongAdder$SerializationProxy";
+        try {
+            serClass = Class.forName(className);
+        } catch (Exception e) {
+            Assert.fail("missing class: " + className, e);
+        }
+
+        Class<?>[] interfaces = {Runnable.class};
+        Runnable proxy = (Runnable) Proxy.newProxyInstance(null,
+                interfaces, (p, m, args) -> p);
+
+        Runnable runnable = (Runnable & Serializable) SerialFilterTest::noop;
+        Object[][] objects = {
+                { null, 0, -1, 0, 0, 0,
+                        new HashSet<>()},        // no callback, no values
+                { objArray, 3, 7, 8, 2, 55,
+                        new HashSet<>(Arrays.asList(objArray.getClass()))},
+                { Object[].class, 1, -1, 1, 1, 40,
+                        new HashSet<>(Arrays.asList(Object[].class))},
+                { new SerialFilterTest(), 1, -1, 1, 1, 37,
+                        new HashSet<>(Arrays.asList(SerialFilterTest.class))},
+                { new LongAdder(), 2, -1, 1, 1, 93,
+                        new HashSet<>(Arrays.asList(LongAdder.class, serClass))},
+                { new byte[14], 2, 14, 1, 1, 27,
+                        new HashSet<>(Arrays.asList(byteArray.getClass()))},
+                { runnable, 13, 0, 10, 2, 514,
+                        new HashSet<>(Arrays.asList(java.lang.invoke.SerializedLambda.class,
+                                SerialFilterTest.class,
+                                objArray.getClass()))},
+                { deepHashSet(10), 48, -1, 49, 11, 619,
+                        new HashSet<>(Arrays.asList(HashSet.class))},
+                { proxy.getClass(), 3, -1, 1, 1, 114,
+                        new HashSet<>(Arrays.asList(Runnable.class,
+                                java.lang.reflect.Proxy.class))},
+        };
+        return objects;
+    }
+
+    @DataProvider(name="Arrays")
+    static Object[][] arrays() {
+        return new Object[][]{
+                {new Object[16], 16},
+                {new boolean[16], 16},
+                {new byte[16], 16},
+                {new char[16], 16},
+                {new int[16], 16},
+                {new long[16], 16},
+                {new short[16], 16},
+                {new float[16], 16},
+                {new double[16], 16},
+        };
+    }
+
+
+    /**
+     * Test each object and verify the classes identified by the filter,
+     * the count of calls to the filter, the max array size, max refs, max depth,
+     * max bytes.
+     * This test ignores/is not dependent on the global filter settings.
+     *
+     * @param object a Serializable object
+     * @param count the expected count of calls to the filter
+     * @param maxArray the maximum array size
+     * @param maxRefs the maximum references
+     * @param maxDepth the maximum depth
+     * @param maxBytes the maximum stream size
+     * @param classes  the expected (unique) classes
+     * @throws IOException
+     */
+    @Test(dataProvider="Objects")
+    public static void t1(Object object,
+                          long count, long maxArray, long maxRefs, long maxDepth, long maxBytes,
+                          Set<Class<?>> classes) throws IOException {
+        byte[] bytes = writeObjects(object);
+        Validator validator = new Validator();
+        validate(bytes, validator);
+        System.out.printf("v: %s%n", validator);
+        Assert.assertEquals(validator.count, count, "callback count wrong");
+        Assert.assertEquals(validator.classes, classes, "classes mismatch");
+        Assert.assertEquals(validator.maxArray, maxArray, "maxArray mismatch");
+        Assert.assertEquals(validator.maxRefs, maxRefs, "maxRefs wrong");
+        Assert.assertEquals(validator.maxDepth, maxDepth, "depth wrong");
+        Assert.assertEquals(validator.maxBytes, maxBytes, "maxBytes wrong");
+    }
+
+    /**
+     * Test each pattern with an appropriate object.
+     * A filter is created from the pattern and used to serialize and
+     * deserialize a generated object with both the positive and negative case.
+     * This test ignores/is not dependent on the global filter settings.
+     *
+     * @param pattern a pattern
+     */
+    @Test(dataProvider="Patterns")
+    static void testPatterns(String pattern) {
+        evalPattern(pattern, (p, o, neg) -> testPatterns(p, o, neg));
+    }
+
+    /**
+     * Test that the filter on a OIS can be set only on a fresh OIS,
+     * before deserializing any objects.
+     * This test is agnostic the global filter being set or not.
+     */
+    @Test
+    static void nonResettableFilter() {
+        Validator validator1 = new Validator();
+        Validator validator2 = new Validator();
+
+        try {
+            byte[] bytes = writeObjects("text1");    // an object
+
+            try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                 ObjectInputStream ois = new ObjectInputStream(bais)) {
+                // Check the initial filter is the global filter; may be null
+                ObjectInputFilter global = ObjectInputFilter.Config.getSerialFilter();
+                ObjectInputFilter initial = ois.getObjectInputFilter();
+                Assert.assertEquals(global, initial, "initial filter should be the global filter");
+
+                // Check if it can be set to null
+                ois.setObjectInputFilter(null);
+                ObjectInputFilter filter = ois.getObjectInputFilter();
+                Assert.assertNull(filter, "set to null should be null");
+
+                ois.setObjectInputFilter(validator1);
+                Object o = ois.readObject();
+                try {
+                    ois.setObjectInputFilter(validator2);
+                    Assert.fail("Should not be able to set filter twice");
+                } catch (IllegalStateException ise) {
+                    // success, the exception was expected
+                }
+            } catch (EOFException eof) {
+                Assert.fail("Should not reach end-of-file", eof);
+            } catch (ClassNotFoundException cnf) {
+                Assert.fail("Deserializing", cnf);
+            }
+        } catch (IOException ex) {
+            Assert.fail("Unexpected IOException", ex);
+        }
+    }
+
+    /**
+     * Test that if an Objects readReadResolve method returns an array
+     * that the callback to the filter includes the proper array length.
+     * @throws IOException if an error occurs
+     */
+    @Test(dataProvider="Arrays")
+    static void testReadResolveToArray(Object array, int length) throws IOException {
+        ReadResolveToArray object = new ReadResolveToArray(array, length);
+        byte[] bytes = writeObjects(object);
+        Object o = validate(bytes, object);    // the object is its own filter
+        Assert.assertEquals(o.getClass(), array.getClass(), "Filter not called with the array");
+    }
+
+
+    /**
+     * Test repeated limits use the last value.
+     * Construct a filter with the limit and the limit repeated -1.
+     * Invoke the filter with the limit to make sure it is rejected.
+     * Invoke the filter with the limit -1 to make sure it is accepted.
+     * @param name the name of the limit to test
+     * @param value a test value
+     */
+    @Test(dataProvider="Limits")
+    static void testLimits(String name, int value) {
+        Class<?> arrayClass = new int[0].getClass();
+        String pattern = String.format("%s=%d;%s=%d", name, value, name, value - 1);
+        ObjectInputFilter filter = ObjectInputFilter.Config.createFilter(pattern);
+        Assert.assertEquals(
+                filter.checkInput(new FilterValues(arrayClass, value, value, value, value)),
+                ObjectInputFilter.Status.REJECTED,
+                "last limit value not used: " + filter);
+        Assert.assertEquals(
+                filter.checkInput(new FilterValues(arrayClass, value-1, value-1, value-1, value-1)),
+                ObjectInputFilter.Status.UNDECIDED,
+                "last limit value not used: " + filter);
+    }
+
+    /**
+     * Test that returning null from a filter causes deserialization to fail.
+     */
+    @Test(expectedExceptions=InvalidClassException.class)
+    static void testNullStatus() throws IOException {
+        byte[] bytes = writeObjects(0); // an Integer
+        try {
+            Object o = validate(bytes, new ObjectInputFilter() {
+                public ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo f) {
+                    return null;
+                }
+            });
+        } catch (InvalidClassException ice) {
+            System.out.printf("Success exception: %s%n", ice);
+            throw ice;
+        }
+    }
+
+    /**
+     * Verify that malformed patterns throw IAE.
+     * @param pattern pattern from the data source
+     */
+    @Test(dataProvider="InvalidPatterns", expectedExceptions=IllegalArgumentException.class)
+    static void testInvalidPatterns(String pattern) {
+        try {
+            ObjectInputFilter.Config.createFilter(pattern);
+        } catch (IllegalArgumentException iae) {
+            System.out.printf("    success exception: %s%n", iae);
+            throw iae;
+        }
+    }
+
+    /**
+     * Test that Config.create returns null if the argument does not contain any patterns or limits.
+     */
+    @Test()
+    static void testEmptyPattern() {
+        ObjectInputFilter filter = ObjectInputFilter.Config.createFilter("");
+        Assert.assertNull(filter, "empty pattern did not return null");
+
+        filter = ObjectInputFilter.Config.createFilter(";;;;");
+        Assert.assertNull(filter, "pattern with only delimiters did not return null");
+    }
+
+    /**
+     * Read objects from the serialized stream, validated with the filter.
+     *
+     * @param bytes a byte array to read objects from
+     * @param filter the ObjectInputFilter
+     * @return the object deserialized if any
+     * @throws IOException can be thrown
+     */
+    static Object validate(byte[] bytes,
+                         ObjectInputFilter filter) throws IOException {
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+             ObjectInputStream ois = new ObjectInputStream(bais)) {
+            ois.setObjectInputFilter(filter);
+
+            Object o = ois.readObject();
+            return o;
+        } catch (EOFException eof) {
+            // normal completion
+        } catch (ClassNotFoundException cnf) {
+            Assert.fail("Deserializing", cnf);
+        }
+        return null;
+    }
+
+    /**
+     * 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;
+    }
+
+    /**
+     * A filter that accumulates information about the checkInput callbacks
+     * that can be checked after readObject completes.
+     */
+    static class Validator implements ObjectInputFilter {
+        long count;          // Count of calls to checkInput
+        HashSet<Class<?>> classes = new HashSet<>();
+        long maxArray = -1;
+        long maxRefs;
+        long maxDepth;
+        long maxBytes;
+
+        Validator() {
+        }
+
+        @Override
+        public ObjectInputFilter.Status checkInput(FilterInfo filter) {
+            count++;
+            if (filter.serialClass() != null) {
+                if (filter.serialClass().getName().contains("$$Lambda$")) {
+                    // TBD: proper identification of serialized Lambdas?
+                    // Fold the serialized Lambda into the SerializedLambda type
+                    classes.add(SerializedLambda.class);
+                } else if (Proxy.isProxyClass(filter.serialClass())) {
+                    classes.add(Proxy.class);
+                } else {
+                    classes.add(filter.serialClass());
+                }
+
+            }
+            this.maxArray = Math.max(this.maxArray, filter.arrayLength());
+            this.maxRefs = Math.max(this.maxRefs, filter.references());
+            this.maxDepth = Math.max(this.maxDepth, filter.depth());
+            this.maxBytes = Math.max(this.maxBytes, filter.streamBytes());
+            return ObjectInputFilter.Status.UNDECIDED;
+        }
+
+        public String toString(){
+            return "count: " + count
+                    + ", classes: " + classes.toString()
+                    + ", maxArray: " + maxArray
+                    + ", maxRefs: " + maxRefs
+                    + ", maxDepth: " + maxDepth
+                    + ", maxBytes: " + maxBytes;
+        }
+    }
+
+
+    /**
+     * Create a filter from a pattern and API factory, then serialize and
+     * deserialize an object and check allowed or reject.
+     *
+     * @param pattern the pattern
+     * @param object the test object
+     * @param allowed the expected result from ObjectInputStream (exception or not)
+     */
+    static void testPatterns(String pattern, Object object, boolean allowed) {
+        try {
+            byte[] bytes = SerialFilterTest.writeObjects(object);
+            ObjectInputFilter filter = ObjectInputFilter.Config.createFilter(pattern);
+            validate(bytes, filter);
+            Assert.assertTrue(allowed, "filter should have thrown an exception");
+        } catch (IllegalArgumentException iae) {
+            Assert.fail("bad format pattern", iae);
+        } catch (InvalidClassException ice) {
+            Assert.assertFalse(allowed, "filter should not have thrown an exception: " + ice);
+        } catch (IOException ioe) {
+            Assert.fail("Unexpected IOException", ioe);
+        }
+    }
+
+    /**
+     * For a filter pattern, generate and apply a test object to the action.
+     * @param pattern a pattern
+     * @param action an action to perform on positive and negative cases
+     */
+    static void evalPattern(String pattern, TriConsumer<String, Object, Boolean> action) {
+        Object o = genTestObject(pattern, true);
+        Assert.assertNotNull(o, "success generation failed");
+        action.accept(pattern, o, true);
+
+        // Test the negative pattern
+        o = genTestObject(pattern, false);
+        Assert.assertNotNull(o, "fail generation failed");
+        String negPattern = pattern.contains("=") ? pattern : "!" + pattern;
+        action.accept(negPattern, o, false);
+    }
+
+    /**
+     * Generate a test object based on the pattern.
+     * Handles each of the forms of the pattern, wildcards,
+     * class name, various limit forms.
+     * @param pattern a pattern
+     * @param allowed a boolean indicating to generate the allowed or disallowed case
+     * @return an object or {@code null} to indicate no suitable object could be generated
+     */
+    static Object genTestObject(String pattern, boolean allowed) {
+        if (pattern.contains("=")) {
+            return genTestLimit(pattern, allowed);
+        } else if (pattern.endsWith("*")) {
+            return genTestObjectWildcard(pattern, allowed);
+        } else {
+            // class
+            // isolate module name, if any
+            int poffset = 0;
+            int soffset = pattern.indexOf('/', poffset);
+            String module = null;
+            if (soffset >= 0) {
+                poffset = soffset + 1;
+                module = pattern.substring(0, soffset);
+            }
+            try {
+                Class<?> clazz = Class.forName(pattern.substring(poffset));
+                Constructor<?> cons = clazz.getConstructor();
+                return cons.newInstance();
+            } catch (ClassNotFoundException ex) {
+                Assert.fail("no such class available: " + pattern);
+            } catch (InvocationTargetException
+                    | NoSuchMethodException
+                    | InstantiationException
+                    | IllegalAccessException ex1) {
+                Assert.fail("newInstance: " + ex1);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Generate an object to be used with the various wildcard pattern forms.
+     * Explicitly supports only specific package wildcards with specific objects.
+     * @param pattern a wildcard pattern ending in "*"
+     * @param allowed a boolean indicating to generate the allowed or disallowed case
+     * @return an object within or outside the wildcard
+     */
+    static Object genTestObjectWildcard(String pattern, boolean allowed) {
+        if (pattern.endsWith(".**")) {
+            // package hierarchy wildcard
+            if (pattern.startsWith("javax.lang.")) {
+                return SourceVersion.RELEASE_5;
+            }
+            if (pattern.startsWith("java.")) {
+                return 4;
+            }
+            if (pattern.startsWith("javax.")) {
+                return SourceVersion.RELEASE_6;
+            }
+            return otherObject;
+        } else if (pattern.endsWith(".*")) {
+            // package wildcard
+            if (pattern.startsWith("javax.lang.model")) {
+                return SourceVersion.RELEASE_6;
+            }
+        } else {
+            // class wildcard
+            if (pattern.equals("*")) {
+                return otherObject; // any object will do
+            }
+            if (pattern.startsWith("java.util.Hash")) {
+                return new Hashtable<String, String>();
+            }
+        }
+        Assert.fail("Object could not be generated for pattern: "
+                + pattern
+                + ", allowed: " + allowed);
+        return null;
+    }
+
+    /**
+     * Generate a limit test object for the pattern.
+     * For positive cases, the object exactly hits the limit.
+     * For negative cases, the object is 1 greater than the limit
+     * @param pattern the pattern, containing "=" and a maxXXX keyword
+     * @param allowed a boolean indicating to generate the allowed or disallowed case
+     * @return a sitable object
+     */
+    static Object genTestLimit(String pattern, boolean allowed) {
+        int ndx = pattern.indexOf('=');
+        Assert.assertNotEquals(ndx, -1, "missing value in limit");
+        long value = Long.parseUnsignedLong(pattern.substring(ndx+1));
+        if (pattern.startsWith("maxdepth=")) {
+            // Return an object with the requested depth (or 1 greater)
+            long depth = allowed ? value : value + 1;
+            Object[] array = new Object[1];
+            for (int i = 1; i < depth; i++) {
+                Object[] n = new Object[1];
+                n[0] = array;
+                array = n;
+            }
+            return array;
+        } else if (pattern.startsWith("maxbytes=")) {
+            // Return a byte array that when written to OOS creates
+            // a stream of exactly the size requested.
+            return genMaxBytesObject(allowed, value);
+        } else if (pattern.startsWith("maxrefs=")) {
+            Object[] array = new Object[allowed ? (int)value - 1 : (int)value];
+            for (int i = 0; i < array.length; i++) {
+                array[i] = otherObject;
+            }
+            return array;
+        } else if (pattern.startsWith("maxarray=")) {
+            return allowed ? new int[(int)value] : new int[(int)value+1];
+        }
+        Assert.fail("Object could not be generated for pattern: "
+                + pattern
+                + ", allowed: " + allowed);
+        return null;
+    }
+
+    /**
+     * Generate an an object that will be serialized to some number of bytes.
+     * Or 1 greater if allowed is false.
+     * It returns a two element Object array holding a byte array sized
+     * to achieve the desired total size.
+     * @param allowed true if the stream should be allowed at that size,
+     *                false if the stream should be larger
+     * @param maxBytes the number of bytes desired in the stream;
+     *                 should not be less than 72 (due to protocol overhead).
+     * @return a object that will be serialized to the length requested
+     */
+    private static Object genMaxBytesObject(boolean allowed, long maxBytes) {
+        Object[] holder = new Object[2];
+        long desiredSize = allowed ? maxBytes : maxBytes + 1;
+        long actualSize = desiredSize;
+        long byteSize = desiredSize - 72;  // estimate needed array size
+        do {
+            byteSize += (desiredSize - actualSize);
+            byte[] a = new byte[(int)byteSize];
+            holder[0] = a;
+            holder[1] = a;
+            try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                 ObjectOutputStream os = new ObjectOutputStream(baos)) {
+                os.writeObject(holder);
+                os.flush();
+                actualSize = baos.size();
+            } catch (IOException ie) {
+                Assert.fail("exception generating stream", ie);
+            }
+        } while (actualSize != desiredSize);
+        return holder;
+    }
+
+    /**
+     * Returns a HashSet of a requested depth.
+     * @param depth the depth
+     * @return a HashSet of HashSets...
+     */
+    static HashSet<Object> deepHashSet(int depth) {
+        HashSet<Object> hashSet = new HashSet<>();
+        HashSet<Object> s1 = hashSet;
+        HashSet<Object> s2 = new HashSet<>();
+        for (int i = 0; i < depth; i++ ) {
+            HashSet<Object> t1 = new HashSet<>();
+            HashSet<Object> t2 = new HashSet<>();
+            // make t1 not equal to t2
+            t1.add("by Jimminy");
+            s1.add(t1);
+            s1.add(t2);
+            s2.add(t1);
+            s2.add(t2);
+            s1 = t1;
+            s2 = t2;
+        }
+        return hashSet;
+    }
+
+    /**
+     * Simple method to use with Serialized Lambda.
+     */
+    private static void noop() {}
+
+
+    /**
+     * Class that returns an array from readResolve and also implements
+     * the ObjectInputFilter to check that it has the expected length.
+     */
+    static class ReadResolveToArray implements Serializable, ObjectInputFilter {
+        private static final long serialVersionUID = 123456789L;
+
+        private final Object array;
+        private final int length;
+
+        ReadResolveToArray(Object array, int length) {
+            this.array = array;
+            this.length = length;
+        }
+
+        Object readResolve() {
+            return array;
+        }
+
+        @Override
+        public ObjectInputFilter.Status checkInput(FilterInfo filter) {
+            if (ReadResolveToArray.class.isAssignableFrom(filter.serialClass())) {
+                return ObjectInputFilter.Status.ALLOWED;
+            }
+            if (filter.serialClass() != array.getClass() ||
+                    (filter.arrayLength() >= 0 && filter.arrayLength() != length)) {
+                return ObjectInputFilter.Status.REJECTED;
+            }
+            return ObjectInputFilter.Status.UNDECIDED;
+        }
+
+    }
+
+    /**
+     * Hold a snapshot of values to be passed to an ObjectInputFilter.
+     */
+    static class FilterValues implements ObjectInputFilter.FilterInfo {
+        private final Class<?> clazz;
+        private final long arrayLength;
+        private final long depth;
+        private final long references;
+        private final long streamBytes;
+
+        public FilterValues(Class<?> clazz, long arrayLength, long depth, long references, long streamBytes) {
+            this.clazz = clazz;
+            this.arrayLength = arrayLength;
+            this.depth = depth;
+            this.references = references;
+            this.streamBytes = streamBytes;
+        }
+
+        @Override
+        public Class<?> serialClass() {
+            return clazz;
+        }
+
+        public long arrayLength() {
+            return arrayLength;
+        }
+
+        public long depth() {
+            return depth;
+        }
+
+        public long references() {
+            return references;
+        }
+
+        public long streamBytes() {
+            return streamBytes;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialFilter/java.security-extra1	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,4 @@
+# Serialization Input Process-wide Filter
+# See conf/security/java.security for pattern synatx
+#
+jdk.serialFilter=java.**;javax.**;maxarray=34;maxdepth=7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialFilter/security.policy	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,12 @@
+// Individual Permissions to for GlobalFilterTest
+grant {
+        // Specific permission under test
+        permission java.security.SerializablePermission "serialFilter";
+        // Permissions needed to run the test
+        permission java.util.PropertyPermission "*", "read";
+        permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
+        permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
+        permission java.security.SecurityPermission "*";
+        permission java.lang.RuntimePermission "accessDeclaredMembers";
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialFilter/security.policy.without.globalFilter	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,9 @@
+// Individual Permissions for FilterWithSecurityManagerTest
+grant {
+        // Permissions needed to run the test
+        permission java.util.PropertyPermission "*", "read";
+        permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
+        permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
+        permission java.lang.RuntimePermission "accessDeclaredMembers";
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ClassLoader/forNameLeak/ClassForName.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,45 @@
+/*
+ * 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.net.URLClassLoader;
+
+/*
+ * This class is loaded by the custom URLClassLoader, and then calls
+ * Class.forName();
+ */
+public class ClassForName implements Runnable {
+    static {
+        if (!(ClassForName.class.getClassLoader() instanceof URLClassLoader)) {
+            throw new RuntimeException("Supposed to be loaded by URLClassLoader");
+        }
+    }
+
+    public void run() {
+        try {
+            Class.forName(java.util.List.class.getName(), false,
+                          ClassLoader.getSystemClassLoader());
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ClassLoader/forNameLeak/ClassForNameLeak.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,121 @@
+/*
+ * 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 8151486
+ * @summary Call Class.forName() on the system classloader from a class loaded
+ *          from a custom classloader.
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.Utils JarUtils
+ * @build ClassForName ClassForNameLeak
+ * @run main/othervm/policy=test.policy -Djava.security.manager ClassForNameLeak
+ */
+
+import java.lang.ref.PhantomReference;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import jdk.testlibrary.Utils;
+
+/*
+ * Create .jar, load ClassForName from .jar using a URLClassLoader
+ */
+public class ClassForNameLeak {
+    private static final long TIMEOUT = (long)(5000.0 * Utils.TIMEOUT_FACTOR);
+    private static final String TESTCLASSES = System.getProperty("test.classes", ".");
+    private static final String CLASSFILENAME = "ClassForName.class";
+    private static final int THREADS = 10;
+    private static final ReferenceQueue<ClassLoader> rq = new ReferenceQueue<>();
+
+    // Use a new classloader to load the ClassForName class, then run its
+    // Runnable.
+    public static PhantomReference<ClassLoader> loadAndRun(Path jarFilePath)
+            throws Exception {
+        ClassLoader classLoader = new URLClassLoader(
+                new URL[]{jarFilePath.toUri().toURL()}) {
+            @Override public String toString() { return "LeakedClassLoader"; }
+        };
+
+        Class<?> loadClass = Class.forName("ClassForName", true, classLoader);
+        ((Runnable) loadClass.newInstance()).run();
+
+        PhantomReference<ClassLoader> ref = new PhantomReference<>(classLoader, rq);
+        System.out.println("returning phantom ref: " + ref + " to " + classLoader);
+        return ref;
+    }
+
+    public static void main(final String[] args) throws Exception {
+        // Create a temporary .jar file containing ClassForName.class
+        Path testClassesDir = Paths.get(TESTCLASSES);
+        Path jarFilePath = Files.createTempFile("cfn", ".jar");
+        JarUtils.createJarFile(jarFilePath, testClassesDir, CLASSFILENAME);
+        jarFilePath.toFile().deleteOnExit();
+
+        // Remove the ClassForName.class file that jtreg built, to make sure
+        // we're loading from the tmp .jar
+        Path classFile = FileSystems.getDefault().getPath(TESTCLASSES,
+                                                          CLASSFILENAME);
+        Files.delete(classFile);
+
+        // Make simultaneous calls to the test method, to stress things a bit
+        ExecutorService es = Executors.newFixedThreadPool(THREADS);
+
+        List<Callable<PhantomReference<ClassLoader>>> callables =
+                Stream.generate(() -> {
+                    Callable<PhantomReference<ClassLoader>> cprcl = () -> {
+                        return loadAndRun(jarFilePath);
+                    };
+                    return cprcl;
+                }).limit(THREADS).collect(Collectors.toList());
+
+        List<Future<PhantomReference<ClassLoader>>> refs = es.invokeAll(callables);
+
+        // Give the GC a chance to enqueue the PhantomReferences
+        for (int i = 0; i < 10; i++) {
+            System.gc();
+        }
+        // Make sure all PhantomReferences to the leaked classloader are enqueued
+        for (int j = 0; j < THREADS; j++) {
+            Reference rmRef = rq.remove(TIMEOUT);
+            if (rmRef == null) {
+                throw new RuntimeException("ClassLoader was never enqueued!");
+            } else {
+                System.out.println("Enqueued " + rmRef);
+            }
+        }
+        System.out.println("All Classloaders successfully enqued");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ClassLoader/forNameLeak/test.policy	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,6 @@
+grant {
+  permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete";
+  permission java.lang.RuntimePermission "createClassLoader";
+  permission java.lang.RuntimePermission "getClassLoader";
+  permission java.util.PropertyPermission "*", "read"; /* for Utils */
+};
--- a/jdk/test/java/lang/Math/FusedMultiplyAddTests.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/lang/Math/FusedMultiplyAddTests.java	Tue Oct 18 17:14:09 2016 +0000
@@ -221,6 +221,9 @@
 
             {Double.MIN_VALUE, -0.0, +0.0,
              +0.0},
+
+            {1.0+Math.ulp(1.0), 1.0+Math.ulp(1.0), -1.0-2.0*Math.ulp(1.0),
+             Math.ulp(1.0)*Math.ulp(1.0)},
         };
 
         for (double[] testCase: testCases)
@@ -344,6 +347,9 @@
 
             {Float.MAX_VALUE, 2.0f, 1.0f,
              InfinityF},
+
+            {1.0f+Math.ulp(1.0f), 1.0f+Math.ulp(1.0f), -1.0f-2.0f*Math.ulp(1.0f),
+             Math.ulp(1.0f)*Math.ulp(1.0f)},
         };
 
         for (float[] testCase: testCases)
--- a/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,6 +1,6 @@
 /*
  * Copyright 2014 Goldman Sachs.
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", ".");
             OutputAnalyzer analyzer = ProcessTools.executeProcess(pb);
             analyzer.shouldNotContain("ASSERTION FAILED");
+            analyzer.shouldHaveExitValue(0);
         }
     }
 }
--- a/jdk/test/java/lang/invoke/CountedLoopIterationCountsTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/lang/invoke/CountedLoopIterationCountsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -71,7 +71,7 @@
         }
     }
 
-    static int step(int counter, int stepCount) {
+    static int step(int stepCount, int counter) {
         return stepCount + 1;
     }
 
--- a/jdk/test/java/lang/invoke/JavaDocExamplesTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/lang/invoke/JavaDocExamplesTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -703,6 +703,66 @@
         }}
     }
 
+    static int inc(int i) { return i + 1; } // drop acc, k
+    static int mult(int i, int acc) { return i * acc; } //drop k
+    static boolean cmp(int i, int k) { return i < k; }
+
+    @Test public void testSimplerLoop() throws Throwable {
+        MethodHandle MH_inc, MH_mult, MH_cmp;
+        Class<?> I = int.class;
+        MH_inc = LOOKUP.findStatic(THIS_CLASS, "inc", methodType(I, I));
+        MH_mult = LOOKUP.findStatic(THIS_CLASS, "mult", methodType(I, I, I));
+        MH_cmp = LOOKUP.findStatic(THIS_CLASS, "cmp", methodType(boolean.class, I, I));
+        {{
+{} /// JAVADOC
+// simplified implementation of the factorial function as a loop handle
+// null initializer for counter, should initialize to 0
+MethodHandle MH_one = MethodHandles.constant(int.class, 1);
+MethodHandle MH_pred = MethodHandles.dropArguments(MH_cmp, 1, int.class); // drop acc
+MethodHandle MH_fin = MethodHandles.dropArguments(MethodHandles.identity(int.class), 0, int.class); // drop i
+MethodHandle[] counterClause = new MethodHandle[]{null, MH_inc};
+MethodHandle[] accumulatorClause = new MethodHandle[]{MH_one, MH_mult, MH_pred, MH_fin};
+MethodHandle loop = MethodHandles.loop(counterClause, accumulatorClause);
+assertEquals(720, loop.invoke(6));
+{}
+        }}
+    }
+
+    // for testFacLoop
+{}
+static class FacLoop {
+  final int k;
+  FacLoop(int k) { this.k = k; }
+  int inc(int i) { return i + 1; }
+  int mult(int i, int acc) { return i * acc; }
+  boolean pred(int i) { return i < k; }
+  int fin(int i, int acc) { return acc; }
+}
+{}
+
+    // assume MH_inc, MH_mult, and MH_pred are handles to the above methods
+    @Test public void testFacLoop() throws Throwable {
+        MethodHandle MH_FacLoop, MH_inc, MH_mult, MH_pred, MH_fin;
+        Class<?> I = int.class;
+        MH_FacLoop = LOOKUP.findConstructor(FacLoop.class, methodType(void.class, I));
+        MH_inc = LOOKUP.findVirtual(FacLoop.class, "inc", methodType(I, I));
+        MH_mult = LOOKUP.findVirtual(FacLoop.class, "mult", methodType(I, I, I));
+        MH_pred = LOOKUP.findVirtual(FacLoop.class, "pred", methodType(boolean.class, I));
+        MH_fin = LOOKUP.findVirtual(FacLoop.class, "fin", methodType(I, I, I));
+        {{
+{} /// JAVADOC
+// instance-based implementation of the factorial function as a loop handle
+// null initializer for counter, should initialize to 0
+MethodHandle MH_one = MethodHandles.constant(int.class, 1);
+MethodHandle[] instanceClause = new MethodHandle[]{MH_FacLoop};
+MethodHandle[] counterClause = new MethodHandle[]{null, MH_inc};
+MethodHandle[] accumulatorClause = new MethodHandle[]{MH_one, MH_mult, MH_pred, MH_fin};
+MethodHandle loop = MethodHandles.loop(instanceClause, counterClause, accumulatorClause);
+assertEquals(5040, loop.invoke(7));
+{}
+        }}
+    }
+
     static List<String> initZip(Iterator<String> a, Iterator<String> b) { return new ArrayList<>(); }
     static boolean zipPred(List<String> zip, Iterator<String> a, Iterator<String> b) { return a.hasNext() && b.hasNext(); }
     static List<String> zipStep(List<String> zip, Iterator<String> a, Iterator<String> b) {
@@ -749,36 +809,81 @@
         }}
     }
 
-    static String start(String arg) { return arg; }
-    static String step(int counter, String v, String arg) { return "na " + v; }
+    static String step(String v, int counter, String start_) { return "na " + v; }  //#0
+    static String step(String v, int counter ) { return "na " + v; } //#1
+    static String step(String v, int counter, int iterations_, String pre, String start_) { return pre + " " + v; } //#2
+    static String step3(String v, int counter, String pre) { return pre + " " + v; } //#3
 
     @Test public void testCountedLoop() throws Throwable {
-        MethodHandle MH_start, MH_step;
-        Class<?> S = String.class;
-        MH_start = LOOKUP.findStatic(THIS_CLASS, "start", methodType(S, S));
-        MH_step = LOOKUP.findStatic(THIS_CLASS, "step", methodType(S, int.class, S, S));
+        MethodHandle MH_step;
+        Class<?> S = String.class, I = int.class;
+        // Theme:
+        MH_step = LOOKUP.findStatic(THIS_CLASS, "step", methodType(S, S, I, S));
         {{
 {} /// JAVADOC
 // String s = "Lambdaman!"; for (int i = 0; i < 13; ++i) { s = "na " + s; } return s;
 // => a variation on a well known theme
 MethodHandle fit13 = MethodHandles.constant(int.class, 13);
-MethodHandle loop = MethodHandles.countedLoop(fit13, MH_start, MH_step);
+MethodHandle start = MethodHandles.identity(String.class);
+MethodHandle loop = MethodHandles.countedLoop(fit13, start, MH_step);  // (v, i, _) -> "na " + v
 assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke("Lambdaman!"));
 {}
         }}
+        // Variation #1:
+        MH_step = LOOKUP.findStatic(THIS_CLASS, "step", methodType(S, S, I));
+        {{
+{} /// JAVADOC
+// String s = "Lambdaman!"; for (int i = 0; i < 13; ++i) { s = "na " + s; } return s;
+// => a variation on a well known theme
+MethodHandle count = MethodHandles.dropArguments(MethodHandles.identity(int.class), 1, String.class);
+MethodHandle start = MethodHandles.dropArguments(MethodHandles.identity(String.class), 0, int.class);
+MethodHandle loop = MethodHandles.countedLoop(count, start, MH_step);  // (v, i) -> "na " + v
+assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke(13, "Lambdaman!"));
+{}
+            assertEquals("na na Lambdaman!", loop.invoke(2, "Lambdaman!"));
+            assertEquals("Lambdaman!", loop.invoke(0, "Lambdaman!"));
+            assertEquals("Lambdaman!", loop.invoke(-1, "Lambdaman!"));
+            assertEquals("Lambdaman!", loop.invoke(Integer.MIN_VALUE, "Lambdaman!"));
+        }}
+        // Variation #2:
+        MH_step = LOOKUP.findStatic(THIS_CLASS, "step", methodType(S, S, I, I, S, S));
+        {{
+{} /// JAVADOC
+// String s = "Lambdaman!", t = "na"; for (int i = 0; i < 13; ++i) { s = t + " " + s; } return s;
+// => a variation on a well known theme
+MethodHandle count = MethodHandles.identity(int.class);
+MethodHandle start = MethodHandles.dropArguments(MethodHandles.identity(String.class), 0, int.class, String.class);
+MethodHandle loop = MethodHandles.countedLoop(count, start, MH_step);  // (v, i, _, pre, _) -> pre + " " + v
+assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke(13, "na", "Lambdaman!"));
+{}
+        }}
+        // Variation #3:
+        MH_step = LOOKUP.findStatic(THIS_CLASS, "step3", methodType(S, S, I, S));
+        {{
+{} /// JAVADOC
+// String s = "Lambdaman!", t = "na"; for (int i = 0; i < 13; ++i) { s = t + " " + s; } return s;
+// => a variation on a well known theme
+MethodType loopType = methodType(String.class, String.class, int.class, String.class);
+MethodHandle count = MethodHandles.dropArgumentsToMatch(MethodHandles.identity(int.class),    0, loopType.parameterList(), 1);
+MethodHandle start = MethodHandles.dropArgumentsToMatch(MethodHandles.identity(String.class), 0, loopType.parameterList(), 2);
+MethodHandle body  = MethodHandles.dropArgumentsToMatch(MH_step,                              2, loopType.parameterList(), 0);
+MethodHandle loop = MethodHandles.countedLoop(count, start, body);  // (v, i, pre, _, _) -> pre + " " + v
+assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke("na", 13, "Lambdaman!"));
+{}
+        }}
     }
 
-    static List<String> reverseStep(String e, List<String> r, List<String> l) {
+    static List<String> reverseStep(List<String> r, String e) {
         r.add(0, e);
         return r;
     }
-    static List<String> newArrayList(List<String> l) { return new ArrayList<>(); }
+    static List<String> newArrayList() { return new ArrayList<>(); }
 
     @Test public void testIteratedLoop() throws Throwable {
         MethodHandle MH_newArrayList, MH_reverseStep;
-        Class<?> L = List.class;
-        MH_newArrayList = LOOKUP.findStatic(THIS_CLASS, "newArrayList", methodType(L, L));
-        MH_reverseStep = LOOKUP.findStatic(THIS_CLASS, "reverseStep", methodType(L, String.class, L, L));
+        Class<?> L = List.class, S = String.class;
+        MH_newArrayList = LOOKUP.findStatic(THIS_CLASS, "newArrayList", methodType(L));
+        MH_reverseStep = LOOKUP.findStatic(THIS_CLASS, "reverseStep", methodType(L, L, S));
         {{
 {} /// JAVADOC
 // reverse a list
--- a/jdk/test/java/lang/invoke/LoopCombinatorTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/lang/invoke/LoopCombinatorTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -28,6 +28,7 @@
  * @bug 8150635
  * @bug 8150956
  * @bug 8150957
+ * @bug 8151179
  * @bug 8152667
  * @bug 8153637
  * @bug 8154751
@@ -146,6 +147,16 @@
         assertEquals(120, loop.invoke(new LoopWithVirtuals(), 5));
     }
 
+    @Test
+    public static void testLoopOmitPred() throws Throwable {
+        // construct a loop to calculate factorial that omits a predicate
+        MethodHandle[] counterClause = new MethodHandle[]{null, Fac.MH_inc, null, Fac.MH_fin};
+        MethodHandle[] accumulatorClause = new MethodHandle[]{Fac.MH_one, Fac.MH_mult, Fac.MH_pred, Fac.MH_fin};
+        MethodHandle loop = MethodHandles.loop(counterClause, accumulatorClause);
+        assertEquals(Fac.MT_fac, loop.type());
+        assertEquals(120, loop.invoke(5));
+    }
+
     @DataProvider
     static Object[][] negativeTestData() {
         MethodHandle i0 = MethodHandles.constant(int.class, 0);
@@ -153,7 +164,8 @@
         MethodHandle id = MethodHandles.dropArguments(i0, 0, int.class, double.class);
         MethodHandle i3 = MethodHandles.dropArguments(i0, 0, int.class, int.class, int.class);
         List<MethodHandle> inits = Arrays.asList(ii, id, i3);
-        List<Class<?>> ints = Arrays.asList(int.class, int.class, int.class);
+        List<Class<?>> ints3 = Arrays.asList(int.class, int.class, int.class);
+        List<Class<?>> ints4 = Arrays.asList(int.class, int.class, int.class, int.class);
         List<MethodHandle> finis = Arrays.asList(Fac.MH_fin, Fac.MH_inc, Counted.MH_step);
         List<MethodHandle> preds1 = Arrays.asList(null, null, null);
         List<MethodHandle> preds2 = Arrays.asList(null, Fac.MH_fin, null);
@@ -174,7 +186,7 @@
                         "clause 0: init and step return types must match: int != void"},
                 {new MethodHandle[][]{{ii}, {id}, {i3}},
                         "found non-effectively identical init parameter type lists: " + inits +
-                                " (common suffix: " + ints + ")"},
+                                " (common suffix: " + ints3 + ")"},
                 {new MethodHandle[][]{{null, Fac.MH_inc, null, Fac.MH_fin}, {null, Fac.MH_inc, null, Fac.MH_inc},
                         {null, Counted.MH_start, null, Counted.MH_step}},
                         "found non-identical finalizer return types: " + finis + " (return type: int)"},
@@ -185,11 +197,11 @@
                 {new MethodHandle[][]{{Fac.MH_zero, Fac.MH_inc}, {Fac.MH_one, eek, Fac.MH_pred, Fac.MH_fin},
                         {null, Fac.MH_dot}},
                         "found non-effectively identical parameter type lists:\nstep: " + nesteps +
-                                "\npred: " + nepreds + "\nfini: " + nefinis + " (common parameter sequence: " + ints + ")"},
+                                "\npred: " + nepreds + "\nfini: " + nefinis + " (common parameter sequence: " + ints3 + ")"},
                 {new MethodHandle[][]{{null, LoopWithVirtuals.MH_inc},
                         {LoopWithVirtuals.MH_one, LoopWithVirtuals.MH_mult, LoopWithVirtuals.MH_pred, LoopWithVirtuals.MH_fin}},
                         "found non-effectively identical parameter type lists:\nstep: " + lvsteps +
-                                "\npred: " + lvpreds + "\nfini: " + lvfinis + " (common parameter sequence: " + ints + ")"}
+                                "\npred: " + lvpreds + "\nfini: " + lvfinis + " (common parameter sequence: " + ints4 + ")"}
         };
     }
 
@@ -207,7 +219,7 @@
     public static void testLoopNegative(MethodHandle[][] clauses, String expectedMessage) throws Throwable {
         boolean caught = false;
         try {
-            MH_loop.invokeWithArguments(clauses);
+            MH_loop.invokeWithArguments((Object[]) clauses);
         } catch (IllegalArgumentException iae) {
             assertEquals(expectedMessage, iae.getMessage());
             caught = true;
@@ -215,12 +227,100 @@
         assertTrue(caught);
     }
 
-    @Test
-    public static void testWhileLoop() throws Throwable {
+    @Test(dataProvider = "whileLoopTestData")
+    public static void testWhileLoop(MethodHandle MH_zero,
+                                     MethodHandle MH_pred,
+                                     MethodHandle MH_step,
+                                     String messageOrNull) throws Throwable {
         // int i = 0; while (i < limit) { ++i; } return i; => limit
-        MethodHandle loop = MethodHandles.whileLoop(While.MH_zero, While.MH_pred, While.MH_step);
-        assertEquals(While.MT_while, loop.type());
-        assertEquals(23, loop.invoke(23));
+        try {
+            MethodHandle loop = MethodHandles.whileLoop(MH_zero, MH_pred, MH_step);
+            assert messageOrNull == null;
+            if (MH_step.type().equals(While.MH_step.type()))
+                assertEquals(While.MT_while, loop.type());
+            assertEquals(MH_step.type().dropParameterTypes(0, 1), loop.type());
+            while (loop.type().parameterCount() > 1)  loop = snip(loop);
+            assertEquals(23, loop.invoke(23));
+        } catch (IllegalArgumentException iae) {
+            assert messageOrNull != null;
+            assertEqualsFIXME(messageOrNull, iae.getMessage());
+        }
+    }
+
+    static void assertEqualsFIXME(String expect, String actual) {
+        if (!expect.equals(actual)) {
+            // just issue a warning
+            System.out.println("*** "+actual+"\n != "+expect);
+        }
+    }
+
+    @DataProvider
+    static Object[][] whileLoopTestData() {
+        MethodHandle
+            zeroI = While.MH_zero,
+            zeroX = snip(zeroI),
+            zeroIB = slap(zeroI, byte.class),
+            predII = While.MH_pred,
+            predIX = snip(predII),
+            predIIB = slap(predII, byte.class),
+            stepII = While.MH_step,
+            stepIX = snip(stepII),
+            stepIIB = slap(stepII, byte.class)
+            ;
+        return new Object[][] {
+            // normal while loop clauses, perhaps with effectively-identical reductions
+            {zeroI, predII, stepII, null},
+            {zeroX, predII, stepII, null},
+            {null, predII, stepII, null},
+            // expanded while loop clauses
+            {zeroIB, predIIB, stepIIB, null},
+            {zeroI, predIIB, stepIIB, null},
+            {null, predIIB, stepIIB, null},
+            {zeroIB, predII, stepIIB, null},
+            {zeroX, predII, stepIIB, null},
+            {null, predII, stepIIB, null},
+            // short step clauses cause errors
+            {zeroI, predII, stepIX, "loop predicate must match: (int,int)boolean != (int)boolean"},
+            {zeroIB, predIX, stepIX, "loop initializer must match: (int,byte)int != ()int"},
+            // bad body type
+            {zeroI, predII, tweak(stepII, -1, char.class), "body function must match: (int,int)char != (char,int,int)char"},
+            {zeroI, predII, tweak(stepII,  0, char.class), "body function must match: (char,int)int != (int,char,int)int"},
+            // bad pred type
+            {zeroI, tweak(predII, -1, char.class), stepII, "loop predicate must match: (int,int)char != (int,int)boolean"},
+            {zeroI, tweak(predII,  0, char.class), stepII, "loop predicate must match: (char,int)boolean != (int,int)boolean"},
+            // bad init type
+            {tweak(zeroI, -1, char.class), predII, stepII, "loop initializer must match: (int)char != (int)int"},
+            {tweak(zeroI,  0, char.class), predII, stepII, "loop initializer must match: (char)int != (int)int"},
+        };
+    }
+
+    // tweak the type of an MH
+    static MethodHandle tweak(MethodHandle mh, int argPos, Class<?> type) {
+        MethodType mt = mh.type();
+        if (argPos == -1)
+            mt = mt.changeReturnType(type);
+        else
+            mt = mt.changeParameterType(argPos, type);
+        return MethodHandles.explicitCastArguments(mh, mt);
+    }
+    // snip off an MH argument, hard-wiring to zero
+    static MethodHandle snip(MethodHandle mh, int argPos) {
+        if (argPos < 0)  return null;  // special case for optional args
+        Class<?> argType = mh.type().parameterType(argPos);
+        Object zero;
+        try {
+            zero = MethodHandles.zero(argType).invoke();
+        } catch (Throwable ex) {
+            throw new AssertionError(ex);
+        }
+        return MethodHandles.insertArguments(mh, argPos, zero);
+    }
+    static MethodHandle snip(MethodHandle mh) {
+        return snip(mh, mh.type().parameterCount()-1);
+    }
+    // slap on an extra type on the end of the MH
+    static MethodHandle slap(MethodHandle mh, Class<?> addType) {
+        return MethodHandles.dropArguments(mh, mh.type().parameterCount(), addType);
     }
 
     @Test
@@ -231,22 +331,42 @@
         assertEquals("a", loop.invoke());
     }
 
-    @Test
-    public static void testDoWhileLoop() throws Throwable {
+    @Test(dataProvider = "whileLoopTestData")
+    public static void testDoWhileLoop(MethodHandle MH_zero,
+                                       MethodHandle MH_pred,
+                                       MethodHandle MH_step,
+                                       String messageOrNull) throws Throwable {
         // int i = 0; do { ++i; } while (i < limit); return i; => limit
-        MethodHandle loop = MethodHandles.doWhileLoop(While.MH_zero, While.MH_step, While.MH_pred);
-        assertEquals(While.MT_while, loop.type());
-        assertEquals(23, loop.invoke(23));
+        try {
+            MethodHandle loop = MethodHandles.doWhileLoop(MH_zero, MH_step, MH_pred);
+            assert messageOrNull == null;
+            if (MH_step.type().equals(While.MH_step.type()))
+                assertEquals(While.MT_while, loop.type());
+            assertEquals(MH_step.type().dropParameterTypes(0, 1), loop.type());
+            while (loop.type().parameterCount() > 1)  loop = snip(loop);
+            assertEquals(23, loop.invoke(23));
+        } catch (IllegalArgumentException iae) {
+            assert messageOrNull != null;
+            if (!messageOrNull.equals(iae.getMessage())) {
+                // just issue a warning
+                System.out.println("*** "+messageOrNull+"\n != "+iae.getMessage());
+            }
+        }
     }
 
     @Test
-    public static void testDoWhileNullInit() throws Throwable {
-        While w = new While();
-        int v = 5;
-        MethodHandle loop = MethodHandles.doWhileLoop(null, While.MH_voidBody.bindTo(w), While.MH_voidPred.bindTo(w));
-        assertEquals(While.MT_void, loop.type());
-        loop.invoke(v);
-        assertEquals(v, w.i);
+    public static void testDoWhileBadInit() throws Throwable {
+        boolean caught = false;
+        try {
+            While w = new While();
+            MethodHandle loop = MethodHandles.doWhileLoop(MethodHandles.empty(methodType(char.class)),
+                                                          While.MH_voidBody.bindTo(w),
+                                                          While.MH_voidPred.bindTo(w));
+        } catch (IllegalArgumentException iae) {
+            assertEquals("loop initializer must match: ()char != (int)void", iae.getMessage());
+            caught = true;
+        }
+        assertTrue(caught);
     }
 
     @Test
@@ -260,13 +380,18 @@
     }
 
     @Test
-    public static void testWhileNullInit() throws Throwable {
-        While w = new While();
-        int v = 5;
-        MethodHandle loop = MethodHandles.whileLoop(null, While.MH_voidPred.bindTo(w), While.MH_voidBody.bindTo(w));
-        assertEquals(While.MT_void, loop.type());
-        loop.invoke(v);
-        assertEquals(v, w.i);
+    public static void testWhileBadInit() throws Throwable {
+        boolean caught = false;
+        try {
+            While w = new While();
+            MethodHandle loop = MethodHandles.whileLoop(MethodHandles.empty(methodType(void.class, char.class)),
+                                                        While.MH_voidPred.bindTo(w),
+                                                        While.MH_voidBody.bindTo(w));
+        } catch (IllegalArgumentException iae) {
+            assertEquals("loop initializer must match: (char)void != (int)void", iae.getMessage());
+            caught = true;
+        }
+        assertTrue(caught);
     }
 
     @Test
@@ -291,10 +416,26 @@
         assertEquals(v, w.i);
     }
 
+    @DataProvider
+    static Object[][] nullArgs() {
+        MethodHandle c = MethodHandles.constant(int.class, 1);
+        return new Object[][]{{null, c}, {c, null}};
+    }
+
+    @Test(dataProvider = "nullArgs", expectedExceptions = NullPointerException.class)
+    public static void testWhileNullArgs(MethodHandle pred, MethodHandle body) {
+        MethodHandles.whileLoop(null, pred, body);
+    }
+
+    @Test(dataProvider = "nullArgs", expectedExceptions = NullPointerException.class)
+    public static void testDoWhileNullArgs(MethodHandle body, MethodHandle pred) {
+        MethodHandles.whileLoop(null, body, pred);
+    }
+
     @Test
     public static void testCountedLoop() throws Throwable {
         // String s = "Lambdaman!"; for (int i = 0; i < 13; ++i) { s = "na " + s; } return s; => a variation on a well known theme
-        MethodHandle fit13 = MethodHandles.constant(int.class, 13);
+        MethodHandle fit13 = MethodHandles.dropArguments(MethodHandles.constant(int.class, 13), 0, String.class);
         MethodHandle loop = MethodHandles.countedLoop(fit13, Counted.MH_start, Counted.MH_step);
         assertEquals(Counted.MT_counted, loop.type());
         assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke("Lambdaman!"));
@@ -303,9 +444,25 @@
     @Test
     public static void testCountedLoopVoidInit() throws Throwable {
         MethodHandle fit5 = MethodHandles.constant(int.class, 5);
-        MethodHandle loop = MethodHandles.countedLoop(fit5, MethodHandles.zero(void.class), Counted.MH_printHello);
-        assertEquals(Counted.MT_countedPrinting, loop.type());
-        loop.invoke();
+        for (int i = 0; i < 8; i++) {
+            MethodHandle zero = MethodHandles.zero(void.class);
+            MethodHandle init = fit5;
+            MethodHandle body = Counted.MH_printHello;
+            boolean useNull = (i & 1) != 0, addInitArg = (i & 2) != 0, addBodyArg = (i & 4) != 0;
+            if (useNull)    zero = null;
+            if (addInitArg) init = MethodHandles.dropArguments(init, 0, int.class);
+            if (addBodyArg) body = MethodHandles.dropArguments(body, 1, int.class);
+            System.out.println("testCountedLoopVoidInit i="+i+" : "+Arrays.asList(init, zero, body));
+            MethodHandle loop = MethodHandles.countedLoop(init, zero, body);
+            MethodType expectedType = Counted.MT_countedPrinting;
+            if (addInitArg || addBodyArg)
+                expectedType = expectedType.insertParameterTypes(0, int.class);
+            assertEquals(expectedType, loop.type());
+            if (addInitArg || addBodyArg)
+                loop.invoke(99);
+            else
+                loop.invoke();
+        }
     }
 
     @Test
@@ -327,7 +484,7 @@
         loop.invoke();
     }
 
-    @Test
+    @Test(expectedExceptions = NullPointerException.class)
     public static void testCountedLoopNullBody() throws Throwable {
         MethodHandle h5 = MethodHandles.constant(int.class, 5);
         MethodHandle h13 = MethodHandles.constant(int.class, 13);
@@ -336,14 +493,14 @@
         assertEquals(13, loop.invoke());
     }
 
-    @Test
+    @Test(expectedExceptions = NullPointerException.class)
     public static void testCountedLoopNullIterations() throws Throwable {
         MethodHandle loop = MethodHandles.countedLoop(null, null, null);
         assertEquals(methodType(void.class), loop.type());
         loop.invoke();
     }
 
-    @Test
+    @Test(expectedExceptions = NullPointerException.class)
     public static void testCountedLoopNullInitAndBody() throws Throwable {
         MethodHandle loop = MethodHandles.countedLoop(MethodHandles.constant(int.class, 5), null, null);
         assertEquals(methodType(void.class), loop.type());
@@ -352,45 +509,63 @@
 
     @DataProvider
     static Object[][] countedLoopBodyParameters() {
+        Class<?> V = String.class, I = int.class, A = List.class;
+        // return types are of these forms:
+        //    {count = int(A...), init = V(A...), body = V(V, I, A...)}
         return new Object[][] {
-                {methodType(String.class), methodType(String.class, int.class)},
-                {methodType(String.class, List.class), methodType(String.class, int.class)},
-                {methodType(String.class, List.class), methodType(String.class, int.class, String.class)}
+            // body leads determining A...
+            {methodType(I), methodType(V), methodType(V, V, I)},
+            {methodType(I), methodType(V), methodType(V, V, I, A)},
+            {methodType(I,A), methodType(V), methodType(V, V, I, A)},
+            {methodType(I), methodType(V,A), methodType(V, V, I, A)},
+            // body leads, with void V
+            {methodType(I), methodType(void.class), methodType(void.class, I)},
+            {methodType(I), methodType(void.class), methodType(void.class, I, A)},
+            {methodType(I,A), methodType(void.class), methodType(void.class, I, A)},
+            {methodType(I), methodType(void.class,A), methodType(void.class, I, A)},
+            // count leads determining A..., but only if body drops all A...
+            {methodType(I,A), methodType(V), methodType(V, V, I)},
+            {methodType(I,A), methodType(V,A), methodType(V, V, I)},
+            // count leads, with void V
+            {methodType(I,A), methodType(void.class), methodType(void.class, I)},
+            {methodType(I,A), methodType(void.class,A), methodType(void.class, I)},
         };
     }
 
     @Test(dataProvider = "countedLoopBodyParameters")
-    public static void testCountedLoopBodyParameters(MethodType initType, MethodType bodyType) throws Throwable {
-        MethodHandle loop = MethodHandles.countedLoop(MethodHandles.constant(int.class, 5),
-                MethodHandles.empty(initType), MethodHandles.empty(bodyType));
-        assertEquals(initType, loop.type());
+    public static void testCountedLoopBodyParameters(MethodType countType, MethodType initType, MethodType bodyType) throws Throwable {
+        MethodHandle loop = MethodHandles.countedLoop(
+                MethodHandles.empty(countType),
+                initType == null ? null : MethodHandles.empty(initType),
+                MethodHandles.empty(bodyType));
+        // The rule:  If body takes the minimum number of parameters, then take what countType offers.
+        // The initType has to just roll with whatever the other two agree on.
+        int innerParams = (bodyType.returnType() == void.class ? 1 : 2);
+        MethodType expectType = bodyType.dropParameterTypes(0, innerParams);
+        if (expectType.parameterCount() == 0)
+            expectType = expectType.insertParameterTypes(0, countType.parameterList());
+        assertEquals(expectType, loop.type());
     }
 
-    @DataProvider
-    static Object[][] countedLoopTypes() {
-        return new Object[][]{{void.class}, {int.class}, {Object.class}, {String.class}, {List.class}};
-    }
-
-    @Test(dataProvider = "countedLoopTypes")
-    public static void testCountedLoopBodyParametersNullInit(Class<?> t) throws Throwable {
-        MethodHandle loop = MethodHandles.countedLoop(MethodHandles.constant(int.class, 5), null,
-                MethodHandles.empty(methodType(t, int.class)));
-        assertEquals(methodType(t), loop.type());
-        loop.invoke();
+    @Test(dataProvider = "countedLoopBodyParameters")
+    public static void testCountedLoopBodyParametersNullInit(MethodType countType, MethodType initType, MethodType bodyType) throws Throwable {
+        testCountedLoopBodyParameters(countType, null, bodyType);
     }
 
     @Test
-    public static void testCountedLoopStateDefinedByBody() throws Throwable {
-        MethodHandle loop = MethodHandles.countedLoop(MethodHandles.constant(int.class, 5), null, Counted.MH_stateBody);
+    public static void testCountedLoopStateInitializedToNull() throws Throwable {
+        MethodHandle loop = MethodHandles.countedLoop(MethodHandles.constant(int.class, 5),
+                MethodHandles.empty(methodType(String.class)), Counted.MH_stateBody);
         assertEquals(Counted.MT_bodyDeterminesState, loop.type());
         assertEquals("sssssnull01234", loop.invoke());
     }
 
     @Test
     public static void testCountedLoopArgsDefinedByIterations() throws Throwable {
-        MethodHandle loop = MethodHandles.countedLoop(
-                MethodHandles.dropArguments(MethodHandles.constant(int.class, 3), 0, String.class),
-                null, Counted.MH_append);
+        MethodHandle iterations =
+                MethodHandles.dropArguments(MethodHandles.constant(int.class, 3), 0, String.class);
+        MethodHandle loop = MethodHandles.countedLoop(iterations,
+                MethodHandles.empty(iterations.type().changeReturnType(String.class)), Counted.MH_append);
         assertEquals(Counted.MT_iterationsDefineArgs, loop.type());
         assertEquals("hello012", loop.invoke("hello"));
     }
@@ -420,7 +595,8 @@
     @Test
     public static void testCountedLoopEmpty() throws Throwable {
         // for (int i = 0; i < 5; ++i) { /* empty */ }
-        MethodHandle loop = MethodHandles.countedLoop(MethodHandles.constant(int.class, 5), null, null);
+        MethodHandle loop = MethodHandles.countedLoop(MethodHandles.constant(int.class, 5), null,
+                MethodHandles.empty(methodType(void.class, int.class)));
         assertEquals(methodType(void.class), loop.type());
         loop.invoke();
     }
@@ -429,11 +605,45 @@
     public static void testCountedRangeLoopEmpty() throws Throwable {
         // for (int i = -5; i < 5; ++i) { /* empty */ }
         MethodHandle loop = MethodHandles.countedLoop(MethodHandles.constant(int.class, -5),
-                MethodHandles.constant(int.class, 5), null, null);
+                MethodHandles.constant(int.class, 5), null, MethodHandles.empty(methodType(void.class, int.class)));
         assertEquals(methodType(void.class), loop.type());
         loop.invoke();
     }
 
+    @DataProvider
+    static Object[][] countedLoopNegativeData() {
+        MethodHandle dummy = MethodHandles.zero(void.class);
+        MethodHandle one = MethodHandles.constant(int.class, 1);
+        MethodHandle oneString = MethodHandles.dropArguments(one, 0, String.class);
+        MethodHandle oneDouble = MethodHandles.dropArguments(one, 0, double.class);
+        return new Object[][]{
+                {dummy, one, dummy, dummy, String.format("start/end must return int %s, %s", dummy, one)},
+                {one, dummy, dummy, dummy, String.format("start/end must return int %s, %s", one, dummy)},
+                {oneString, oneDouble, dummy, dummy,
+                        String.format("start and end parameter types must match: %s != %s", oneString.type(),
+                                oneDouble.type())},
+                {oneString, oneString, dummy, dummy,
+                        String.format("start/end and init parameter types must match: %s != %s", oneString.type(),
+                                dummy.type())},
+                {one, one, null, dummy, String.format("actual and expected body signatures must match: %s != %s",
+                        dummy.type(), dummy.type().appendParameterTypes(int.class))}
+        };
+    }
+
+    @Test(dataProvider = "countedLoopNegativeData")
+    public static void testCountedLoopNegative(MethodHandle start, MethodHandle end, MethodHandle init,
+                                               MethodHandle body, String msg) {
+        if (true)  return;  //%%%FIXME%%%%
+        boolean caught = false;
+        try {
+            MethodHandles.countedLoop(start, end, init, body);
+        } catch (IllegalArgumentException iae) {
+            assertEquals(msg, iae.getMessage());
+            caught = true;
+        }
+        assertTrue(caught);
+    }
+
     @Test
     public static void testIterateSum() throws Throwable {
         // Integer[] a = new Integer[]{1,2,3,4,5,6}; int sum = 0; for (int e : a) { sum += e; } return sum; => 21
@@ -442,50 +652,106 @@
         assertEquals(21, loop.invoke(new Integer[]{1, 2, 3, 4, 5, 6}));
     }
 
-    @Test
-    public static void testIterateReverse() throws Throwable {
-        MethodHandle loop = MethodHandles.iteratedLoop(null, Iterate.MH_reverseInit, Iterate.MH_reverseStep);
-        assertEquals(Iterate.MT_reverse, loop.type());
-        List<String> list = Arrays.asList("a", "b", "c", "d", "e");
-        List<String> reversedList = Arrays.asList("e", "d", "c", "b", "a");
-        assertEquals(reversedList, (List<String>) loop.invoke(list));
+    @DataProvider
+    static Object[][] iteratorInits() {
+        return new Object[][]{{Iterate.MH_iteratorFromList}, {Iterate.MH_iteratorFromIterable}, {null}};
+    }
+
+    @Test(dataProvider = "iteratorInits")
+    public static void testIterateReverse(MethodHandle iterator) throws Throwable {
+        // this test uses List as its loop state type; don't try to change that
+        if (iterator != null)
+            iterator = iterator.asType(iterator.type().changeParameterType(0, List.class));
+        for (int i = 0; i < 4; i++) {
+            MethodHandle init = Iterate.MH_reverseInit, body = Iterate.MH_reverseStep;
+            boolean snipInit = (i & 1) != 0, snipBody = (i & 2) != 0;
+            if (snipInit)  init = snip(init);
+            if (snipBody)  body = snip(body);
+            if (!snipInit && snipBody && iterator == null) {
+                // Body does not determine (A...), so the default guy just picks Iterable.
+                // If body insisted on (List), the default guy would adjust himself.
+                // Init has no authority to change the (A...), so must patch init.
+                // All according to plan!
+                init = slap(snip(init), Iterable.class);
+            }
+            System.out.println("testIterateReverse i="+i+" : "+Arrays.asList(iterator, init, body));
+            MethodHandle loop = MethodHandles.iteratedLoop(iterator, init, body);
+            MethodType expectedType = Iterate.MT_reverse;
+            if (iterator == null && i >= 2)
+                expectedType = expectedType.changeParameterType(0, Iterable.class);
+            assertEquals(expectedType, loop.type());
+            List<String> list = Arrays.asList("a", "b", "c", "d", "e");
+            List<String> reversedList = Arrays.asList("e", "d", "c", "b", "a");
+            assertEquals(reversedList, (List<String>) loop.invoke(list));
+        }
     }
 
-    @Test
-    public static void testIterateLength() throws Throwable {
-        MethodHandle loop = MethodHandles.iteratedLoop(null, Iterate.MH_lengthInit, Iterate.MH_lengthStep);
-        assertEquals(Iterate.MT_length, loop.type());
-        List<Double> list = Arrays.asList(23.0, 148.0, 42.0);
-        assertEquals(list.size(), (int) loop.invoke(list));
+    @Test(dataProvider = "iteratorInits")
+    public static void testIterateLength(MethodHandle iterator) throws Throwable {
+        MethodHandle body = Iterate.MH_lengthStep;
+        MethodHandle init = Iterate.MH_lengthInit;
+        MethodType expectedType = Iterate.MT_length;
+        int barity = body.type().parameterCount();
+        Class<?> iteratorSource = iterator == null ? null : iterator.type().parameterType(0);
+        if (iterator != null && iteratorSource != body.type().parameterType(barity-1)) {
+            // adjust body to accept the other type
+            body = body.asType(body.type().changeParameterType(barity-1, iteratorSource));
+            init = init.asType(init.type().changeParameterType(0, iteratorSource));
+            expectedType = expectedType.changeParameterType(0, iteratorSource);
+        }
+        for (;; init = snip(init)) {
+            System.out.println("testIterateLength.init = "+init);
+            MethodHandle loop = MethodHandles.iteratedLoop(iterator, init, body);
+            assertEquals(expectedType, loop.type());
+            List<Double> list = Arrays.asList(23.0, 148.0, 42.0);
+            assertEquals(list.size(), (int) loop.invoke(list));
+            if (init == null)  break;
+        }
     }
 
-    @Test
-    public static void testIterateMap() throws Throwable {
-        MethodHandle loop = MethodHandles.iteratedLoop(null, Iterate.MH_mapInit, Iterate.MH_mapStep);
-        assertEquals(Iterate.MT_map, loop.type());
-        List<String> list = Arrays.asList("Hello", "world", "!");
-        List<String> upList = Arrays.asList("HELLO", "WORLD", "!");
-        assertEquals(upList, (List<String>) loop.invoke(list));
+    @Test(dataProvider = "iteratorInits")
+    public static void testIterateMap(MethodHandle iterator) throws Throwable {
+        MethodHandle body = Iterate.MH_mapStep;
+        MethodHandle init = Iterate.MH_mapInit;
+        MethodType expectedType = Iterate.MT_map;
+        int barity = body.type().parameterCount();
+        Class<?> iteratorSource = iterator == null ? null : iterator.type().parameterType(0);
+        if (iterator != null && iteratorSource != body.type().parameterType(barity-1)) {
+            // adjust body to accept the other type
+            body = body.asType(body.type().changeParameterType(barity-1, iteratorSource));
+            init = init.asType(init.type().changeParameterType(0, iteratorSource));
+            expectedType = expectedType.changeParameterType(0, iteratorSource);
+        }
+        for (; init != null; init = snip(init)) {
+            System.out.println("testIterateMap.init = "+init);
+            MethodHandle loop = MethodHandles.iteratedLoop(iterator, init, body);
+            assertEquals(expectedType, loop.type());
+            List<String> list = Arrays.asList("Hello", "world", "!");
+            List<String> upList = Arrays.asList("HELLO", "WORLD", "!");
+            assertEquals(upList, (List<String>) loop.invoke(list));
+        }
     }
 
-    @Test
-    public static void testIteratePrint() throws Throwable {
-        MethodHandle loop = MethodHandles.iteratedLoop(null, null, Iterate.MH_printStep);
-        assertEquals(Iterate.MT_print, loop.type());
+    @Test(dataProvider = "iteratorInits")
+    public static void testIteratePrint(MethodHandle iterator) throws Throwable {
+        MethodHandle body = Iterate.MH_printStep;
+        MethodType expectedType = Iterate.MT_print;
+        int barity = body.type().parameterCount();
+        Class<?> iteratorSource = iterator == null ? null : iterator.type().parameterType(0);
+        if (iterator != null && iteratorSource != body.type().parameterType(barity-1)) {
+            // adjust body to accept the other type
+            body = body.asType(body.type().changeParameterType(barity-1, iteratorSource));
+            expectedType = expectedType.changeParameterType(0, iteratorSource);
+        }
+        MethodHandle loop = MethodHandles.iteratedLoop(iterator, null, body);
+        assertEquals(expectedType, loop.type());
         loop.invoke(Arrays.asList("hello", "world"));
     }
 
-    @Test
+    @Test(expectedExceptions = NullPointerException.class)
     public static void testIterateNullBody() {
-        boolean caught = false;
-        try {
-            MethodHandles.iteratedLoop(MethodHandles.empty(methodType(Iterator.class, int.class)),
-                    MethodHandles.identity(int.class), null);
-        } catch (IllegalArgumentException iae) {
-            assertEquals("iterated loop body must not be null", iae.getMessage());
-            caught = true;
-        }
-        assertTrue(caught);
+        MethodHandles.iteratedLoop(MethodHandles.empty(methodType(Iterator.class, int.class)),
+                MethodHandles.identity(int.class), null);
     }
 
     @DataProvider
@@ -500,15 +766,18 @@
         try {
             MethodHandles.iteratedLoop(MethodHandles.empty(v), null, MethodHandles.empty(v));
         } catch(IllegalArgumentException iae) {
-            assertEquals("iteratedLoop first argument must have Iterator return type", iae.getMessage());
+            assertEqualsFIXME("iteratedLoop first argument must have Iterator return type", iae.getMessage());
             caught = true;
         }
         assertTrue(caught);
     }
 
-    @Test
-    public static void testIterateVoidInit() throws Throwable {
-        MethodHandle loop = MethodHandles.iteratedLoop(null, Iterate.MH_voidInit, Iterate.MH_printStep);
+    @Test(dataProvider = "iteratorInits")
+    public static void testIterateVoidInit(MethodHandle iterator) throws Throwable {
+        // this test uses List as its loop state type; don't try to change that
+        if (iterator != null)
+            iterator = iterator.asType(iterator.type().changeParameterType(0, List.class));
+        MethodHandle loop = MethodHandles.iteratedLoop(iterator, Iterate.MH_voidInit, Iterate.MH_printStep);
         assertEquals(Iterate.MT_print, loop.type());
         loop.invoke(Arrays.asList("hello", "world"));
     }
@@ -516,60 +785,79 @@
     @DataProvider
     static Object[][] iterateParameters() {
         MethodType i = methodType(int.class);
-        MethodType sil_i = methodType(int.class, String.class, int.class, List.class);
+        MethodType sil_v = methodType(void.class, String.class, int.class, List.class);
+        MethodType isl_i = methodType(int.class, int.class, String.class, List.class);
+        MethodType isli_i = methodType(int.class, int.class, String.class, List.class, int.class);
         MethodType sl_v = methodType(void.class, String.class, List.class);
+        MethodType sli_v = methodType(void.class, String.class, List.class, int.class);
         MethodType l_it = methodType(Iterator.class, List.class);
+        MethodType li_i = methodType(int.class, List.class, int.class);
         MethodType li_it = methodType(Iterator.class, List.class, int.class);
+        MethodType il_it = methodType(Iterator.class, int.class, List.class);
         MethodType l_i = methodType(int.class, List.class);
-        MethodType _it = methodType(Iterator.class);
-        MethodType si_i = methodType(int.class, String.class, int.class);
-        MethodType s_i = methodType(int.class, String.class);
         return new Object[][]{
-                {null, null, sl_v},
-                {null, i, sil_i},
-                {null, l_i, sil_i},
-                {l_it, null, sl_v},
-                {l_it, i, sil_i},
-                {li_it, l_i, sil_i},
-                {l_it, null, sil_i},
-                {li_it, null, sl_v},
-                {_it, l_i, si_i},
-                {_it, l_i, s_i}
+                {l_it, null, sl_v, ""},
+                {l_it, l_i, isl_i, ""},
+                {l_it, null, sl_v, ""},
+                {li_it, li_i, isli_i, ""},
+                {il_it, null, sil_v, "inferred first loop argument must inherit from Iterable: int"},
+                {li_it, null, sli_v, ""},
+                {sl_v, null, sl_v, "iteratedLoop first argument must have Iterator return type"},
+                {li_it, l_it, sl_v,
+                        String.format("iterator and init parameter lists must match: %s != %s", li_it, l_it)},
+                {li_it, li_i, isl_i,
+                        String.format("body types (regard parameter types after index 0, and result type) must match: %s != %s",
+                                isl_i, isl_i.dropParameterTypes(0, 1).appendParameterTypes(int.class))}
         };
     }
 
     @Test(dataProvider = "iterateParameters")
-    public static void testIterateParameters(MethodType it, MethodType in, MethodType bo) throws Throwable {
+    public static void testIterateParameters(MethodType it, MethodType in, MethodType bo, String msg) {
+        boolean negative = !msg.isEmpty();
         MethodHandle iterator = it == null ? null : MethodHandles.empty(it);
         MethodHandle init = in == null ? null : MethodHandles.empty(in);
-        MethodHandle loop = MethodHandles.iteratedLoop(iterator, init, MethodHandles.empty(bo));
-        MethodType lt = loop.type();
-        if (it == null && in == null) {
-            assertEquals(bo.dropParameterTypes(0, 1), lt);
-        } else if (it == null) {
-            if (in.parameterCount() == 0) {
-                assertEquals(bo.dropParameterTypes(0, in.returnType() == void.class ? 1 : 2), lt);
-            } else {
-                assertEquals(methodType(bo.returnType(), in.parameterArray()), lt);
+        boolean caught = false;
+        MethodHandle loop = null;
+        try {
+            loop = MethodHandles.iteratedLoop(iterator, init, MethodHandles.empty(bo));
+        } catch (Throwable t) {
+            if (!negative) {
+                throw t;
             }
-        } else if (in == null) {
-            assertEquals(methodType(bo.returnType(), it.parameterArray()), lt);
-        } else if (it.parameterCount() > in.parameterCount()) {
-            assertEquals(methodType(bo.returnType(), it.parameterArray()), lt);
-        } else if (it.parameterCount() < in.parameterCount()) {
-            assertEquals(methodType(bo.returnType(), in.parameterArray()), lt);
+            assertEqualsFIXME(msg, t.getMessage());
+            caught = true;
+        }
+        if (negative) {
+            assertTrue(caught);
         } else {
-            // both it, in present; with equal parameter list lengths
-            assertEquals(it.parameterList(), lt.parameterList());
-            assertEquals(in.parameterList(), lt.parameterList());
-            assertEquals(bo.returnType(), lt.returnType());
+            MethodType lt = loop.type();
+            if (it == null && in == null) {
+                assertEquals(bo.dropParameterTypes(0, 1), lt);
+            } else if (it == null) {
+                if (in.parameterCount() == 0) {
+                    assertEquals(bo.dropParameterTypes(0, in.returnType() == void.class ? 1 : 2), lt);
+                } else {
+                    assertEquals(methodType(bo.returnType(), in.parameterArray()), lt);
+                }
+            } else if (in == null) {
+                assertEquals(methodType(bo.returnType(), it.parameterArray()), lt);
+            } else if (it.parameterCount() > in.parameterCount()) {
+                assertEquals(methodType(bo.returnType(), it.parameterArray()), lt);
+            } else if (it.parameterCount() < in.parameterCount()) {
+                assertEquals(methodType(bo.returnType(), in.parameterArray()), lt);
+            } else {
+                // both it, in present; with equal parameter list lengths
+                assertEquals(it.parameterList(), lt.parameterList());
+                assertEquals(in.parameterList(), lt.parameterList());
+                assertEquals(bo.returnType(), lt.returnType());
+            }
         }
     }
 
     @Test
     public static void testIteratorSubclass() throws Throwable {
         MethodHandle loop = MethodHandles.iteratedLoop(MethodHandles.empty(methodType(BogusIterator.class, List.class)),
-                null, MethodHandles.empty(methodType(void.class, String.class)));
+                null, MethodHandles.empty(methodType(void.class, String.class, List.class)));
         assertEquals(methodType(void.class, List.class), loop.type());
     }
 
@@ -892,7 +1180,7 @@
             return arg;
         }
 
-        static String step(int counter, String v, String arg) {
+        static String step(String v, int counter) {
             return "na " + v;
         }
 
@@ -904,15 +1192,15 @@
             System.out.print("hello");
         }
 
-        static int addCounter(int counter, int x) {
+        static int addCounter(int x, int counter) {
             return x + counter;
         }
 
-        static String stateBody(int counter, String s) {
+        static String stateBody(String s, int counter) {
             return "s" + s + counter;
         }
 
-        static String append(int counter, String localState, String loopArg) {
+        static String append(String localState, int counter, String loopArg) {
             if (null == localState) {
                 return loopArg + counter;
             }
@@ -922,12 +1210,12 @@
         static final Class<Counted> COUNTED = Counted.class;
 
         static final MethodType MT_start = methodType(String.class, String.class);
-        static final MethodType MT_step = methodType(String.class, int.class, String.class, String.class);
+        static final MethodType MT_step = methodType(String.class, String.class, int.class);
         static final MethodType MT_stepUpdateArray = methodType(void.class, int.class, int[].class);
         static final MethodType MT_printHello = methodType(void.class, int.class);
         static final MethodType MT_addCounter = methodType(int.class, int.class, int.class);
-        static final MethodType MT_stateBody = methodType(String.class, int.class, String.class);
-        static final MethodType MT_append = methodType(String.class, int.class, String.class, String.class);
+        static final MethodType MT_stateBody = methodType(String.class, String.class, int.class);
+        static final MethodType MT_append = methodType(String.class, String.class, int.class, String.class);
 
         static final MethodHandle MH_13;
         static final MethodHandle MH_m5;
@@ -984,7 +1272,7 @@
             return new ArrayList<>();
         }
 
-        static List<String> reverseStep(String e, List<String> r, List<String> l) {
+        static List<String> reverseStep(List<String> r, String e, List<String> l) {
             r.add(0, e);
             return r;
         }
@@ -993,7 +1281,7 @@
             return 0;
         }
 
-        static int lengthStep(Object o, int len, List<Double> l) {
+        static int lengthStep(int len, Object o, List<Double> l) {
             return len + 1;
         }
 
@@ -1001,7 +1289,7 @@
             return new ArrayList<>();
         }
 
-        static List<String> mapStep(String e, List<String> r, List<String> l) {
+        static List<String> mapStep(List<String> r, String e, List<String> l) {
             r.add(e.toUpperCase());
             return r;
         }
@@ -1010,10 +1298,18 @@
             System.out.print(s);
         }
 
-        static void voidInit() {
+        static void voidInit(List<String> l) {
             // empty
         }
 
+        static ListIterator<?> iteratorFromList(List<?> l) {
+            return l.listIterator();
+        }
+
+        static Iterator<?> iteratorFromIterable(Iterable<?> l) {
+            return l.iterator();
+        }
+
         static final Class<Iterate> ITERATE = Iterate.class;
 
         static final MethodType MT_sumIterator = methodType(Iterator.class, Integer[].class);
@@ -1024,12 +1320,15 @@
         static final MethodType MT_mapInit = methodType(List.class, List.class);
 
         static final MethodType MT_sumStep = methodType(int.class, int.class, int.class, Integer[].class);
-        static final MethodType MT_reverseStep = methodType(List.class, String.class, List.class, List.class);
-        static final MethodType MT_lengthStep = methodType(int.class, Object.class, int.class, List.class);
-        static final MethodType MT_mapStep = methodType(List.class, String.class, List.class, List.class);
+        static final MethodType MT_reverseStep = methodType(List.class, List.class, String.class, List.class);
+        static final MethodType MT_lengthStep = methodType(int.class, int.class, Object.class, List.class);
+        static final MethodType MT_mapStep = methodType(List.class, List.class, String.class, List.class);
         static final MethodType MT_printStep = methodType(void.class, String.class, List.class);
 
-        static final MethodType MT_voidInit = methodType(void.class);
+        static final MethodType MT_voidInit = methodType(void.class, List.class);
+
+        static final MethodType MT_iteratorFromList = methodType(ListIterator.class, List.class);
+        static final MethodType MT_iteratorFromIterable = methodType(Iterator.class, Iterable.class);
 
         static final MethodHandle MH_sumIterator;
         static final MethodHandle MH_sumInit;
@@ -1047,6 +1346,9 @@
 
         static final MethodHandle MH_voidInit;
 
+        static final MethodHandle MH_iteratorFromList;
+        static final MethodHandle MH_iteratorFromIterable;
+
         static final MethodType MT_sum = methodType(int.class, Integer[].class);
         static final MethodType MT_reverse = methodType(List.class, List.class);
         static final MethodType MT_length = methodType(int.class, List.class);
@@ -1066,6 +1368,8 @@
                 MH_mapStep = LOOKUP.findStatic(ITERATE, "mapStep", MT_mapStep);
                 MH_printStep = LOOKUP.findStatic(ITERATE, "printStep", MT_printStep);
                 MH_voidInit = LOOKUP.findStatic(ITERATE, "voidInit", MT_voidInit);
+                MH_iteratorFromList = LOOKUP.findStatic(ITERATE, "iteratorFromList", MT_iteratorFromList);
+                MH_iteratorFromIterable = LOOKUP.findStatic(ITERATE, "iteratorFromIterable", MT_iteratorFromIterable);
             } catch (Exception e) {
                 throw new ExceptionInInitializerError(e);
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/DatagramSocket/ReuseAddressTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,466 @@
+/* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.IOException;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.MulticastSocket;
+import java.net.SocketException;
+
+/*
+ * @test
+ * @bug 8153674
+ * @summary Expected SocketException not thrown when calling bind() with
+ *   setReuseAddress(false)
+ * @run main/othervm ReuseAddressTest
+ */
+
+public class ReuseAddressTest {
+
+    String getInfo(DatagramSocket soc) {
+        if (soc == null) {
+            return null;
+        }
+
+        return "localPort: " + soc.getLocalPort()
+                + "; localAddress: " + soc.getLocalAddress()
+                + "; remotePort: " + soc.getPort()
+                + "; remoteAddress: " + soc.getInetAddress()
+                + "; isClosed: " + soc.isClosed()
+                + "; isBound: " + soc.isBound();
+    }
+
+    static InetSocketAddress createSocketAddress(int testMcastPort) throws Exception {
+        InetAddress localAddress = InetAddress.getLocalHost();
+        InetSocketAddress localSocketAddress = new InetSocketAddress(localAddress, testMcastPort);
+        return localSocketAddress;
+    }
+
+    /* standalone interface */
+    public static void main(String argv[]) throws Exception {
+        ReuseAddressTest test = new ReuseAddressTest();
+        test.DatagramSocket0029();
+        test.DatagramSocket0030();
+        test.DatagramSocket0031();
+        test.DatagramSocket0032();
+        test.DatagramSocket0034();
+        test.DatagramSocket0035();
+        test.DatagramSocket2028();
+        test.DatagramSocket2029();
+        test.DatagramSocket2030();
+
+    }
+
+    /**
+     * Equivalence class partitioning with input values orientation for public
+     * void setReuseAddress(boolean on) throws SocketException,
+     * <br><b>on</b>: false.
+     * <br><b>Expected results</b>: getReuseAddress() will return false
+     */
+    public void DatagramSocket0029() throws Exception {
+        String testCaseID = "DatagramSocket0029";
+        System.out.println(" >> " + testCaseID + ": " + "public void setReuseAddress(boolean on) throws SocketException");
+
+        DatagramSocket ds = null;
+        try {
+            ds = new DatagramSocket(null);
+            ds.setReuseAddress(false);
+            if (ds.getReuseAddress() == true) {
+                throw new RuntimeException("SO_REUSEADDR is not set to false");
+            }
+        } catch (IOException e) {
+            e.printStackTrace(System.out);
+            throw new RuntimeException("unexpected: " + e);
+        } catch (SecurityException e) {
+            System.out.println("Security restriction");
+        } finally {
+            if (ds != null) {
+                ds.close();
+            }
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Equivalence class partitioning with input values orientation for public
+     * void setReuseAddress(boolean on) throws SocketException,
+     * <br><b>on</b>: true.
+     * <br><b>Expected results</b>: Allows completely duplicate bindings (same
+     * address and port) on multicast sockets
+     */
+    public void DatagramSocket0030() throws Exception {
+        String testCaseID = "DatagramSocket0030";
+        System.out.println(" >> " + testCaseID + ": " + "public void setReuseAddress(boolean on) throws SocketException");
+
+        MulticastSocket ms1 = null;
+        MulticastSocket ms2 = null;
+        try {
+            InetSocketAddress addr = createSocketAddress(5050);
+
+            ms1 = new MulticastSocket(null);
+            ms1.setReuseAddress(true);
+            if (!ms1.getReuseAddress()) {
+                System.out.println("Cannot check: "
+                        + " safety for SO_REUSEADDR option is not guaranteed");
+            }
+
+            try {
+                ms1.bind(addr);
+            } catch (SocketException e) {
+                throw new RuntimeException("cannot bind first socket to " + addr
+                        + " unexpected " + e);
+            }
+
+            ms2 = new MulticastSocket(null);
+            ms2.setReuseAddress(true);
+            if (!ms2.getReuseAddress()) {
+                System.out.println("Cannot check: "
+                        + " safety for SO_REUSEADDR option is not guaranteed");
+            }
+
+            try {
+                ms2.bind(addr);
+            } catch (SocketException e) {
+                throw new RuntimeException("cannot bind second socket to " + addr
+                        + " unexpected " + e);
+            }
+
+            if (ms1.getLocalPort() != addr.getPort() || !ms1.isBound()
+                    || ms2.getLocalPort() != addr.getPort() || !ms2.isBound()) {
+                System.out.println("bind() fails with: " + addr);
+                System.out.println("  ms1 [" + getInfo(ms1) + "]");
+                System.out.println("  ms2 [" + getInfo(ms2) + "]");
+                System.out.println("  getReuseAddress(): " + ms2.getReuseAddress());
+                throw new RuntimeException("bind() fails with: " + addr);
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace(System.out);
+            throw new RuntimeException("unexpected: " + e);
+        } catch (SecurityException e) {
+            System.out.println("Security restriction");
+        } finally {
+            if (ms1 != null) {
+                ms1.close();
+            }
+            if (ms2 != null) {
+                ms2.close();
+            }
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Equivalence class partitioning with input values orientation for public
+     * void setReuseAddress(boolean on) throws SocketException,
+     * <br><b>on</b>: false.
+     * <br><b>Expected results</b>: The second bind will throw SocketException,
+     * when SO_REUSEADDR disable
+     */
+    public void DatagramSocket0031() throws Exception {
+        String testCaseID = "DatagramSocket0031";
+        System.out.println(" >> " + testCaseID + ": " + "public void setReuseAddress(boolean on) throws SocketException");
+
+        MulticastSocket ms1 = null;
+        MulticastSocket ms2 = null;
+        try {
+            InetSocketAddress addr = createSocketAddress(6060);
+
+            ms1 = new MulticastSocket(null);
+            try {
+                ms1.bind(addr);
+            } catch (SocketException e) {
+                throw new RuntimeException("cannot bind first socket to " + addr
+                        + " unexpected " + e);
+            }
+
+            ms2 = new MulticastSocket(null);
+            ms2.setReuseAddress(false);  // method under test
+
+            try {
+                ms2.bind(addr);
+                System.out.println("No exceptions: ");
+                System.out.println("  addr: " + addr);
+                System.out.println("  ms1 [" + getInfo(ms1) + "]");
+                System.out.println("  ms2 [" + getInfo(ms2) + "]");
+                System.out.println("  getReuseAddress(): " + ms2.getReuseAddress());
+                throw new RuntimeException("no exceptions from bind() with " + addr);
+            } catch (SocketException e) {
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace(System.out);
+            throw new RuntimeException("unexpected: " + e);
+        } catch (SecurityException e) {
+            System.out.println("Security restriction");
+        } finally {
+            if (ms1 != null) {
+                ms1.close();
+            }
+            if (ms2 != null) {
+                ms2.close();
+            }
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Equivalence class partitioning with input values orientation for public
+     * void setReuseAddress(boolean on) throws SocketException,
+     * <br><b>on</b>: true.
+     * <br><b>Expected results</b>: Allows a single process to bind the same
+     * port to multiple sockets as long as each bind specifies a different local
+     * IP address
+     */
+    public void DatagramSocket0032() throws Exception {
+        String testCaseID = "DatagramSocket0032";
+        System.out.println(" >> " + testCaseID + ": " + "public void setReuseAddress(boolean on) throws SocketException");
+
+        DatagramSocket ds1 = null;
+        DatagramSocket ds2 = null;
+        try {
+
+            InetSocketAddress isa = createSocketAddress(7070);
+            InetAddress addr = isa.getAddress();
+            InetAddress wildcard = InetAddress.getByName("0.0.0.0");
+            if (addr.equals(wildcard) || addr.isLoopbackAddress()) {
+                System.out.println("Cannot check: addresses are equal");
+            }
+
+            InetSocketAddress isa1 = new InetSocketAddress(addr, isa.getPort());
+            InetSocketAddress isa2 = new InetSocketAddress(wildcard, isa.getPort());
+
+            ds1 = new DatagramSocket(null);
+            ds1.setReuseAddress(true);    // method under test
+            if (!ds1.getReuseAddress()) {
+                System.out.println("Cannot check: "
+                        + " safety for SO_REUSEADDR option is not guaranteed");
+            }
+            ds1.bind(isa1);
+
+            ds2 = new DatagramSocket(null);
+            ds2.setReuseAddress(true);    // method under test
+            if (!ds2.getReuseAddress()) {
+                System.out.println("Cannot check: "
+                        + " safety for SO_REUSEADDR option is not guaranteed");
+            }
+
+            try {
+                ds2.bind(isa2);
+            } catch (SocketException e) {
+                throw new RuntimeException("cannot bind second socket to " + isa2
+                        + " unexpected " + e);
+            }
+
+            if (ds1.getLocalPort() != isa.getPort() || !ds1.isBound()
+                    || ds2.getLocalPort() != isa.getPort() || !ds2.isBound()) {
+                System.out.println("bind() fails with: " + addr);
+                System.out.println("  ds1 [" + getInfo(ds1) + "]");
+                System.out.println("  ds2 [" + getInfo(ds2) + "]");
+                System.out.println("  getReuseAddress(): " + ds2.getReuseAddress());
+                throw new RuntimeException("bind() fails with: " + addr);
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace(System.out);
+            throw new RuntimeException("unexpected: " + e);
+        } catch (SecurityException e) {
+            System.out.println("Security restriction");
+        } finally {
+            if (ds1 != null) {
+                ds1.close();
+            }
+            if (ds2 != null) {
+                ds2.close();
+            }
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Assertion testing for public int getTrafficClass() throws
+     * SocketException, will return a number in range from 0 to 255 or throw
+     * SocketException.
+     */
+    public void DatagramSocket2028() throws Exception {
+        String testCaseID = "DatagramSocket2028";
+        System.out.println(" >> " + testCaseID + ": " + "public int getTrafficClass() throws SocketException");
+
+        DatagramSocket ds = null;
+        try {
+            ds = new DatagramSocket();
+            int tc = ds.getTrafficClass();
+            if (tc < 0 || tc > 255) {
+                throw new RuntimeException("getTrafficClass() returns: " + tc);
+            }
+        } catch (SecurityException e) {
+            System.out.println("Security restriction: " + e);
+        } catch (SocketException e) {
+            e.printStackTrace(System.out);
+            throw new RuntimeException("Unexpected exception : " + e);
+        } finally {
+            if (ds != null) {
+                ds.close();
+            }
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Assertion testing for public void setTrafficClass(int tc) throws
+     * SocketException, IAE will be thrown with tc less than 0 or greater than
+     * 255.
+     */
+    public void DatagramSocket2029() throws Exception {
+        String testCaseID = "DatagramSocket2029";
+        System.out.println(" >> " + testCaseID + ": " + "public void setTrafficClass(int tc) throws SocketException");
+
+        DatagramSocket ds = null;
+        try {
+            ds = new DatagramSocket();
+        } catch (SecurityException e) {
+            System.out.println("Security restriction: " + e);
+        } catch (IOException e) {
+            e.printStackTrace(System.out);
+            throw new RuntimeException("cannot create socket: " + e);
+        }
+
+        int[] values = {
+            Integer.MIN_VALUE, Integer.MIN_VALUE + 1, -1000, -2, -1,
+            256, 257, 1000, 50000, Integer.MAX_VALUE - 1, Integer.MAX_VALUE
+        };
+
+        for (int i = 0; i < values.length; i++) {
+            try {
+                ds.setTrafficClass(values[i]);
+                System.out.println("No exception with: " + values[i]);
+                System.out.println("getTrafficClass() returns: " + ds.getTrafficClass());
+                ds.close();
+                throw new RuntimeException("setTrafficClass() fails with : " + values[i]);
+            } catch (SocketException e) {
+                ds.close();
+                e.printStackTrace(System.out);
+                throw new RuntimeException("setTrafficClass() throws : " + e);
+            } catch (IllegalArgumentException e) {
+            }
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Assertion testing for public void setTrafficClass(int tc) throws
+     * SocketException, only SocketException may be thrown with tc in range from
+     * 0 to 255.
+     */
+    public void DatagramSocket2030() throws Exception {
+        String testCaseID = "DatagramSocket2030";
+        System.out.println(" >> " + testCaseID + ": " + "public void setTrafficClass(int tc) throws SocketException");
+
+        DatagramSocket ds = null;
+        try {
+            ds = new DatagramSocket();
+        } catch (SecurityException e) {
+            System.out.println("Security restriction: " + e);
+        } catch (IOException e) {
+            e.printStackTrace(System.out);
+            throw new RuntimeException("cannot create socket: " + e);
+        }
+
+        for (int i = 0; i <= 255; i++) {
+            try {
+                ds.setTrafficClass(i);
+            } catch (SocketException e) {
+            }
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Equivalence class partitioning with input values orientation for public
+     * void setBroadcast(boolean on) throws SocketException,
+     * <br><b>on</b>: false.
+     * <br><b>Expected results</b>: getBroadcast() will return false
+     */
+    public void DatagramSocket0034() throws Exception {
+        String testCaseID = "DatagramSocket0034";
+        System.out.println(" >> " + testCaseID + ": " + "public void setBroadcast(boolean on) throws SocketException");
+
+        DatagramSocket ds = null;
+        try {
+            ds = new DatagramSocket();
+            ds.setBroadcast(false);
+            if (ds.getBroadcast() == true) {
+                throw new RuntimeException("SO_BROADCAST is not set to false");
+            }
+        } catch (IOException e) {
+            e.printStackTrace(System.out);
+            throw new RuntimeException("unexpected: " + e);
+        } catch (SecurityException e) {
+            System.out.println("Security restriction");
+        } finally {
+            if (ds != null) {
+                ds.close();
+            }
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Equivalence class partitioning with input values orientation for public
+     * void setBroadcast(boolean on) throws SocketException,
+     * <br><b>on</b>: true.
+     * <br><b>Expected results</b>: getBroadcast() will return true
+     */
+    public void DatagramSocket0035() throws Exception {
+        String testCaseID = "DatagramSocket0035";
+        System.out.println(" >> " + testCaseID + ": " + "public void setBroadcast(boolean on) throws SocketException");
+
+        DatagramSocket ds = null;
+        try {
+            ds = new DatagramSocket();
+            ds.setBroadcast(true);
+            if (ds.getBroadcast() == false) {
+                throw new RuntimeException("SO_BROADCAST is not set to true");
+            }
+        } catch (IOException e) {
+            e.printStackTrace(System.out);
+            throw new RuntimeException("unexpected: " + e);
+        } catch (SecurityException e) {
+            System.out.println("Security restriction");
+        } finally {
+            if (ds != null) {
+                ds.close();
+            }
+        }
+
+        System.out.println("OKAY");
+    }
+}
--- a/jdk/test/java/net/URLClassLoader/getresourceasstream/Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/net/URLClassLoader/getresourceasstream/Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,12 +26,12 @@
 
 public class Test {
     public static void main (String[] args) throws Exception {
-        test1();
+        test1(args[0]);
     }
 
-    public static void test1 () throws Exception {
+    public static void test1 (String s) throws Exception {
         URLClassLoader cl = new URLClassLoader (new URL[] {
-            new URL ("file:./test.jar")
+            new URL ("file:" + s)
         });
         Class clazz = Class.forName ("Test\u00a3", true, cl);
         InputStream is = clazz.getResourceAsStream ("Test\u00a3.class");
--- a/jdk/test/java/net/URLClassLoader/getresourceasstream/test.sh	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/net/URLClassLoader/getresourceasstream/test.sh	Tue Oct 18 17:14:09 2016 +0000
@@ -39,18 +39,33 @@
 
 checkExit () {
     if [ $? != 0 ]; then
-	exit 1;
+	exit $1;
     fi
 }
 
 ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java
 cp ${TESTSRC}/test.jar .
 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
-checkExit 
+${TESTJAVA}/bin/java ${TESTVMOPTS} Test ./test.jar
+checkExit 1
 
 # try with security manager
 
-${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.security.policy=file:./policy -Djava.security.manager Test
-checkExit 
+${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.security.policy=file:./policy \
+		-Djava.security.manager Test ./test.jar
+checkExit 2
+
+mkdir tmp
+cd tmp
+${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.security.policy=file:../policy \
+		-cp .. -Djava.security.manager Test ../test.jar
+checkExit 3
+
+cd ..
+THISDIR=$(basename $(pwd))
+cd ..
+${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.security.policy=file:$THISDIR/policy \
+		-cp $THISDIR -Djava.security.manager Test $THISDIR/test.jar
+checkExit 4
+
 exit 0
--- a/jdk/test/java/net/httpclient/http2/ErrorTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/net/httpclient/http2/ErrorTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -28,6 +28,7 @@
  * @library /lib/testlibrary
  * @build jdk.testlibrary.SimpleSSLContext
  * @modules java.httpclient
+ *          java.security.jgss
  * @compile/module=java.httpclient java/net/http/BodyOutputStream.java
  * @compile/module=java.httpclient java/net/http/BodyInputStream.java
  * @compile/module=java.httpclient java/net/http/EchoHandler.java
@@ -41,18 +42,21 @@
  * @summary check exception thrown when bad TLS parameters selected
  */
 
-import java.io.*;
-import java.net.*;
-import java.net.http.*;
-import static java.net.http.HttpClient.Version.HTTP_2;
-import javax.net.ssl.*;
-import java.nio.file.*;
-import java.util.concurrent.*;
+import java.io.IOException;
+import java.net.URI;
+import java.net.http.EchoHandler;
+import java.net.http.HttpClient;
+import java.net.http.Http2TestServer;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.util.concurrent.ExecutorService;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLParameters;
 import jdk.testlibrary.SimpleSSLContext;
 
+import org.testng.annotations.Test;
 
-import org.testng.annotations.Test;
-import org.testng.annotations.Parameters;
+import static java.net.http.HttpClient.Version.HTTP_2;
 
 /**
  * When selecting an unacceptable cipher suite the TLS handshake will fail.
--- a/jdk/test/java/net/httpclient/http2/HpackDriver.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/net/httpclient/http2/HpackDriver.java	Tue Oct 18 17:14:09 2016 +0000
@@ -33,7 +33,6 @@
  * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.CircularBufferTest
  * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.DecoderTest
  * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.EncoderTest
- * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.HeaderTableTest
  * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.HuffmanTest
  * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.TestHelper
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/httpclient/http2/HpackDriverHeaderTable.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,35 @@
+/*
+ * 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 8153353
+ * @modules java.httpclient/sun.net.httpclient.hpack
+ *          jdk.localedata
+ * @key randomness
+ * @compile/module=java.httpclient sun/net/httpclient/hpack/SpecHelper.java
+ * @compile/module=java.httpclient sun/net/httpclient/hpack/TestHelper.java
+ * @compile/module=java.httpclient sun/net/httpclient/hpack/BuffersTestingKit.java
+ * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.HeaderTableTest
+ */
+public class HpackDriverHeaderTable { }
--- a/jdk/test/java/net/httpclient/security/Driver.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/net/httpclient/security/Driver.java	Tue Oct 18 17:14:09 2016 +0000
@@ -23,10 +23,12 @@
  * questions.
  */
 
-/**
+/*
  * @test
  * @bug 8087112
  * @library /lib/testlibrary/
+ * @modules java.httpclient
+ *          jdk.httpserver
  * @build jdk.testlibrary.SimpleSSLContext jdk.testlibrary.Utils
  * @compile ../../../../com/sun/net/httpserver/LogFilter.java
  * @compile ../../../../com/sun/net/httpserver/FileServerHandler.java
@@ -43,11 +45,14 @@
  * The tests are in Security.java and port number supplied in -Dport.number
  * and -Dport.number1 for tests that require a second free port
  */
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
-import java.io.*;
-import java.net.*;
 
 import jdk.testlibrary.OutputAnalyzer;
 import jdk.testlibrary.Utils;
--- a/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java	Tue Oct 18 17:14:09 2016 +0000
@@ -21,11 +21,19 @@
  * questions.
  */
 
-import java.io.*;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Reader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.SequenceInputStream;
+import java.io.StringWriter;
+import java.io.Writer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.*;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -46,6 +54,7 @@
  * @test
  * @bug 8064924
  * @modules java.compiler
+ *          jdk.compiler
  * @summary Basic test for URLStreamHandlerProvider
  * @library /lib/testlibrary
  * @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
--- a/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
 import java.util.Arrays;
 import java.util.List;
 
-/**
+/*
  * @test
  * @bug 8048362
  * @compile ../../../lib/testlibrary/JavaToolUtils.java
@@ -41,6 +41,7 @@
  * DoPrivAccmplice.jar for reading user.home property from a PrivilagedAction.
  * Run DoPrivTest.jar and try to access user.home property using
  * DoPrivAccmplice.jar.
+ * @modules jdk.compiler
  * @run main/othervm DoPrivAccompliceTest
  */
 
--- a/jdk/test/java/security/Security/ClassLoader/DeprivilegedModuleLoaderTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/security/Security/ClassLoader/DeprivilegedModuleLoaderTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -21,6 +21,17 @@
  * questions.
  */
 
+/*
+ * @test
+ * @bug 8159964
+ * @summary Classes from deprivileged modules should get loaded through
+ *          Platform Classloader.
+ * @modules java.xml.crypto
+ *          jdk.security.auth
+ *          jdk.security.jgss
+ * @run main DeprivilegedModuleLoaderTest
+ */
+
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
@@ -30,13 +41,6 @@
 import com.sun.security.auth.callback.TextCallbackHandler;
 import com.sun.security.jgss.AuthorizationDataEntry;
 
-/*
- * @test
- * @bug 8159964
- * @summary Classes from deprivileged modules should get loaded through
- *          Platform Classloader.
- * @run main DeprivilegedModuleLoaderTest
- */
 public class DeprivilegedModuleLoaderTest {
 
     public static void main(String[] args) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/Signature/ResetAfterException.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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.
+ */
+
+/**
+ * @test
+ * @bug 8149802
+ * @summary Ensure that Signature objects are reset after verification errored out.
+ */
+import java.util.Arrays;
+import java.security.*;
+
+public class ResetAfterException {
+
+    public static void main(String[] args) throws Exception {
+
+        byte[] data = "data to be signed".getBytes();
+        byte[] shortBuffer = new byte[2];
+
+        Provider[] provs = Security.getProviders();
+        boolean failed = false;
+
+        for (Provider p : provs) {
+            Signature sig;
+            try {
+                sig = Signature.getInstance("SHA256withRSA", p);
+            } catch (NoSuchAlgorithmException nsae) {
+                // no support, skip
+                continue;
+            }
+
+            boolean res = true;
+            System.out.println("Testing Provider: " + p.getName());
+            KeyPairGenerator keyGen = null;
+            try {
+                // It's possible that some provider, e.g. SunMSCAPI,
+                // doesn't work well with keys from other providers
+                // so we use the same provider to generate key first
+                keyGen = KeyPairGenerator.getInstance("RSA", p);
+            } catch (NoSuchAlgorithmException nsae) {
+                keyGen = KeyPairGenerator.getInstance("RSA");
+            }
+            if (keyGen == null) {
+                throw new RuntimeException("Error: No support for RSA KeyPairGenerator");
+            }
+            keyGen.initialize(1024);
+            KeyPair keyPair = keyGen.generateKeyPair();
+
+            sig.initSign(keyPair.getPrivate());
+            sig.update(data);
+            byte[] signature = sig.sign();
+            // First check signing
+            try {
+                sig.update(data);
+                // sign with short output buffer to cause exception
+                int len = sig.sign(shortBuffer, 0, shortBuffer.length);
+                System.out.println("FAIL: Should throw SE with short buffer");
+                res = false;
+            } catch (SignatureException e) {
+                // expected exception; ignore
+                System.out.println("Expected Ex for short output buffer: " + e);
+            }
+            // Signature object should reset after a failed generation
+            sig.update(data);
+            byte[] signature2 = sig.sign();
+            if (!Arrays.equals(signature, signature2)) {
+                System.out.println("FAIL: Generated different signature");
+                res = false;
+            } else {
+                System.out.println("Generated same signature");
+            }
+
+            // Now, check signature verification
+            sig.initVerify(keyPair.getPublic());
+            sig.update(data);
+            try {
+                // first verify with valid signature bytes
+                res = sig.verify(signature);
+            } catch (SignatureException e) {
+                System.out.println("FAIL: Valid signature rejected");
+                e.printStackTrace();
+                res = false;
+            }
+
+            try {
+                sig.update(data);
+                // verify with short signaure to cause exception
+                if (sig.verify(shortBuffer)) {
+                    System.out.println("FAIL: Invalid signature verified");
+                    res = false;
+                } else {
+                    System.out.println("Invalid signature rejected");
+                }
+            } catch (SignatureException e) {
+                // expected exception; ignore
+                System.out.println("Expected Ex for short output buffer: " + e);
+            }
+            // Signature object should reset after an a failed verification
+            sig.update(data);
+            try {
+                // verify with valid signature bytes again
+                res = sig.verify(signature);
+                if (!res) {
+                    System.out.println("FAIL: Valid signature is rejected");
+                } else {
+                    System.out.println("Valid signature is accepted");
+                }
+            } catch (GeneralSecurityException e) {
+                System.out.println("FAIL: Valid signature is rejected");
+                e.printStackTrace();
+                res = false;
+            }
+            failed |= !res;
+        }
+        if (failed) {
+            throw new RuntimeException("One or more test failed");
+        } else {
+            System.out.println("Test Passed");
+        }
+   }
+}
--- a/jdk/test/java/security/Signature/SignatureLength.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/security/Signature/SignatureLength.java	Tue Oct 18 17:14:09 2016 +0000
@@ -21,15 +21,20 @@
  * questions.
  */
 
-import java.security.*;
-
 /*
  * @test
  * @bug 8161571
  * @summary Reject signatures presented for verification that contain extra
  *          bytes.
+ * @modules jdk.crypto.ec
  * @run main SignatureLength
  */
+
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.Signature;
+import java.security.SignatureException;
+
 public class SignatureLength {
 
     public static void main(String[] args) throws Exception {
--- a/jdk/test/java/security/testlibrary/Proc.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/security/testlibrary/Proc.java	Tue Oct 18 17:14:09 2016 +0000
@@ -29,6 +29,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.security.Permission;
+import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Base64;
@@ -37,6 +38,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 /**
@@ -49,7 +51,8 @@
  *        .args("x")            // with args
  *        .env("env", "value")  // and an environment variable
  *        .prop("key","value")  // and a system property
- *        .perm(perm)           // with granted permissions
+ *        .grant(file)          // grant codes in this codebase
+ *        .perm(perm)           // with the permission
  *        .start();             // and start
  *
  * create/start must be called, args/env/prop/perm can be called zero or
@@ -57,7 +60,7 @@
  *
  * The controller can call inheritIO to share its I/O to the process.
  * Otherwise, it can send data into a proc's stdin with write/println, and
- * read its stdout with readLine. stderr is always redirected to DFILE
+ * read its stdout with readLine. stderr is always redirected to a file
  * unless nodump() is called. A protocol is designed to make
  * data exchange among the controller and the processes super easy, in which
  * useful data are always printed with a special prefix ("PROCISFUN:").
@@ -84,10 +87,10 @@
  *
  * As the Proc objects are hidden so deeply, two static methods, d(String) and
  * d(Throwable) are provided to output info into stderr, where they will
- * normally be appended messages to DFILE (unless nodump() is called).
+ * normally be appended messages to a debug file (unless nodump() is called).
  * Developers can view the messages in real time by calling
  *
- *    tail -f proc.debug
+ *    {@code tail -f stderr.<debug>}
  *
  * TODO:
  *
@@ -104,19 +107,24 @@
     private BufferedReader br;      // the stdout of a process
     private String launcher;        // Optional: the java program
 
-    private List<Permission> perms = new ArrayList<>();
     private List<String> args = new ArrayList<>();
     private Map<String,String> env = new HashMap<>();
     private Map<String,String> prop = new HashMap();
     private boolean inheritIO = false;
     private boolean noDump = false;
 
+    private List<String> cp;        // user-provided classpath
     private String clazz;           // Class to launch
     private String debug;           // debug flag, controller will show data
-                                    // transfer between procs
+                                    // transfer between procs. If debug is set,
+                                    // it MUST be different between Procs.
 
     final private static String PREFIX = "PROCISFUN:";
-    final private static String DFILE = "proc.debug";
+
+    // policy file
+    final private StringBuilder perms = new StringBuilder();
+    // temporary saving the grant line in a policy file
+    final private StringBuilder grant = new StringBuilder();
 
     // The following methods are called by controllers
 
@@ -168,10 +176,68 @@
         prop.put(a, b);
         return this;
     }
-    // Adds a perm to policy. Can be called multiple times. In order to make it
-    // effective, please also call prop("java.security.manager", "").
+    // Sets classpath. If not called, Proc will choose a classpath. If called
+    // with no arg, no classpath will be used. Can be called multiple times.
+    public Proc cp(String... s) {
+        if (cp == null) {
+            cp = new ArrayList<>();
+        }
+        cp.addAll(Arrays.asList(s));
+        return this;
+    }
+    // Adds a permission to policy. Can be called multiple times.
+    // All perm() calls after a series of grant() calls are grouped into
+    // a single grant block. perm() calls before any grant() call are grouped
+    // into a grant block with no restriction.
+    // Please note that in order to make permissions effective, also call
+    // prop("java.security.manager", "").
     public Proc perm(Permission p) {
-        perms.add(p);
+        if (grant.length() != 0) {      // Right after grant(s)
+            if (perms.length() != 0) {  // Not first block
+                perms.append("};\n");
+            }
+            perms.append("grant ").append(grant).append(" {\n");
+            grant.setLength(0);
+        } else {
+            if (perms.length() == 0) {  // First block w/o restriction
+                perms.append("grant {\n");
+            }
+        }
+        if (p.getActions().isEmpty()) {
+            String s = String.format("%s \"%s\"",
+                    p.getClass().getCanonicalName(),
+                    p.getName()
+                            .replace("\\", "\\\\").replace("\"", "\\\""));
+            perms.append("    permission ").append(s).append(";\n");
+        } else {
+            String s = String.format("%s \"%s\", \"%s\"",
+                    p.getClass().getCanonicalName(),
+                    p.getName()
+                            .replace("\\", "\\\\").replace("\"", "\\\""),
+                    p.getActions());
+            perms.append("    permission ").append(s).append(";\n");
+        }
+        return this;
+    }
+
+    // Adds a grant option to policy. If called in a row, a single grant block
+    // with all options will be created. If there are perm() call(s) between
+    // grant() calls, they belong to different grant blocks
+
+    // grant on a principal
+    public Proc grant(Principal p) {
+        grant.append("principal ").append(p.getClass().getName())
+                .append(" \"").append(p.getName()).append("\", ");
+        return this;
+    }
+    // grant on a codebase
+    public Proc grant(File f) {
+        grant.append("codebase \"").append(f.toURI()).append("\", ");
+        return this;
+    }
+    // arbitrary grant
+    public Proc grant(String v) {
+        grant.append(v).append(", ");
         return this;
     }
     // Starts the proc
@@ -191,30 +257,22 @@
         Collections.addAll(cmd, splitProperty("test.vm.opts"));
         Collections.addAll(cmd, splitProperty("test.java.opts"));
 
-        cmd.add("-cp");
-        cmd.add(System.getProperty("test.class.path") + File.pathSeparator +
-                System.getProperty("test.src.path"));
+        if (cp == null) {
+            cmd.add("-cp");
+            cmd.add(System.getProperty("test.class.path") + File.pathSeparator +
+                    System.getProperty("test.src.path"));
+        } else if (!cp.isEmpty()) {
+            cmd.add("-cp");
+            cmd.add(cp.stream().collect(Collectors.joining(File.pathSeparator)));
+        }
 
         for (Entry<String,String> e: prop.entrySet()) {
             cmd.add("-D" + e.getKey() + "=" + e.getValue());
         }
-        if (!perms.isEmpty()) {
-            Path p = Files.createTempFile(
-                    Paths.get(".").toAbsolutePath(), "policy", null);
-            StringBuilder sb = new StringBuilder();
-            sb.append("grant {\n");
-            for (Permission perm: perms) {
-                // Sometimes a permission has no name or actions.
-                // but it's safe to use an empty string.
-                String s = String.format("%s \"%s\", \"%s\"",
-                        perm.getClass().getCanonicalName(),
-                        perm.getName()
-                                .replace("\\", "\\\\").replace("\"", "\\\""),
-                        perm.getActions());
-                sb.append("    permission ").append(s).append(";\n");
-            }
-            sb.append("};\n");
-            Files.write(p, sb.toString().getBytes());
+        if (perms.length() > 0) {
+            Path p = Paths.get(getId("policy")).toAbsolutePath();
+            perms.append("};\n");
+            Files.write(p, perms.toString().getBytes());
             cmd.add("-Djava.security.policy=" + p.toString());
         }
         cmd.add(clazz);
@@ -223,6 +281,15 @@
         }
         if (debug != null) {
             System.out.println("PROC: " + debug + " cmdline: " + cmd);
+            for (String c : cmd) {
+                if (c.indexOf('\\') >= 0 || c.indexOf(' ') > 0) {
+                    System.out.print('\'' + c + '\'');
+                } else {
+                    System.out.print(c);
+                }
+                System.out.print(' ');
+            }
+            System.out.println();
         }
         ProcessBuilder pb = new ProcessBuilder(cmd);
         for (Entry<String,String> e: env.entrySet()) {
@@ -233,12 +300,17 @@
         } else if (noDump) {
             pb.redirectError(ProcessBuilder.Redirect.INHERIT);
         } else {
-            pb.redirectError(ProcessBuilder.Redirect.appendTo(new File(DFILE)));
+            pb.redirectError(ProcessBuilder.Redirect
+                    .appendTo(new File(getId("stderr"))));
         }
         p = pb.start();
         br = new BufferedReader(new InputStreamReader(p.getInputStream()));
         return this;
     }
+    String getId(String prefix) {
+        if (debug != null) return prefix + "." + debug;
+        else return prefix + "." + System.identityHashCode(this);
+    }
     // Reads a line from stdout of proc
     public String readLine() throws IOException {
         String s = br.readLine();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/text/Format/DecimalFormat/Bug8165466.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,95 @@
+/*
+ * 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 8165466
+ * @summary Checks the subsequent function calls of the DecimalFormat.format()
+ *          method in which the minimumFractionDigit is set to 0 and one of
+ *          the format() call include formatting of the number with zero
+ *          fraction value e.g. 0.00, 9.00
+ */
+
+import java.text.DecimalFormat;
+import java.util.Locale;
+
+public class Bug8165466 {
+
+    public static void main(String[] args) {
+        DecimalFormat nf = (DecimalFormat) DecimalFormat
+                .getPercentInstance(Locale.US);
+        nf.setMaximumFractionDigits(3);
+        nf.setMinimumFractionDigits(0);
+        nf.setMultiplier(1);
+
+        double d = 0.005678;
+        String result = nf.format(d);
+        if (!result.equals("0.006%")) {
+            throw new RuntimeException("[Failed while formatting the double"
+                    + " value: " + d + " Expected: 0.006%, Found: " + result
+                    + "]");
+        }
+
+        d = 0.00;
+        result = nf.format(d);
+        if (!result.equals("0%")) {
+            throw new RuntimeException("[Failed while formatting the double"
+                    + " value: " + d + " Expected: 0%, Found: " + result
+                    + "]");
+        }
+
+        d = 0.005678;
+        result = nf.format(d);
+        if (!result.equals("0.006%")) {
+            throw new RuntimeException("[Failed while formatting the double"
+                    + " value: " + d + " Expected: 0.006%, Found: " + result
+                    + "]");
+        }
+
+        //checking with the non zero value
+        d = 0.005678;
+        result = nf.format(d);
+        if (!result.equals("0.006%")) {
+            throw new RuntimeException("[Failed while formatting the double"
+                    + " value: " + d + " Expected: 0.006%, Found: " + result
+                    + "]");
+        }
+
+        d = 9.00;
+        result = nf.format(d);
+        if (!result.equals("9%")) {
+            throw new RuntimeException("[Failed while formatting the double"
+                    + " value: " + d + " Expected: 9%, Found: " + result
+                    + "]");
+        }
+
+        d = 0.005678;
+        result = nf.format(d);
+        if (!result.equals("0.006%")) {
+            throw new RuntimeException("[Failed while formatting the double"
+                    + " value: " + d + " Expected: 0.006%, Found: " + result
+                    + "]");
+        }
+    }
+
+}
+
--- a/jdk/test/java/text/Format/NumberFormat/DFSSerialization.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/text/Format/NumberFormat/DFSSerialization.java	Tue Oct 18 17:14:09 2016 +0000
@@ -27,13 +27,21 @@
  * @library /java/text/testlib
  * @build DFSSerialization IntlTest HexDumpReader
  * @run main DFSSerialization
- * @summary Three different tests are done. 1.read from the object created using jdk1.4.2  2.create a valid DecimalFormatSymbols object with current JDK, then read the object 3.Try to create an valid DecimalFormatSymbols object by passing null to set null for the exponent separator symbol. Expect the NullPointerException.
+ * @summary Three different tests are done.
+ *    1. read from the object created using jdk1.4.2
+ *    2. create a valid DecimalFormatSymbols object with current JDK, then read the object
+ *    3. Try to create an valid DecimalFormatSymbols object by passing null to set null
+ *       for the exponent separator symbol. Expect the NullPointerException.
  */
 
-import java.awt.*;
-import java.text.*;
-import java.util.*;
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
 
 public class DFSSerialization extends IntlTest{
     public static void main(String[] args) throws Exception {
--- a/jdk/test/java/text/Format/NumberFormat/SerializationLoadTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/text/Format/NumberFormat/SerializationLoadTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -31,10 +31,13 @@
  * @key randomness
  */
 
-import java.awt.*;
-import java.text.*;
-import java.util.*;
-import java.io.*;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
+import java.util.Random;
 
 public class SerializationLoadTest {
 
--- a/jdk/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java	Tue Oct 18 17:14:09 2016 +0000
@@ -49,7 +49,7 @@
 
 /*
  * @test
- * @bug 8081022 8151876
+ * @bug 8081022 8151876 8166875
  * @key randomness
  */
 
--- a/jdk/test/java/time/test/java/time/format/ZoneName.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/time/test/java/time/format/ZoneName.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -378,6 +378,7 @@
         "Europe/Helsinki", "Europe_Eastern", "Europe/Bucharest",
         "America/Nome", "Alaska", "America/Juneau",
         "Asia/Yakutsk", "Yakutsk", "Asia/Yakutsk",
+        "Asia/Yangon", "Myanmar", "Asia/Rangoon",
         "Africa/Conakry", "GMT", "Atlantic/Reykjavik",
         "Asia/Seoul", "Korea", "Asia/Seoul",
         "America/Antigua", "Atlantic", "America/Halifax",
@@ -747,6 +748,7 @@
         "NZ", "Pacific/Auckland",
         "Asia/Tel_Aviv", "Asia/Jerusalem",
         "Hongkong", "Asia/Hong_Kong",
+        "Asia/Rangoon", "Asia/Yangon",
     };
 
     private static final Map<String, String> zidToMzone = new HashMap<>();
--- a/jdk/test/java/util/TimeZone/TimeZoneTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/util/TimeZone/TimeZoneTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 4028006 4044013 4096694 4107276 4107570 4112869 4130885 7039469 7126465 7158483
- *      8008577 8077685 8098547 8133321 8138716 8148446 8151876 8159684
+ *      8008577 8077685 8098547 8133321 8138716 8148446 8151876 8159684 8166875
  * @modules java.base/sun.util.resources
  * @library /java/text/testlib
  * @summary test TimeZone
--- a/jdk/test/java/util/concurrent/tck/AtomicBoolean9Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/util/concurrent/tck/AtomicBoolean9Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -162,6 +162,19 @@
     }
 
     /**
+     * repeated weakCompareAndSetPlain succeeds in changing value when equal
+     * to expected
+     */
+    public void testWeakCompareAndSetPlain() {
+        AtomicBoolean ai = new AtomicBoolean(true);
+        do {} while (!ai.weakCompareAndSetPlain(true, false));
+        do {} while (!ai.weakCompareAndSetPlain(false, false));
+        assertFalse(ai.get());
+        do {} while (!ai.weakCompareAndSetPlain(false, true));
+        assertTrue(ai.get());
+    }
+
+    /**
      * repeated weakCompareAndSetVolatile succeeds in changing value when equal
      * to expected
      */
--- a/jdk/test/java/util/concurrent/tck/AtomicInteger9Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/util/concurrent/tck/AtomicInteger9Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -162,6 +162,19 @@
     }
 
     /**
+     * repeated weakCompareAndSetPlain succeeds in changing value when equal
+     * to expected
+     */
+    public void testWeakCompareAndSetPlain() {
+        AtomicInteger ai = new AtomicInteger(1);
+        do {} while (!ai.weakCompareAndSetPlain(1, 2));
+        do {} while (!ai.weakCompareAndSetPlain(2, -4));
+        assertEquals(-4, ai.get());
+        do {} while (!ai.weakCompareAndSetPlain(-4, 7));
+        assertEquals(7, ai.get());
+    }
+
+    /**
      * repeated weakCompareAndSetVolatile succeeds in changing value when equal
      * to expected
      */
--- a/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -62,6 +62,7 @@
                 () -> aa.compareAndExchange(j, 1, 2),
                 () -> aa.compareAndExchangeAcquire(j, 1, 2),
                 () -> aa.compareAndExchangeRelease(j, 1, 2),
+                () -> aa.weakCompareAndSetPlain(j, 1, 2),
                 () -> aa.weakCompareAndSetVolatile(j, 1, 2),
                 () -> aa.weakCompareAndSetAcquire(j, 1, 2),
                 () -> aa.weakCompareAndSetRelease(j, 1, 2),
@@ -216,6 +217,22 @@
     }
 
     /**
+     * repeated weakCompareAndSetPlain succeeds in changing value when equal
+     * to expected
+     */
+    public void testWeakCompareAndSetPlain() {
+        AtomicIntegerArray aa = new AtomicIntegerArray(SIZE);
+        for (int i = 0; i < SIZE; i++) {
+            aa.set(i, 1);
+            do {} while (!aa.weakCompareAndSetPlain(i, 1, 2));
+            do {} while (!aa.weakCompareAndSetPlain(i, 2, -4));
+            assertEquals(-4, aa.get(i));
+            do {} while (!aa.weakCompareAndSetPlain(i, -4, 7));
+            assertEquals(7, aa.get(i));
+        }
+    }
+
+    /**
      * repeated weakCompareAndSetVolatile succeeds in changing value when equal
      * to expected
      */
--- a/jdk/test/java/util/concurrent/tck/AtomicLong9Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/util/concurrent/tck/AtomicLong9Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -162,6 +162,19 @@
     }
 
     /**
+     * repeated weakCompareAndSetPlain succeeds in changing value when equal
+     * to expected
+     */
+    public void testWeakCompareAndSetPlain() {
+        AtomicLong ai = new AtomicLong(1);
+        do {} while (!ai.weakCompareAndSetPlain(1, 2));
+        do {} while (!ai.weakCompareAndSetPlain(2, -4));
+        assertEquals(-4, ai.get());
+        do {} while (!ai.weakCompareAndSetPlain(-4, 7));
+        assertEquals(7, ai.get());
+    }
+
+    /**
      * repeated weakCompareAndSetVolatile succeeds in changing value when equal
      * to expected
      */
--- a/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -61,6 +61,7 @@
                 () -> aa.compareAndExchange(j, 1, 2),
                 () -> aa.compareAndExchangeAcquire(j, 1, 2),
                 () -> aa.compareAndExchangeRelease(j, 1, 2),
+                () -> aa.weakCompareAndSetPlain(j, 1, 2),
                 () -> aa.weakCompareAndSetVolatile(j, 1, 2),
                 () -> aa.weakCompareAndSetAcquire(j, 1, 2),
                 () -> aa.weakCompareAndSetRelease(j, 1, 2),
@@ -215,6 +216,22 @@
     }
 
     /**
+     * repeated weakCompareAndSetPlain succeeds in changing value when equal
+     * to expected
+     */
+    public void testWeakCompareAndSetPlain() {
+        AtomicLongArray aa = new AtomicLongArray(SIZE);
+        for (int i = 0; i < SIZE; i++) {
+            aa.set(i, 1);
+            do {} while (!aa.weakCompareAndSetPlain(i, 1, 2));
+            do {} while (!aa.weakCompareAndSetPlain(i, 2, -4));
+            assertEquals(-4, aa.get(i));
+            do {} while (!aa.weakCompareAndSetPlain(i, -4, 7));
+            assertEquals(7, aa.get(i));
+        }
+    }
+
+    /**
      * repeated weakCompareAndSetVolatile succeeds in changing value when equal
      * to expected
      */
--- a/jdk/test/java/util/concurrent/tck/AtomicReference9Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/util/concurrent/tck/AtomicReference9Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -162,6 +162,19 @@
     }
 
     /**
+     * repeated weakCompareAndSetPlain succeeds in changing value when equal
+     * to expected
+     */
+    public void testWeakCompareAndSetPlain() {
+        AtomicReference<Integer> ai = new AtomicReference<>(one);
+        do {} while (!ai.weakCompareAndSetPlain(one, two));
+        do {} while (!ai.weakCompareAndSetPlain(two, m4));
+        assertEquals(m4, ai.get());
+        do {} while (!ai.weakCompareAndSetPlain(m4, seven));
+        assertEquals(seven, ai.get());
+    }
+
+    /**
      * repeated weakCompareAndSetVolatile succeeds in changing value when equal
      * to expected
      */
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -61,6 +61,7 @@
                 () -> aa.compareAndExchange(j, null, null),
                 () -> aa.compareAndExchangeAcquire(j, null, null),
                 () -> aa.compareAndExchangeRelease(j, null, null),
+                () -> aa.weakCompareAndSetPlain(j, null, null),
                 () -> aa.weakCompareAndSetVolatile(j, null, null),
                 () -> aa.weakCompareAndSetAcquire(j, null, null),
                 () -> aa.weakCompareAndSetRelease(j, null, null),
@@ -215,6 +216,22 @@
     }
 
     /**
+     * repeated weakCompareAndSetPlain succeeds in changing value when equal
+     * to expected
+     */
+    public void testWeakCompareAndSetPlain() {
+        AtomicReferenceArray<Integer> aa = new AtomicReferenceArray<>(SIZE);
+        for (int i = 0; i < SIZE; i++) {
+            aa.set(i, one);
+            do {} while (!aa.weakCompareAndSetPlain(i, one, two));
+            do {} while (!aa.weakCompareAndSetPlain(i, two, m4));
+            assertEquals(m4, aa.get(i));
+            do {} while (!aa.weakCompareAndSetPlain(i, m4, seven));
+            assertEquals(seven, aa.get(i));
+        }
+    }
+
+    /**
      * repeated weakCompareAndSetVolatile succeeds in changing value when equal
      * to expected
      */
--- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java	Tue Oct 18 17:14:09 2016 +0000
@@ -40,6 +40,7 @@
 import java.util.Arrays;
 import java.util.Map;
 import java.util.Random;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
@@ -133,11 +134,14 @@
         testCustomMultiReleaseValue(value, Map.of(), expected);
     }
 
+    private static final AtomicInteger JAR_COUNT = new AtomicInteger(0);
+
     private void testCustomMultiReleaseValue(String value,
             Map<String, String> extraAttributes, boolean expected)
             throws Exception {
-        creator.buildCustomMultiReleaseJar("custom-mr.jar", value, extraAttributes);
-        File custom = new File(userdir, "custom-mr.jar");
+        String fileName = "custom-mr" + JAR_COUNT.incrementAndGet() + ".jar";
+        creator.buildCustomMultiReleaseJar(fileName, value, extraAttributes);
+        File custom = new File(userdir, fileName);
         try (JarFile jf = new JarFile(custom, true, ZipFile.OPEN_READ, Runtime.version())) {
             Assert.assertEquals(jf.isMultiRelease(), expected);
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/spi/ToolProviderTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 8159855
+ * @summary test ToolProvider SPI
+ * @run main/othervm ToolProviderTest
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.spi.ToolProvider;
+
+public class ToolProviderTest {
+    public static void main(String... args) throws Exception {
+        ToolProviderTest t = new ToolProviderTest();
+        t.run();
+    }
+
+    void run() throws Exception {
+        initServices();
+
+        System.out.println("test without security manager present:");
+        test();
+
+        System.setSecurityManager(new SecurityManager());
+
+        System.out.println("test with security manager present:");
+        test();
+    }
+
+    private void test() throws Exception {
+        ToolProvider testProvider = ToolProvider.findFirst("test").get();
+        int rc = testProvider.run(System.out, System.err, "hello test");
+        if (rc != 0) {
+            throw new Exception("unexpected exit code: " + rc);
+        }
+    }
+
+    private void initServices() throws IOException {
+        Path testClasses = Paths.get(System.getProperty("test.classes"));
+        Path services = testClasses.resolve(Paths.get("META-INF", "services"));
+        Files.createDirectories(services);
+        Files.write(services.resolve(ToolProvider.class.getName()),
+                Arrays.asList(TestProvider.class.getName()));
+    }
+
+    public static class TestProvider implements ToolProvider {
+        public TestProvider() {
+            checkPrivileges();
+        }
+
+        public String name() {
+            return "test";
+        }
+
+        public int run(PrintWriter out, PrintWriter err, String... args) {
+            out.println("Test: " + Arrays.toString(args));
+            return 0;
+        }
+
+        private void checkPrivileges() {
+            boolean haveSecurityManager = (System.getSecurityManager() != null);
+            try {
+                // validate appropriate privileges by checking access to a
+                // system property
+                System.getProperty("java.home");
+                if (haveSecurityManager) {
+                    throw new Error("exception exception not thrown");
+                }
+            } catch (SecurityException e) {
+                if (!haveSecurityManager) {
+                    throw new Error("unexpected exception: " + e);
+                }
+            }
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/crypto/Cipher/EmptyFinalBuffer.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,85 @@
+/*
+ * 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 6946830
+ * @summary Test the Cipher.doFinal() with 0-length buffer
+ * @key randomness
+ */
+
+import java.util.*;
+import java.nio.*;
+
+import java.security.*;
+
+import javax.crypto.*;
+import javax.crypto.spec.*;
+
+public class EmptyFinalBuffer {
+
+    private static final String[] ALGOS = {
+        "AES/ECB/PKCS5Padding", "AES/CBC/PKCS5Padding"
+    };
+
+    public static void main(String[] args) throws Exception {
+
+        Provider[] provs = Security.getProviders();
+
+        SecretKey key = new SecretKeySpec(new byte[16], "AES");
+
+        boolean testFailed = false;
+        for (Provider p : provs) {
+            System.out.println("Testing: " + p.getName());
+            for (String algo : ALGOS) {
+                System.out.print("Algo: " + algo);
+                Cipher c;
+                try {
+                    c = Cipher.getInstance(algo, p);
+                } catch (NoSuchAlgorithmException nsae) {
+                    // skip
+                    System.out.println("=> No Support");
+                    continue;
+                }
+                c.init(Cipher.ENCRYPT_MODE, key);
+                AlgorithmParameters params = c.getParameters();
+                c.init(Cipher.DECRYPT_MODE, key, params);
+                try {
+                    byte[] out = c.doFinal(new byte[0]);
+                    System.out.println("=> Accepted w/ " +
+                        (out == null? "null" : (out.length + "-byte")) +
+                        " output");
+                } catch (Exception e) {
+                    testFailed = true;
+                    System.out.println("=> Rejected w/ Exception");
+                    e.printStackTrace();
+                }
+            }
+        }
+        if (testFailed) {
+            throw new Exception("One or more tests failed");
+        } else {
+            System.out.println("All tests passed");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/WriteAbortTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,169 @@
+/*
+ * 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     8164931
+ * @summary Test verifies that if we call ImageWriter.abort() in
+ *          IIOWriteProgressListener.imageStarted() or
+ *          IIOWriteProgressListener.imageProgress() are we
+ *          calling IIOWriteProgressListener.readAborted() for all readers.
+ * @run     main WriteAbortTest
+ */
+import java.awt.image.BufferedImage;
+import java.io.File;
+import javax.imageio.ImageIO;
+import javax.imageio.stream.ImageInputStream;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.nio.file.Files;
+import javax.imageio.ImageWriter;
+import javax.imageio.event.IIOWriteProgressListener;
+import javax.imageio.stream.ImageOutputStream;
+
+public class WriteAbortTest implements IIOWriteProgressListener {
+
+    ImageWriter writer = null;
+    ImageOutputStream ios = null;
+    BufferedImage bimg = null;
+    File file;
+    boolean startAbort = false;
+    boolean startAborted = false;
+    boolean progressAbort = false;
+    boolean progressAborted = false;
+    Color srccolor = Color.red;
+    int width = 100;
+    int heght = 100;
+
+    public WriteAbortTest(String format) throws Exception {
+        try {
+            System.out.println("Test for format " + format);
+            bimg = new BufferedImage(width, heght,
+                    BufferedImage.TYPE_INT_RGB);
+
+            Graphics2D g = bimg.createGraphics();
+            g.setColor(srccolor);
+            g.fillRect(0, 0, width, heght);
+            g.dispose();
+
+            file = File.createTempFile("src_", "." + format, new File("."));
+            ImageInputStream ios = ImageIO.createImageOutputStream(file);
+
+            ImageWriter writer =
+                    ImageIO.getImageWritersByFormatName(format).next();
+
+            writer.setOutput(ios);
+            writer.addIIOWriteProgressListener(this);
+
+            // Abort writing in IIOWriteProgressListener.imageStarted().
+            startAbort = true;
+            writer.write(bimg);
+            startAbort = false;
+
+            // Abort writing in IIOWriteProgressListener.imageProgress().
+            progressAbort = true;
+            writer.write(bimg);
+            progressAbort = false;
+
+            ios.close();
+            /*
+             * All abort requests from imageStarted,imageProgress
+             * from IIOWriteProgressListener should be reached
+             * otherwise throw RuntimeException.
+             */
+            if (!(startAborted
+                    && progressAborted)) {
+                throw new RuntimeException("All IIOWriteProgressListener abort"
+                        + " requests are not processed for format "
+                        + format);
+            }
+        } finally {
+            Files.delete(file.toPath());
+        }
+    }
+
+    /*
+     * Abstract methods that we need to implement from
+     * IIOWriteProgressListener, and relevant for this test case.
+     */
+    @Override
+    public void imageStarted(ImageWriter source, int imageIndex) {
+        System.out.println("imageStarted called");
+        if (startAbort) {
+            source.abort();
+        }
+    }
+
+    @Override
+    public void imageProgress(ImageWriter source, float percentageDone) {
+        System.out.println("imageProgress called");
+        if (progressAbort) {
+            source.abort();
+        }
+    }
+
+    @Override
+    public void writeAborted(ImageWriter source) {
+        System.out.println("writeAborted called");
+        // Verify IIOWriteProgressListener.imageStarted() abort request.
+        if (startAbort) {
+            System.out.println("imageStarted aborted ");
+            startAborted = true;
+        }
+
+        // Verify IIOWriteProgressListener.imageProgress() abort request.
+        if (progressAbort) {
+            System.out.println("imageProgress aborted ");
+            progressAborted = true;
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+        final String[] formats = {"bmp", "png", "gif", "jpg", "tif"};
+        for (String format : formats) {
+            new WriteAbortTest(format);
+        }
+    }
+
+    /*
+     * Remaining abstract methods that we need to implement from
+     * IIOWriteProgressListener, but not relevant for this test case.
+     */
+    @Override
+    public void imageComplete(ImageWriter source) {
+    }
+
+    @Override
+    public void thumbnailStarted(ImageWriter source, int imageIndex,
+                                 int thumbnailIndex) {
+    }
+
+    @Override
+    public void thumbnailProgress(ImageWriter source, float percentageDone) {
+    }
+
+    @Override
+    public void thumbnailComplete(ImageWriter source) {
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/templates/SSLTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,493 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.SocketTimeoutException;
+import java.security.KeyStore;
+import java.util.Arrays;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+/**
+ * Helper class for JSSE tests.
+ *
+ * Please run in othervm mode.  SunJSSE does not support dynamic system
+ * properties, no way to re-use system properties in samevm/agentvm mode.
+ */
+public class SSLTest {
+
+    public static final String TEST_SRC = System.getProperty("test.src", ".");
+
+    /*
+     * Where do we find the keystores?
+     */
+    public static final String PATH_TO_STORES = "../etc";
+    public static final String KEY_STORE_FILE = "keystore";
+    public static final String TRUST_STORE_FILE = "truststore";
+    public static final String PASSWORD = "passphrase";
+
+    public static final int FREE_PORT = 0;
+
+    // in seconds
+    public static final long CLIENT_SIGNAL_TIMEOUT = 30L;
+    public static final long SERVER_SIGNAL_TIMEOUT = 90L;
+
+    // in millis
+    public static final int CLIENT_TIMEOUT = 15000;
+    public static final int SERVER_TIMEOUT = 30000;
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    private boolean separateServerThread = false;
+
+    /*
+     * What's the server port?  Use any free port by default
+     */
+    private volatile int serverPort;
+
+    private volatile Exception serverException;
+    private volatile Exception clientException;
+
+    private Thread clientThread;
+    private Thread serverThread;
+
+    private Peer serverPeer;
+    private Peer clientPeer;
+
+    private Application serverApplication;
+    private Application clientApplication;
+
+    private SSLContext context;
+
+    /*
+     * Is the server ready to serve?
+     */
+    private final CountDownLatch serverCondition = new CountDownLatch(1);
+
+    /*
+     * Is the client ready to handshake?
+     */
+    private final CountDownLatch clientCondition = new CountDownLatch(1);
+
+    /*
+     * Public API.
+     */
+
+    public static interface Peer {
+        void run(SSLTest test) throws Exception;
+    }
+
+    public static interface Application {
+        void run(SSLSocket socket, SSLTest test) throws Exception;
+    }
+
+    public static void debug() {
+        debug("ssl");
+    }
+
+    public static void debug(String mode) {
+        System.setProperty("javax.net.debug", mode);
+    }
+
+    public static void setup(String keyFilename, String trustFilename,
+            String password) {
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", password);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", password);
+    }
+
+    public static void setup() throws Exception {
+        String keyFilename = TEST_SRC + "/" + PATH_TO_STORES + "/"
+                + KEY_STORE_FILE;
+        String trustFilename = TEST_SRC + "/" + PATH_TO_STORES + "/"
+                + TRUST_STORE_FILE;
+
+        setup(keyFilename, trustFilename, PASSWORD);
+    }
+
+    public static void print(String message, Throwable... errors) {
+        synchronized (System.out) {
+            System.out.println(message);
+            Arrays.stream(errors).forEach(e -> e.printStackTrace(System.out));
+        }
+    }
+
+    public static KeyStore loadJksKeyStore(String filename, String password)
+            throws Exception {
+
+        return loadKeyStore(filename, password, "JKS");
+    }
+
+    public static KeyStore loadKeyStore(String filename, String password,
+            String type) throws Exception {
+
+        KeyStore keystore = KeyStore.getInstance(type);
+        try (FileInputStream fis = new FileInputStream(filename)) {
+            keystore.load(fis, password.toCharArray());
+        }
+        return keystore;
+    }
+
+    public SSLTest setSeparateServerThread(boolean separateServerThread) {
+        this.separateServerThread = separateServerThread;
+        return this;
+    }
+
+    public SSLTest setServerPort(int serverPort) {
+        this.serverPort = serverPort;
+        return this;
+    }
+
+    public int getServerPort() {
+        return serverPort;
+    }
+
+    public SSLTest setSSLContext(SSLContext context) {
+        this.context = context;
+        return this;
+    }
+
+    public SSLContext getSSLContext() {
+        return context;
+    }
+
+    public SSLServerSocketFactory getSSLServerSocketFactory() {
+        if (context != null) {
+            return context.getServerSocketFactory();
+        }
+
+        return (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+    }
+
+    public SSLSocketFactory getSSLSocketFactory() {
+        if (context != null) {
+            return context.getSocketFactory();
+        }
+
+        return (SSLSocketFactory) SSLSocketFactory.getDefault();
+    }
+
+    public void signalServerReady() {
+        serverCondition.countDown();
+    }
+
+    public boolean waitForClientSignal(long timeout, TimeUnit unit)
+            throws InterruptedException {
+
+        return clientCondition.await(timeout, unit);
+    }
+
+    public boolean waitForClientSignal() throws InterruptedException {
+        return waitForClientSignal(CLIENT_SIGNAL_TIMEOUT, TimeUnit.SECONDS);
+    }
+
+    public void signalClientReady() {
+        clientCondition.countDown();
+    }
+
+    public boolean waitForServerSignal(long timeout, TimeUnit unit)
+            throws InterruptedException {
+
+        return serverCondition.await(timeout, unit);
+    }
+
+    public boolean waitForServerSignal() throws InterruptedException {
+        return waitForServerSignal(SERVER_SIGNAL_TIMEOUT, TimeUnit.SECONDS);
+    }
+
+    public SSLTest setServerPeer(Peer serverPeer) {
+        this.serverPeer = serverPeer;
+        return this;
+    }
+
+    public Peer getServerPeer() {
+        return serverPeer;
+    }
+
+    public SSLTest setServerApplication(Application serverApplication) {
+        this.serverApplication = serverApplication;
+        return this;
+    }
+
+    public Application getServerApplication() {
+        return serverApplication;
+    }
+
+    public SSLTest setClientPeer(Peer clientPeer) {
+        this.clientPeer = clientPeer;
+        return this;
+    }
+
+    public Peer getClientPeer() {
+        return clientPeer;
+    }
+
+    public SSLTest setClientApplication(Application clientApplication) {
+        this.clientApplication = clientApplication;
+        return this;
+    }
+
+    public Application getClientApplication() {
+        return clientApplication;
+    }
+
+    public void runTest() throws Exception {
+        if (separateServerThread) {
+            startServer(true, this);
+            startClient(false, this);
+            serverThread.join();
+        } else {
+            startClient(true, this);
+            startServer(false, this);
+            clientThread.join();
+        }
+
+        if (clientException != null || serverException != null) {
+            throw new RuntimeException("Test failed");
+        }
+    }
+
+    public SSLTest() {
+        serverPeer = (test) -> doServerSide(test);
+        clientPeer = (test) -> doClientSide(test);
+        serverApplication = (socket, test) -> runServerApplication(socket);
+        clientApplication = (socket, test) -> runClientApplication(socket);
+    }
+
+    /*
+     * Private part.
+     */
+
+
+    /*
+     * Define the server side of the test.
+     */
+    private static void doServerSide(SSLTest test) throws Exception {
+        SSLServerSocket sslServerSocket;
+
+        // kick start the server side service
+        SSLServerSocketFactory sslssf = test.getSSLServerSocketFactory();
+        sslServerSocket = (SSLServerSocket)sslssf.createServerSocket(FREE_PORT);
+
+        test.setServerPort(sslServerSocket.getLocalPort());
+        print("Server is listening on port " + test.getServerPort());
+
+        // Signal the client, the server is ready to accept connection.
+        test.signalServerReady();
+
+        // Try to accept a connection in 30 seconds.
+        SSLSocket sslSocket;
+        try {
+            sslServerSocket.setSoTimeout(SERVER_TIMEOUT);
+            sslSocket = (SSLSocket) sslServerSocket.accept();
+            print("Server accepted connection");
+        } catch (SocketTimeoutException ste) {
+            sslServerSocket.close();
+
+            // Ignore the test case if no connection within 30 seconds.
+            print("No incoming client connection in 30 seconds. "
+                    + "Ignore in server side.", ste);
+            return;
+        }
+
+        // handle the connection
+        try {
+            // Is it the expected client connection?
+            //
+            // Naughty test cases or third party routines may try to
+            // connection to this server port unintentionally.  In
+            // order to mitigate the impact of unexpected client
+            // connections and avoid intermittent failure, it should
+            // be checked that the accepted connection is really linked
+            // to the expected client.
+            boolean clientIsReady = test.waitForClientSignal();
+
+            if (clientIsReady) {
+                // Run the application in server side.
+                print("Run server application");
+                test.getServerApplication().run(sslSocket, test);
+            } else {    // Otherwise, ignore
+                // We don't actually care about plain socket connections
+                // for TLS communication testing generally.  Just ignore
+                // the test if the accepted connection is not linked to
+                // the expected client or the client connection timeout
+                // in 30 seconds.
+                print("The client is not the expected one or timeout. "
+                        + "Ignore in server side.");
+            }
+        } finally {
+            sslSocket.close();
+            sslServerSocket.close();
+        }
+    }
+
+    /*
+     * Define the server side application of the test for the specified socket.
+     */
+    private static void runServerApplication(SSLSocket socket)
+            throws Exception {
+
+        // here comes the test logic
+        InputStream sslIS = socket.getInputStream();
+        OutputStream sslOS = socket.getOutputStream();
+
+        sslIS.read();
+        sslOS.write(85);
+        sslOS.flush();
+    }
+
+    /*
+     * Define the client side of the test.
+     */
+    private static void doClientSide(SSLTest test) throws Exception {
+
+        // Wait for server to get started.
+        //
+        // The server side takes care of the issue if the server cannot
+        // get started in 90 seconds.  The client side would just ignore
+        // the test case if the serer is not ready.
+        boolean serverIsReady = test.waitForServerSignal();
+        if (!serverIsReady) {
+            print("The server is not ready yet in 90 seconds. "
+                    + "Ignore in client side.");
+            return;
+        }
+
+        SSLSocketFactory sslsf = test.getSSLSocketFactory();
+        try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket()) {
+            try {
+                sslSocket.connect(
+                        new InetSocketAddress("localhost",
+                                test.getServerPort()), CLIENT_TIMEOUT);
+                print("Client connected to server");
+            } catch (IOException ioe) {
+                // The server side may be impacted by naughty test cases or
+                // third party routines, and cannot accept connections.
+                //
+                // Just ignore the test if the connection cannot be
+                // established.
+                print("Cannot make a connection in 15 seconds. "
+                        + "Ignore in client side.", ioe);
+                return;
+            }
+
+            // OK, here the client and server get connected.
+
+            // Signal the server, the client is ready to communicate.
+            test.signalClientReady();
+
+            // There is still a chance in theory that the server thread may
+            // wait client-ready timeout and then quit.  The chance should
+            // be really rare so we don't consider it until it becomes a
+            // real problem.
+
+            // Run the application in client side.
+            print("Run client application");
+            test.getClientApplication().run(sslSocket, test);
+        }
+    }
+
+    /*
+     * Define the client side application of the test for the specified socket.
+     */
+    private static void runClientApplication(SSLSocket socket)
+            throws Exception {
+
+        InputStream sslIS = socket.getInputStream();
+        OutputStream sslOS = socket.getOutputStream();
+
+        sslOS.write(280);
+        sslOS.flush();
+        sslIS.read();
+    }
+
+    private void startServer(boolean newThread, SSLTest test) throws Exception {
+        if (newThread) {
+            serverThread = new Thread() {
+                @Override
+                public void run() {
+                    try {
+                        serverPeer.run(test);
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        print("Server died ...", e);
+                        serverException = e;
+                    }
+                }
+            };
+            serverThread.start();
+        } else {
+            try {
+                serverPeer.run(test);
+            } catch (Exception e) {
+                print("Server failed ...", e);
+                serverException = e;
+            }
+        }
+    }
+
+    private void startClient(boolean newThread, SSLTest test) throws Exception {
+        if (newThread) {
+            clientThread = new Thread() {
+                @Override
+                public void run() {
+                    try {
+                        clientPeer.run(test);
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        print("Client died ...", e);
+                        clientException = e;
+                    }
+                }
+            };
+            clientThread.start();
+        } else {
+            try {
+                clientPeer.run(test);
+            } catch (Exception e) {
+                print("Client failed ...", e);
+                clientException = e;
+            }
+        }
+    }
+}
--- a/jdk/test/javax/sound/sampled/spi/AudioFileReader/ReadersExceptions.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/ReadersExceptions.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,11 +74,56 @@
     // empty channels
     static byte[] wrongAUCh =
             {0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC
+             0, 0, 0, 24, // headerSize
+             0, 0, 0, 0, // dataSize
+             0, 0, 0, 1, // encoding_local AuFileFormat.AU_ULAW_8
+             0, 0, 0, 1, // sampleRate
+             0, 0, 0, 0 // channels
+            };
+    // empty sample rate
+    static byte[] wrongAUSR =
+            {0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC
+             0, 0, 0, 24, // headerSize
+             0, 0, 0, 0, // dataSize
+             0, 0, 0, 1, // encoding_local AuFileFormat.AU_ULAW_8
+             0, 0, 0, 0, // sampleRate
+             0, 0, 0, 1 // channels
+            };
+    // empty header size
+    static byte[] wrongAUEmptyHeader =
+            {0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC
              0, 0, 0, 0, // headerSize
              0, 0, 0, 0, // dataSize
              0, 0, 0, 1, // encoding_local AuFileFormat.AU_ULAW_8
-             0, 0, 0, 0, // sampleRate
-             0, 0, 0, 0 // channels
+             0, 0, 0, 1, // sampleRate
+             0, 0, 0, 1 // channels
+            };
+    // small header size
+    static byte[] wrongAUSmallHeader =
+            {0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC
+             0, 0, 0, 7, // headerSize
+             0, 0, 0, 0, // dataSize
+             0, 0, 0, 1, // encoding_local AuFileFormat.AU_ULAW_8
+             0, 0, 0, 1, // sampleRate
+             0, 0, 0, 1 // channels
+            };
+    // frame size overflow, when result negative
+    static byte[] wrongAUFrameSizeOverflowNegativeResult =
+            {0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC
+             0, 0, 0, 24, // headerSize
+             0, 0, 0, 0, // dataSize
+             0, 0, 0, 5, // encoding_local AuFileFormat.AU_LINEAR_32
+             0, 0, 0, 1, // sampleRate
+             0x7F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF // channels
+            };
+    // frame size overflow, when result positive
+    static byte[] wrongAUFrameSizeOverflowPositiveResult =
+            {0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC
+             0, 0, 0, 24, // headerSize
+             0, 0, 0, 0, // dataSize
+             0, 0, 0, 4, // encoding_local AuFileFormat.AU_LINEAR_24
+             0, 0, 0, 1, // sampleRate
+             0x7F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF // channels
             };
     // empty channels
     static byte[] wrongWAVCh =
@@ -113,8 +158,12 @@
              0, 0, 0, 0, // dataLength
             };
 
-    static byte[][] data = {wrongAIFFCh, wrongAIFFSSL, wrongAIFFSSH, wrongAUCh,
-                            wrongWAVCh, wrongWAVSSB};
+    static byte[][] data = {
+            wrongAIFFCh, wrongAIFFSSL, wrongAIFFSSH, wrongAUCh, wrongAUSR,
+            wrongAUEmptyHeader, wrongAUSmallHeader,
+            wrongAUFrameSizeOverflowNegativeResult,
+            wrongAUFrameSizeOverflowPositiveResult, wrongWAVCh, wrongWAVSSB
+    };
 
     public static void main(final String[] args) throws IOException {
         for (final byte[] bytes : data) {
--- a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RepeatedFormatReader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RepeatedFormatReader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -45,10 +45,10 @@
     };
 
     private static byte[] headerAU = {0x2e, 0x73, 0x6e, 0x64, // AU_SUN_MAGIC
-                                      0, 0, 0, 0, // headerSize
+                                      0, 0, 0, 24, // headerSize
                                       0, 0, 0, 0, // dataSize
                                       0, 0, 0, 1, // encoding
-                                      0, 0, 0, 0, // sampleRate
+                                      0, 0, 0, 1, // sampleRate
                                       0, 0, 0, 1  // channels
     };
 
--- a/jdk/test/javax/swing/JMenuItem/8158566/CloseOnMouseClickPropertyTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/javax/swing/JMenuItem/8158566/CloseOnMouseClickPropertyTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -37,45 +37,67 @@
 
 /*
  * @test
- * @bug 8158566 8160879 8160977
+ * @bug 8158566 8160879 8160977 8158566
  * @summary Provide a Swing property which modifies MenuItemUI behaviour
  */
 public class CloseOnMouseClickPropertyTest {
 
+    private static final String CHECK_BOX_PROP = "CheckBoxMenuItem."
+            + "doNotCloseOnMouseClick";
+    private static final String RADIO_BUTTON_PROP = "RadioButtonMenuItem"
+            + ".doNotCloseOnMouseClick";
+
     private static JFrame frame;
     private static JMenu menu;
 
+    private static TestItem[] TEST_ITEMS = {
+        new TestItem(TestType.CHECK_BOX_MENU_ITEM, true, true),
+        new TestItem(TestType.CHECK_BOX_MENU_ITEM, true, false),
+        new TestItem(TestType.CHECK_BOX_MENU_ITEM, false, true),
+        new TestItem(TestType.CHECK_BOX_MENU_ITEM, false, false),
+
+        new TestItem(TestType.CHECK_BOX_MENU_ITEM, null, true),
+        new TestItem(TestType.CHECK_BOX_MENU_ITEM, null, false),
+        new TestItem(TestType.CHECK_BOX_MENU_ITEM, true, null),
+        new TestItem(TestType.CHECK_BOX_MENU_ITEM, false, null),
+
+
+        new TestItem(TestType.RADIO_BUTTON_MENU_ITEM, true, true),
+        new TestItem(TestType.RADIO_BUTTON_MENU_ITEM, true, false),
+        new TestItem(TestType.RADIO_BUTTON_MENU_ITEM, false, true),
+        new TestItem(TestType.RADIO_BUTTON_MENU_ITEM, false, false),
+
+        new TestItem(TestType.RADIO_BUTTON_MENU_ITEM, true, null),
+        new TestItem(TestType.RADIO_BUTTON_MENU_ITEM, false, null),
+        new TestItem(TestType.RADIO_BUTTON_MENU_ITEM, null, true),
+        new TestItem(TestType.RADIO_BUTTON_MENU_ITEM, null, false),
+
+        new TestItem(TestType.MENU_ITEM, true, true),
+        new TestItem(TestType.MENU_ITEM, true, false),
+        new TestItem(TestType.MENU_ITEM, false, true),
+        new TestItem(TestType.MENU_ITEM, false, false),
+
+        new TestItem(TestType.MENU_ITEM, true, null),
+        new TestItem(TestType.MENU_ITEM, false, null),
+        new TestItem(TestType.MENU_ITEM, null, true),
+        new TestItem(TestType.MENU_ITEM, null, false),
+    };
+
     public static void main(String[] args) throws Exception {
 
         for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
             UIManager.setLookAndFeel(info.getClassName());
-            test(true);
-
-            setProperty(false);
-            test(false);
-
-            setProperty(true);
-            test(true);
+            for (TestItem testItem : TEST_ITEMS) {
+                test(testItem);
+            }
         }
     }
 
-    private static void setProperty(boolean closeOnMouseClick) {
-        UIManager.put("CheckBoxMenuItem.closeOnMouseClick", closeOnMouseClick);
-        UIManager.put("RadioButtonMenuItem.closeOnMouseClick", closeOnMouseClick);
-    }
-
-    private static void test(boolean closeOnMouseClick) throws Exception {
-        for (TestType testType : TestType.values()) {
-            test(testType, closeOnMouseClick);
-        }
-    }
-
-    private static void test(TestType testType, boolean closeOnMouseClick)
-            throws Exception {
+    private static void test(TestItem item) throws Exception {
 
         Robot robot = new Robot();
         robot.setAutoDelay(50);
-        SwingUtilities.invokeAndWait(() -> createAndShowGUI(testType));
+        SwingUtilities.invokeAndWait(() -> createAndShowGUI(item));
         robot.waitForIdle();
 
         Point point = getClickPoint(true);
@@ -94,21 +116,13 @@
             JMenuItem menuItem = menu.getItem(0);
             boolean isShowing = menuItem.isShowing();
             frame.dispose();
-
-            if (TestType.MENU_ITEM.equals(testType)) {
-                if (isShowing) {
-                    throw new RuntimeException("Menu Item is not closed!");
-                }
-            } else {
-                if (isShowing ^ !closeOnMouseClick) {
-                    throw new RuntimeException("Property is not taken into account:"
-                            + " closeOnMouseClick");
-                }
+            if (isShowing ^ item.doNotCloseOnMouseClick()) {
+                throw new RuntimeException("Property is not taken into account!");
             }
         });
     }
 
-    private static void createAndShowGUI(TestType testType) {
+    private static void createAndShowGUI(TestItem testItem) {
 
         frame = new JFrame();
         frame.setSize(300, 300);
@@ -116,23 +130,15 @@
 
         JMenuBar menuBar = new JMenuBar();
         menu = new JMenu("Menu");
-        menu.add(getMenuItem(testType));
+        JMenuItem menuItem = testItem.getMenuItem();
+        testItem.setProperties(menuItem);
+        menu.add(menuItem);
         menuBar.add(menu);
+
         frame.setJMenuBar(menuBar);
         frame.setVisible(true);
     }
 
-    private static JMenuItem getMenuItem(TestType testType) {
-        switch (testType) {
-            case CHECK_BOX_MENU_ITEM:
-                return new JCheckBoxMenuItem("Check Box");
-            case RADIO_BUTTON_MENU_ITEM:
-                return new JRadioButtonMenuItem("Radio Button");
-            default:
-                return new JMenuItem("Menu Item");
-        }
-    }
-
     private static Point getClickPoint(boolean parent) throws Exception {
         Point points[] = new Point[1];
 
@@ -157,4 +163,60 @@
         CHECK_BOX_MENU_ITEM,
         RADIO_BUTTON_MENU_ITEM
     }
-}
+
+    static class TestItem {
+
+        TestType type;
+        Boolean compDoNotCloseOnMouseClick;
+        Boolean lafDoNotCloseOnMouseClick;
+
+        public TestItem(TestType type,
+                        Boolean compDoNotCloseOnMouseClick,
+                        Boolean lafDoNotCloseOnMouseClick)
+        {
+            this.type = type;
+            this.compDoNotCloseOnMouseClick = compDoNotCloseOnMouseClick;
+            this.lafDoNotCloseOnMouseClick = lafDoNotCloseOnMouseClick;
+        }
+
+        boolean doNotCloseOnMouseClick() {
+            switch (type) {
+                case MENU_ITEM:
+                    return false;
+                default:
+                    return compDoNotCloseOnMouseClick != null
+                            ? compDoNotCloseOnMouseClick
+                            : lafDoNotCloseOnMouseClick;
+            }
+        }
+
+        void setProperties(JMenuItem menuItem) {
+            switch (type) {
+                case CHECK_BOX_MENU_ITEM:
+                    menuItem.putClientProperty(CHECK_BOX_PROP, compDoNotCloseOnMouseClick);
+                    UIManager.put(CHECK_BOX_PROP, lafDoNotCloseOnMouseClick);
+                    break;
+                case RADIO_BUTTON_MENU_ITEM:
+                    menuItem.putClientProperty(RADIO_BUTTON_PROP, compDoNotCloseOnMouseClick);
+                    UIManager.put(RADIO_BUTTON_PROP, lafDoNotCloseOnMouseClick);
+                    break;
+                default:
+                    menuItem.putClientProperty(CHECK_BOX_PROP, compDoNotCloseOnMouseClick);
+                    menuItem.putClientProperty(RADIO_BUTTON_PROP, compDoNotCloseOnMouseClick);
+                    UIManager.put(CHECK_BOX_PROP, lafDoNotCloseOnMouseClick);
+                    UIManager.put(RADIO_BUTTON_PROP, lafDoNotCloseOnMouseClick);
+            }
+        }
+
+        JMenuItem getMenuItem() {
+            switch (type) {
+                case CHECK_BOX_MENU_ITEM:
+                    return new JCheckBoxMenuItem("Check Box");
+                case RADIO_BUTTON_MENU_ITEM:
+                    return new JRadioButtonMenuItem("Radio Button");
+                default:
+                    return new JMenuItem("Menu Item");
+            }
+        }
+    }
+}
\ No newline at end of file
--- a/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
  * @key headful
  * @library ../../regtesthelpers
  * @build Util
- * @bug 8033699
+ * @bug 8033699 8154043
  * @summary  Incorrect radio button behavior when pressing tab key
  * @author Vivi An
  * @run main bug8033699
@@ -135,6 +135,7 @@
     private static void runTest1() throws Exception{
         hitKey(robot, KeyEvent.VK_TAB);
         hitKey(robot, KeyEvent.VK_TAB);
+        hitKey(robot, KeyEvent.VK_TAB);
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -163,11 +164,12 @@
     private static void runTest3() throws Exception{
         hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
         hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
+        hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
-                if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) {
+                if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) {
                     System.out.println("Radio button Group/Non Grouped Radio Button SHIFT-Tab Key Test failed");
-                    throw new RuntimeException("Focus is not on Radio Button C as Expected");
+                    throw new RuntimeException("Focus is not on Radio Button A as Expected");
                 }
             }
         });
@@ -175,39 +177,39 @@
 
     // Using arrow key to move focus in radio button group
     private static void runTest4() throws Exception{
-        hitKey(robot, KeyEvent.VK_UP);
-        hitKey(robot, KeyEvent.VK_LEFT);
+        hitKey(robot, KeyEvent.VK_DOWN);
+        hitKey(robot, KeyEvent.VK_RIGHT);
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
-                if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) {
+                if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) {
                     System.out.println("Radio button Group UP/LEFT Arrow Key Move Focus Failed");
-                    throw new RuntimeException("Focus is not on Radio Button A as Expected");
+                    throw new RuntimeException("Focus is not on Radio Button C as Expected");
                 }
             }
         });
     }
 
     private static void runTest5() throws Exception{
-        hitKey(robot, KeyEvent.VK_DOWN);
-        hitKey(robot, KeyEvent.VK_RIGHT);
+        hitKey(robot, KeyEvent.VK_UP);
+        hitKey(robot, KeyEvent.VK_LEFT);
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
-                if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) {
+                if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) {
                     System.out.println("Radio button Group Left/Up Arrow Key Move Focus Failed");
-                    throw new RuntimeException("Focus is not on Radio Button C as Expected");
+                    throw new RuntimeException("Focus is not on Radio Button A as Expected");
                 }
             }
         });
     }
 
     private static void runTest6() throws Exception{
-        hitKey(robot, KeyEvent.VK_DOWN);
-        hitKey(robot, KeyEvent.VK_DOWN);
+        hitKey(robot, KeyEvent.VK_UP);
+        hitKey(robot, KeyEvent.VK_UP);
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn2) {
                     System.out.println("Radio button Group Circle Back To First Button Test");
-                    throw new RuntimeException("Focus is not on Radio Button A as Expected");
+                    throw new RuntimeException("Focus is not on Radio Button B as Expected");
                 }
             }
         });
@@ -229,9 +231,9 @@
         hitKey(robot, KeyEvent.VK_TAB);
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
-                if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) {
+                if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) {
                     System.out.println("Separate Component added in button group layout");
-                    throw new RuntimeException("Focus is not on Radio Button C as Expected");
+                    throw new RuntimeException("Focus is not on Radio Button Single as Expected");
                 }
             }
         });
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/windows/8165594/WindowsClassicHiDPIIconsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,193 @@
+/*
+ * 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.FlowLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.ScrollPaneConstants;
+import javax.swing.SwingUtilities;
+
+/*
+ * @test
+ * @bug 8165594
+ * @key headful
+ * @requires (os.family == "windows")
+ * @summary Bad rendering of Swing UI controls with Windows Classic L&F on HiDPI
+ *          display
+ * @run main/manual/othervm -Dsun.java2d.uiScale=2
+ * -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel
+ * WindowsClassicHiDPIIconsTest
+ */
+
+public class WindowsClassicHiDPIIconsTest {
+
+    private static volatile boolean testResult = false;
+    private static volatile CountDownLatch countDownLatch;
+    private static final String INSTRUCTIONS = "INSTRUCTIONS:\n"
+            + "Check that the icons are painted smoothly on Swing UI controls:\n"
+            + "  - JRadioButton\n"
+            + "  - JCheckBox\n"
+            + "  - JComboBox\n"
+            + "  - JScrollPane (vertical and horizontal scroll bars)\n"
+            + "\n"
+            + "If so, press PASS, else press FAIL.\n";
+
+    public static void main(String args[]) throws Exception {
+        countDownLatch = new CountDownLatch(1);
+
+        SwingUtilities.invokeLater(WindowsClassicHiDPIIconsTest::createUI);
+        countDownLatch.await(15, TimeUnit.MINUTES);
+
+        if (!testResult) {
+            throw new RuntimeException("Test fails!");
+        }
+    }
+
+    private static void createUI() {
+
+        final JFrame mainFrame = new JFrame("Windows Classic L&F icons test");
+        GridBagLayout layout = new GridBagLayout();
+        JPanel mainControlPanel = new JPanel(layout);
+        JPanel resultButtonPanel = new JPanel(layout);
+
+        GridBagConstraints gbc = new GridBagConstraints();
+
+
+        JPanel testPanel = createJPanel();
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        mainControlPanel.add(testPanel, gbc);
+
+        JTextArea instructionTextArea = new JTextArea();
+        instructionTextArea.setText(INSTRUCTIONS);
+        instructionTextArea.setEditable(false);
+        instructionTextArea.setBackground(Color.white);
+
+        gbc.gridx = 0;
+        gbc.gridy = 1;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        mainControlPanel.add(instructionTextArea, gbc);
+
+        JButton passButton = new JButton("Pass");
+        passButton.setActionCommand("Pass");
+        passButton.addActionListener((ActionEvent e) -> {
+            testResult = true;
+            mainFrame.dispose();
+            countDownLatch.countDown();
+
+        });
+
+        JButton failButton = new JButton("Fail");
+        failButton.setActionCommand("Fail");
+        failButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                mainFrame.dispose();
+                countDownLatch.countDown();
+            }
+        });
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        resultButtonPanel.add(passButton, gbc);
+
+        gbc.gridx = 1;
+        gbc.gridy = 0;
+        resultButtonPanel.add(failButton, gbc);
+
+        gbc.gridx = 0;
+        gbc.gridy = 2;
+        mainControlPanel.add(resultButtonPanel, gbc);
+
+        mainFrame.add(mainControlPanel);
+        mainFrame.pack();
+
+        mainFrame.addWindowListener(new WindowAdapter() {
+
+            @Override
+            public void windowClosing(WindowEvent e) {
+                mainFrame.dispose();
+                countDownLatch.countDown();
+            }
+        });
+        mainFrame.setVisible(true);
+    }
+
+    private static JPanel createJPanel() {
+        JPanel panel = new JPanel();
+        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+
+        JPanel iconPanel = new JPanel(new FlowLayout());
+        JRadioButton radioButton = new JRadioButton();
+        radioButton.setSelected(false);
+        iconPanel.add(radioButton);
+        radioButton = new JRadioButton();
+        radioButton.setSelected(true);
+        iconPanel.add(radioButton);
+        panel.add(iconPanel);
+
+        iconPanel = new JPanel(new FlowLayout());
+        JCheckBox checkBox = new JCheckBox();
+        checkBox.setSelected(false);
+        iconPanel.add(checkBox);
+        checkBox = new JCheckBox();
+        checkBox.setSelected(true);
+        iconPanel.add(checkBox);
+        panel.add(iconPanel);
+
+        iconPanel = new JPanel(new FlowLayout());
+        JComboBox<String> comboBox = new JComboBox(new String[]{"111", "222"});
+        iconPanel.add(comboBox);
+        panel.add(iconPanel);
+
+        iconPanel = new JPanel(new FlowLayout());
+        JTextArea textArea = new JTextArea(3, 7);
+        textArea.setText("AAA");
+        JScrollPane scrollPane = new JScrollPane(textArea);
+        scrollPane.setHorizontalScrollBarPolicy(
+                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
+        scrollPane.setVerticalScrollBarPolicy(
+                ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+        iconPanel.add(scrollPane);
+        panel.add(iconPanel);
+
+        return panel;
+    }
+}
--- a/jdk/test/jdk/internal/misc/Unsafe/CopyMemory.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/jdk/internal/misc/Unsafe/CopyMemory.java	Tue Oct 18 17:14:09 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.internal.misc.Unsafe;
-import java.lang.reflect.Field;
 
 /*
  * @test
@@ -40,7 +39,6 @@
      */
     private void testPositive() {
         testSmallCopy(false);
-        testLargeCopy(false);
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/misc/Unsafe/CopyMemoryLarge.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,58 @@
+/*
+ * 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 jdk.internal.misc.Unsafe;
+
+/*
+ * @test
+ * @summary Test Unsafe.copyMemory
+ * @modules java.base/jdk.internal.misc
+ * @requires os.maxMemory > 8G
+ */
+public class CopyMemoryLarge extends CopyCommon {
+    private CopyMemoryLarge() {
+    }
+
+    /**
+     * Run positive tests
+     *
+     * @throws RuntimeException if an error is found
+     */
+    private void testPositive() {
+        testLargeCopy(false);
+    }
+
+    /**
+     * Run all tests
+     *
+     * @throws RuntimeException if an error is found
+     */
+    private void test() {
+        testPositive();
+    }
+
+    public static void main(String[] args) {
+        CopyMemoryLarge cs = new CopyMemoryLarge();
+        cs.test();
+    }
+}
--- a/jdk/test/jdk/internal/misc/Unsafe/CopySwap.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/jdk/internal/misc/Unsafe/CopySwap.java	Tue Oct 18 17:14:09 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.internal.misc.Unsafe;
-import java.lang.reflect.Field;
 
 /*
  * @test
@@ -40,7 +39,6 @@
      */
     private void testPositive() {
         testSmallCopy(true);
-        testLargeCopy(true);
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/misc/Unsafe/CopySwapLarge.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,58 @@
+/*
+ * 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 jdk.internal.misc.Unsafe;
+
+/*
+ * @test
+ * @summary Test Unsafe.copySwapMemory
+ * @modules java.base/jdk.internal.misc
+ * @requires os.maxMemory > 8G
+ */
+public class CopySwapLarge extends CopyCommon {
+    private CopySwapLarge() {
+    }
+
+    /**
+     * Run positive tests
+     *
+     * @throws RuntimeException if an error is found
+     */
+    private void testPositive() {
+        testLargeCopy(true);
+    }
+
+    /**
+     * Run all tests
+     *
+     * @throws RuntimeException if an error is found
+     */
+    private void test() {
+        testPositive();
+    }
+
+    public static void main(String[] args) {
+        CopySwapLarge cs = new CopySwapLarge();
+        cs.test();
+    }
+}
--- a/jdk/test/sun/java2d/cmm/ColorConvertOp/RGBColorConvertTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/java2d/cmm/ColorConvertOp/RGBColorConvertTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,7 +26,6 @@
  * @bug 6279846
  * @summary Verifies that transform between the same ICC color spaces does not
  * change pixels
- * @run main ColorConvertTest
  */
 
 import java.awt.image.*;
--- a/jdk/test/sun/java2d/pipe/hw/RSLAPITest/RSLAPITest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/java2d/pipe/hw/RSLAPITest/RSLAPITest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -47,7 +47,6 @@
 import sun.java2d.Surface;
 import sun.java2d.pipe.BufferedContext;
 import sun.java2d.pipe.RenderQueue;
-import sun.java2d.pipe.hw.AccelDeviceEventListener;
 import sun.java2d.pipe.hw.AccelGraphicsConfig;
 import sun.java2d.pipe.hw.AccelSurface;
 import static java.awt.Transparency.*;
@@ -254,16 +253,6 @@
 
     private static void testContext(final AccelGraphicsConfig agc) {
         BufferedContext c = agc.getContext();
-        final AccelDeviceEventListener l = new AccelDeviceEventListener() {
-            public void onDeviceDispose() {
-                System.out.println("onDeviceDispose invoked");
-                agc.removeDeviceEventListener(this);
-            }
-            public void onDeviceReset() {
-                System.out.println("onDeviceReset invoked");
-            }
-        };
-        agc.addDeviceEventListener(l);
 
         RenderQueue rq = c.getRenderQueue();
         rq.lock();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/java2d/xrender/HugeGradientTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+import javax.swing.*;
+
+/**
+ * @test
+ * @bug 8162591
+ * @summary tests gradients with start/endpoints exceeding Short.MAX coordinates
+ * @author ceisserer
+ */
+public class HugeGradientTest extends Frame {
+        public static volatile boolean success = false;
+
+        public HugeGradientTest() {
+                Image dstImg = getGraphicsConfiguration()
+                        .createCompatibleVolatileImage(30, 30);
+                Graphics2D g = (Graphics2D) dstImg.getGraphics();
+
+                g.setPaint(new LinearGradientPaint(0f, Short.MAX_VALUE, 0f, Short.MAX_VALUE +31,
+                        new float[]{0f, 1f}, new Color[]{Color.BLACK, Color.RED}));
+                g.translate(0, -Short.MAX_VALUE);
+                g.fillRect (0, 0, Short.MAX_VALUE*2 , Short.MAX_VALUE*2);
+
+                BufferedImage readBackImg = new BufferedImage(dstImg.getWidth(null),
+                dstImg.getHeight(null), BufferedImage.TYPE_INT_RGB);
+                readBackImg.getGraphics().drawImage(dstImg, 0, 0, null);
+
+                for (int x = 0; x < readBackImg.getWidth(); x++) {
+                        for (int y = 0; y < readBackImg.getHeight(); y++) {
+                                int redVal = (readBackImg.getRGB(x, y) & 0x00FF0000) >> 16;
+
+                                if (redVal > 127) {
+                                        return;
+                                }
+                        }
+                }
+
+                throw new RuntimeException("Test Failed");
+        }
+
+        public static void main(String[] args) throws Exception {
+                SwingUtilities.invokeLater(new Runnable() {
+                        public void run() {
+                                new HugeGradientTest();
+                        }
+                });
+        }
+}
--- a/jdk/test/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,9 @@
  * @bug 4328195
  * @summary Need to include the alternate subject DN for certs,
  *          https should check for this
- * @run main/othervm ServerIdentityTest
+ * @library /javax/net/ssl/templates
+ * @run main/othervm ServerIdentityTest dnsstore
+ * @run main/othervm ServerIdentityTest ipstore
  *
  *     SunJSSE does not support dynamic system properties, no way to re-use
  *     system properties in samevm/agentvm mode.
@@ -34,242 +36,71 @@
  * @author Yingxian Wang
  */
 
-import java.io.*;
-import java.net.*;
-import javax.net.ssl.*;
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.security.KeyStore;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
 
 public class ServerIdentityTest {
 
-    /*
-     * =============================================================
-     * Set the various variables needed for the tests, then
-     * specify what tests to run on each side.
-     */
-
-    /*
-     * Should we run the client or server in a separate thread?
-     * Both sides can throw exceptions, but do you have a preference
-     * as to which side should be the main thread.
-     */
-    static boolean separateServerThread = true;
-
-    /*
-     * Where do we find the keystores?
-     */
-    static String pathToStores = "./";
-    static String[] keyStoreFiles = {"dnsstore", "ipstore"};
-    static String[] trustStoreFiles = {"dnsstore", "ipstore"};
-    static String passwd = "changeit";
-
-    /*
-     * Is the server ready to serve?
-     */
-    boolean serverReady = false;
-
-    /*
-     * Turn on SSL debugging?
-     */
-    static boolean debug = false;
-
-    /*
-     * If the client or server is doing some kind of object creation
-     * that the other side depends on, and that thread prematurely
-     * exits, you may experience a hang.  The test harness will
-     * terminate all hung threads after its timeout has expired,
-     * currently 3 minutes by default, but you might try to be
-     * smart about it....
-     */
-
-    /*
-     * Define the server side of the test.
-     *
-     * If the server prematurely exits, serverReady will be set to true
-     * to avoid infinite hangs.
-     */
-    void doServerSide() throws Exception {
-        SSLServerSocketFactory sslssf =
-            context.getServerSocketFactory();
-        SSLServerSocket sslServerSocket =
-            (SSLServerSocket) sslssf.createServerSocket(serverPort);
-        serverPort = sslServerSocket.getLocalPort();
-
-        /*
-         * Signal Client, we're ready for his connect.
-         */
-        serverReady = true;
-
-        SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
-        OutputStream sslOS = sslSocket.getOutputStream();
-        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(sslOS));
-        bw.write("HTTP/1.1 200 OK\r\n\r\n\r\n");
-        bw.flush();
-        Thread.sleep(2000);
-        sslSocket.getSession().invalidate();
-        sslSocket.close();
-    }
-
-    /*
-     * Define the client side of the test.
-     *
-     * If the server prematurely exits, serverReady will be set to true
-     * to avoid infinite hangs.
-     */
-    void doClientSide() throws Exception {
-        /*
-         * Wait for server to get started.
-         */
-        while (!serverReady) {
-            Thread.sleep(50);
-        }
-        String host = iphost? "127.0.0.1": "localhost";
-        URL url = new URL("https://"+host+":"+serverPort+"/index.html");
-
-        HttpURLConnection urlc = (HttpURLConnection)url.openConnection();
-        InputStream is = urlc.getInputStream();
-        is.close();
-    }
-
-    /*
-     * =============================================================
-     * The remainder is just support stuff
-     */
-
-    volatile int serverPort = 0;
-
-    volatile Exception serverException = null;
-    volatile Exception clientException = null;
+    private static final String PASSWORD = "changeit";
 
     public static void main(String[] args) throws Exception {
-        SSLSocketFactory reservedSFactory =
-                HttpsURLConnection.getDefaultSSLSocketFactory();
-        try {
-            for (int i = 0; i < keyStoreFiles.length; i++) {
-                String keyFilename =
-                    System.getProperty("test.src", ".") + "/" + pathToStores +
-                    "/" + keyStoreFiles[i];
-                String trustFilename =
-                    System.getProperty("test.src", ".") + "/" + pathToStores +
-                    "/" + trustStoreFiles[i];
+        final String keystore = args[0];
+        String keystoreFilename = SSLTest.TEST_SRC + "/" + keystore;
 
-                System.setProperty("javax.net.ssl.keyStore", keyFilename);
-                System.setProperty("javax.net.ssl.keyStorePassword", passwd);
-                System.setProperty("javax.net.ssl.trustStore", trustFilename);
-                System.setProperty("javax.net.ssl.trustStorePassword", passwd);
-
-                if (debug)
-                    System.setProperty("javax.net.debug", "all");
-                SSLContext context = SSLContext.getInstance("SSL");
+        SSLTest.setup(keystoreFilename, keystoreFilename, PASSWORD);
 
-                KeyManager[] kms = new KeyManager[1];
-                KeyStore ks = KeyStore.getInstance("JKS");
-                FileInputStream fis = new FileInputStream(keyFilename);
-                ks.load(fis, passwd.toCharArray());
-                fis.close();
-                KeyManager km = new MyKeyManager(ks, passwd.toCharArray());
-                kms[0] = km;
-                context.init(kms, null, null);
-                HttpsURLConnection.setDefaultSSLSocketFactory(
-                     context.getSocketFactory());
+        SSLContext context = SSLContext.getInstance("SSL");
 
-                /*
-                 * Start the tests.
-                 */
-                System.out.println("Testing " + keyFilename);
-                new ServerIdentityTest(context, keyStoreFiles[i]);
-            }
-        } finally {
-            HttpsURLConnection.setDefaultSSLSocketFactory(reservedSFactory);
-        }
-    }
-
-    Thread clientThread = null;
-    Thread serverThread = null;
-
-    /*
-     * Primary constructor, used to drive remainder of the test.
-     *
-     * Fork off the other side, then do your work.
-     */
-    SSLContext context;
-    boolean iphost = false;
-    ServerIdentityTest(SSLContext context, String keystore)
-        throws Exception {
-        this.context = context;
-        iphost = keystore.equals("ipstore");
-        if (separateServerThread) {
-            startServer(true);
-            startClient(false);
-        } else {
-            startClient(true);
-            startServer(false);
-        }
+        KeyManager[] kms = new KeyManager[1];
+        KeyStore ks = SSLTest.loadJksKeyStore(keystoreFilename, PASSWORD);
+        KeyManager km = new MyKeyManager(ks, PASSWORD.toCharArray());
+        kms[0] = km;
+        context.init(kms, null, null);
+        HttpsURLConnection.setDefaultSSLSocketFactory(
+                context.getSocketFactory());
 
         /*
-         * Wait for other side to close down.
+         * Start the test.
          */
-        if (separateServerThread) {
-            serverThread.join();
-        } else {
-            clientThread.join();
-        }
-
-        /*
-         * When we get here, the test is pretty much over.
-         *
-         * If the main thread excepted, that propagates back
-         * immediately.  If the other thread threw an exception, we
-         * should report back.
-         */
-        if (serverException != null)
-            throw serverException;
-        if (clientException != null)
-            throw clientException;
-    }
+        System.out.println("Testing " + keystore);
 
-    void startServer(boolean newThread) throws Exception {
-        if (newThread) {
-            serverThread = new Thread() {
-                public void run() {
-                    try {
-                        doServerSide();
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                        /*
-                         * Our server thread just died.
-                         *
-                         * Release the client, if not active already...
-                         */
-                        System.err.println("Server died...");
-                        serverReady = true;
-                        serverException = e;
-                    }
+        new SSLTest()
+            .setSSLContext(context)
+            .setServerApplication((socket, test) -> {
+                BufferedWriter bw = new BufferedWriter(
+                        new OutputStreamWriter(socket.getOutputStream()));
+                bw.write("HTTP/1.1 200 OK\r\n\r\n\r\n");
+                bw.flush();
+                Thread.sleep(2000);
+                socket.getSession().invalidate();
+                SSLTest.print("Server application is done");
+            })
+            .setClientPeer((test) -> {
+                boolean serverIsReady = test.waitForServerSignal();
+                if (!serverIsReady) {
+                    SSLTest.print(
+                            "The server is not ready, ignore on client side.");
+                    return;
                 }
-            };
-            serverThread.start();
-        } else {
-            doServerSide();
-        }
-    }
+
+                // Signal the server, the client is ready to communicate.
+                test.signalClientReady();
 
-    void startClient(boolean newThread) throws Exception {
-        if (newThread) {
-            clientThread = new Thread() {
-                public void run() {
-                    try {
-                        doClientSide();
-                    } catch (Exception e) {
-                        /*
-                         * Our client thread just died.
-                         */
-                        System.err.println("Client died...");
-                        clientException = e;
-                    }
-                }
-            };
-            clientThread.start();
-        } else {
-            doClientSide();
-        }
+                String host = keystore.equals("ipstore")
+                        ? "127.0.0.1" : "localhost";
+                URL url = new URL("https://" + host + ":" + test.getServerPort()
+                        + "/index.html");
+
+                ((HttpURLConnection) url.openConnection())
+                        .getInputStream().close();
+
+                SSLTest.print("Client is done");
+            }).runTest();
     }
 }
--- a/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java	Tue Oct 18 17:14:09 2016 +0000
@@ -27,6 +27,7 @@
  * @summary Test that URL connections to multi-release jars can be runtime versioned
  * @library /lib/testlibrary/java/util/jar
  * @modules java.compiler
+ *          jdk.compiler
  *          jdk.httpserver
  *          jdk.jartool
  * @build Compiler JarBuilder CreateMultiReleaseTestJars SimpleHttpServer
--- a/jdk/test/sun/security/provider/PolicyFile/CanonPath.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/security/provider/PolicyFile/CanonPath.java	Tue Oct 18 17:14:09 2016 +0000
@@ -150,9 +150,9 @@
             //
             // on unix, /- implies everything
 
-            if (w.implies(u) || !u.implies(w)) {
-                throw new Exception("SLASH/- test failed");
-            }
+            //if (w.implies(u) || !u.implies(w)) {
+            //    throw new Exception("SLASH/- test failed");
+            //}
         }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/util/FilePermCompat/CompatImpact.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,270 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8164705
+ * @summary check compatibility after FilePermission change
+ * @library /java/security/testlibrary/
+ * @modules java.base/jdk.internal.misc
+ * @run main CompatImpact prepare
+ * @run main CompatImpact builtin
+ * @run main CompatImpact mine
+ * @run main CompatImpact dopriv
+ */
+
+import java.io.File;
+import java.io.FilePermission;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.AccessController;
+import java.security.AllPermission;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Policy;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+import java.security.SecurityPermission;
+
+public class CompatImpact {
+
+    public static void main(String[] args) throws Exception {
+        switch (args[0]) {
+            // copy class files to future classpath
+            case "prepare":
+                // cp in .
+                String cp = System.getProperty("test.classes");
+                Files.copy(Paths.get(cp, "CompatImpact.class"),
+                        Paths.get("CompatImpact.class"));
+                Files.copy(Paths.get(cp, "CompatImpact$MP.class"),
+                        Paths.get("CompatImpact$MP.class"));
+                Files.write(Paths.get("f"), new byte[10]);
+                // cp in ./sub
+                Files.createDirectory(Paths.get("sub"));
+                Files.copy(Paths.get(cp, "CompatImpact.class"),
+                        Paths.get("sub", "CompatImpact.class"));
+                Files.copy(Paths.get(cp, "CompatImpact$MP.class"),
+                        Paths.get("sub", "CompatImpact$MP.class"));
+                Files.write(Paths.get("sub", "f"), new byte[10]);
+                // cp in ./inner
+                Files.createDirectory(Paths.get("inner"));
+                Files.copy(Paths.get(cp, "CompatImpact$DoPrivInner.class"),
+                        Paths.get("inner", "CompatImpact$DoPrivInner.class"));
+                break;
+            // run tests with different policy impls
+            case "builtin":
+            case "mine":
+                cp = System.getProperty("test.classes");
+                Proc p;
+                String failed = "";
+                String testcase = "";
+                String cwd = System.getProperty("user.dir");
+
+                // Granting a FilePermission on an absolute path
+                testcase = "PonA";
+                p = p(args[0], cwd + "/f")
+                        .args("f", cwd + "/f")
+                        .debug(testcase)
+                        .start();
+                if (p.waitFor() != 0) {
+                    Files.copy(Paths.get("stderr." + testcase), System.out);
+                    failed += testcase + " ";
+                }
+
+                // Granting a FilePermission on a relative path
+                testcase = "PonR";
+                p = p(args[0], "f")
+                        .args("f", cwd + "/f")
+                        .debug(testcase)
+                        .start();
+                if (p.waitFor() != 0) {
+                    Files.copy(Paths.get("stderr." + testcase), System.out);
+                    failed += testcase + " ";
+                }
+
+                // Reading file on classpath, not cwd
+                testcase = "cp";
+                String cprel = Paths.get(cwd).relativize(Paths.get(cp))
+                        .normalize().toString();
+                p = p(args[0], "x")
+                        .args(cp + "/f", cprel + "/f")
+                        .debug(testcase)
+                        .start();
+                if (p.waitFor() != 0) {
+                    Files.copy(Paths.get("stderr." + testcase), System.out);
+                    failed += testcase + " ";
+                }
+
+                // Reading file on classpath, cwd
+                testcase = "cpHere";
+                p = p(args[0], "x")
+                        .args(cwd + "/f", "f", "RES")
+                        .cp(".")   // Must! cancel the old CLASSPATH.
+                        .debug(testcase)
+                        .start();
+                if (p.waitFor() != 0) {
+                    Files.copy(Paths.get("stderr." + testcase), System.out);
+                    failed += testcase + " ";
+                }
+
+                // Reading file on classpath, cwd
+                testcase = "cpSub";
+                p = p(args[0], "x")
+                        .args(cwd + "/sub/f", "sub/f", "RES")
+                        .cp("sub")   // Must! There's CLASSPATH.
+                        .debug(testcase)
+                        .start();
+                if (p.waitFor() != 0) {
+                    Files.copy(Paths.get("stderr." + testcase), System.out);
+                    failed += testcase + " ";
+                }
+
+                if (!failed.isEmpty()) {
+                    throw new Exception(failed + "failed");
+                }
+                break;
+            // test <policy_type> <grant> <read...>
+            case "test":
+                if (args[1].equals("mine")) {
+                    Policy.setPolicy(new MP(args[2]));
+                }
+                Exception e = null;
+                for (int i = 3; i < args.length; i++) {
+                    try {
+                        System.out.println(args[i]);
+                        if (args[i].equals("RES")) {
+                            CompatImpact.class.getResourceAsStream("f")
+                                    .close();
+                        } else {
+                            new File(args[i]).exists();
+                        }
+                    } catch (Exception e2) {
+                        e = e2;
+                        e2.printStackTrace(System.out);
+                    }
+                }
+                if (e != null) {
+                    System.err.println("====================");
+                    throw e;
+                }
+                break;
+            // doPrivWithPerm test launcher
+            case "dopriv":
+                cwd = System.getProperty("user.dir");
+                // caller (CompatImpact doprivouter, no permission) in sub,
+                // executor (DoPrivInner, AllPermission) in inner.
+                p = Proc.create("CompatImpact")
+                        .args("doprivouter")
+                        .prop("java.security.manager", "")
+                        .grant(new File("inner"))
+                        .perm(new AllPermission())
+                        .cp("sub", "inner")
+                        .debug("doPriv")
+                        .args(cwd)
+                        .start();
+                if (p.waitFor() != 0) {
+                    throw new Exception("dopriv test fails");
+                }
+                break;
+            // doprivouter <cwd>
+            case "doprivouter":
+                DoPrivInner.main(args);
+                break;
+            default:
+                throw new Exception("unknown " + args[0]);
+        }
+    }
+
+    // Call by CompatImpact doprivouter, with AllPermission
+    public static class DoPrivInner {
+        public static void main(String[] args) throws Exception {
+            AccessController.doPrivileged((PrivilegedAction<Boolean>)
+                            () -> new File("x").exists(),
+                    null,
+                    new FilePermission(args[1] + "/x", "read"));
+            AccessController.doPrivileged((PrivilegedAction<Boolean>)
+                            () -> new File(args[1] + "/x").exists(),
+                    null,
+                    new FilePermission("x", "read"));
+            try {
+                AccessController.doPrivileged((PrivilegedAction<Boolean>)
+                                () -> new File("x").exists(),
+                        null,
+                        new FilePermission("y", "read"));
+                throw new Exception("Should not read");
+            } catch (SecurityException se) {
+                // Expected
+            }
+        }
+    }
+
+    // Return a Proc object for different policy types
+    private static Proc p(String type, String f) throws Exception {
+        Proc p = Proc.create("CompatImpact")
+                .prop("java.security.manager", "");
+        p.args("test", type);
+        switch (type) {
+            case "builtin":
+                // For builtin policy, reading access to f can be
+                // granted as a permission
+                p.perm(new FilePermission(f, "read"));
+                p.args("-");
+                break;
+            case "mine":
+                // For my policy, f is passed into test and new MP(f)
+                // will be set as new policy
+                p.perm(new SecurityPermission("setPolicy"));
+                p.args(f);
+                break;
+            default:
+                throw new Exception("unknown " + type);
+        }
+        return p;
+    }
+
+    // My own Policy impl, with only one granted permission, also not smart
+    // enough to know whether ProtectionDomain grants any permission
+    static class MP extends Policy {
+        final PermissionCollection pc;
+        MP(String f) {
+            FilePermission p = new FilePermission(f, "read");
+            pc = p.newPermissionCollection();
+            pc.add(p);
+        }
+        @Override
+        public PermissionCollection getPermissions(CodeSource codesource) {
+            return pc;
+        }
+
+        @Override
+        public PermissionCollection getPermissions(ProtectionDomain domain) {
+            return pc;
+        }
+
+        @Override
+        public boolean implies(ProtectionDomain domain, Permission permission) {
+            return pc.implies(permission);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/util/FilePermCompat/Flag.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8164705
+ * @summary check jdk.filepermission.canonicalize
+ * @library /java/security/testlibrary/
+ * @modules java.base/jdk.internal.misc
+ * @run main/othervm -Djdk.io.permissionsUseCanonicalPath=true Flag truetrue
+ * @run main/othervm -Djdk.io.permissionsUseCanonicalPath=false Flag falsetrue
+ * @run main/othervm Flag falsetrue
+ */
+
+import java.io.File;
+import java.io.FilePermission;
+import java.lang.*;
+import java.security.Permission;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+
+public class Flag {
+    public static void main(String[] args) throws Exception {
+
+        boolean test1;
+        boolean test2;
+
+        String here = System.getProperty("user.dir");
+        File abs = new File(here, "x");
+        FilePermission fp1 = new FilePermission("x", "read");
+        FilePermission fp2 = new FilePermission(abs.toString(), "read");
+        test1 = fp1.equals(fp2);
+
+        Policy pol = new Policy() {
+            @java.lang.Override
+            public boolean implies(ProtectionDomain domain, Permission permission) {
+                return fp1.implies(permission);
+            }
+        };
+
+        Policy.setPolicy(pol);
+        System.setSecurityManager(new SecurityManager());
+        try {
+            System.getSecurityManager().checkPermission(fp2);
+            test2 = true;
+        } catch (SecurityException se) {
+            test2 = false;
+        }
+
+        if (!args[0].equals(test1 + "" + test2)) {
+            throw new Exception("Test failed: " + test1 + test2);
+        }
+    }
+}
--- a/jdk/test/sun/util/calendar/zi/tzdata/VERSION	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/VERSION	Tue Oct 18 17:14:09 2016 +0000
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2016f
+tzdata2016g
--- a/jdk/test/sun/util/calendar/zi/tzdata/africa	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/africa	Tue Oct 18 17:14:09 2016 +0000
@@ -487,7 +487,7 @@
 # http://www.libyaherald.com/2013/10/24/correction-no-time-change-tomorrow/
 #
 # From Paul Eggert (2013-10-25):
-# For now, assume they're reverting to the pre-2012 rules of permanent UTC+2.
+# For now, assume they're reverting to the pre-2012 rules of permanent UT +02.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Libya	1951	only	-	Oct	14	2:00	1:00	S
--- a/jdk/test/sun/util/calendar/zi/tzdata/antarctica	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/antarctica	Tue Oct 18 17:14:09 2016 +0000
@@ -33,9 +33,7 @@
 # http://www.spri.cam.ac.uk/bob/periant.htm
 # for information.
 # Unless otherwise specified, we have no time zone information.
-#
-# Except for the French entries,
-# I made up all time zone abbreviations mentioned here; corrections welcome!
+
 # FORMAT is '-00' and GMTOFF is 0 for locations while uninhabited.
 
 # Argentina - year-round bases
@@ -52,7 +50,7 @@
 #	previously sealers and scientific personnel wintered
 #	Margaret Turner reports
 #	http://web.archive.org/web/20021204222245/http://www.dstc.qut.edu.au/DST/marg/daylight.html
-#	(1999-09-30) that they're UTC+5, with no DST;
+#	(1999-09-30) that they're UT +05, with no DST;
 #	presumably this is when they have visitors.
 #
 # year-round bases
@@ -91,23 +89,22 @@
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Casey	0	-	-00	1969
-			8:00	-	AWST	2009 Oct 18  2:00
-						# Australian Western Std Time
-			11:00	-	CAST	2010 Mar  5  2:00  # Casey Time
-			8:00	-	AWST	2011 Oct 28  2:00
-			11:00	-	CAST	2012 Feb 21 17:00u
-			8:00	-	AWST
+			8:00	-	+08	2009 Oct 18  2:00
+			11:00	-	+11	2010 Mar  5  2:00
+			8:00	-	+08	2011 Oct 28  2:00
+			11:00	-	+11	2012 Feb 21 17:00u
+			8:00	-	+08
 Zone Antarctica/Davis	0	-	-00	1957 Jan 13
-			7:00	-	DAVT	1964 Nov    # Davis Time
+			7:00	-	+07	1964 Nov
 			0	-	-00	1969 Feb
-			7:00	-	DAVT	2009 Oct 18  2:00
-			5:00	-	DAVT	2010 Mar 10 20:00u
-			7:00	-	DAVT	2011 Oct 28  2:00
-			5:00	-	DAVT	2012 Feb 21 20:00u
-			7:00	-	DAVT
+			7:00	-	+07	2009 Oct 18  2:00
+			5:00	-	+05	2010 Mar 10 20:00u
+			7:00	-	+07	2011 Oct 28  2:00
+			5:00	-	+05	2012 Feb 21 20:00u
+			7:00	-	+07
 Zone Antarctica/Mawson	0	-	-00	1954 Feb 13
-			6:00	-	MAWT	2009 Oct 18  2:00 # Mawson Time
-			5:00	-	MAWT
+			6:00	-	+06	2009 Oct 18  2:00
+			5:00	-	+05
 # References:
 # Casey Weather (1998-02-26)
 # http://www.antdiv.gov.au/aad/exop/sfo/casey/casey_aws.html
@@ -161,7 +158,7 @@
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Indian/Kerguelen	0	-	-00	1950 # Port-aux-Français
-			5:00	-	TFT	# ISO code TF Time
+			5:00	-	+05
 #
 # year-round base in the main continent
 # Dumont d'Urville, Île des Pétrels, -6640+14001, since 1956-11
@@ -172,9 +169,9 @@
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/DumontDUrville 0 -	-00	1947
-			10:00	-	PMT	1952 Jan 14 # Port-Martin Time
+			10:00	-	+10	1952 Jan 14
 			0	-	-00	1956 Nov
-			10:00	-	DDUT	# Dumont-d'Urville Time
+			10:00	-	+10
 
 # France & Italy - year-round base
 # Concordia, -750600+1232000, since 2005
@@ -200,7 +197,7 @@
 # station of Japan, it's appropriate for the principal location.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Syowa	0	-	-00	1957 Jan 29
-			3:00	-	SYOT	# Syowa Time
+			3:00	-	+03
 # See:
 # NIPR Antarctic Research Activities (1999-08-17)
 # http://www.nipr.ac.jp/english/ara01.html
@@ -237,17 +234,17 @@
 # correct, but they should be quite close to the actual dates.
 #
 # From Paul Eggert (2014-03-21):
-# The CET-switching Troll rules require zic from tzcode 2014b or later, so as
+# The CET-switching Troll rules require zic from tz 2014b or later, so as
 # suggested by Bengt-Inge Larsson comment them out for now, and approximate
 # with only UTC and CEST.  Uncomment them when 2014b is more prevalent.
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-#Rule	Troll	2005	max	-	Mar	 1	1:00u	1:00	CET
-Rule	Troll	2005	max	-	Mar	lastSun	1:00u	2:00	CEST
-#Rule	Troll	2005	max	-	Oct	lastSun	1:00u	1:00	CET
-#Rule	Troll	2004	max	-	Nov	 7	1:00u	0:00	UTC
+#Rule	Troll	2005	max	-	Mar	 1	1:00u	1:00	+01
+Rule	Troll	2005	max	-	Mar	lastSun	1:00u	2:00	+02
+#Rule	Troll	2005	max	-	Oct	lastSun	1:00u	1:00	+01
+#Rule	Troll	2004	max	-	Nov	 7	1:00u	0:00	+00
 # Remove the following line when uncommenting the above '#Rule' lines.
-Rule	Troll	2004	max	-	Oct	lastSun	1:00u	0:00	UTC
+Rule	Troll	2004	max	-	Oct	lastSun	1:00u	0:00	+00
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Troll	0	-	-00	2005 Feb 12
 			0:00	Troll	%s
@@ -288,10 +285,10 @@
 # changes during the year and does not necessarily correspond to mean
 # solar noon.  So the Vostok time might have been whatever the clocks
 # happened to be during their visit.  So we still don't really know what time
-# it is at Vostok.  But we'll guess UTC+6.
+# it is at Vostok.  But we'll guess +06.
 #
 Zone Antarctica/Vostok	0	-	-00	1957 Dec 16
-			6:00	-	VOST	# Vostok time
+			6:00	-	+06
 
 # S Africa - year-round bases
 # Marion Island, -4653+03752
@@ -324,7 +321,7 @@
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Rothera	0	-	-00	1976 Dec  1
-			-3:00	-	ROTT	# Rothera time
+			-3:00	-	-03
 
 # Uruguay - year round base
 # Artigas, King George Island, -621104-0585107
--- a/jdk/test/sun/util/calendar/zi/tzdata/asia	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/asia	Tue Oct 18 17:14:09 2016 +0000
@@ -139,13 +139,11 @@
 # http://www.worldtimezone.com/dst_news/dst_news_armenia03.html
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Yerevan	2:58:00 -	LMT	1924 May  2
-			3:00	-	YERT	1957 Mar    # Yerevan Time
-			4:00 RussiaAsia YER%sT	1991 Mar 31  2:00s
-			3:00	1:00	YERST	1991 Sep 23 # independence
-			3:00 RussiaAsia	AM%sT	1995 Sep 24  2:00s
-			4:00	-	AMT	1997
-			4:00 RussiaAsia	AM%sT	2012 Feb  9
-			4:00	-	AMT
+			3:00	-	+03	1957 Mar
+			4:00 RussiaAsia +04/+05	1991 Mar 31  2:00s
+			3:00 RussiaAsia	+03/+04	1995 Sep 24  2:00s
+			4:00	-	+04	1997
+			4:00 RussiaAsia	+04/+05
 
 # Azerbaijan
 
@@ -166,13 +164,12 @@
 Rule	Azer	1997	2015	-	Oct	lastSun	 5:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Baku	3:19:24 -	LMT	1924 May  2
-			3:00	-	BAKT	1957 Mar    # Baku Time
-			4:00 RussiaAsia BAK%sT	1991 Mar 31  2:00s
-			3:00	1:00	BAKST	1991 Aug 30 # independence
-			3:00 RussiaAsia	AZ%sT	1992 Sep lastSun  2:00s
-			4:00	-	AZT	1996     # Azerbaijan Time
-			4:00	EUAsia	AZ%sT	1997
-			4:00	Azer	AZ%sT
+			3:00	-	+03	1957 Mar
+			4:00 RussiaAsia +04/+05	1991 Mar 31  2:00s
+			3:00 RussiaAsia	+03/+04	1992 Sep lastSun  2:00s
+			4:00	-	+04	1996
+			4:00	EUAsia	+04/+05	1997
+			4:00	Azer	+04/+05
 
 # Bahrain
 # See Asia/Qatar.
@@ -291,7 +288,7 @@
 # Milne says 6:24:40 was the meridian of the time ball observatory at Rangoon.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone	Asia/Rangoon	6:24:40 -	LMT	1880        # or Yangon
+Zone	Asia/Yangon	6:24:40 -	LMT	1880        # or Rangoon
 			6:24:40	-	RMT	1920        # Rangoon Mean Time?
 			6:30	-	BURT	1942 May    # Burma Time
 			9:00	-	JST	1945 May  3
@@ -406,7 +403,7 @@
 # Lewiston (ME) Daily Sun (1939-05-29), p 17, said "Even the time is
 # different - the occupied districts going by Tokyo time, an hour
 # ahead of that prevailing in the rest of Shanghai."  Guess that the
-# Xujiahui Observatory was under French control and stuck with UT+8.
+# Xujiahui Observatory was under French control and stuck with UT +08.
 #
 # In earlier versions of this file, China had many separate Zone entries, but
 # this was based on what were apparently incorrect data in Shanks & Pottenger.
@@ -415,26 +412,26 @@
 # Proposed in 1918 and theoretically in effect until 1949 (although in practice
 # mainly observed in coastal areas), the five zones were:
 #
-# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT+8.5
+# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT +08:30
 # Asia/Harbin (currently a link to Asia/Shanghai)
 # Heilongjiang (except Mohe county), Jilin
 #
-# Zhongyuan Time ("Central plain Time") UT+8
+# Zhongyuan Time ("Central plain Time") UT +08
 # Asia/Shanghai
 # most of China
 # This currently represents most other zones as well,
 # as apparently these regions have been the same since 1970.
 # Milne gives 8:05:43.2 for Xujiahui Observatory time; round to nearest.
-# Guo says Shanghai switched to UT+8 "from the end of the 19th century".
+# Guo says Shanghai switched to UT +08 "from the end of the 19th century".
 #
-# Long-shu Time (probably due to Long and Shu being two names of that area) UT+7
+# Long-shu Time (probably due to Long and Shu being two names of the area) UT +07
 # Asia/Chongqing (currently a link to Asia/Shanghai)
 # Guangxi, Guizhou, Hainan, Ningxia, Sichuan, Shaanxi, and Yunnan;
 # most of Gansu; west Inner Mongolia; west Qinghai; and the Guangdong
 # counties Deqing, Enping, Kaiping, Luoding, Taishan, Xinxing,
 # Yangchun, Yangjiang, Yu'nan, and Yunfu.
 #
-# Xin-zang Time ("Xinjiang-Tibet Time") UT+6
+# Xin-zang Time ("Xinjiang-Tibet Time") UT +06
 # Asia/Urumqi
 # This currently represents Kunlun Time as well,
 # as apparently the two regions have been the same since 1970.
@@ -447,7 +444,7 @@
 # Shihezi, Changji, Yanqi, Heshuo, Tuokexun, Tulufan, Shanshan, Hami,
 # Fukang, Kuitun, Kumukuli, Miquan, Qitai, and Turfan.
 #
-# Kunlun Time UT+5.5
+# Kunlun Time UT +05:30
 # Asia/Kashgar (currently a link to Asia/Urumqi)
 # West Tibet, including Pulan, Aheqi, Shufu, Shule;
 # West Xinjiang, including Aksu, Atushi, Yining, Hetian, Cele, Luopu, Nileke,
@@ -463,7 +460,7 @@
 #
 # On the other hand, ethnic Uyghurs, who make up about half the
 # population of Xinjiang, typically use "Xinjiang time" which is two
-# hours behind Beijing time, or UTC +0600. The government of the Xinjiang
+# hours behind Beijing time, or UT +06. The government of the Xinjiang
 # Uyghur Autonomous Region, (XAUR, or just Xinjiang for short) as well as
 # local governments such as the Ürümqi city government use both times in
 # publications, referring to what is popularly called Xinjiang time as
@@ -519,8 +516,8 @@
 # having the same time as Beijing.
 
 # From Paul Eggert (2014-06-30):
-# In the early days of the PRC, Tibet was given its own time zone (UT+6) but
-# this was withdrawn in 1959 and never reinstated; see Tubten Khétsun,
+# In the early days of the PRC, Tibet was given its own time zone (UT +06)
+# but this was withdrawn in 1959 and never reinstated; see Tubten Khétsun,
 # Memories of life in Lhasa under Chinese Rule, Columbia U Press, ISBN
 # 978-0231142861 (2008), translator's introduction by Matthew Akester, p x.
 # As this is before our 1970 cutoff, Tibet doesn't need a separate zone.
@@ -534,12 +531,12 @@
 # Republics, the Soviet Union, the Kuomintang, and the People's Republic of
 # China, and tracking down all these organizations' timekeeping rules would be
 # quite a trick.  Approximate this lost history by a transition from LMT to
-# XJT at the start of 1928, the year of accession of the warlord Jin Shuren,
+# UT +06 at the start of 1928, the year of accession of the warlord Jin Shuren,
 # which happens to be the date given by Shanks & Pottenger (no doubt as a
-# guess) as the transition from LMT.  Ignore the usage of UT+8 before
-# 1986-02-01 under the theory that the transition date to UT+8 is unknown and
+# guess) as the transition from LMT.  Ignore the usage of +08 before
+# 1986-02-01 under the theory that the transition date to +08 is unknown and
 # that the sort of users who prefer Asia/Urumqi now typically ignored the
-# UT+8 mandate back then.
+# +08 mandate back then.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Beijing time, used throughout China; represented by Shanghai.
@@ -744,7 +741,7 @@
 # be found from historical government announcement database.
 
 # From Paul Eggert (2014-07-03):
-# As per Yu-Cheng Chuang, say that Taiwan was at UT+9 from 1937-10-01
+# As per Yu-Cheng Chuang, say that Taiwan was at UT +09 from 1937-10-01
 # until 1945-09-21 at 01:00, overriding Shanks & Pottenger.
 # Likewise, use Yu-Cheng Chuang's data for DST in Taiwan.
 
@@ -858,16 +855,15 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Tbilisi	2:59:11 -	LMT	1880
 			2:59:11	-	TBMT	1924 May  2 # Tbilisi Mean Time
-			3:00	-	TBIT	1957 Mar    # Tbilisi Time
-			4:00 RussiaAsia TBI%sT	1991 Mar 31  2:00s
-			3:00	1:00	TBIST	1991 Apr  9 # independence
-			3:00 RussiaAsia GE%sT	1992        # Georgia Time
-			3:00 E-EurAsia	GE%sT	1994 Sep lastSun
-			4:00 E-EurAsia	GE%sT	1996 Oct lastSun
-			4:00	1:00	GEST	1997 Mar lastSun
-			4:00 E-EurAsia	GE%sT	2004 Jun 27
-			3:00 RussiaAsia	GE%sT	2005 Mar lastSun  2:00
-			4:00	-	GET
+			3:00	-	+03	1957 Mar
+			4:00 RussiaAsia +04/+05	1991 Mar 31  2:00s
+			3:00 RussiaAsia +03/+04	1992
+			3:00 E-EurAsia	+03/+04	1994 Sep lastSun
+			4:00 E-EurAsia	+04/+05	1996 Oct lastSun
+			4:00	1:00	+05	1997 Mar lastSun
+			4:00 E-EurAsia	+04/+05	2004 Jun 27
+			3:00 RussiaAsia	+03/+04	2005 Mar lastSun  2:00
+			4:00	-	+04
 
 # East Timor
 
@@ -944,7 +940,7 @@
 # These would be the earliest possible times for a change.
 # Régimes horaires pour le monde entier, by Henri Le Corre, (Éditions
 # Traditionnelles, 1987, Paris) says that Java and Madura switched
-# from JST to UTC+07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura
+# from UT +09 to +07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura
 # (Hollandia).  For now, assume all Indonesian locations other than Jayapura
 # switched on 1945-09-23.
 #
@@ -955,11 +951,11 @@
 # summary published by the Time and Frequency Laboratory of the
 # Research Center for Calibration, Instrumentation and Metrology,
 # Indonesia, <http://time.kim.lipi.go.id/time-eng.php> (2006-09-29).
-# The abbreviations are:
+# The time zone abbreviations and UT offsets are:
 #
-# WIB  - UTC+7 - Waktu Indonesia Barat (Indonesia western time)
-# WITA - UTC+8 - Waktu Indonesia Tengah (Indonesia central time)
-# WIT  - UTC+9 - Waktu Indonesia Timur (Indonesia eastern time)
+# WIB  - +07 - Waktu Indonesia Barat (Indonesia western time)
+# WITA - +08 - Waktu Indonesia Tengah (Indonesia central time)
+# WIT  - +09 - Waktu Indonesia Timur (Indonesia eastern time)
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Java, Sumatra
@@ -1848,11 +1844,11 @@
 Rule	Kyrgyz	1997	2004	-	Oct	lastSun	2:30	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Bishkek	4:58:24 -	LMT	1924 May  2
-			5:00	-	FRUT	1930 Jun 21 # Frunze Time
-			6:00 RussiaAsia FRU%sT	1991 Mar 31  2:00s
-			5:00	1:00	FRUST	1991 Aug 31  2:00 # independence
-			5:00	Kyrgyz	KG%sT	2005 Aug 12 # Kyrgyzstan Time
-			6:00	-	KGT
+			5:00	-	+05	1930 Jun 21
+			6:00 RussiaAsia +06/+07	1991 Mar 31  2:00s
+			5:00 RussiaAsia	+05/+06	1991 Aug 31  2:00
+			5:00	Kyrgyz	+05/+06	2005 Aug 12
+			6:00	-	+06
 
 ###############################################################################
 
@@ -1891,25 +1887,24 @@
 Rule	ROK	1987	1988	-	May	Sun>=8	2:00	1:00	D
 Rule	ROK	1987	1988	-	Oct	Sun>=8	3:00	0	S
 
-# From Paul Eggert (2014-10-30):
+# From Paul Eggert (2016-08-23):
 # The Korean Wikipedia entry gives the following sources for UT offsets:
 #
-# 1908: Official Journal Article No. 3994 (Edict No. 5)
+# 1908: Official Journal Article No. 3994 (decree No. 5)
 # 1912: Governor-General of Korea Official Gazette Issue No. 367
 #       (Announcement No. 338)
 # 1954: Presidential Decree No. 876 (1954-03-17)
 # 1961: Law No. 676 (1961-08-07)
-# 1987: Law No. 3919 (1986-12-31)
 #
-# The Wikipedia entry also has confusing information about a change
-# to UT+9 in April 1910, but then what would be the point of the later change
-# to UT+9 on 1912-01-01?  Omit the 1910 change for now.
+# (Another source "1987: Law No. 3919 (1986-12-31)" was in the 2014-10-30
+# edition of the Korean Wikipedia entry.)
 #
 # I guessed that time zone abbreviations through 1945 followed the same
 # rules as discussed under Taiwan, with nominal switches from JST to KST
 # when the respective cities were taken over by the Allies after WWII.
 #
-# For Pyongyang we have no information; guess no changes since World War II.
+# For Pyongyang, guess no changes from World War II until 2015, as we
+# have no information otherwise.
 
 # From Steffen Thorsen (2015-08-07):
 # According to many news sources, North Korea is going to change to
@@ -2069,7 +2064,7 @@
 # Bill Bonnet (2005-05-19) reports that the US Embassy in Ulaanbaatar says
 # there is only one time zone and that DST is observed, citing Microsoft
 # Windows XP as the source.  Risto Nykänen (2005-05-16) reports that
-# travelmongolia.org says there are two time zones (UTC+7, UTC+8) with no DST.
+# travelmongolia.org says there are two time zones (UT +07, +08) with no DST.
 # Oscar van Vlijmen (2005-05-20) reports that the Mongolian Embassy in
 # Washington, DC says there are two time zones, with DST observed.
 # He also found
@@ -2705,7 +2700,7 @@
 # earlier date.
 #
 # Shanks & Pottenger also state that until 1968-05-01 Saudi Arabia had two
-# time zones; the other zone, at UTC+4, was in the far eastern part of
+# time zones; the other zone, at UT +04, was in the far eastern part of
 # the country.  Ignore this, as it's before our 1970 cutoff.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -2974,10 +2969,10 @@
 # From Shanks & Pottenger.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dushanbe	4:35:12 -	LMT	1924 May  2
-			5:00	-	DUST	1930 Jun 21 # Dushanbe Time
-			6:00 RussiaAsia DUS%sT	1991 Mar 31  2:00s
-			5:00	1:00	DUSST	1991 Sep  9  2:00s
-			5:00	-	TJT	# Tajikistan Time
+			5:00	-	+05	1930 Jun 21
+			6:00 RussiaAsia +06/+07	1991 Mar 31  2:00s
+			5:00	1:00	+05/+06	1991 Sep  9  2:00s
+			5:00	-	+05
 
 # Thailand
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -2991,11 +2986,10 @@
 # From Shanks & Pottenger.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Ashgabat	3:53:32 -	LMT	1924 May  2 # or Ashkhabad
-			4:00	-	ASHT	1930 Jun 21 # Ashkhabad Time
-			5:00 RussiaAsia	ASH%sT	1991 Mar 31  2:00
-			4:00 RussiaAsia	ASH%sT	1991 Oct 27 # independence
-			4:00 RussiaAsia	TM%sT	1992 Jan 19  2:00
-			5:00	-	TMT
+			4:00	-	+04	1930 Jun 21
+			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00
+			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00
+			5:00	-	+05
 
 # United Arab Emirates
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -3007,20 +3001,18 @@
 # Byalokoz 1919 says Uzbekistan was 4:27:53.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Samarkand	4:27:53 -	LMT	1924 May  2
-			4:00	-	SAMT	1930 Jun 21 # Samarkand Time
-			5:00	-	SAMT	1981 Apr  1
-			5:00	1:00	SAMST	1981 Oct  1
-			6:00	-	TAST	1982 Apr  1 # Tashkent Time
-			5:00 RussiaAsia	SAM%sT	1991 Sep  1 # independence
-			5:00 RussiaAsia	UZ%sT	1992
-			5:00	-	UZT
+			4:00	-	+04	1930 Jun 21
+			5:00	-	+05	1981 Apr  1
+			5:00	1:00	+06	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1992
+			5:00	-	+05
 # Milne says Tashkent was 4:37:10.8; round to nearest.
 Zone	Asia/Tashkent	4:37:11 -	LMT	1924 May  2
-			5:00	-	TAST	1930 Jun 21 # Tashkent Time
-			6:00 RussiaAsia	TAS%sT	1991 Mar 31  2:00
-			5:00 RussiaAsia	TAS%sT	1991 Sep  1 # independence
-			5:00 RussiaAsia	UZ%sT	1992
-			5:00	-	UZT
+			5:00	-	+05	1930 Jun 21
+			6:00 RussiaAsia	+06/+07	1991 Mar 31  2:00
+			5:00 RussiaAsia	+05/+06	1992
+			5:00	-	+05
 
 # Vietnam
 
--- a/jdk/test/sun/util/calendar/zi/tzdata/australasia	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/australasia	Tue Oct 18 17:14:09 2016 +0000
@@ -568,7 +568,7 @@
 # Base the Bougainville entry on the Arawa-Kieta region, which appears to have
 # the most people even though it was devastated in the Bougainville Civil War.
 #
-# Although Shanks gives 1942-03-15 / 1943-11-01 for JST, these dates
+# Although Shanks gives 1942-03-15 / 1943-11-01 for UT +09, these dates
 # are apparently rough guesswork from the starts of military campaigns.
 # The World War II entries below are instead based on Arawa-Kieta.
 # The Japanese occupied Kieta in July 1942,
@@ -576,8 +576,8 @@
 # http://pwencycl.kgbudge.com/B/o/Bougainville.htm
 # and seem to have controlled it until their 1945-08-21 surrender.
 #
-# The Autonomous Region of Bougainville plans to switch from UTC+10 to UTC+11
-# on 2014-12-28 at 02:00.  They call UTC+11 "Bougainville Standard Time";
+# The Autonomous Region of Bougainville switched from UT +10 to +11
+# on 2014-12-28 at 02:00.  They call +11 "Bougainville Standard Time";
 # abbreviate this as BST.  See:
 # http://www.bougainville24.com/bougainville-issues/bougainville-gets-own-timezone/
 #
@@ -643,7 +643,7 @@
 # From Paul Eggert (2014-06-27):
 # The International Date Line Act 2011
 # http://www.parliament.gov.ws/images/ACTS/International_Date_Line_Act__2011_-_Eng.pdf
-# changed Samoa from UTC-11 to UTC+13, effective "12 o'clock midnight, on
+# changed Samoa from UT -11 to +13, effective "12 o'clock midnight, on
 # Thursday 29th December 2011".  The International Date Line was adjusted
 # accordingly.
 
@@ -738,7 +738,7 @@
 # 1886-1891; Baker was similar but exact dates are not known.
 # Inhabited by civilians 1935-1942; U.S. military bases 1943-1944;
 # uninhabited thereafter.
-# Howland observed Hawaii Standard Time (UT-10:30) in 1937;
+# Howland observed Hawaii Standard Time (UT -10:30) in 1937;
 # see page 206 of Elgen M. Long and Marie K. Long,
 # Amelia Earhart: the Mystery Solved, Simon & Schuster (2000).
 # So most likely Howland and Baker observed Hawaii Time from 1935
@@ -1496,7 +1496,7 @@
 # Zealand time.  I understand that is the time they keep locally, anyhow."
 # For now, assume this practice goes back to the introduction of standard time
 # in New Zealand, as this would make Chatham Islands time almost exactly match
-# LMT back when New Zealand was at UTC+11:30; also, assume Chatham Islands did
+# LMT back when New Zealand was at UT +11:30; also, assume Chatham Islands did
 # not observe New Zealand's prewar DST.
 
 ###############################################################################
@@ -1552,7 +1552,7 @@
 # For now, we assume the Ladrones switched at the same time as the Philippines;
 # see Asia/Manila.
 
-# US Public Law 106-564 (2000-12-23) made UTC+10 the official standard time,
+# US Public Law 106-564 (2000-12-23) made UT +10 the official standard time,
 # under the name "Chamorro Standard Time".  There is no official abbreviation,
 # but Congressman Robert A. Underwood, author of the bill that became law,
 # wrote in a press release (2000-12-27) that he will seek the use of "ChST".
@@ -1564,15 +1564,15 @@
 # "I am certain, having lived there for the past decade, that 'Truk'
 # (now properly known as Chuuk) ... is in the time zone GMT+10."
 #
-# Shanks & Pottenger write that Truk switched from UTC+10 to UTC+11
+# Shanks & Pottenger write that Truk switched from UT +10 to +11
 # on 1978-10-01; ignore this for now.
 
 # From Paul Eggert (1999-10-29):
 # The Federated States of Micronesia Visitors Board writes in
 # The Federated States of Micronesia - Visitor Information (1999-01-26)
 # http://www.fsmgov.org/info/clocks.html
-# that Truk and Yap are UTC+10, and Ponape and Kosrae are UTC+11.
-# We don't know when Kosrae switched from UTC+12; assume January 1 for now.
+# that Truk and Yap are UT +10, and Ponape and Kosrae are +11.
+# We don't know when Kosrae switched from +12; assume January 1 for now.
 
 
 # Midway
@@ -1638,11 +1638,11 @@
 # ordaining - by a masterpiece of diplomatic flattery - that
 # the Fourth of July should be celebrated twice in that year."
 
-# Although Shanks & Pottenger says they both switched to UTC-11:30
-# in 1911, and to UTC-11 in 1950. many earlier sources give UTC-11
+# Although Shanks & Pottenger says they both switched to UT -11:30
+# in 1911, and to -11 in 1950. many earlier sources give -11
 # for American Samoa, e.g., the US National Bureau of Standards
 # circular "Standard Time Throughout the World", 1932.
-# Assume American Samoa switched to UTC-11 in 1911, not 1950,
+# Assume American Samoa switched to -11 in 1911, not 1950,
 # and that after 1950 they agreed until (western) Samoa skipped a
 # day in 2011.  Assume also that the Samoas follow the US and New
 # Zealand's "ST"/"DT" style of daylight-saving abbreviations.
--- a/jdk/test/sun/util/calendar/zi/tzdata/backward	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/backward	Tue Oct 18 17:14:09 2016 +0000
@@ -59,6 +59,7 @@
 Link	Asia/Urumqi		Asia/Kashgar
 Link	Asia/Kathmandu		Asia/Katmandu
 Link	Asia/Macau		Asia/Macao
+Link	Asia/Yangon		Asia/Rangoon
 Link	Asia/Ho_Chi_Minh	Asia/Saigon
 Link	Asia/Jerusalem		Asia/Tel_Aviv
 Link	Asia/Thimphu		Asia/Thimbu
--- a/jdk/test/sun/util/calendar/zi/tzdata/etcetera	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/etcetera	Tue Oct 18 17:14:09 2016 +0000
@@ -31,6 +31,13 @@
 # need now for the entries that are not on UTC are for ships at sea
 # that cannot use POSIX TZ settings.
 
+# Starting with POSIX 1003.1-2001, the entries below are all
+# unnecessary as settings for the TZ environment variable.  E.g.,
+# instead of TZ='Etc/GMT+4' one can use the POSIX setting TZ='<-04>+4'.
+#
+# Do not use a POSIX TZ setting like TZ='GMT+4', which is four hours
+# behind GMT but uses the completely misleading abbreviation "GMT".
+
 Zone	Etc/GMT		0	-	GMT
 Zone	Etc/UTC		0	-	UTC
 Zone	Etc/UCT		0	-	UCT
@@ -49,23 +56,13 @@
 Link	Etc/GMT				Etc/GMT+0
 Link	Etc/GMT				Etc/GMT0
 
-# We use POSIX-style signs in the Zone names and the output abbreviations,
+# Be consistent with POSIX TZ settings in the Zone names,
 # even though this is the opposite of what many people expect.
 # POSIX has positive signs west of Greenwich, but many people expect
 # positive signs east of Greenwich.  For example, TZ='Etc/GMT+4' uses
-# the abbreviation "GMT+4" and corresponds to 4 hours behind UT
+# the abbreviation "-04" and corresponds to 4 hours behind UT
 # (i.e. west of Greenwich) even though many people would expect it to
 # mean 4 hours ahead of UT (i.e. east of Greenwich).
-#
-# In the draft 5 of POSIX 1003.1-200x, the angle bracket notation allows for
-# TZ='<GMT-4>+4'; if you want time zone abbreviations conforming to
-# ISO 8601 you can use TZ='<-0400>+4'.  Thus the commonly-expected
-# offset is kept within the angle bracket (and is used for display)
-# while the POSIX sign is kept outside the angle bracket (and is used
-# for calculation).
-#
-# Do not use a TZ setting like TZ='GMT+4', which is four hours behind
-# GMT but uses the completely misleading abbreviation "GMT".
 
 # Earlier incarnations of this package were not POSIX-compliant,
 # and had lines such as
@@ -74,30 +71,31 @@
 # way does a
 #		zic -l GMT-12
 # so we moved the names into the Etc subdirectory.
+# Also, the time zone abbreviations are now compatible with %z.
 
-Zone	Etc/GMT-14	14	-	GMT-14	# 14 hours ahead of GMT
-Zone	Etc/GMT-13	13	-	GMT-13
-Zone	Etc/GMT-12	12	-	GMT-12
-Zone	Etc/GMT-11	11	-	GMT-11
-Zone	Etc/GMT-10	10	-	GMT-10
-Zone	Etc/GMT-9	9	-	GMT-9
-Zone	Etc/GMT-8	8	-	GMT-8
-Zone	Etc/GMT-7	7	-	GMT-7
-Zone	Etc/GMT-6	6	-	GMT-6
-Zone	Etc/GMT-5	5	-	GMT-5
-Zone	Etc/GMT-4	4	-	GMT-4
-Zone	Etc/GMT-3	3	-	GMT-3
-Zone	Etc/GMT-2	2	-	GMT-2
-Zone	Etc/GMT-1	1	-	GMT-1
-Zone	Etc/GMT+1	-1	-	GMT+1
-Zone	Etc/GMT+2	-2	-	GMT+2
-Zone	Etc/GMT+3	-3	-	GMT+3
-Zone	Etc/GMT+4	-4	-	GMT+4
-Zone	Etc/GMT+5	-5	-	GMT+5
-Zone	Etc/GMT+6	-6	-	GMT+6
-Zone	Etc/GMT+7	-7	-	GMT+7
-Zone	Etc/GMT+8	-8	-	GMT+8
-Zone	Etc/GMT+9	-9	-	GMT+9
-Zone	Etc/GMT+10	-10	-	GMT+10
-Zone	Etc/GMT+11	-11	-	GMT+11
-Zone	Etc/GMT+12	-12	-	GMT+12
+Zone	Etc/GMT-14	14	-	+14
+Zone	Etc/GMT-13	13	-	+13
+Zone	Etc/GMT-12	12	-	+12
+Zone	Etc/GMT-11	11	-	+11
+Zone	Etc/GMT-10	10	-	+10
+Zone	Etc/GMT-9	9	-	+09
+Zone	Etc/GMT-8	8	-	+08
+Zone	Etc/GMT-7	7	-	+07
+Zone	Etc/GMT-6	6	-	+06
+Zone	Etc/GMT-5	5	-	+05
+Zone	Etc/GMT-4	4	-	+04
+Zone	Etc/GMT-3	3	-	+03
+Zone	Etc/GMT-2	2	-	+02
+Zone	Etc/GMT-1	1	-	+01
+Zone	Etc/GMT+1	-1	-	-01
+Zone	Etc/GMT+2	-2	-	-02
+Zone	Etc/GMT+3	-3	-	-03
+Zone	Etc/GMT+4	-4	-	-04
+Zone	Etc/GMT+5	-5	-	-05
+Zone	Etc/GMT+6	-6	-	-06
+Zone	Etc/GMT+7	-7	-	-07
+Zone	Etc/GMT+8	-8	-	-08
+Zone	Etc/GMT+9	-9	-	-09
+Zone	Etc/GMT+10	-10	-	-10
+Zone	Etc/GMT+11	-11	-	-11
+Zone	Etc/GMT+12	-12	-	-12
--- a/jdk/test/sun/util/calendar/zi/tzdata/europe	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/europe	Tue Oct 18 17:14:09 2016 +0000
@@ -98,8 +98,7 @@
 #        1:00       CET CEST CEMT Central Europe
 #        1:00:14    SET           Swedish (1879-1899)*
 #        2:00       EET EEST      Eastern Europe
-#        3:00       FET           Further-eastern Europe (2011-2014)*
-#        3:00       MSK MSD  MSM* Minsk, Moscow
+#        3:00       MSK MSD       Moscow
 
 # From Peter Ilieve (1994-12-04),
 # The original six [EU members]: Belgium, France, (West) Germany, Italy,
@@ -606,16 +605,33 @@
 Rule	E-Eur	1981	max	-	Mar	lastSun	 0:00	1:00	S
 Rule	E-Eur	1996	max	-	Oct	lastSun	 0:00	0	-
 
+
+# Daylight saving time for Russia and the Soviet Union
+#
+# The 1917-1921 decree URLs are from Alexander Belopolsky (2016-08-23).
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Russia	1917	only	-	Jul	 1	23:00	1:00	MST  # Moscow Summer Time
+#
+# Decree No. 142 (1917-12-22) http://istmat.info/node/28137
 Rule	Russia	1917	only	-	Dec	28	 0:00	0	MMT  # Moscow Mean Time
+#
+# Decree No. 497 (1918-05-30) http://istmat.info/node/30001
 Rule	Russia	1918	only	-	May	31	22:00	2:00	MDST # Moscow Double Summer Time
 Rule	Russia	1918	only	-	Sep	16	 1:00	1:00	MST
+#
+# Decree No. 258 (1919-05-29) http://istmat.info/node/37949
 Rule	Russia	1919	only	-	May	31	23:00	2:00	MDST
-Rule	Russia	1919	only	-	Jul	 1	 2:00	1:00	MSD
+#
+Rule	Russia	1919	only	-	Jul	 1	 0:00u	1:00	MSD
 Rule	Russia	1919	only	-	Aug	16	 0:00	0	MSK
+#
+# Decree No. 63 (1921-02-03) http://istmat.info/node/45840
 Rule	Russia	1921	only	-	Feb	14	23:00	1:00	MSD
-Rule	Russia	1921	only	-	Mar	20	23:00	2:00	MSM  # Midsummer
+#
+# Decree No. 121 (1921-03-07) http://istmat.info/node/45949
+Rule	Russia	1921	only	-	Mar	20	23:00	2:00	+05
+#
 Rule	Russia	1921	only	-	Sep	 1	 0:00	1:00	MSD
 Rule	Russia	1921	only	-	Oct	 1	 0:00	0	-
 # Act No. 925 of the Council of Ministers of the USSR (1980-10-24):
@@ -798,8 +814,6 @@
 # From Alexander Bokovoy (2014-10-09):
 # Belarussian government decided against changing to winter time....
 # http://eng.belta.by/all_news/society/Belarus-decides-against-adjusting-time-in-Russias-wake_i_76335.html
-# From Paul Eggert (2014-10-08):
-# Hence Belarus can share time zone abbreviations with Moscow again.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Europe/Minsk	1:50:16 -	LMT	1880
@@ -810,8 +824,7 @@
 			3:00	Russia	MSK/MSD	1990
 			3:00	-	MSK	1991 Mar 31  2:00s
 			2:00	Russia	EE%sT	2011 Mar 27  2:00s
-			3:00	-	FET	2014 Oct 26  1:00s
-			3:00	-	MSK
+			3:00	-	+03
 
 # Belgium
 #
@@ -1319,7 +1332,7 @@
 # http://www.parlament-berlin.de/pds-fraktion.nsf/727459127c8b66ee8525662300459099/defc77cb784f180ac1256c2b0030274b/$FILE/bersarint.pdf
 # says that Bersarin issued an order to use Moscow time on May 20.
 # However, Moscow did not observe daylight saving in 1945, so
-# this was equivalent to CEMT (GMT+3), not GMT+4.
+# this was equivalent to UT +03, not +04.
 
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
@@ -2283,7 +2296,6 @@
 # http://www.worldtimezone.com/dst_news/dst_news_russia-map-2014-07.html
 
 # From Paul Eggert (2006-03-22):
-# Except for Moscow after 1919-07-01, I invented the time zone abbreviations.
 # Moscow time zone abbreviations after 1919-07-01, and Moscow rules after 1991,
 # are from Andrey A. Chernov.  The rest is from Shanks & Pottenger,
 # except we follow Chernov's report that 1992 DST transitions were Sat
@@ -2359,7 +2371,7 @@
 			 2:00	Poland	CE%sT	1946
 			 3:00	Russia	MSK/MSD	1989 Mar 26  2:00s
 			 2:00	Russia	EE%sT	2011 Mar 27  2:00s
-			 3:00	-	FET	2014 Oct 26  2:00s
+			 3:00	-	+03	2014 Oct 26  2:00s
 			 2:00	-	EET
 
 
@@ -2412,6 +2424,16 @@
 # 78	RU-SPE	Saint Petersburg
 # 83	RU-NEN	Nenets Autonomous Okrug
 
+# From Paul Eggert (2016-08-23):
+# The Soviets switched to UT-based time in 1919.  Decree No. 59
+# (1919-02-08) http://istmat.info/node/35567 established UT-based time
+# zones, and Decree No. 147 (1919-03-29) http://istmat.info/node/35854
+# specified a transition date of 1919-07-01, apparently at 00:00 UT.
+# No doubt only the Soviet-controlled regions switched on that date;
+# later transitions to UT-based time in other parts of Russia are
+# taken from what appear to be guesses by Shanks.
+# (Thanks to Alexander Belopolsky for pointers to the decrees.)
+
 # From Stepan Golosunov (2016-03-07):
 # 11. Regions-violators, 1981-1982.
 # Wikipedia refers to
@@ -2453,7 +2475,7 @@
 # attributes the 1982 changes to the Act of the Council of Ministers
 # of the USSR No. 126 from 18.02.1982.  1980-925.txt also adds
 # Udmurtia to the list of affected territories and lists Khatangsky
-# district separately from Taymyr Autonomous Okurg.  Probably erroneously.
+# district separately from Taymyr Autonomous Okrug.  Probably erroneously.
 #
 # The affected territories are currently listed under Europe/Moscow,
 # Asia/Yekaterinburg and Asia/Krasnoyarsk.
@@ -2513,7 +2535,7 @@
 
 Zone Europe/Moscow	 2:30:17 -	LMT	1880
 			 2:30:17 -	MMT	1916 Jul  3 # Moscow Mean Time
-			 2:31:19 Russia	%s	1919 Jul  1  2:00
+			 2:31:19 Russia	%s	1919 Jul  1  0:00u
 			 3:00	Russia	%s	1921 Oct
 			 3:00	Russia	MSK/MSD	1922 Oct
 			 2:00	-	EET	1930 Jun 21
@@ -2596,22 +2618,21 @@
 # The 1988 transition is from USSR act No. 5 (1988-01-04).
 
 Zone Europe/Volgograd	 2:57:40 -	LMT	1920 Jan  3
-			 3:00	-	TSAT	1925 Apr  6 # Tsaritsyn Time
-			 3:00	-	STAT	1930 Jun 21 # Stalingrad Time
-			 4:00	-	STAT	1961 Nov 11
-			 4:00	Russia	VOL%sT	1988 Mar 27  2:00s # Volgograd T
-			 3:00	Russia	VOL%sT	1991 Mar 31  2:00s
-			 4:00	-	VOLT	1992 Mar 29  2:00s
-			 3:00	Russia	MSK/MSD	2011 Mar 27  2:00s
-			 4:00	-	MSK	2014 Oct 26  2:00s
-			 3:00	-	MSK
+			 3:00	-	+03	1930 Jun 21
+			 4:00	-	+04	1961 Nov 11
+			 4:00	Russia	+04/+05	1988 Mar 27  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 4:00	-	+04	1992 Mar 29  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04	2014 Oct 26  2:00s
+			 3:00	-	+03
 
 # From Paul Eggert (2016-03-18):
 # Europe/Kirov covers:
 # 43	RU-KIR	Kirov Oblast
 # The 1989 transition is from USSR act No. 227 (1989-03-14).
 #
-Zone Europe/Kirov	 3:18:48 -	LMT	1919 Jul  1  2:00
+Zone Europe/Kirov	 3:18:48 -	LMT	1919 Jul  1  0:00u
 			 3:00	-	+03	1930 Jun 21
 			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
 			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
@@ -2629,16 +2650,16 @@
 # Byalokoz 1919 says Samara was 3:20:20.
 # The 1989 transition is from USSR act No. 227 (1989-03-14).
 
-Zone Europe/Samara	 3:20:20 -	LMT	1919 Jul  1  2:00
-			 3:00	-	SAMT	1930 Jun 21 # Samara Time
-			 4:00	-	SAMT	1935 Jan 27
-			 4:00	Russia	KUY%sT	1989 Mar 26  2:00s # Kuybyshev
-			 3:00	Russia	MSK/MSD	1991 Mar 31  2:00s
-			 2:00	Russia	EE%sT	1991 Sep 29  2:00s
-			 3:00	-	SAMT	1991 Oct 20  3:00
-			 4:00	Russia	SAM%sT	2010 Mar 28  2:00s
-			 3:00	Russia	SAM%sT	2011 Mar 27  2:00s
-			 4:00	-	SAMT
+Zone Europe/Samara	 3:20:20 -	LMT	1919 Jul  1  0:00u
+			 3:00	-	+03	1930 Jun 21
+			 4:00	-	+04	1935 Jan 27
+			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 2:00	Russia	+02/+03	1991 Sep 29  2:00s
+			 3:00	-	+03	1991 Oct 20  3:00
+			 4:00	Russia	+04/+05	2010 Mar 28  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04
 
 # From Paul Eggert (2016-03-18):
 # Europe/Ulyanovsk covers:
@@ -2653,7 +2674,7 @@
 # From Matt Johnson (2016-03-09):
 # http://publication.pravo.gov.ru/Document/View/0001201603090051
 
-Zone Europe/Ulyanovsk	 3:13:36 -	LMT	1919 Jul  1  2:00
+Zone Europe/Ulyanovsk	 3:13:36 -	LMT	1919 Jul  1  0:00u
 			 3:00	-	+03	1930 Jun 21
 			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
 			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
@@ -2685,12 +2706,12 @@
 
 Zone Asia/Yekaterinburg	 4:02:33 -	LMT	1916 Jul  3
 			 3:45:05 -	PMT	1919 Jul 15  4:00
-			 4:00	-	SVET	1930 Jun 21 # Sverdlovsk Time
-			 5:00	Russia	SVE%sT	1991 Mar 31  2:00s
-			 4:00	Russia	SVE%sT	1992 Jan 19  2:00s
-			 5:00	Russia	YEK%sT	2011 Mar 27  2:00s
-			 6:00	-	YEKT	2014 Oct 26  2:00s
-			 5:00	-	YEKT
+			 4:00	-	+04	1930 Jun 21
+			 5:00	Russia	+05/+06	1991 Mar 31  2:00s
+			 4:00	Russia	+04/+05	1992 Jan 19  2:00s
+			 5:00	Russia	+05/+06	2011 Mar 27  2:00s
+			 6:00	-	+06	2014 Oct 26  2:00s
+			 5:00	-	+05
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
@@ -2700,12 +2721,12 @@
 # Byalokoz 1919 says Omsk was 4:53:30.
 
 Zone Asia/Omsk		 4:53:30 -	LMT	1919 Nov 14
-			 5:00	-	OMST	1930 Jun 21 # Omsk Time
-			 6:00	Russia	OMS%sT	1991 Mar 31  2:00s
-			 5:00	Russia	OMS%sT	1992 Jan 19  2:00s
-			 6:00	Russia	OMS%sT	2011 Mar 27  2:00s
-			 7:00	-	OMST	2014 Oct 26  2:00s
-			 6:00	-	OMST
+			 5:00	-	+05	1930 Jun 21
+			 6:00	Russia	+06/+07	1991 Mar 31  2:00s
+			 5:00	Russia	+05/+06	1992 Jan 19  2:00s
+			 6:00	Russia	+06/+07	2011 Mar 27  2:00s
+			 7:00	-	+07	2014 Oct 26  2:00s
+			 6:00	-	+06
 
 # From Paul Eggert (2016-02-22):
 # Asia/Barnaul covers:
@@ -2785,7 +2806,7 @@
 # Note that time belts (numbered from 2 (Moscow) to 12 according to their
 # GMT/UTC offset and having too many exceptions like regions formally
 # belonging to one belt but using time from another) were replaced
-# with time zones in 2011 with different numberings (there was a
+# with time zones in 2011 with different numbering (there was a
 # 2-hour gap between second and third zones in 2011-2014).
 
 # From Stepan Golosunov (2016-04-12):
@@ -2868,12 +2889,12 @@
 # Byalokoz 1919 says Krasnoyarsk was 6:11:26.
 
 Zone Asia/Krasnoyarsk	 6:11:26 -	LMT	1920 Jan  6
-			 6:00	-	KRAT	1930 Jun 21 # Krasnoyarsk Time
-			 7:00	Russia	KRA%sT	1991 Mar 31  2:00s
-			 6:00	Russia	KRA%sT	1992 Jan 19  2:00s
-			 7:00	Russia	KRA%sT	2011 Mar 27  2:00s
-			 8:00	-	KRAT	2014 Oct 26  2:00s
-			 7:00	-	KRAT
+			 6:00	-	+06	1930 Jun 21
+			 7:00	Russia	+07/+08	1991 Mar 31  2:00s
+			 6:00	Russia	+06/+07	1992 Jan 19  2:00s
+			 7:00	Russia	+07/+08	2011 Mar 27  2:00s
+			 8:00	-	+08	2014 Oct 26  2:00s
+			 7:00	-	+07
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
@@ -2890,12 +2911,12 @@
 
 Zone Asia/Irkutsk	 6:57:05 -	LMT	1880
 			 6:57:05 -	IMT	1920 Jan 25 # Irkutsk Mean Time
-			 7:00	-	IRKT	1930 Jun 21 # Irkutsk Time
-			 8:00	Russia	IRK%sT	1991 Mar 31  2:00s
-			 7:00	Russia	IRK%sT	1992 Jan 19  2:00s
-			 8:00	Russia	IRK%sT	2011 Mar 27  2:00s
-			 9:00	-	IRKT	2014 Oct 26  2:00s
-			 8:00	-	IRKT
+			 7:00	-	+07	1930 Jun 21
+			 8:00	Russia	+08/+09	1991 Mar 31  2:00s
+			 7:00	Russia	+07/+08	1992 Jan 19  2:00s
+			 8:00	Russia	+08/+09	2011 Mar 27  2:00s
+			 9:00	-	+09	2014 Oct 26  2:00s
+			 8:00	-	+08
 
 
 # From Tim Parenti (2014-07-06):
@@ -2912,13 +2933,13 @@
 # http://publication.pravo.gov.ru/Document/View/0001201512300107
 
 Zone Asia/Chita	 7:33:52 -	LMT	1919 Dec 15
-			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
-			 9:00	Russia	YAK%sT	1991 Mar 31  2:00s
-			 8:00	Russia	YAK%sT	1992 Jan 19  2:00s
-			 9:00	Russia	YAK%sT	2011 Mar 27  2:00s
-			10:00	-	YAKT	2014 Oct 26  2:00s
-			 8:00	-	IRKT	2016 Mar 27  2:00
-			 9:00	-	YAKT
+			 8:00	-	+08	1930 Jun 21
+			 9:00	Russia	+09/+10	1991 Mar 31  2:00s
+			 8:00	Russia	+08/+09	1992 Jan 19  2:00s
+			 9:00	Russia	+09/+10	2011 Mar 27  2:00s
+			10:00	-	+10	2014 Oct 26  2:00s
+			 8:00	-	+08	2016 Mar 27  2:00
+			 9:00	-	+09
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29):
@@ -2958,12 +2979,12 @@
 # Byalokoz 1919 says Yakutsk was 8:38:58.
 
 Zone Asia/Yakutsk	 8:38:58 -	LMT	1919 Dec 15
-			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
-			 9:00	Russia	YAK%sT	1991 Mar 31  2:00s
-			 8:00	Russia	YAK%sT	1992 Jan 19  2:00s
-			 9:00	Russia	YAK%sT	2011 Mar 27  2:00s
-			10:00	-	YAKT	2014 Oct 26  2:00s
-			 9:00	-	YAKT
+			 8:00	-	+08	1930 Jun 21
+			 9:00	Russia	+09/+10	1991 Mar 31  2:00s
+			 8:00	Russia	+08/+09	1992 Jan 19  2:00s
+			 9:00	Russia	+09/+10	2011 Mar 27  2:00s
+			10:00	-	+10	2014 Oct 26  2:00s
+			 9:00	-	+09
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29):
@@ -2981,12 +3002,12 @@
 # Go with Byalokoz.
 
 Zone Asia/Vladivostok	 8:47:31 -	LMT	1922 Nov 15
-			 9:00	-	VLAT	1930 Jun 21 # Vladivostok Time
-			10:00	Russia	VLA%sT	1991 Mar 31  2:00s
-			 9:00	Russia	VLA%sT	1992 Jan 19  2:00s
-			10:00	Russia	VLA%sT	2011 Mar 27  2:00s
-			11:00	-	VLAT	2014 Oct 26  2:00s
-			10:00	-	VLAT
+			 9:00	-	+09	1930 Jun 21
+			10:00	Russia	+10/+11	1991 Mar 31  2:00s
+			 9:00	Russia	+09/+10	1992 Jan 19  2:00s
+			10:00	Russia	+10/+11	2011 Mar 27  2:00s
+			11:00	-	+11	2014 Oct 26  2:00s
+			10:00	-	+10
 
 
 # From Tim Parenti (2014-07-03):
@@ -3004,14 +3025,14 @@
 # This transition is no doubt wrong, but we have no better info.
 
 Zone Asia/Khandyga	 9:02:13 -	LMT	1919 Dec 15
-			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
-			 9:00	Russia	YAK%sT	1991 Mar 31  2:00s
-			 8:00	Russia	YAK%sT	1992 Jan 19  2:00s
-			 9:00	Russia	YAK%sT	2004
-			10:00	Russia	VLA%sT	2011 Mar 27  2:00s
-			11:00	-	VLAT	2011 Sep 13  0:00s # Decree 725?
-			10:00	-	YAKT	2014 Oct 26  2:00s
-			 9:00	-	YAKT
+			 8:00	-	+08	1930 Jun 21
+			 9:00	Russia	+09/+10	1991 Mar 31  2:00s
+			 8:00	Russia	+08/+09	1992 Jan 19  2:00s
+			 9:00	Russia	+09/+10	2004
+			10:00	Russia	+10/+11	2011 Mar 27  2:00s
+			11:00	-	+11	2011 Sep 13  0:00s # Decree 725?
+			10:00	-	+10	2014 Oct 26  2:00s
+			 9:00	-	+09
 
 
 # From Tim Parenti (2014-07-03):
@@ -3027,15 +3048,14 @@
 
 # The Zone name should be Asia/Yuzhno-Sakhalinsk, but that's too long.
 Zone Asia/Sakhalin	 9:30:48 -	LMT	1905 Aug 23
-			 9:00	-	JCST	1937 Oct  1
-			 9:00	-	JST	1945 Aug 25
-			11:00	Russia	SAK%sT	1991 Mar 31  2:00s # Sakhalin T
-			10:00	Russia	SAK%sT	1992 Jan 19  2:00s
-			11:00	Russia	SAK%sT	1997 Mar lastSun  2:00s
-			10:00	Russia	SAK%sT	2011 Mar 27  2:00s
-			11:00	-	SAKT	2014 Oct 26  2:00s
-			10:00	-	SAKT	2016 Mar 27  2:00s
-			11:00	-	SAKT
+			 9:00	-	+09	1945 Aug 25
+			11:00	Russia	+11/+12	1991 Mar 31  2:00s # Sakhalin T
+			10:00	Russia	+10/+11	1992 Jan 19  2:00s
+			11:00	Russia	+11/+12	1997 Mar lastSun  2:00s
+			10:00	Russia	+10/+11	2011 Mar 27  2:00s
+			11:00	-	+11	2014 Oct 26  2:00s
+			10:00	-	+10	2016 Mar 27  2:00s
+			11:00	-	+11
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29):
@@ -3058,13 +3078,13 @@
 # http://publication.pravo.gov.ru/Document/View/0001201604050038
 
 Zone Asia/Magadan	10:03:12 -	LMT	1924 May  2
-			10:00	-	MAGT	1930 Jun 21 # Magadan Time
-			11:00	Russia	MAG%sT	1991 Mar 31  2:00s
-			10:00	Russia	MAG%sT	1992 Jan 19  2:00s
-			11:00	Russia	MAG%sT	2011 Mar 27  2:00s
-			12:00	-	MAGT	2014 Oct 26  2:00s
-			10:00	-	MAGT	2016 Apr 24  2:00s
-			11:00	-	MAGT
+			10:00	-	+10	1930 Jun 21 # Magadan Time
+			11:00	Russia	+11/+12	1991 Mar 31  2:00s
+			10:00	Russia	+10/+11	1992 Jan 19  2:00s
+			11:00	Russia	+11/+12	2011 Mar 27  2:00s
+			12:00	-	+12	2014 Oct 26  2:00s
+			10:00	-	+10	2016 Apr 24  2:00s
+			11:00	-	+11
 
 
 # From Tim Parenti (2014-07-06):
@@ -3107,17 +3127,14 @@
 # in Russian.)  In addition, Srednekolymsk appears to be a much older
 # settlement and the population of Zyryanka seems to be declining.
 # Go with Srednekolymsk.
-#
-# Since Magadan Oblast moves to UTC+10 on 2014-10-26, we cannot keep using MAGT
-# as the abbreviation.  Use SRET instead.
 
 Zone Asia/Srednekolymsk	10:14:52 -	LMT	1924 May  2
-			10:00	-	MAGT	1930 Jun 21 # Magadan Time
-			11:00	Russia	MAG%sT	1991 Mar 31  2:00s
-			10:00	Russia	MAG%sT	1992 Jan 19  2:00s
-			11:00	Russia	MAG%sT	2011 Mar 27  2:00s
-			12:00	-	MAGT	2014 Oct 26  2:00s
-			11:00	-	SRET	# Srednekolymsk Time
+			10:00	-	+10	1930 Jun 21
+			11:00	Russia	+11/+12	1991 Mar 31  2:00s
+			10:00	Russia	+10/+11	1992 Jan 19  2:00s
+			11:00	Russia	+11/+12	2011 Mar 27  2:00s
+			12:00	-	+12	2014 Oct 26  2:00s
+			11:00	-	+11
 
 
 # From Tim Parenti (2014-07-03):
@@ -3135,14 +3152,14 @@
 # UTC+12 since at least then, too.
 
 Zone Asia/Ust-Nera	 9:32:54 -	LMT	1919 Dec 15
-			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
-			 9:00	Russia	YAKT	1981 Apr  1
-			11:00	Russia	MAG%sT	1991 Mar 31  2:00s
-			10:00	Russia	MAG%sT	1992 Jan 19  2:00s
-			11:00	Russia	MAG%sT	2011 Mar 27  2:00s
-			12:00	-	MAGT	2011 Sep 13  0:00s # Decree 725?
-			11:00	-	VLAT	2014 Oct 26  2:00s
-			10:00	-	VLAT
+			 8:00	-	+08	1930 Jun 21
+			 9:00	Russia	+09/+10	1981 Apr  1
+			11:00	Russia	+11/+12	1991 Mar 31  2:00s
+			10:00	Russia	+10/+11	1992 Jan 19  2:00s
+			11:00	Russia	+11/+12	2011 Mar 27  2:00s
+			12:00	-	+12	2011 Sep 13  0:00s # Decree 725?
+			11:00	-	+11	2014 Oct 26  2:00s
+			10:00	-	+10
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
@@ -3155,12 +3172,12 @@
 # The Zone name should be Asia/Petropavlovsk-Kamchatski or perhaps
 # Asia/Petropavlovsk-Kamchatsky, but these are too long.
 Zone Asia/Kamchatka	10:34:36 -	LMT	1922 Nov 10
-			11:00	-	PETT	1930 Jun 21 # P-K Time
-			12:00	Russia	PET%sT	1991 Mar 31  2:00s
-			11:00	Russia	PET%sT	1992 Jan 19  2:00s
-			12:00	Russia	PET%sT	2010 Mar 28  2:00s
-			11:00	Russia	PET%sT	2011 Mar 27  2:00s
-			12:00	-	PETT
+			11:00	-	+11	1930 Jun 21
+			12:00	Russia	+12/+13	1991 Mar 31  2:00s
+			11:00	Russia	+11/+12	1992 Jan 19  2:00s
+			12:00	Russia	+12/+13	2010 Mar 28  2:00s
+			11:00	Russia	+11/+12	2011 Mar 27  2:00s
+			12:00	-	+12
 
 
 # From Tim Parenti (2014-07-03):
@@ -3168,13 +3185,13 @@
 # 87	RU-CHU	Chukotka Autonomous Okrug
 
 Zone Asia/Anadyr	11:49:56 -	LMT	1924 May  2
-			12:00	-	ANAT	1930 Jun 21 # Anadyr Time
-			13:00	Russia	ANA%sT	1982 Apr  1  0:00s
-			12:00	Russia	ANA%sT	1991 Mar 31  2:00s
-			11:00	Russia	ANA%sT	1992 Jan 19  2:00s
-			12:00	Russia	ANA%sT	2010 Mar 28  2:00s
-			11:00	Russia	ANA%sT	2011 Mar 27  2:00s
-			12:00	-	ANAT
+			12:00	-	+12	1930 Jun 21
+			13:00	Russia	+13/+14	1982 Apr  1  0:00s
+			12:00	Russia	+12/+13	1991 Mar 31  2:00s
+			11:00	Russia	+11/+12	1992 Jan 19  2:00s
+			12:00	Russia	+12/+13	2010 Mar 28  2:00s
+			11:00	Russia	+11/+12	2011 Mar 27  2:00s
+			12:00	-	+12
 
 
 # San Marino
@@ -3495,6 +3512,14 @@
 # Engineered Standard Time," said Twitter user @aysekarahasan.
 # http://www.bbc.com/news/world-europe-34631326
 
+# From Burak AYDIN (2016-09-08):
+# Turkey will stay in Daylight Saving Time even in winter....
+# http://www.resmigazete.gov.tr/eskiler/2016/09/20160908-2.pdf
+#
+# From Paul Eggert (2016-09-07):
+# The change is permanent, so this is the new standard time in Turkey.
+# It takes effect today, which is not much notice.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Turkey	1916	only	-	May	 1	0:00	1:00	S
 Rule	Turkey	1916	only	-	Oct	 1	0:00	0	-
@@ -3558,7 +3583,7 @@
 Zone	Europe/Istanbul	1:55:52 -	LMT	1880
 			1:56:56	-	IMT	1910 Oct # Istanbul Mean Time?
 			2:00	Turkey	EE%sT	1978 Oct 15
-			3:00	Turkey	TR%sT	1985 Apr 20 # Turkey Time
+			3:00	Turkey	+03/+04	1985 Apr 20
 			2:00	Turkey	EE%sT	2007
 			2:00	EU	EE%sT	2011 Mar 27  1:00u
 			2:00	-	EET	2011 Mar 28  1:00u
@@ -3566,7 +3591,8 @@
 			2:00	-	EET	2014 Mar 31  1:00u
 			2:00	EU	EE%sT	2015 Oct 25  1:00u
 			2:00	1:00	EEST	2015 Nov  8  1:00u
-			2:00	EU	EE%sT
+			2:00	EU	EE%sT	2016 Sep  7
+			3:00	-	+03
 Link	Europe/Istanbul	Asia/Istanbul	# Istanbul is in both continents.
 
 # Ukraine
--- a/jdk/test/sun/util/calendar/zi/tzdata/factory	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/factory	Tue Oct 18 17:14:09 2016 +0000
@@ -24,9 +24,10 @@
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
-# For companies who don't want to put time zone specification in
-# their installation procedures.  When users run date, they'll get the message.
-# Also useful for the "comp.sources" version.
+# For distributors who don't want to put time zone specification in
+# their installation procedures.  Users that run 'date' will get the
+# time zone abbreviation "-00", indicating that the actual time zone
+# is unknown.
 
 # Zone	NAME	GMTOFF	RULES	FORMAT
-Zone	Factory	0	- "Local time zone must be set--see zic manual page"
+Zone	Factory	0	-	-00
--- a/jdk/test/sun/util/calendar/zi/tzdata/leapseconds	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/leapseconds	Tue Oct 18 17:14:09 2016 +0000
@@ -79,6 +79,7 @@
 Leap	2008	Dec	31	23:59:60	+	S
 Leap	2012	Jun	30	23:59:60	+	S
 Leap	2015	Jun	30	23:59:60	+	S
+Leap	2016	Dec	31	23:59:60	+	S
 
-#	Updated through IERS Bulletin C51
-#	File expires on:  28 December 2016
+#	Updated through IERS Bulletin C52
+#	File expires on:  28 June 2017
--- a/jdk/test/sun/util/calendar/zi/tzdata/northamerica	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/northamerica	Tue Oct 18 17:14:09 2016 +0000
@@ -436,11 +436,42 @@
 # north of the Salmon River, and the towns of Burgdorf and Warren),
 # Nevada (except West Wendover), Oregon (except the northern 3/4 of
 # Malheur county), and Washington
+
+# From Paul Eggert (2016-08-20):
+# In early February 1948, in response to California's electricity shortage,
+# PG&E changed power frequency from 60 to 59.5 Hz during daylight hours,
+# causing electric clocks to lose six minutes per day.  (This did not change
+# legal time, and is not part of the data here.)  See:
+# Ross SA. An energy crisis from the past: Northern California in 1948.
+# Working Paper No. 8, Institute of Governmental Studies, UC Berkeley,
+# 1973-11.  http://escholarship.org/uc/item/8x22k30c
+#
+# In another measure to save electricity, DST was instituted from 1948-03-14
+# at 02:01 to 1949-01-16 at 02:00, with the governor having the option to move
+# the fallback transition earlier.  See pages 3-4 of:
+# http://clerk.assembly.ca.gov/sites/clerk.assembly.ca.gov/files/archive/Statutes/1948/48Vol1_Chapters.pdf
+#
+# In response:
+#
+#   Governor Warren received a torrent of objecting mail, and it is not too much
+#   to speculate that the objections to Daylight Saving Time were one important
+#   factor in the defeat of the Dewey-Warren Presidential ticket in California.
+#     -- Ross, p 25
+#
+# On December 8 the governor exercised the option, setting the date to January 1
+# (LA Times 1948-12-09).  The transition time was 02:00 (LA Times 1949-01-01).
+#
+# Despite the controversy, in 1949 California voters approved Proposition 12,
+# which established DST from April's last Sunday at 01:00 until September's
+# last Sunday at 02:00. This was amended by 1962's Proposition 6, which changed
+# the fall-back date to October's last Sunday. See:
+# http://repository.uchastings.edu/cgi/viewcontent.cgi?article=1501&context=ca_ballot_props
+# http://repository.uchastings.edu/cgi/viewcontent.cgi?article=1636&context=ca_ballot_props
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER
-Rule	CA	1948	only	-	Mar	14	2:00	1:00	D
+Rule	CA	1948	only	-	Mar	14	2:01	1:00	D
 Rule	CA	1949	only	-	Jan	 1	2:00	0	S
-Rule	CA	1950	1966	-	Apr	lastSun	2:00	1:00	D
+Rule	CA	1950	1966	-	Apr	lastSun	1:00	1:00	D
 Rule	CA	1950	1961	-	Sep	lastSun	2:00	0	S
 Rule	CA	1962	1966	-	Oct	lastSun	2:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -3304,7 +3335,7 @@
 # indicating that the normal ET rules are followed.
 #
 # From Paul Eggert (2014-08-19):
-# The 2014-08-13 Cabinet meeting decided to stay on UTC-4 year-round.  See:
+# The 2014-08-13 Cabinet meeting decided to stay on UT -04 year-round.  See:
 # http://tcweeklynews.com/daylight-savings-time-to-be-maintained-p5353-127.htm
 # Model this as a switch from EST/EDT to AST ...
 # From Chris Walton (2014-11-04):
--- a/jdk/test/sun/util/calendar/zi/tzdata/southamerica	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/southamerica	Tue Oct 18 17:14:09 2016 +0000
@@ -433,9 +433,9 @@
 # stuck on Summer daylight savings time even though the summer is over.
 
 # From Paul Eggert (2013-09-05):
-# Perhaps San Luis operates on the legal fiction that it is at UTC-4
+# Perhaps San Luis operates on the legal fiction that it is at -04
 # with perpetual summer time, but ordinary usage typically seems to
-# just say it's at UTC-3; see, for example,
+# just say it's at -03; see, for example,
 # http://es.wikipedia.org/wiki/Hora_oficial_argentina
 # We've documented similar situations as being plain changes to
 # standard time, so let's do that here too.  This does not change UTC
--- a/jdk/test/sun/util/calendar/zi/tzdata/zone.tab	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/sun/util/calendar/zi/tzdata/zone.tab	Tue Oct 18 17:14:09 2016 +0000
@@ -284,7 +284,7 @@
 MH	+0905+16720	Pacific/Kwajalein	Kwajalein
 MK	+4159+02126	Europe/Skopje
 ML	+1239-00800	Africa/Bamako
-MM	+1647+09610	Asia/Rangoon
+MM	+1647+09610	Asia/Yangon
 MN	+4755+10653	Asia/Ulaanbaatar	Mongolia (most areas)
 MN	+4801+09139	Asia/Hovd	Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan
 MN	+4804+11430	Asia/Choibalsan	Dornod, Sukhbaatar
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/InputFilesTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,212 @@
+/*
+ * 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 8165944
+ * @summary test several jar tool input file scenarios with variations on -C
+ *          options with/without a --release option.  Some input files are
+ *          duplicates that sometimes cause exceptions and other times do not,
+ *          demonstrating identical behavior to JDK 8 jar tool.
+ * @library /lib/testlibrary
+ * @modules jdk.jartool/sun.tools.jar
+ * @build jdk.testlibrary.FileUtils
+ * @run testng InputFilesTest
+ */
+
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+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.stream.Stream;
+import java.util.zip.ZipException;
+
+import jdk.testlibrary.FileUtils;
+
+public class InputFilesTest {
+    private final String nl = System.lineSeparator();
+    private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    private final PrintStream out = new PrintStream(baos);
+    private Runnable onCompletion;
+
+    @BeforeMethod
+    public void reset() {
+        onCompletion = null;
+    }
+
+    @AfterMethod
+    public void run() {
+        if (onCompletion != null) {
+            onCompletion.run();
+        }
+    }
+
+    @Test
+    public void test1() throws IOException {
+        mkdir("test1 test2");
+        touch("test1/testfile1 test2/testfile2");
+        jar("cf test.jar -C test1 . -C test2 .");
+        jar("tf test.jar");
+        println();
+        String output = "META-INF/" + nl +
+                "META-INF/MANIFEST.MF" + nl +
+                "testfile1" + nl +
+                "testfile2" + nl;
+        rm("test.jar test1 test2");
+        Assert.assertEquals(baos.toByteArray(), output.getBytes());
+    }
+
+    @Test
+    public void test2() throws IOException {
+        mkdir("test1 test2 test3 test4");
+        touch("test1/testfile1 test2/testfile2 test3/testfile3 test4/testfile4");
+        jar("cf test.jar -C test1 . -C test2 . --release 9 -C test3 . -C test4 .");
+        jar("tf test.jar");
+        println();
+        String output = "META-INF/" + nl +
+                "META-INF/MANIFEST.MF" + nl +
+                "testfile1" + nl +
+                "testfile2" + nl +
+                "META-INF/versions/9/testfile3" + nl +
+                "META-INF/versions/9/testfile4" + nl;
+        rm("test.jar test1 test2 test3 test4");
+        Assert.assertEquals(baos.toByteArray(), output.getBytes());
+    }
+
+    @Test
+    public void test3() throws IOException {
+        touch("test");
+        jar("cf test.jar test test");
+        jar("tf test.jar");
+        println();
+        String output = "META-INF/" + nl +
+                "META-INF/MANIFEST.MF" + nl +
+                "test" + nl;
+        rm("test.jar test");
+        Assert.assertEquals(baos.toByteArray(), output.getBytes());
+    }
+
+    @Test
+    public void test4() throws IOException {
+        mkdir("a");
+        touch("a/test");
+        jar("cf test.jar -C a test -C a test");
+        jar("tf test.jar");
+        println();
+        String output = "META-INF/" + nl +
+                "META-INF/MANIFEST.MF" + nl +
+                "test" + nl;
+        rm("test.jar a");
+        Assert.assertEquals(baos.toByteArray(), output.getBytes());
+    }
+
+    @Test(expectedExceptions = {ZipException.class})
+    public void test5() throws IOException {
+        mkdir("a");
+        touch("test a/test");
+        onCompletion = () -> rm("test a");
+        jar("cf test.jar -C a test test");
+    }
+
+    @Test(expectedExceptions = {ZipException.class})
+    public void test6() throws IOException {
+        mkdir("test1 test2");
+        touch("test1/a test2/a");
+        onCompletion = () -> rm("test1 test2");
+        jar("cf test.jar --release 9 -C test1 a -C test2 a");
+    }
+
+    private Stream<Path> mkpath(String... args) {
+        return Arrays.stream(args).map(d -> Paths.get(".", d.split("/")));
+    }
+
+    private void mkdir(String cmdline) {
+        System.out.println("mkdir -p " + cmdline);
+        mkpath(cmdline.split(" +")).forEach(p -> {
+            try {
+                Files.createDirectories(p);
+            } catch (IOException x) {
+                throw new UncheckedIOException(x);
+            }
+        });
+    }
+
+    private void touch(String cmdline) {
+        System.out.println("touch " + cmdline);
+        mkpath(cmdline.split(" +")).forEach(p -> {
+            try {
+                Files.createFile(p);
+            } catch (IOException x) {
+                throw new UncheckedIOException(x);
+            }
+        });
+    }
+
+    private void rm(String cmdline) {
+        System.out.println("rm -rf " + cmdline);
+        mkpath(cmdline.split(" +")).forEach(p -> {
+            try {
+                if (Files.isDirectory(p)) {
+                    FileUtils.deleteFileTreeWithRetry(p);
+                } else {
+                    FileUtils.deleteFileIfExistsWithRetry(p);
+                }
+            } catch (IOException x) {
+                throw new UncheckedIOException(x);
+            }
+        });
+    }
+
+    private void jar(String cmdline) throws IOException {
+        System.out.println("jar " + cmdline);
+        baos.reset();
+
+        // the run method catches IOExceptions, we need to expose them
+        ByteArrayOutputStream baes = new ByteArrayOutputStream();
+        PrintStream err = new PrintStream(baes);
+        PrintStream saveErr = System.err;
+        System.setErr(err);
+        boolean ok = new sun.tools.jar.Main(out, err, "jar").run(cmdline.split(" +"));
+        System.setErr(saveErr);
+        if (!ok) {
+            String s = baes.toString();
+            if (s.startsWith("java.util.zip.ZipException: duplicate entry: ")) {
+                throw new ZipException(s);
+            }
+            throw new IOException(s);
+        }
+    }
+
+    private void println() throws IOException {
+        System.out.println(new String(baos.toByteArray()));
+    }
+}
--- a/jdk/test/tools/jar/multiRelease/Basic.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/tools/jar/multiRelease/Basic.java	Tue Oct 18 17:14:09 2016 +0000
@@ -195,6 +195,8 @@
                 new String[] {"v10", "version", "Version.class"}
         );
 
+        compare(jarfile, names);
+
         delete(jarfile);
         deleteDir(Paths.get(usr, "classes"));
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jjs/addmodulesrepeat.js	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,17 @@
+/*
+ * This is the test JavaScript program used in jjs-modulepathTest.sh
+ */
+
+print("--module-path passed: " + $OPTIONS._module_path);
+print("--add-modules passed: " + $OPTIONS._add_modules);
+
+if ($OPTIONS._add_modules != "java.base,com.greetings") {
+    throw new Error("--add-modules values are not merged!");
+}
+
+var Hello = com.greetings.Hello;
+
+var moduleName = Hello.class.module.name;
+if (moduleName != "com.greetings") {
+    throw new Error("Expected module name to be com.greetings");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jjs/com.greetings/com/greetings/Hello.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 com.greetings;
+
+public class Hello {
+    public static String greet() {
+        return "Hello World!";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jjs/com.greetings/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 com.greetings {
+    exports com.greetings;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jjs/jjs-modulepathTest.sh	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+
+# @test
+# @bug 8167018
+# @summary Nashorn and jjs should support --module-path and --add-modules options
+# @run shell jjs-modulepathTest.sh
+# Tests --module-path option to set the module path for jjs
+
+. ${TESTSRC-.}/common.sh
+
+setup
+
+mkdir -p ${TESTCLASSES}/com.greetings
+rm -rf ${TESTCLASSES}/com.greetings
+
+${JAVAC} ${TESTSRC}/com.greetings/module-info.java \
+    ${TESTSRC}/com.greetings/com/greetings/*.java   \
+     -d ${TESTCLASSES}/com.greetings
+
+# no --add-modules passed. This should result in error.
+${JJS} -scripting --module-path ${TESTCLASSES} ${TESTSRC}/modulepath.js
+
+if [ $? -ne 0 ]; then
+   echo "Error thrown as expected when --add-modules is missing!"
+else
+   echo "Should have thrown error for missing --add-modules!"
+   exit 1
+fi
+
+# proper usage of --module-path with --add-modules
+${JJS} -scripting --module-path ${TESTCLASSES} --add-modules com.greetings ${TESTSRC}/modulepath.js
+if [ $? -ne 0 ]; then
+   exit 1
+fi
+
+# check that repeated --add-modules values are combined
+${JJS} -scripting --module-path ${TESTCLASSES} --add-modules java.base --add-modules com.greetings ${TESTSRC}/addmodulesrepeat.js
+if [ $? -ne 0 ]; then
+   exit 1
+fi
+
+rm -rf ${TESTCLASSES}/com.greetings
+echo "Passed"
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jjs/modulepath.js	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,21 @@
+/*
+ * This is the test JavaScript program used in jjs-modulepathTest.sh
+ */
+
+print("--module-path passed: " + $OPTIONS._module_path);
+print("--add-modules passed: " + $OPTIONS._add_modules);
+
+var Hello = com.greetings.Hello;
+var moduleName = Hello.class.module.name;
+if (moduleName != "com.greetings") {
+    throw new Error("Expected module name to be com.greetings");
+} else {
+    print("Module name is " + moduleName);
+}
+
+var msg = Hello.greet();
+if (msg != "Hello World!") {
+    throw new Error("Expected 'Hello World!'");
+} else {
+    print(msg);
+}
--- a/jdk/test/tools/jlink/JLinkNegativeTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/tools/jlink/JLinkNegativeTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -191,7 +191,7 @@
                     .output(imageFile)
                     .addMods("not_zip")
                     .modulePath(helper.defaultModulePath())
-                    .call().assertFailure("Error: java.util.zip.ZipException: zip file is empty");
+                    .call().assertFailure("Error: java.io.IOException: Invalid jmod file");
         } finally {
             deleteDirectory(jmod);
         }
@@ -236,13 +236,10 @@
         JImageGenerator.addFiles(module, new InMemoryFile("unknown/A.class", new byte[0]));
         try {
             Result result = helper.generateDefaultImage(moduleName);
-            if (result.getExitCode() != 4) {
+            System.err.println(result.getMessage());
+            if (result.getExitCode() == 0) {
                 throw new AssertionError("Crash expected");
             }
-            if (!result.getMessage().contains("java.lang.InternalError: unexpected entry: unknown")) {
-                System.err.println(result.getMessage());
-                throw new AssertionError("InternalError expected");
-            }
         } finally {
             deleteDirectory(module);
         }
@@ -250,7 +247,7 @@
 
     @Test(enabled = true)
     public void testSectionsAreFiles() throws IOException {
-        String moduleName = "module";
+        String moduleName = "hacked4";
         Path jmod = helper.generateDefaultJModule(moduleName).assertSuccess();
         JImageGenerator.addFiles(jmod,
                 new InMemoryFile("/native", new byte[0]),
@@ -258,13 +255,10 @@
                 new InMemoryFile("/bin", new byte[0]));
         try {
             Result result = helper.generateDefaultImage(moduleName);
-            if (result.getExitCode() != 4) {
+            System.err.println(result.getMessage());
+            if (result.getExitCode() == 0) {
                 throw new AssertionError("Crash expected");
             }
-            if (!result.getMessage().contains("java.lang.InternalError: unexpected entry: ")) {
-                System.err.println(result.getMessage());
-                throw new AssertionError("InternalError expected");
-            }
         } finally {
             deleteDirectory(jmod);
         }
--- a/jdk/test/tools/jlink/JLinkTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/tools/jlink/JLinkTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -122,15 +122,6 @@
         }
 
         {
-            String moduleName = "filter";
-            Path jmod = helper.generateDefaultJModule(moduleName).assertSuccess();
-            String className = "_A.class";
-            JImageGenerator.addFiles(jmod, new InMemoryFile(className, new byte[0]));
-            Path image = helper.generateDefaultImage(moduleName).assertSuccess();
-            helper.checkImage(image, moduleName, new String[] {"/" + moduleName + "/" + className}, null);
-        }
-
-        {
             String moduleName = "m"; // 8163382
             Path jmod = helper.generateDefaultJModule(moduleName).assertSuccess();
             JImageGenerator.getJLinkTask()
@@ -150,6 +141,43 @@
         }
 
         {
+            String moduleName = "m_8165735"; // JDK-8165735
+            helper.generateDefaultJModule(moduleName+"dependency").assertSuccess();
+            Path jmod = helper.generateDefaultJModule(moduleName, moduleName+"dependency").assertSuccess();
+            JImageGenerator.getJLinkTask()
+                    .modulePath(helper.defaultModulePath())
+                    .repeatedModulePath(".") // second --module-path overrides the first one
+                    .output(helper.createNewImageDir(moduleName))
+                    .addMods(moduleName)
+                    // second --module-path does not have that module
+                    .call().assertFailure("Error: Module m_8165735 not found");
+
+            JImageGenerator.getJLinkTask()
+                    .modulePath(".") // first --module-path overridden later
+                    .repeatedModulePath(helper.defaultModulePath())
+                    .output(helper.createNewImageDir(moduleName))
+                    .addMods(moduleName)
+                    // second --module-path has that module
+                    .call().assertSuccess();
+
+            JImageGenerator.getJLinkTask()
+                    .modulePath(helper.defaultModulePath())
+                    .output(helper.createNewImageDir(moduleName))
+                    .limitMods(moduleName)
+                    .repeatedLimitMods("java.base") // second --limit-modules overrides first
+                    .addMods(moduleName)
+                    .call().assertFailure("Error: Module m_8165735dependency not found, required by m_8165735");
+
+            JImageGenerator.getJLinkTask()
+                    .modulePath(helper.defaultModulePath())
+                    .output(helper.createNewImageDir(moduleName))
+                    .limitMods("java.base")
+                    .repeatedLimitMods(moduleName) // second --limit-modules overrides first
+                    .addMods(moduleName)
+                    .call().assertSuccess();
+        }
+
+        {
             // Help
             StringWriter writer = new StringWriter();
             jdk.tools.jlink.internal.Main.run(new String[]{"--help"}, new PrintWriter(writer));
--- a/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -92,7 +92,7 @@
 
         // Asterisk works exactly the same as above
         {
-            "*",
+            "--include-locales=*",
             "jdk.localedata",
             List.of(
                 "/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
--- a/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -202,7 +202,7 @@
 
 
     /**
-     * --add-exports can only be specified once
+     * --add-exports allows duplicates
      */
     public void testWithDuplicateOption() throws Exception {
 
@@ -212,10 +212,40 @@
                                "-version")
                 .outputTo(System.out)
                 .errorTo(System.out)
-                .shouldContain("specified more than once")
                 .getExitValue();
 
-        assertTrue(exitValue != 0);
+        assertTrue(exitValue == 0);
+    }
+
+
+    /**
+     * Exercise --add-exports with unknown values.  Warning is emitted.
+     */
+    @Test(dataProvider = "unknownvalues")
+    public void testWithUnknownValue(String value, String ignore) throws Exception {
+
+        //  --add-exports $VALUE -version
+        int exitValue =
+            executeTestJava("--add-exports", value,
+                            "-version")
+                .stderrShouldMatch("WARNING: .*.monkey.*")
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .getExitValue();
+
+        assertTrue(exitValue == 0);
+    }
+
+    @DataProvider(name = "unknownvalues")
+    public Object[][] unknownValues() {
+        return new Object[][]{
+
+            { "java.base/jdk.internal.misc=sun.monkey", null }, // unknown target
+            { "java.monkey/sun.monkey=ALL-UNNAMED",     null }, // unknown module
+            { "java.base/sun.monkey=ALL-UNNAMED",       null }, // unknown package
+            { "java.monkey/sun.monkey=ALL-UNNAMED",     null }, // unknown module/package
+
+        };
     }
 
 
@@ -241,10 +271,6 @@
         return new Object[][]{
 
             { "java.base/jdk.internal.misc",            null }, // missing target
-            { "java.base/jdk.internal.misc=sun.monkey", null }, // unknown target
-            { "java.monkey/sun.monkey=ALL-UNNAMED",     null }, // unknown module
-            { "java.base/sun.monkey=ALL-UNNAMED",       null }, // unknown package
-            { "java.monkey/sun.monkey=ALL-UNNAMED",     null }, // unknown module/package
             { "java.base=ALL-UNNAMED",                  null }, // missing package
             { "java.base/=ALL-UNNAMED",                 null }  // missing package
 
--- a/jdk/test/tools/launcher/modules/addreads/AddReadsTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/tools/launcher/modules/addreads/AddReadsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -182,28 +182,43 @@
                   "--add-reads", "m1=java.xml",
                   "--add-reads", "m1=junit",
                   "-m", MAIN)
-                  .shouldContain("specified more than once")
                  .getExitValue();
 
-        assertTrue(exitValue != 0);
+        assertTrue(exitValue == 0);
     }
 
 
     /**
-     * Exercise --add-reads with bad values
+     * Exercise --add-reads with missing source
+     */
+    public void testWithMissingSource() throws Exception {
+
+        //  --add-exports $VALUE -version
+        assertTrue(run("--add-reads", "java.base", "-version").getExitValue() != 0);
+    }
+
+
+    /**
+     * Exercise --add-reads with unknown source/target module.
+     * Warning is emitted.
      */
     @Test(dataProvider = "badvalues")
     public void testWithBadValue(String value, String ignore) throws Exception {
 
         //  --add-exports $VALUE -version
-        assertTrue(run("--add-reads", value, "-version").getExitValue() != 0);
+        int exitValue = run("--add-reads", value, "-version")
+                            .stderrShouldMatch("WARNING: Unknown module: .*.monkey")
+                            .outputTo(System.out)
+                            .errorTo(System.out)
+                            .getExitValue();
+
+        assertTrue(exitValue == 0);
     }
 
     @DataProvider(name = "badvalues")
     public Object[][] badValues() {
         return new Object[][]{
 
-            { "java.base",                  null }, // missing source
             { "java.monkey=java.base",      null }, // unknown module
             { "java.base=sun.monkey",       null }, // unknown source
 
--- a/jdk/test/tools/lib/tests/JImageGenerator.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/jdk/test/tools/lib/tests/JImageGenerator.java	Tue Oct 18 17:14:09 2016 +0000
@@ -564,6 +564,10 @@
         private final List<String> limitMods = new ArrayList<>();
         private final List<String> options = new ArrayList<>();
         private String modulePath;
+        // if you want to specifiy repeated --module-path option
+        private String repeatedModulePath;
+        // if you want to specifiy repeated --limit-modules option
+        private String repeatedLimitMods;
         private Path output;
         private Path existing;
 
@@ -572,6 +576,11 @@
             return this;
         }
 
+        public JLinkTask repeatedModulePath(String modulePath) {
+            this.repeatedModulePath = modulePath;
+            return this;
+        }
+
         public JLinkTask addJars(Path jars) {
             this.jars.add(jars);
             return this;
@@ -597,6 +606,11 @@
             return this;
         }
 
+        public JLinkTask repeatedLimitMods(String modules) {
+            this.repeatedLimitMods = modules;
+            return this;
+        }
+
         public JLinkTask output(Path output) {
             this.output = output;
             return this;
@@ -639,6 +653,10 @@
                 options.add(LIMIT_MODULES_OPTION);
                 options.add(limitMods.stream().collect(Collectors.joining(",")));
             }
+            if (repeatedLimitMods != null) {
+                options.add(LIMIT_MODULES_OPTION);
+                options.add(repeatedLimitMods);
+            }
             if (!jars.isEmpty() || !jmods.isEmpty()) {
                 options.add(MODULE_PATH_OPTION);
                 options.add(modulePath());
@@ -647,6 +665,10 @@
                 options.add(MODULE_PATH_OPTION);
                 options.add(modulePath);
             }
+            if (repeatedModulePath != null) {
+                options.add(MODULE_PATH_OPTION);
+                options.add(repeatedModulePath);
+            }
             if (!pluginModulePath.isEmpty()) {
                 options.add(PLUGIN_MODULE_PATH);
                 options.add(toPath(pluginModulePath));
--- a/langtools/.hgtags	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/.hgtags	Tue Oct 18 17:14:09 2016 +0000
@@ -380,3 +380,5 @@
 af5eb8f3ffd21288305a54ea177ffad75021a741 jdk-9+135
 c8f02f0ecbd7cd6700f47416e4b7e9d5ec20ad77 jdk-9+136
 dd56c243c199a540c9f1fbff4855f0934b32a9d0 jdk-9+137
+90dd93e668a521642382561c47abe96ee2e065b7 jdk-9+138
+17a82cb0e4b480e97021691d39917f15e3f7b653 jdk-9+139
--- a/langtools/ASSEMBLY_EXCEPTION	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/ASSEMBLY_EXCEPTION	Tue Oct 18 17:14:09 2016 +0000
@@ -1,27 +1,27 @@
 
 OPENJDK ASSEMBLY EXCEPTION
 
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
 only ("GPL2"), with the following clarification and special exception.
 
     Linking this OpenJDK Code statically or dynamically with other code
     is making a combined work based on this library.  Thus, the terms
     and conditions of GPL2 cover the whole combination.
 
-    As a special exception, Sun gives you permission to link this
-    OpenJDK Code with certain code licensed by Sun as indicated at
+    As a special exception, Oracle gives you permission to link this
+    OpenJDK Code with certain code licensed by Oracle as indicated at
     http://openjdk.java.net/legal/exception-modules-2007-05-08.html
     ("Designated Exception Modules") to produce an executable,
     regardless of the license terms of the Designated Exception Modules,
     and to copy and distribute the resulting executable under GPL2,
     provided that the Designated Exception Modules continue to be
-    governed by the licenses under which they were offered by Sun.
+    governed by the licenses under which they were offered by Oracle.
 
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception).  If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception).  If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/langtools/make/CompileInterim.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/make/CompileInterim.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
           $$(wildcard $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1)), \
       EXCLUDES := sun com/sun/tools/jdeps com/sun/tools/javap \
           com/sun/tools/jdeprscan, \
-      EXCLUDE_FILES := module-info.java, \
+      EXCLUDE_FILES := module-info.java JavacToolProvider.java JavadocToolProvider.java, \
       COPY := .gif .png .xml .css .js javax.tools.JavaCompilerTool, \
       BIN := $(BUILDTOOLS_OUTPUTDIR)/override_modules/$(strip $1), \
       ADD_JAVAC_FLAGS := -Xbootclasspath/p:$$(call PathList, \
--- a/langtools/make/gendata/Gendata-jdk.compiler.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/make/gendata/Gendata-jdk.compiler.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -52,7 +52,7 @@
 	$(RM) -r $(@D)
 	$(MKDIR) -p $(@D)
 	$(ECHO) Creating ct.sym classes
-	$(JAVA) $(INTERIM_LANGTOOLS_ARGS) \
+	$(JAVA_SMALL) $(INTERIM_LANGTOOLS_ARGS) \
 	    $(COMPILECREATESYMBOLS_ADD_EXPORTS) \
 	    -classpath $(BUILDTOOLS_OUTPUTDIR)/create_symbols \
 	    build.tools.symbolgenerator.CreateSymbols \
--- a/langtools/make/gensrc/GensrcCommon.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/make/gensrc/GensrcCommon.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -32,12 +32,12 @@
 
 ################################################################################
 # The compileprops tools compiles a properties file into a resource bundle.
-TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
+TOOL_COMPILEPROPS_CMD := $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
     compileproperties.CompileProperties -quiet
 
 ################################################################################
 # The compileprops tools compiles a properties file into an enum-like class.
-TOOL_PARSEPROPS_CMD := $(JAVA) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
+TOOL_PARSEPROPS_CMD := $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
     propertiesparser.PropertiesParser
 
 
--- a/langtools/make/tools/crules/MutableFieldsAnalyzer.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java	Tue Oct 18 17:14:09 2016 +0000
@@ -111,6 +111,8 @@
                 "loadMethod");
         ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$VMHelper",
                 "vmClass", "getRuntimeArgumentsMethod");
+        ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$JmodFile",
+                "jmodFileClass", "checkMagicMethod");
     }
 
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java	Tue Oct 18 17:14:09 2016 +0000
@@ -112,12 +112,11 @@
 
     /**
      * Create a new {@code DocCommentTree} object, to represent a complete doc comment.
-     * @param firstSentence the first sentence of the doc comment
-     * @param body the body of the doc comment following the first sentence
+     * @param fullBody the entire body of the doc comment
      * @param tags the block tags in the doc comment
      * @return a {@code DocCommentTree} object
      */
-    DocCommentTree newDocCommentTree(List<? extends DocTree> firstSentence, List<? extends DocTree> body, List<? extends DocTree> tags);
+    DocCommentTree newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags);
 
     /**
      * Create a new {@code DocRootTree} object, to represent an {@code {@docroot} } tag.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/source/util/TreePathScanner.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/source/util/TreePathScanner.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,10 @@
  * Inside your method, call super.visitXYZ to visit descendant
  * nodes.
  *
+ * @apiNote
+ * In order to initialize the "current path", the scan must be
+ * started by calling one of the {@code scan} methods.
+ *
  * @author Jonathan Gibbons
  * @since 1.6
  */
@@ -58,6 +62,13 @@
     /**
      * Scans a single node.
      * The current path is updated for the duration of the scan.
+     *
+     * @apiNote This method should normally only be called by the
+     * scanner's {@code visit} methods, as part of an ongoing scan
+     * initiated by {@link #scan(TreePath,Object) scan(TreePath, P)}.
+     * The one exception is that it may also be called to initiate
+     * a full scan of a {@link CompilationUnitTree}.
+     *
      * @return the result value from the visit method
      */
     @Override
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java	Tue Oct 18 17:14:09 2016 +0000
@@ -31,6 +31,7 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Set;
+import java.util.function.Function;
 
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileManager.Location;
@@ -38,10 +39,14 @@
 import javax.tools.JavaFileObject.Kind;
 import javax.tools.StandardLocation;
 
+import com.sun.tools.javac.code.Symbol.Completer;
 import com.sun.tools.javac.code.Symbol.CompletionFailure;
 import com.sun.tools.javac.code.Symbol.ModuleSymbol;
+import com.sun.tools.javac.jvm.ModuleNameReader;
+import com.sun.tools.javac.jvm.ModuleNameReader.BadClassFile;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.resources.CompilerProperties.Fragments;
+import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.JCDiagnostic.Fragment;
@@ -50,7 +55,6 @@
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
-import com.sun.tools.javac.util.StringUtils;
 
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 
@@ -84,6 +88,10 @@
 
     private final JCDiagnostic.Factory diags;
 
+    private ModuleNameReader moduleNameReader;
+
+    public ModuleInfoSourceFileCompleter sourceFileCompleter;
+
     /** Get the ModuleFinder instance for this invocation. */
     public static ModuleFinder instance(Context context) {
         ModuleFinder instance = context.get(moduleFinderKey);
@@ -182,6 +190,8 @@
         return list;
     }
 
+    private boolean inFindSingleModule;
+
     public ModuleSymbol findSingleModule() {
         try {
             JavaFileObject src_fo = getModuleInfoFromLocation(StandardLocation.SOURCE_PATH, Kind.SOURCE);
@@ -194,26 +204,41 @@
             if (fo == null) {
                 msym = syms.unnamedModule;
             } else {
-                // Note: the following may trigger a re-entrant call to Modules.enter
-//                msym = new ModuleSymbol();
-//                ClassSymbol info = new ClassSymbol(Flags.MODULE, names.module_info, msym);
-//                info.modle = msym;
-//                info.classfile = fo;
-//                info.members_field = WriteableScope.create(info);
-//                msym.module_info = info;
-                msym = ModuleSymbol.create(null, names.module_info);
-                msym.module_info.classfile = fo;
-                msym.completer = sym -> classFinder.fillIn(msym.module_info);
-//                // TODO: should we do the following here, or as soon as we find the name in
-//                // the source or class file?
-//                // Consider the case when the class/source path module shadows one on the
-//                // module source path
-//                if (syms.modules.get(msym.name) != null) {
-//                    // error: module already defined
-//                    System.err.println("ERROR: module already defined: " + msym);
-//                } else {
-//                    syms.modules.put(msym.name, msym);
-//                }
+                switch (fo.getKind()) {
+                    case SOURCE:
+                        if (!inFindSingleModule) {
+                            try {
+                                inFindSingleModule = true;
+                                // Note: the following will trigger a re-entrant call to Modules.enter
+                                msym = sourceFileCompleter.complete(fo);
+                                msym.module_info.classfile = fo;
+                            } finally {
+                                inFindSingleModule = false;
+                            }
+                        } else {
+                            //the module-info.java does not contain a module declaration,
+                            //avoid infinite recursion:
+                            msym = syms.unnamedModule;
+                        }
+                        break;
+                    case CLASS:
+                        Name name;
+                        try {
+                            name = names.fromString(readModuleName(fo));
+                        } catch (BadClassFile | IOException ex) {
+                            //fillIn will report proper errors:
+                            name = names.error;
+                        }
+                        msym = syms.enterModule(name);
+                        msym.module_info.classfile = fo;
+                        msym.completer = Completer.NULL_COMPLETER;
+                        classFinder.fillIn(msym.module_info);
+                        break;
+                    default:
+                        Assert.error();
+                        msym = syms.unnamedModule;
+                        break;
+                }
             }
 
             msym.classLocation = StandardLocation.CLASS_OUTPUT;
@@ -224,6 +249,12 @@
         }
     }
 
+    private String readModuleName(JavaFileObject jfo) throws IOException, ModuleNameReader.BadClassFile {
+        if (moduleNameReader == null)
+            moduleNameReader = new ModuleNameReader();
+        return moduleNameReader.readModuleName(jfo);
+    }
+
     private JavaFileObject getModuleInfoFromLocation(Location location, Kind kind) throws IOException {
         if (!fileManager.hasLocation(location))
             return null;
@@ -332,4 +363,8 @@
         }
     }
 
+    public interface ModuleInfoSourceFileCompleter {
+        public ModuleSymbol complete(JavaFileObject file);
+    }
+
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Oct 18 17:14:09 2016 +0000
@@ -916,7 +916,6 @@
 
         /**
          * Create a ModuleSymbol with an associated module-info ClassSymbol.
-         * The name of the module may be null, if it is not known yet.
          */
         public static ModuleSymbol create(Name name, Name module_info) {
             ModuleSymbol msym = new ModuleSymbol(name, null);
@@ -930,6 +929,7 @@
 
         public ModuleSymbol(Name name, Symbol owner) {
             super(MDL, 0, name, null, owner);
+            Assert.checkNonNull(name);
             this.type = new ModuleType(this);
         }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Tue Oct 18 17:14:09 2016 +0000
@@ -764,17 +764,6 @@
         return msym;
     }
 
-    public void enterModule(ModuleSymbol msym, Name name) {
-        Assert.checkNull(modules.get(name));
-        Assert.checkNull(msym.name);
-        msym.name = name;
-        addRootPackageFor(msym);
-        ClassSymbol info = msym.module_info;
-        info.fullname = msym.name.append('.', names.module_info);
-        info.flatname = info.fullname;
-        modules.put(name, msym);
-    }
-
     public ModuleSymbol getModule(Name name) {
         return modules.get(name);
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Oct 18 17:14:09 2016 +0000
@@ -4415,6 +4415,7 @@
                 chk.checkDeprecatedAnnotation(env.tree.pos(), c);
                 chk.checkClassOverrideEqualsAndHashIfNeeded(env.tree.pos(), c);
                 chk.checkFunctionalInterface((JCClassDecl) env.tree, c);
+                chk.checkLeaksNotAccessible(env, (JCClassDecl) env.tree);
             } finally {
                 env.info.returnResult = prevReturnRes;
                 log.useSource(prev);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Tue Oct 18 17:14:09 2016 +0000
@@ -31,10 +31,13 @@
 
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Attribute.Compound;
+import com.sun.tools.javac.code.Directive.ExportsDirective;
+import com.sun.tools.javac.code.Directive.RequiresDirective;
 import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.resources.CompilerProperties.Fragments;
+import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
@@ -3661,4 +3664,178 @@
         }
     }
 
+    public void checkLeaksNotAccessible(Env<AttrContext> env, JCClassDecl check) {
+        JCCompilationUnit toplevel = env.toplevel;
+
+        if (   toplevel.modle == syms.unnamedModule
+            || toplevel.modle == syms.noModule
+            || (check.sym.flags() & COMPOUND) != 0) {
+            return ;
+        }
+
+        ExportsDirective currentExport = findExport(toplevel.packge);
+
+        if (   currentExport == null //not exported
+            || currentExport.modules != null) //don't check classes in qualified export
+            return ;
+
+        new TreeScanner() {
+            Lint lint = env.info.lint;
+            boolean inSuperType;
+
+            @Override
+            public void visitBlock(JCBlock tree) {
+            }
+            @Override
+            public void visitMethodDef(JCMethodDecl tree) {
+                if (!isAPISymbol(tree.sym))
+                    return;
+                Lint prevLint = lint;
+                try {
+                    lint = lint.augment(tree.sym);
+                    if (lint.isEnabled(LintCategory.EXPORTS)) {
+                        super.visitMethodDef(tree);
+                    }
+                } finally {
+                    lint = prevLint;
+                }
+            }
+            @Override
+            public void visitVarDef(JCVariableDecl tree) {
+                if (!isAPISymbol(tree.sym) && tree.sym.owner.kind != MTH)
+                    return;
+                Lint prevLint = lint;
+                try {
+                    lint = lint.augment(tree.sym);
+                    if (lint.isEnabled(LintCategory.EXPORTS)) {
+                        scan(tree.mods);
+                        scan(tree.vartype);
+                    }
+                } finally {
+                    lint = prevLint;
+                }
+            }
+            @Override
+            public void visitClassDef(JCClassDecl tree) {
+                if (tree != check)
+                    return ;
+
+                if (!isAPISymbol(tree.sym))
+                    return ;
+
+                Lint prevLint = lint;
+                try {
+                    lint = lint.augment(tree.sym);
+                    if (lint.isEnabled(LintCategory.EXPORTS)) {
+                        scan(tree.mods);
+                        scan(tree.typarams);
+                        try {
+                            inSuperType = true;
+                            scan(tree.extending);
+                            scan(tree.implementing);
+                        } finally {
+                            inSuperType = false;
+                        }
+                        scan(tree.defs);
+                    }
+                } finally {
+                    lint = prevLint;
+                }
+            }
+            @Override
+            public void visitTypeApply(JCTypeApply tree) {
+                scan(tree.clazz);
+                boolean oldInSuperType = inSuperType;
+                try {
+                    inSuperType = false;
+                    scan(tree.arguments);
+                } finally {
+                    inSuperType = oldInSuperType;
+                }
+            }
+            @Override
+            public void visitIdent(JCIdent tree) {
+                Symbol sym = TreeInfo.symbol(tree);
+                if (sym.kind == TYP && !sym.type.hasTag(TYPEVAR)) {
+                    checkVisible(tree.pos(), sym, toplevel.packge, inSuperType);
+                }
+            }
+
+            @Override
+            public void visitSelect(JCFieldAccess tree) {
+                Symbol sym = TreeInfo.symbol(tree);
+                Symbol sitesym = TreeInfo.symbol(tree.selected);
+                if (sym.kind == TYP && sitesym.kind == PCK) {
+                    checkVisible(tree.pos(), sym, toplevel.packge, inSuperType);
+                } else {
+                    super.visitSelect(tree);
+                }
+            }
+
+            @Override
+            public void visitAnnotation(JCAnnotation tree) {
+                if (tree.attribute.type.tsym.getAnnotation(java.lang.annotation.Documented.class) != null)
+                    super.visitAnnotation(tree);
+            }
+
+        }.scan(check);
+    }
+        //where:
+        private ExportsDirective findExport(PackageSymbol pack) {
+            for (ExportsDirective d : pack.modle.exports) {
+                if (d.packge == pack)
+                    return d;
+            }
+
+            return null;
+        }
+        private boolean isAPISymbol(Symbol sym) {
+            while (sym.kind != PCK) {
+                if ((sym.flags() & Flags.PUBLIC) == 0 && (sym.flags() & Flags.PROTECTED) == 0) {
+                    return false;
+                }
+                sym = sym.owner;
+            }
+            return true;
+        }
+        private void checkVisible(DiagnosticPosition pos, Symbol what, PackageSymbol inPackage, boolean inSuperType) {
+            if (!isAPISymbol(what) && !inSuperType) { //package private/private element
+                log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessible(kindName(what), what, what.packge().modle));
+                return ;
+            }
+
+            PackageSymbol whatPackage = what.packge();
+            ExportsDirective whatExport = findExport(whatPackage);
+            ExportsDirective inExport = findExport(inPackage);
+
+            if (whatExport == null) { //package not exported:
+                log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleUnexported(kindName(what), what, what.packge().modle));
+                return ;
+            }
+
+            if (whatExport.modules != null) {
+                if (inExport.modules == null || !whatExport.modules.containsAll(inExport.modules)) {
+                    log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleUnexportedQualified(kindName(what), what, what.packge().modle));
+                }
+            }
+
+            if (whatPackage.modle != inPackage.modle && whatPackage.modle != syms.java_base) {
+                //check that relativeTo.modle requires public what.modle, somehow:
+                List<ModuleSymbol> todo = List.of(inPackage.modle);
+
+                while (todo.nonEmpty()) {
+                    ModuleSymbol current = todo.head;
+                    todo = todo.tail;
+                    if (current == whatPackage.modle)
+                        return ; //OK
+                    for (RequiresDirective req : current.requires) {
+                        if (req.isPublic()) {
+                            todo = todo.prepend(req.module);
+                        }
+                    }
+                }
+
+                log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleNotRequiredPublic(kindName(what), what, what.packge().modle));
+            }
+        }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Tue Oct 18 17:14:09 2016 +0000
@@ -292,15 +292,12 @@
             Name name = TreeInfo.fullName(decl.qualId);
             ModuleSymbol sym;
             if (c != null) {
-               sym = (ModuleSymbol) c.owner;
-               if (sym.name == null) {
-                   //ModuleFinder.findSingleModule creates a stub of a ModuleSymbol without a name,
-                   //fill the name here after the module-info.java has been parsed
-                   //also enter the ModuleSymbol among modules:
-                   syms.enterModule(sym, name);
-               } else {
-                   // TODO: validate name
-               }
+                sym = (ModuleSymbol) c.owner;
+                Assert.checkNonNull(sym.name);
+                Name treeName = TreeInfo.fullName(decl.qualId);
+                if (sym.name != treeName) {
+                    log.error(decl.pos(), Errors.ModuleNameMismatch(name, sym.name));
+                }
             } else {
                 sym = syms.enterModule(name);
                 if (sym.module_info.sourcefile != null && sym.module_info.sourcefile != toplevel.sourcefile) {
@@ -1006,6 +1003,10 @@
         return new Symbol.Completer() {
             @Override
             public void complete(Symbol sym) throws CompletionFailure {
+                if (inInitModules) {
+                    sym.completer = this;
+                    return ;
+                }
                 ModuleSymbol msym = (ModuleSymbol) sym;
                 Set<ModuleSymbol> allModules = allModules();
                 for (ModuleSymbol m : allModules) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Tue Oct 18 17:14:09 2016 +0000
@@ -415,10 +415,10 @@
                 if (!isSameMemberWhenErased(dest, impl, impl_erasure))
                     return true;
 
-                // If the erasure of the return type is different, a
-                // bridge is needed.
-                return !types.isSameType(impl_erasure.getReturnType(),
-                                         method_erasure.getReturnType());
+                /* Bottom line: A bridge is needed if the erasure of the implementation
+                   is different from that of the method that it overrides.
+                */
+                return !types.isSameType(impl_erasure, method_erasure);
             } else {
                // method and impl are the same...
                 if ((method.flags() & ABSTRACT) != 0) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Tue Oct 18 17:14:09 2016 +0000
@@ -78,8 +78,10 @@
 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;
+import com.sun.tools.javac.util.JDK9Wrappers;
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.jvm.ModuleNameReader;
 import com.sun.tools.javac.util.Pair;
 import com.sun.tools.javac.util.StringUtils;
 
@@ -1102,6 +1104,11 @@
 
                 if (p.getFileName().toString().endsWith(".jmod")) {
                     try {
+                        // check if the JMOD file is valid
+                        JDK9Wrappers.JmodFile.checkMagic(p);
+
+                        // No JMOD file system.  Use JarFileSystem to
+                        // workaround for now
                         FileSystem fs = fileSystems.get(p);
                         if (fs == null) {
                             URI uri = URI.create("jar:" + p.toUri());
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ModuleNameReader.java	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +0,0 @@
-/*
- * 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
- * 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.file;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import com.sun.tools.javac.jvm.ClassFile;
-
-import static com.sun.tools.javac.jvm.ClassFile.*;
-
-
-/**
- * Stripped down ClassReader, just sufficient to read module names from module-info.class files
- * while analyzing the module path.
- *
- * <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>
- */
-public class ModuleNameReader {
-    static class BadClassFile extends Exception {
-        private static final long serialVersionUID = 0;
-        BadClassFile(String msg) {
-            super(msg);
-        }
-    }
-
-    private static final int INITIAL_BUFFER_SIZE = 0x0fff0;
-
-    /** The buffer containing the currently read class file.
-     */
-    private byte[] buf = new byte[INITIAL_BUFFER_SIZE];
-
-    /** The current input pointer.
-     */
-    private int bp;
-
-    /** The objects of the constant pool.
-     */
-    private Object[] poolObj;
-
-    /** For every constant pool entry, an index into buf where the
-     *  defining section of the entry is found.
-     */
-    private int[] poolIdx;
-
-    ModuleNameReader() {
-    }
-
-    String readModuleName(Path p) throws IOException, BadClassFile {
-        try (InputStream in = Files.newInputStream(p)) {
-            bp = 0;
-            buf = readInputStream(buf, in);
-
-            int magic = nextInt();
-            if (magic != JAVA_MAGIC)
-                throw new BadClassFile("illegal.start.of.class.file");
-
-            int minorVersion = nextChar();
-            int majorVersion = nextChar();
-
-            indexPool();
-
-            int accessflags = nextChar();
-            return readModuleInfoName(nextChar());
-        }
-    }
-
-    /** Extract a character at position bp from buf.
-     */
-    char getChar(int bp) {
-        return
-            (char)(((buf[bp] & 0xFF) << 8) + (buf[bp+1] & 0xFF));
-    }
-
-    /** Read a character.
-     */
-    char nextChar() {
-        return (char)(((buf[bp++] & 0xFF) << 8) + (buf[bp++] & 0xFF));
-    }
-
-    /** Read an integer.
-     */
-    int nextInt() {
-        return
-            ((buf[bp++] & 0xFF) << 24) +
-            ((buf[bp++] & 0xFF) << 16) +
-            ((buf[bp++] & 0xFF) << 8) +
-            (buf[bp++] & 0xFF);
-    }
-
-    /** Index all constant pool entries, writing their start addresses into
-     *  poolIdx.
-     */
-    void indexPool() throws BadClassFile {
-        poolIdx = new int[nextChar()];
-        poolObj = new Object[poolIdx.length];
-        int i = 1;
-        while (i < poolIdx.length) {
-            poolIdx[i++] = bp;
-            byte tag = buf[bp++];
-            switch (tag) {
-            case CONSTANT_Utf8: case CONSTANT_Unicode: {
-                int len = nextChar();
-                bp = bp + len;
-                break;
-            }
-            case CONSTANT_Class:
-            case CONSTANT_String:
-            case CONSTANT_MethodType:
-                bp = bp + 2;
-                break;
-            case CONSTANT_MethodHandle:
-                bp = bp + 3;
-                break;
-            case CONSTANT_Fieldref:
-            case CONSTANT_Methodref:
-            case CONSTANT_InterfaceMethodref:
-            case CONSTANT_NameandType:
-            case CONSTANT_Integer:
-            case CONSTANT_Float:
-            case CONSTANT_InvokeDynamic:
-                bp = bp + 4;
-                break;
-            case CONSTANT_Long:
-            case CONSTANT_Double:
-                bp = bp + 8;
-                i++;
-                break;
-            default:
-                throw new BadClassFile("malformed constant pool");
-            }
-        }
-    }
-
-    /** Read the class name of a module-info.class file.
-     * The name is stored in a CONSTANT_Class entry, where the
-     * class name is of the form module-name/module-info.
-     */
-    String readModuleInfoName(int i) throws BadClassFile {
-        int classIndex = poolIdx[i];
-        if (buf[classIndex] == CONSTANT_Class) {
-            int utf8Index = poolIdx[getChar(classIndex + 1)];
-            if (buf[utf8Index] == CONSTANT_Utf8) {
-                int len = getChar(utf8Index + 1);
-                int start = utf8Index + 3;
-                String suffix = "/module-info";
-                if (endsWith(buf, start, len, suffix))
-                    return new String(ClassFile.internalize(buf, start, len - suffix.length()));
-            }
-        }
-        throw new BadClassFile("bad module-info name");
-    }
-
-    private boolean endsWith(byte[] buf, int start, int len, String suffix) {
-        if (len <= suffix.length())
-            return false;
-        for (int i = 0; i < suffix.length(); i++) {
-            if (buf[start + len - suffix.length() + i] != suffix.charAt(i))
-                return false;
-        }
-        return true;
-    }
-
-    private static byte[] readInputStream(byte[] buf, InputStream s) throws IOException {
-        try {
-            buf = ensureCapacity(buf, s.available());
-            int r = s.read(buf);
-            int bp = 0;
-            while (r != -1) {
-                bp += r;
-                buf = ensureCapacity(buf, bp);
-                r = s.read(buf, bp, buf.length - bp);
-            }
-            return buf;
-        } finally {
-            try {
-                s.close();
-            } catch (IOException e) {
-                /* Ignore any errors, as this stream may have already
-                 * thrown a related exception which is the one that
-                 * should be reported.
-                 */
-            }
-        }
-    }
-
-    /*
-     * ensureCapacity will increase the buffer as needed, taking note that
-     * the new buffer will always be greater than the needed and never
-     * exactly equal to the needed size or bp. If equal then the read (above)
-     * will infinitely loop as buf.length - bp == 0.
-     */
-    private static byte[] ensureCapacity(byte[] buf, int needed) {
-        if (buf.length <= needed) {
-            byte[] old = buf;
-            buf = new byte[Integer.highestOneBit(needed) << 1];
-            System.arraycopy(old, 0, buf, 0, old.length);
-        }
-        return buf;
-    }
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -2396,12 +2396,15 @@
         } else {
             c.flags_field = flags;
             Name modInfoName = readModuleInfoName(nextChar());
-            if (c.owner.name == null) {
-                syms.enterModule((ModuleSymbol) c.owner, Convert.packagePart(modInfoName));
-            } else {
-                // TODO: validate name
+            currentModule = (ModuleSymbol) c.owner;
+            if (currentModule.name.append('.', names.module_info) != modInfoName) {
+                //strip trailing .module-info, if exists:
+                int modInfoStart = modInfoName.length() - names.module_info.length();
+                modInfoName = modInfoName.subName(modInfoStart, modInfoName.length()) == names.module_info &&
+                              modInfoName.charAt(modInfoStart - 1) == '.' ?
+                                  modInfoName.subName(0, modInfoStart - 1) : modInfoName;
+                throw badClassFile("module.name.mismatch", modInfoName, currentModule.name);
             }
-            currentModule = (ModuleSymbol) c.owner;
         }
 
         // class attributes must be read before class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ModuleNameReader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,235 @@
+/*
+ * 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
+ * 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.jvm;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.jvm.ClassFile;
+
+import static com.sun.tools.javac.jvm.ClassFile.*;
+
+
+/**
+ * Stripped down ClassReader, just sufficient to read module names from module-info.class files
+ * while analyzing the module path.
+ *
+ * <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>
+ */
+public class ModuleNameReader {
+    public static class BadClassFile extends Exception {
+        private static final long serialVersionUID = 0;
+        BadClassFile(String msg) {
+            super(msg);
+        }
+    }
+
+    private static final int INITIAL_BUFFER_SIZE = 0x0fff0;
+
+    /** The buffer containing the currently read class file.
+     */
+    private byte[] buf = new byte[INITIAL_BUFFER_SIZE];
+
+    /** The current input pointer.
+     */
+    private int bp;
+
+    /** For every constant pool entry, an index into buf where the
+     *  defining section of the entry is found.
+     */
+    private int[] poolIdx;
+
+    public ModuleNameReader() {
+    }
+
+    public String readModuleName(Path p) throws IOException, BadClassFile {
+        try (InputStream in = Files.newInputStream(p)) {
+            return readModuleName(in);
+        }
+    }
+
+    public String readModuleName(JavaFileObject jfo) throws IOException, BadClassFile {
+        try (InputStream in = jfo.openInputStream()) {
+            return readModuleName(in);
+        }
+    }
+
+    public String readModuleName(InputStream in) throws IOException, BadClassFile {
+        bp = 0;
+        buf = readInputStream(buf, in);
+
+        int magic = nextInt();
+        if (magic != JAVA_MAGIC)
+            throw new BadClassFile("illegal.start.of.class.file");
+
+        int minorVersion = nextChar();
+        int majorVersion = nextChar();
+
+        indexPool();
+
+        int accessflags = nextChar();
+        return readModuleInfoName(nextChar());
+    }
+
+    /** Extract a character at position bp from buf.
+     */
+    char getChar(int bp) {
+        return
+            (char)(((buf[bp] & 0xFF) << 8) + (buf[bp+1] & 0xFF));
+    }
+
+    /** Read a character.
+     */
+    char nextChar() {
+        return (char)(((buf[bp++] & 0xFF) << 8) + (buf[bp++] & 0xFF));
+    }
+
+    /** Read an integer.
+     */
+    int nextInt() {
+        return
+            ((buf[bp++] & 0xFF) << 24) +
+            ((buf[bp++] & 0xFF) << 16) +
+            ((buf[bp++] & 0xFF) << 8) +
+            (buf[bp++] & 0xFF);
+    }
+
+    /** Index all constant pool entries, writing their start addresses into
+     *  poolIdx.
+     */
+    void indexPool() throws BadClassFile {
+        poolIdx = new int[nextChar()];
+        int i = 1;
+        while (i < poolIdx.length) {
+            poolIdx[i++] = bp;
+            byte tag = buf[bp++];
+            switch (tag) {
+            case CONSTANT_Utf8: case CONSTANT_Unicode: {
+                int len = nextChar();
+                bp = bp + len;
+                break;
+            }
+            case CONSTANT_Class:
+            case CONSTANT_String:
+            case CONSTANT_MethodType:
+                bp = bp + 2;
+                break;
+            case CONSTANT_MethodHandle:
+                bp = bp + 3;
+                break;
+            case CONSTANT_Fieldref:
+            case CONSTANT_Methodref:
+            case CONSTANT_InterfaceMethodref:
+            case CONSTANT_NameandType:
+            case CONSTANT_Integer:
+            case CONSTANT_Float:
+            case CONSTANT_InvokeDynamic:
+                bp = bp + 4;
+                break;
+            case CONSTANT_Long:
+            case CONSTANT_Double:
+                bp = bp + 8;
+                i++;
+                break;
+            default:
+                throw new BadClassFile("malformed constant pool");
+            }
+        }
+    }
+
+    /** Read the class name of a module-info.class file.
+     * The name is stored in a CONSTANT_Class entry, where the
+     * class name is of the form module-name/module-info.
+     */
+    String readModuleInfoName(int i) throws BadClassFile {
+        int classIndex = poolIdx[i];
+        if (buf[classIndex] == CONSTANT_Class) {
+            int utf8Index = poolIdx[getChar(classIndex + 1)];
+            if (buf[utf8Index] == CONSTANT_Utf8) {
+                int len = getChar(utf8Index + 1);
+                int start = utf8Index + 3;
+                String suffix = "/module-info";
+                if (endsWith(buf, start, len, suffix))
+                    return new String(ClassFile.internalize(buf, start, len - suffix.length()));
+            }
+        }
+        throw new BadClassFile("bad module-info name");
+    }
+
+    private boolean endsWith(byte[] buf, int start, int len, String suffix) {
+        if (len <= suffix.length())
+            return false;
+        for (int i = 0; i < suffix.length(); i++) {
+            if (buf[start + len - suffix.length() + i] != suffix.charAt(i))
+                return false;
+        }
+        return true;
+    }
+
+    private static byte[] readInputStream(byte[] buf, InputStream s) throws IOException {
+        try {
+            buf = ensureCapacity(buf, s.available());
+            int r = s.read(buf);
+            int bp = 0;
+            while (r != -1) {
+                bp += r;
+                buf = ensureCapacity(buf, bp);
+                r = s.read(buf, bp, buf.length - bp);
+            }
+            return buf;
+        } finally {
+            try {
+                s.close();
+            } catch (IOException e) {
+                /* Ignore any errors, as this stream may have already
+                 * thrown a related exception which is the one that
+                 * should be reported.
+                 */
+            }
+        }
+    }
+
+    /*
+     * ensureCapacity will increase the buffer as needed, taking note that
+     * the new buffer will always be greater than the needed and never
+     * exactly equal to the needed size or bp. If equal then the read (above)
+     * will infinitely loop as buf.length - bp == 0.
+     */
+    private static byte[] ensureCapacity(byte[] buf, int needed) {
+        if (buf.length <= needed) {
+            byte[] old = buf;
+            buf = new byte[Integer.highestOneBit(needed) << 1];
+            System.arraycopy(old, 0, buf, 0, old.length);
+        }
+        return buf;
+    }
+}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/CommandLine.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/CommandLine.java	Tue Oct 18 17:14:09 2016 +0000
@@ -27,7 +27,6 @@
 
 import java.io.IOException;
 import java.io.Reader;
-import java.io.StreamTokenizer;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 
@@ -51,10 +50,11 @@
      * '@file' argument replaced with the resulting tokens. Recursive command
      * files are not supported. The '@' character itself can be quoted with
      * the sequence '@@'.
+     * @param args the arguments that may contain @files
+     * @return the arguments, with @files expanded
+     * @throws IOException if there is a problem reading any of the @files
      */
-    public static String[] parse(String[] args)
-        throws IOException
-    {
+    public static String[] parse(String[] args) throws IOException {
         ListBuffer<String> newArgs = new ListBuffer<>();
         for (String arg : args) {
             if (arg.length() > 1 && arg.charAt(0) == '@') {
@@ -71,19 +71,120 @@
         return newArgs.toList().toArray(new String[newArgs.length()]);
     }
 
-    private static void loadCmdFile(String name, ListBuffer<String> args)
-        throws IOException
-    {
+    private static void loadCmdFile(String name, ListBuffer<String> args) throws IOException {
         try (Reader r = Files.newBufferedReader(Paths.get(name))) {
-            StreamTokenizer st = new StreamTokenizer(r);
-            st.resetSyntax();
-            st.wordChars(' ', 255);
-            st.whitespaceChars(0, ' ');
-            st.commentChar('#');
-            st.quoteChar('"');
-            st.quoteChar('\'');
-            while (st.nextToken() != StreamTokenizer.TT_EOF) {
-                args.append(st.sval);
+            Tokenizer t = new Tokenizer(r);
+            String s;
+            while ((s = t.nextToken()) != null) {
+                args.append(s);
+            }
+        }
+    }
+
+    public static class Tokenizer {
+        private final Reader in;
+        private int ch;
+
+        public Tokenizer(Reader in) throws IOException {
+            this.in = in;
+            ch = in.read();
+        }
+
+        public String nextToken() throws IOException {
+            skipWhite();
+            if (ch == -1) {
+                return null;
+            }
+
+            StringBuilder sb = new StringBuilder();
+            char quoteChar = 0;
+
+            while (ch != -1) {
+                switch (ch) {
+                    case ' ':
+                    case '\t':
+                    case '\f':
+                        if (quoteChar == 0) {
+                            return sb.toString();
+                        }
+                        sb.append((char) ch);
+                        break;
+
+                    case '\n':
+                    case '\r':
+                        return sb.toString();
+
+                    case '\'':
+                    case '"':
+                        if (quoteChar == 0) {
+                            quoteChar = (char) ch;
+                        } else if (quoteChar == ch) {
+                            quoteChar = 0;
+                        } else {
+                            sb.append((char) ch);
+                        }
+                        break;
+
+                    case '\\':
+                        if (quoteChar != 0) {
+                            ch = in.read();
+                            switch (ch) {
+                                case '\n':
+                                case '\r':
+                                    while (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\f') {
+                                        ch = in.read();
+                                    }
+                                    continue;
+
+                                case 'n':
+                                    ch = '\n';
+                                    break;
+                                case 'r':
+                                    ch = '\r';
+                                    break;
+                                case 't':
+                                    ch = '\t';
+                                    break;
+                                case 'f':
+                                    ch = '\f';
+                                    break;
+                            }
+                        }
+                        sb.append((char) ch);
+                        break;
+
+                    default:
+                        sb.append((char) ch);
+                }
+
+                ch = in.read();
+            }
+
+            return sb.toString();
+        }
+
+        void skipWhite() throws IOException {
+            while (ch != -1) {
+                switch (ch) {
+                    case ' ':
+                    case '\t':
+                    case '\n':
+                    case '\r':
+                    case '\f':
+                        break;
+
+                    case '#':
+                        ch = in.read();
+                        while (ch != '\n' && ch != '\r' && ch != -1) {
+                            ch = in.read();
+                        }
+                        break;
+
+                    default:
+                        return;
+                }
+
+                ch = in.read();
             }
         }
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Oct 18 17:14:09 2016 +0000
@@ -37,6 +37,7 @@
 import java.util.Queue;
 import java.util.ResourceBundle;
 import java.util.Set;
+import java.util.function.Function;
 
 import javax.annotation.processing.Processor;
 import javax.lang.model.SourceVersion;
@@ -67,7 +68,9 @@
 import com.sun.tools.javac.tree.JCTree.JCLambda;
 import com.sun.tools.javac.tree.JCTree.JCMemberReference;
 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
+import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.tree.JCTree.Tag;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.JCDiagnostic.Factory;
@@ -341,6 +344,13 @@
                 }
             };
 
+    protected final ModuleFinder.ModuleInfoSourceFileCompleter moduleInfoSourceFileCompleter =
+            fo -> (ModuleSymbol) readSourceFile(parseImplicitFile(fo), null, tl -> {
+                return tl.defs.nonEmpty() && tl.defs.head.hasTag(Tag.MODULEDEF) ?
+                        ((JCModuleDecl) tl.defs.head).sym.module_info :
+                        syms.defineClass(names.module_info, syms.errModule);
+            }).owner;
+
     /**
      * Command line options.
      */
@@ -411,6 +421,7 @@
         diags = Factory.instance(context);
 
         finder.sourceCompleter = sourceCompleter;
+        moduleFinder.sourceFileCompleter = moduleInfoSourceFileCompleter;
 
         options = Options.instance(context);
 
@@ -779,6 +790,19 @@
         readSourceFile(null, c);
     }
 
+    private JCTree.JCCompilationUnit parseImplicitFile(JavaFileObject filename) {
+        JavaFileObject prev = log.useSource(filename);
+        try {
+            JCTree.JCCompilationUnit t = parse(filename, filename.getCharContent(false));
+            return t;
+        } catch (IOException e) {
+            log.error("error.reading.file", filename, JavacFileManager.getMessage(e));
+            return make.TopLevel(List.<JCTree>nil());
+        } finally {
+            log.useSource(prev);
+        }
+    }
+
     /** Compile a ClassSymbol from source, optionally using the given compilation unit as
      *  the source tree.
      *  @param tree the compilation unit in which the given ClassSymbol resides,
@@ -789,20 +813,20 @@
         if (completionFailureName == c.fullname) {
             throw new CompletionFailure(c, "user-selected completion failure by class name");
         }
-        JavaFileObject filename = c.classfile;
-        JavaFileObject prev = log.useSource(filename);
 
         if (tree == null) {
-            try {
-                tree = parse(filename, filename.getCharContent(false));
-            } catch (IOException e) {
-                log.error("error.reading.file", filename, JavacFileManager.getMessage(e));
-                tree = make.TopLevel(List.<JCTree>nil());
-            } finally {
-                log.useSource(prev);
-            }
+            tree = parseImplicitFile(c.classfile);
         }
 
+        readSourceFile(tree, c, cut -> c);
+    }
+
+    private ClassSymbol readSourceFile(JCCompilationUnit tree,
+                                       ClassSymbol expectedSymbol,
+                                       Function<JCCompilationUnit, ClassSymbol> symbolGetter)
+                                           throws CompletionFailure {
+        Assert.checkNonNull(tree);
+
         if (!taskListener.isEmpty()) {
             TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, tree);
             taskListener.started(e);
@@ -814,18 +838,20 @@
         // Note that if module resolution failed, we may not even
         // have enough modules available to access java.lang, and
         // so risk getting FatalError("no.java.lang") from MemberEnter.
-        if (!modules.enter(List.of(tree), c)) {
-            throw new CompletionFailure(c, diags.fragment("cant.resolve.modules"));
+        if (!modules.enter(List.of(tree), expectedSymbol)) {
+            throw new CompletionFailure(symbolGetter.apply(tree),
+                                        diags.fragment("cant.resolve.modules"));
         }
 
-        enter.complete(List.of(tree), c);
+        enter.complete(List.of(tree), expectedSymbol);
 
         if (!taskListener.isEmpty()) {
             TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, tree);
             taskListener.finished(e);
         }
 
-        if (enter.getEnv(c) == null) {
+        ClassSymbol sym = symbolGetter.apply(tree);
+        if (sym == null || enter.getEnv(sym) == null) {
             boolean isPkgInfo =
                 tree.sourcefile.isNameCompatible("package-info",
                                                  JavaFileObject.Kind.SOURCE);
@@ -836,24 +862,26 @@
                 if (enter.getEnv(tree.modle) == null) {
                     JCDiagnostic diag =
                         diagFactory.fragment("file.does.not.contain.module");
-                    throw new ClassFinder.BadClassFile(c, filename, diag, diagFactory);
+                    throw new ClassFinder.BadClassFile(sym, tree.sourcefile, diag, diagFactory);
                 }
             } else if (isPkgInfo) {
                 if (enter.getEnv(tree.packge) == null) {
                     JCDiagnostic diag =
                         diagFactory.fragment("file.does.not.contain.package",
-                                                 c.location());
-                    throw new ClassFinder.BadClassFile(c, filename, diag, diagFactory);
+                                                 sym.location());
+                    throw new ClassFinder.BadClassFile(sym, tree.sourcefile, diag, diagFactory);
                 }
             } else {
                 JCDiagnostic diag =
                         diagFactory.fragment("file.doesnt.contain.class",
-                                            c.getQualifiedName());
-                throw new ClassFinder.BadClassFile(c, filename, diag, diagFactory);
+                                            sym.getQualifiedName());
+                throw new ClassFinder.BadClassFile(sym, tree.sourcefile, diag, diagFactory);
             }
         }
 
         implicitSourceFilesRead = true;
+
+        return sym;
     }
 
     /** Track when the JavaCompiler has been used to compile something. */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavacToolProvider.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,48 @@
+/*
+ * 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 com.sun.tools.javac.main;
+
+import java.io.PrintWriter;
+import java.util.spi.ToolProvider;
+
+/**
+ * An implementation of the {@link java.util.spi.ToolProvider ToolProvider} SPI,
+ * providing access to JDK Java compiler, javac.
+ *
+ * @since 9
+ */
+// This is currently a stand-alone top-level class so that it can easily be excluded
+// from interims builds of javac, used while building JDK.
+public class JavacToolProvider implements ToolProvider {
+    public String name() {
+        return "javac";
+    }
+
+    public int run(PrintWriter out, PrintWriter err, String... args) {
+        Main compiler = new Main("javac", out, err);
+        return compiler.compile(args).exitCode;
+    }
+}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java	Tue Oct 18 17:14:09 2016 +0000
@@ -119,6 +119,18 @@
         this.stdOut = this.stdErr = out;
     }
 
+    /**
+     * Construct a compiler instance.
+     * @param name the name of this tool
+     * @param out a stream to which to write expected output
+     * @param err a stream to which to write diagnostic output
+     */
+    public Main(String name, PrintWriter out, PrintWriter err) {
+        this.ownName = name;
+        this.stdOut = out;
+        this.stdErr = err;
+    }
+
     /** Report a usage error.
      */
     void error(String key, Object... args) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Tue Oct 18 17:14:09 2016 +0000
@@ -425,8 +425,7 @@
     J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, ArgKind.ADJACENT) {
         @Override
         public boolean process(OptionHelper helper, String option) {
-            throw new AssertionError
-                ("the -J flag should be caught by the launcher.");
+            throw new AssertionError("the -J flag should be caught by the launcher.");
         }
     },
 
@@ -691,7 +690,7 @@
          * This option takes an argument.
          * If the name of option ends with ':' or '=', the argument must be provided directly
          * after that separator.
-         * Otherwise, if may appear after an '=' or in the following argument position.
+         * Otherwise, it may appear after an '=' or in the following argument position.
          */
         REQUIRED,
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1336,8 +1336,7 @@
 
         errorStatus = errorStatus || (compiler.errorCount() > 0);
 
-        if (!errorStatus)
-            round.finalCompiler();
+        round.finalCompiler();
 
         if (newSourceFiles.size() > 0)
             roots = roots.appendList(compiler.parseFiles(newSourceFiles));
@@ -1350,10 +1349,8 @@
         if (!taskListener.isEmpty())
             taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
 
-        if (errorStatus) {
-            if (compiler.errorCount() == 0)
-                compiler.log.nerrors++;
-            return true;
+        if (errorStatus && compiler.errorCount() == 0) {
+            compiler.log.nerrors++;
         }
 
         compiler.enterTreesIfNeeded(roots);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Oct 18 17:14:09 2016 +0000
@@ -2770,6 +2770,10 @@
 compiler.err.module.name.mismatch=\
     module name {0} does not match expected name {1}
 
+# 0: name, 1: name
+compiler.misc.module.name.mismatch=\
+    module name {0} does not match expected name {1}
+
 compiler.err.module.decl.sb.in.module-info.java=\
     module declarations should be in a file named module-info.java
 
@@ -2861,6 +2865,19 @@
 compiler.warn.service.provided.but.not.exported.or.used=\
     service interface provided but not exported or used
 
+# 0: kind name, 1: symbol, 2: symbol
+compiler.warn.leaks.not.accessible=\
+    {0} {1} in module {2} is not accessible to clients that require this module
+# 0: kind name, 1: symbol, 2: symbol
+compiler.warn.leaks.not.accessible.unexported=\
+    {0} {1} in module {2} is not exported
+# 0: kind name, 1: symbol, 2: symbol
+compiler.warn.leaks.not.accessible.not.required.public=\
+    {0} {1} in module {2} is not indirectly exported using 'requires public'
+# 0: kind name, 1: symbol, 2: symbol
+compiler.warn.leaks.not.accessible.unexported.qualified=\
+    {0} {1} in module {2} may not be visible to all clients that require this module
+
 ###
 # errors related to options
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java	Tue Oct 18 17:14:09 2016 +0000
@@ -203,11 +203,10 @@
      * where the trees are being synthesized by a tool.
      */
     @Override @DefinedBy(Api.COMPILER_TREE)
-    public DCDocComment newDocCommentTree(List<? extends DocTree> firstSentence, List<? extends DocTree> body, List<? extends DocTree> tags) {
+    public DCDocComment newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags) {
         ListBuffer<DCTree> lb = new ListBuffer<>();
-        lb.addAll(cast(firstSentence));
-        lb.addAll(cast(body));
-        List<DCTree> fullBody = lb.toList();
+        lb.addAll(cast(fullBody));
+        List<DCTree> fBody = lb.toList();
 
         // A dummy comment to keep the diagnostics logic happy.
         Comment c = new Comment() {
@@ -231,8 +230,8 @@
                 return false;
             }
         };
-
-        DCDocComment tree = new DCDocComment(c, fullBody, cast(firstSentence), cast(body), cast(tags));
+        Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
+        DCDocComment tree = new DCDocComment(c, fBody, pair.fst, pair.snd, cast(tags));
         return tree;
     }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Iterators.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Iterators.java	Tue Oct 18 17:14:09 2016 +0000
@@ -46,7 +46,8 @@
 
         private final Iterator<I> inputs;
         private final Function<I, Iterator<O>> convertor;
-        private Iterator<O> currentIterator;
+        @SuppressWarnings("unchecked")
+        private Iterator<O> currentIterator = EMPTY;
 
         public CompoundIterator(Iterable<I> inputs, Function<I, Iterator<O>> convertor) {
             this.inputs = inputs.iterator();
@@ -54,10 +55,10 @@
         }
 
         public boolean hasNext() {
-            while (inputs.hasNext() && (currentIterator == null || !currentIterator.hasNext())) {
-                currentIterator = convertor.apply(inputs.next());
+            if (currentIterator != null && !currentIterator.hasNext()) {
+                update();
             }
-            return currentIterator != null && currentIterator.hasNext();
+            return currentIterator != null;
         }
 
         public O next() {
@@ -70,5 +71,25 @@
         public void remove() {
             throw new UnsupportedOperationException();
         }
+
+        private void update() {
+            while (inputs.hasNext()) {
+                currentIterator = convertor.apply(inputs.next());
+                if (currentIterator.hasNext()) return;
+            }
+            currentIterator = null;
+        }
     }
+
+    @SuppressWarnings("rawtypes")
+    private final static Iterator EMPTY = new Iterator() {
+        public boolean hasNext() {
+            return false;
+        }
+
+        @Override
+        public Object next() {
+            return null;
+        }
+    };
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java	Tue Oct 18 17:14:09 2016 +0000
@@ -25,6 +25,7 @@
 
 package com.sun.tools.javac.util;
 
+import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.nio.file.Path;
@@ -367,4 +368,41 @@
             }
         }
     }
+
+    /**
+     * Helper class for new method in jdk.internal.jmod.JmodFile
+     */
+    public static final class JmodFile {
+        public static final String JMOD_FILE_CLASSNAME = "jdk.internal.jmod.JmodFile";
+
+        public static void checkMagic(Path file) throws IOException {
+            try {
+                init();
+                checkMagicMethod.invoke(null, file);
+            } catch (InvocationTargetException ex) {
+                if (ex.getCause() instanceof IOException) {
+                    throw IOException.class.cast(ex.getCause());
+                }
+                throw new Abort(ex);
+            } catch (IllegalAccessException | IllegalArgumentException | SecurityException ex) {
+                throw new Abort(ex);
+            }
+        }
+
+        // -----------------------------------------------------------------------------------------
+
+        private static Class<?> jmodFileClass = null;
+        private static Method checkMagicMethod = null;
+
+        private static void init() {
+            if (jmodFileClass == null) {
+                try {
+                    jmodFileClass = Class.forName(JMOD_FILE_CLASSNAME, false, null);
+                    checkMagicMethod = jmodFileClass.getDeclaredMethod("checkMagic", Path.class);
+                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
+                    throw new Abort(ex);
+                }
+            }
+        }
+    }
 }
--- a/langtools/src/jdk.compiler/share/classes/module-info.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -70,6 +70,9 @@
     uses com.sun.source.util.Plugin;
     uses com.sun.tools.javac.platform.PlatformProvider;
 
+    provides java.util.spi.ToolProvider
+        with com.sun.tools.javac.main.JavacToolProvider;
+
     provides com.sun.tools.javac.platform.PlatformProvider
         with com.sun.tools.javac.platform.JDKPlatformProvider;
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java	Tue Oct 18 17:14:09 2016 +0000
@@ -165,9 +165,11 @@
     public int isSupportedOption(String option) {
         if (option == null)
             throw new NullPointerException();
-        for (ToolOption o: ToolOption.values()) {
-            if (o.opt.equals(option))
-                return o.hasArg ? 1 : 0;
+        for (ToolOption o : ToolOption.values()) {
+            for (String name : o.names) {
+                if (name.equals(option))
+                    return o.hasArg ? 1 : 0;
+            }
         }
         return -1;
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -368,7 +368,7 @@
      * @param htmltree the content tree to which the comment will be added.
      */
     protected void addComment(Element member, Content htmltree) {
-        if (!utils.getBody(member).isEmpty()) {
+        if (!utils.getFullBody(member).isEmpty()) {
             writer.addInlineComment(member, htmltree);
         }
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -290,8 +290,8 @@
      */
     @Override
     public void addAnnotationTypeDescription(Content annotationInfoTree) {
-        if(!configuration.nocomment) {
-            if (!utils.getBody(annotationType).isEmpty()) {
+        if (!configuration.nocomment) {
+            if (!utils.getFullBody(annotationType).isEmpty()) {
                 addInlineComment(annotationType, annotationInfoTree);
             }
         }
@@ -302,7 +302,7 @@
      */
     @Override
     public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
-        if(!configuration.nocomment) {
+        if (!configuration.nocomment) {
             addTagsInfo(annotationType, annotationInfoTree);
         }
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -353,7 +353,7 @@
     public void addClassDescription(Content classInfoTree) {
         if(!configuration.nocomment) {
             // generate documentation for the class.
-            if (!utils.getBody(typeElement).isEmpty()) {
+            if (!utils.getFullBody(typeElement).isEmpty()) {
                 addInlineComment(typeElement, classInfoTree);
             }
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -595,8 +595,9 @@
 
     @Override
     public Set<Doclet.Option> getSupportedOptions() {
+        Resources resources = getResources();
         Doclet.Option[] options = {
-            new Option(this, "-bottom", 1) {
+            new Option(resources, "-bottom", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -604,7 +605,7 @@
                     return true;
                 }
             },
-            new Option(this, "-charset", 1) {
+            new Option(resources, "-charset", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -612,7 +613,7 @@
                     return true;
                 }
             },
-            new Option(this, "-doctitle", 1) {
+            new Option(resources, "-doctitle", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -620,7 +621,7 @@
                     return true;
                 }
             },
-            new Option(this, "-footer", 1) {
+            new Option(resources, "-footer", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -628,7 +629,7 @@
                     return true;
                 }
             },
-            new Option(this, "-header", 1) {
+            new Option(resources, "-header", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -636,7 +637,7 @@
                     return true;
                 }
             },
-            new Option(this, "-helpfile", 1) {
+            new Option(resources, "-helpfile", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -644,7 +645,7 @@
                     return true;
                 }
             },
-            new Option(this, "-html4") {
+            new Option(resources, "-html4") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -652,7 +653,7 @@
                     return true;
                 }
             },
-            new Option(this, "-html5") {
+            new Option(resources, "-html5") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -660,7 +661,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nohelp") {
+            new Option(resources, "-nohelp") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -668,7 +669,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nodeprecatedlist") {
+            new Option(resources, "-nodeprecatedlist") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -676,7 +677,7 @@
                     return true;
                 }
             },
-            new Option(this, "-noindex") {
+            new Option(resources, "-noindex") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -684,7 +685,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nonavbar") {
+            new Option(resources, "-nonavbar") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -692,7 +693,7 @@
                     return true;
                 }
             },
-            new Hidden(this, "-nooverview") {
+            new Hidden(resources, "-nooverview") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -700,7 +701,7 @@
                     return true;
                 }
             },
-            new Option(this, "-notree") {
+            new Option(resources, "-notree") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -708,7 +709,7 @@
                     return true;
                 }
             },
-            new Option(this, "-overview", 1) {
+            new Option(resources, "-overview", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -716,7 +717,7 @@
                     return true;
                 }
             },
-            new Option(this, "--frames") {
+            new Option(resources, "--frames") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -724,7 +725,7 @@
                     return true;
                 }
             },
-            new Option(this, "--no-frames") {
+            new Option(resources, "--no-frames") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -732,7 +733,7 @@
                     return true;
                 }
             },
-            new Hidden(this, "-packagesheader", 1) {
+            new Hidden(resources, "-packagesheader", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -740,7 +741,7 @@
                     return true;
                 }
             },
-            new Option(this, "-splitindex") {
+            new Option(resources, "-splitindex") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -748,7 +749,7 @@
                     return true;
                 }
             },
-            new Option(this, "-stylesheetfile", 1) {
+            new Option(resources, "-stylesheetfile", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -756,7 +757,7 @@
                     return true;
                 }
             },
-            new Option(this, "-top", 1) {
+            new Option(resources, "-top", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -764,7 +765,7 @@
                     return true;
                 }
             },
-            new Option(this, "-use") {
+            new Option(resources, "-use") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -772,7 +773,7 @@
                     return true;
                 }
             },
-            new Option(this, "-windowtitle", 1) {
+            new Option(resources, "-windowtitle", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -780,7 +781,7 @@
                     return true;
                 }
             },
-            new XOption(this, "-Xdoclint") {
+            new XOption(resources, "-Xdoclint") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -788,7 +789,7 @@
                     return true;
                 }
             },
-            new XOption(this, "-Xdocrootparent", 1) {
+            new XOption(resources, "-Xdocrootparent", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -796,7 +797,7 @@
                     return true;
                 }
             },
-            new XOption(this, "doclet.xusage.xdoclint-extended.", "-Xdoclint:", 0) {
+            new XOption(resources, "doclet.usage.xdoclint-extended", "-Xdoclint:", 0) {
                 @Override
                 public boolean matches(String option) {
                     return option.toLowerCase().startsWith(getName().toLowerCase());
@@ -809,7 +810,7 @@
                     return true;
                 }
             },
-            new XOption(this, "doclet.xusage.xdoclint-package.", "-Xdoclint/package:", 0) {
+            new XOption(resources, "doclet.usage.xdoclint-package", "-Xdoclint/package:", 0) {
                 @Override
                 public boolean matches(String option) {
                     return option.toLowerCase().startsWith(getName().toLowerCase());
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -146,7 +146,7 @@
      */
     @Override
     public void addComments(VariableElement field, Content fieldTree) {
-        if (!utils.getBody(field).isEmpty()) {
+        if (!utils.getFullBody(field).isEmpty()) {
             writer.addInlineComment(field, fieldTree);
         }
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1704,7 +1704,7 @@
      * @param htmltree the documentation tree to which the inline comments will be added
      */
     public void addInlineComment(Element element, Content htmltree) {
-        addCommentTags(element, utils.getBody(element), false, false, htmltree);
+        addCommentTags(element, utils.getFullBody(element), false, false, htmltree);
     }
 
     /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -159,7 +159,7 @@
      * @param contentTree the tree to which the deprecated info will be added
      */
     public void addMemberDescription(VariableElement field, Content contentTree) {
-        if (!utils.getBody(field).isEmpty()) {
+        if (!utils.getFullBody(field).isEmpty()) {
             writer.addInlineComment(field, contentTree);
         }
         List<? extends DocTree> tags = utils.getBlockTags(field, DocTree.Kind.SERIAL);
@@ -210,7 +210,7 @@
      */
     public boolean shouldPrintOverview(VariableElement field) {
         if (!configuration.nocomment) {
-            if(!utils.getBody(field).isEmpty() ||
+            if(!utils.getFullBody(field).isEmpty() ||
                     writer.hasSerializationOverviewTags(field))
                 return true;
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -172,7 +172,7 @@
     @Override
     public void addComments(TypeMirror holderType, ExecutableElement method, Content methodDocTree) {
         TypeElement holder = utils.asTypeElement(holderType);
-        if (!utils.getBody(method).isEmpty()) {
+        if (!utils.getFullBody(method).isEmpty()) {
             if (holder.equals(typeElement) ||
                     !(utils.isPublic(holder) ||
                     utils.isLinkable(holder))) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -182,7 +182,7 @@
     @Override
     protected void addOverviewHeader(Content body) {
         addConfigurationTitle(body);
-        if (!utils.getBody(configuration.overviewElement).isEmpty()) {
+        if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
             HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
             subTitleDiv.addStyle(HtmlStyle.subTitle);
             addSummaryComment(configuration.overviewElement, subTitleDiv);
@@ -212,7 +212,7 @@
      *                 be added
      */
     protected void addOverviewComment(Content htmltree) {
-        if (!utils.getBody(configuration.overviewElement).isEmpty()) {
+        if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
             htmltree.addContent(getMarkerAnchor(SectionName.OVERVIEW_DESCRIPTION));
             addInlineComment(configuration.overviewElement, htmltree);
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -484,7 +484,7 @@
      * {@inheritDoc}
      */
     public void addModuleDescription(Content moduleContentTree) {
-        if (!utils.getBody(mdle).isEmpty()) {
+        if (!utils.getFullBody(mdle).isEmpty()) {
             Content tree = configuration.allowTag(HtmlTag.SECTION) ? HtmlTree.SECTION() : moduleContentTree;
             tree.addContent(HtmlConstants.START_OF_MODULE_DESCRIPTION);
             tree.addContent(getMarkerAnchor(SectionName.MODULE_DESCRIPTION));
@@ -528,7 +528,7 @@
         li.addContent(Contents.SPACE);
         Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
         Content liNav = new HtmlTree(HtmlTag.LI);
-        liNav.addContent(!utils.getBody(mdle).isEmpty() && !configuration.nocomment
+        liNav.addContent(!utils.getFullBody(mdle).isEmpty() && !configuration.nocomment
                 ? getHyperLink(SectionName.MODULE_DESCRIPTION, contents.navModuleDescription)
                 : contents.navModuleDescription);
         addNavGap(liNav);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -175,7 +175,7 @@
     @Override
     protected void addOverviewHeader(Content body) {
         addConfigurationTitle(body);
-        if (!utils.getBody(configuration.overviewElement).isEmpty()) {
+        if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
             HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
             subTitleDiv.addStyle(HtmlStyle.subTitle);
             addSummaryComment(configuration.overviewElement, subTitleDiv);
@@ -205,7 +205,7 @@
      *                 be added
      */
     protected void addOverviewComment(Content htmltree) {
-        if (!utils.getBody(configuration.overviewElement).isEmpty()) {
+        if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
             htmltree.addContent(getMarkerAnchor(SectionName.OVERVIEW_DESCRIPTION));
             addInlineComment(configuration.overviewElement, htmltree);
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -143,19 +143,6 @@
         Content packageHead = new StringContent(heading);
         tHeading.addContent(packageHead);
         div.addContent(tHeading);
-        addDeprecationInfo(div);
-        if (!utils.getBody(packageElement).isEmpty() && !configuration.nocomment) {
-            HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV);
-            docSummaryDiv.addStyle(HtmlStyle.docSummary);
-            addSummaryComment(packageElement, docSummaryDiv);
-            div.addContent(docSummaryDiv);
-            Content space = Contents.SPACE;
-            Content descLink = getHyperLink(getDocLink(
-                    SectionName.PACKAGE_DESCRIPTION),
-                    contents.descriptionLabel, "", "");
-            Content descPara = new HtmlTree(HtmlTag.P, contents.seeLabel, space, descLink);
-            div.addContent(descPara);
-        }
         if (configuration.allowTag(HtmlTag.MAIN)) {
             mainTree.addContent(div);
         } else {
@@ -259,19 +246,9 @@
     @Override
     public void addPackageDescription(Content packageContentTree) {
         if (!utils.getBody(packageElement).isEmpty()) {
-            packageContentTree.addContent(
-                    getMarkerAnchor(SectionName.PACKAGE_DESCRIPTION));
-            Content h2Content = new StringContent(
-                    configuration.getText("doclet.Package_Description",
-                    packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement)));
-            Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, h2Content);
-            if (configuration.allowTag(HtmlTag.SECTION)) {
-                sectionTree.addContent(heading);
-                addInlineComment(packageElement, sectionTree);
-            } else {
-                packageContentTree.addContent(heading);
-                addInlineComment(packageElement, packageContentTree);
-            }
+            Content tree = configuration.allowTag(HtmlTag.SECTION) ? sectionTree : packageContentTree;
+            addDeprecationInfo(tree);
+            addInlineComment(packageElement, tree);
         }
     }
 
@@ -284,6 +261,9 @@
                 ? sectionTree
                 : packageContentTree;
         addTagsInfo(packageElement, htmlTree);
+        if (configuration.allowTag(HtmlTag.SECTION)) {
+            packageContentTree.addContent(sectionTree);
+        }
     }
 
     /**
@@ -292,7 +272,6 @@
     @Override
     public void addPackageContent(Content contentTree, Content packageContentTree) {
         if (configuration.allowTag(HtmlTag.MAIN)) {
-            packageContentTree.addContent(sectionTree);
             mainTree.addContent(packageContentTree);
             contentTree.addContent(mainTree);
         } else {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -147,7 +147,7 @@
     @Override
     public void addComments(ExecutableElement property, Content propertyDocTree) {
         TypeElement holder = (TypeElement)property.getEnclosingElement();
-        if (!utils.getBody(property).isEmpty()) {
+        if (!utils.getFullBody(property).isEmpty()) {
             if (holder.equals(typeElement) ||
                     (!utils.isPublic(holder) || utils.isLinkable(holder))) {
                 writer.addInlineComment(property, propertyDocTree);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Tue Oct 18 17:14:09 2016 +0000
@@ -97,7 +97,6 @@
 doclet.deprecated_annotation_type_members=deprecated annotation type elements
 doclet.Generated_Docs_Untitled=Generated Documentation (Untitled)
 doclet.Other_Packages=Other Packages
-doclet.Package_Description=Package {0} Description
 doclet.Description=Description
 doclet.Specified_By=Specified by:
 doclet.in_interface=in interface
@@ -191,144 +190,196 @@
 doclet.Same_package_name_used=Package name format used twice: {0}
 
 # option specifiers
-doclet.usage.d.parameters=<directory>
-doclet.usage.d.description=Destination directory for output files
+doclet.usage.d.parameters=\
+    <directory>
+doclet.usage.d.description=\
+    Destination directory for output files
 
-doclet.usage.use.description=Create class and package usage pages
-
-doclet.usage.version.description=Include @version paragraphs
+doclet.usage.use.description=\
+    Create class and package usage pages
 
-doclet.usage.author.description=Include @author paragraphs
+doclet.usage.version.description=\
+    Include @version paragraphs
 
-doclet.usage.docfilessubdirs.description=Recursively copy doc-file subdirectories
+doclet.usage.author.description=\
+    Include @author paragraphs
 
-doclet.usage.splitindex.description=Split index into one file per letter
+doclet.usage.docfilessubdirs.description=\
+    Recursively copy doc-file subdirectories
 
-doclet.usage.overview.parameters=<file>
-doclet.usage.overview.description=Read overview documentation from HTML file
+doclet.usage.splitindex.description=\
+    Split index into one file per letter
 
+doclet.usage.overview.parameters=\
+    <file>
+doclet.usage.overview.description=\
+    Read overview documentation from HTML file
 
-doclet.usage.windowtitle.parameters=<text>
-doclet.usage.windowtitle.description=Browser window title for the documentation
-
-doclet.usage.doctitle.parameters=<html-code>
-doclet.usage.doctitle.description=Include title for the overview page
+doclet.usage.windowtitle.parameters=\
+    <text>
+doclet.usage.windowtitle.description=\
+    Browser window title for the documentation
 
-doclet.usage.header.parameters=<html-code>
-doclet.usage.header.description=Include header text for each page
-
-doclet.usage.html4.description=Generate HTML 4.01 output
+doclet.usage.doctitle.parameters=\
+    <html-code>
+doclet.usage.doctitle.description=\
+    Include title for the overview page
 
-doclet.usage.html5.description=Generate HTML 5 output
+doclet.usage.header.parameters=\
+    <html-code>
+doclet.usage.header.description=\
+    Include header text for each page
 
-doclet.usage.footer.parameters=<html-code>
-doclet.usage.footer.description=Include footer text for each page
+doclet.usage.html4.description=\
+    Generate HTML 4.01 output
+
+doclet.usage.html5.description=\
+    Generate HTML 5 output
 
-doclet.usage.top.parameters=<html-code>
-doclet.usage.top.description=Include top text for each page
+doclet.usage.footer.parameters=\
+    <html-code>
+doclet.usage.footer.description=\
+    Include footer text for each page
 
-doclet.usage.bottom.parameters=<html-code>
-doclet.usage.bottom.description=Include bottom text for each page
-
-doclet.usage.link.parameters=<url>
-doclet.usage.link.description=Create links to javadoc output at <url>
+doclet.usage.top.parameters=\
+    <html-code>
+doclet.usage.top.description=\
+    Include top text for each page
 
-doclet.usage.linkoffline.parameters=<url1> <url2>
-doclet.usage.linkoffline.description=Link to docs at <url1> using package list\n\
-\                                   at <url2>
+doclet.usage.bottom.parameters=\
+    <html-code>
+doclet.usage.bottom.description=\
+    Include bottom text for each page
 
-doclet.usage.excludedocfilessubdir.parameters=<name>:..
-doclet.usage.excludedocfilessubdir.description=\n\
-\                                   Exclude any doc-files subdirectories with\n\
-\                                   given name
+doclet.usage.link.parameters=\
+    <url>
+doclet.usage.link.description=\
+    Create links to javadoc output at <url>
 
-doclet.usage.group.parameters=<name> <p1>:<p2>..
-doclet.usage.group.description=Group specified packages together\n\
-\                                   in overview page
+doclet.usage.linkoffline.parameters=\
+    <url1> <url2>
+doclet.usage.linkoffline.description=\
+    Link to docs at <url1> using package list at <url2>
 
-doclet.usage.nocomment.description=Suppress description and tags, generate\n\
-\                                   only declarations
-
-doclet.usage.nodeprecated.description=Do not include @deprecated information
+doclet.usage.excludedocfilessubdir.parameters=\
+    <name>:..
+doclet.usage.excludedocfilessubdir.description=\
+    Exclude any doc-files subdirectories with given name
 
-doclet.usage.noqualifier.parameters=<name1>:<name2>:..
-doclet.usage.noqualifier.description=Exclude the list of qualifiers from the output
+doclet.usage.group.parameters=\
+    <name> <p1>:<p2>..
+doclet.usage.group.description=\
+    Group specified packages together in overview page
 
-doclet.usage.nosince.description=Do not include @since information
+doclet.usage.nocomment.description=\
+    Suppress description and tags, generate only declarations
 
-doclet.usage.notimestamp.description=Do not include hidden time stamp
+doclet.usage.nodeprecated.description=\
+    Do not include @deprecated information
 
-doclet.usage.nodeprecatedlist.description=Do not generate deprecated list
+doclet.usage.noqualifier.parameters=\
+    <name1>:<name2>:..
+doclet.usage.noqualifier.description=\
+    Exclude the list of qualifiers from the output
 
-doclet.usage.notree.description=Do not generate class hierarchy
+doclet.usage.nosince.description=\
+    Do not include @since information
 
-doclet.usage.noindex.description=Do not generate index
+doclet.usage.notimestamp.description=\
+    Do not include hidden time stamp
 
-doclet.usage.nohelp.description=Do not generate help link
+doclet.usage.nodeprecatedlist.description=\
+    Do not generate deprecated list
 
-doclet.usage.nonavbar.description=Do not generate navigation bar
+doclet.usage.notree.description=\
+    Do not generate class hierarchy
 
-doclet.usage.nooverview.description=Do not generate overview pages
+doclet.usage.noindex.description=\
+    Do not generate index
 
-doclet.usage.serialwarn.description=Generate warning about @serial tag
+doclet.usage.nohelp.description=\
+    Do not generate help link
+
+doclet.usage.nonavbar.description=\
+    Do not generate navigation bar
 
-doclet.usage.tag.parameters=<name>:<locations>:<header>
-doclet.usage.tag.description=\n\
-\                                   Specify single argument custom tags
+doclet.usage.nooverview.description=\
+    Do not generate overview pages
 
-doclet.usage.taglet.description=The fully qualified name of Taglet to register
+doclet.usage.serialwarn.description=\
+    Generate warning about @serial tag
 
-doclet.usage.tagletpath.description=The path to Taglets
+doclet.usage.tag.parameters=\
+    <name>:<locations>:<header>
+doclet.usage.tag.description=\
+    Specify single argument custom tags
 
-doclet.usage.charset.parameters=<charset>
-doclet.usage.charset.description=Charset for cross-platform viewing of\n\
-\                                   generated documentation
+doclet.usage.taglet.description=\
+    The fully qualified name of Taglet to register
 
-doclet.usage.helpfile.parameters=<file>
-doclet.usage.helpfile.description=Include file that help link links to
+doclet.usage.tagletpath.description=\
+    The path to Taglets
 
-doclet.usage.linksource.description=Generate source in HTML
+doclet.usage.charset.parameters=\
+    <charset>
+doclet.usage.charset.description=\
+    Charset for cross-platform viewing of generated documentation
 
-doclet.usage.sourcetab.parameters=<tab length>
-doclet.usage.sourcetab.description=Specify the number of spaces each tab\n\
-\                                   takes up in the source
+doclet.usage.helpfile.parameters=\
+    <file>
+doclet.usage.helpfile.description=\
+    Include file that help link links to
 
-doclet.usage.keywords.description=Include HTML meta tags with package,\n\
-\                                   class and member info
+doclet.usage.linksource.description=\
+    Generate source in HTML
 
-doclet.usage.stylesheetfile.parameters=<path>
-doclet.usage.stylesheetfile.description=File to change style of the generated\n\
-\                                   documentation
+doclet.usage.sourcetab.parameters=\
+    <tab length>
+doclet.usage.sourcetab.description=\
+    Specify the number of spaces each tab takes up in the source
 
-doclet.usage.docencoding.parameters=<name>
-doclet.usage.docencoding.description=Specify the character encoding for the output
-
-doclet.usage.frames.description=Enable the use of frames in the generated output (default)
+doclet.usage.keywords.description=\
+    Include HTML meta tags with package, class and member info
 
-doclet.usage.no-frames.description=Disable the use of frames in the generated output
+doclet.usage.stylesheetfile.parameters=\
+    <path>
+doclet.usage.stylesheetfile.description=\
+    File to change style of the generated documentation
 
-doclet.xusage.xdocrootparent.parameters=<url>
-doclet.xusage.xdocrootparent.description=Replaces all @docRoot followed by /..\n\
-\                                   in doc comments with <url>
+doclet.usage.docencoding.parameters=\
+    <name>
+doclet.usage.docencoding.description=\
+    Specify the character encoding for the output
 
-doclet.xusage.xdoclint.description=Enable recommended checks for problems in\n\
-\                                   javadoc comments
+doclet.usage.frames.description=\
+    Enable the use of frames in the generated output (default)
+
+doclet.usage.no-frames.description=\
+    Disable the use of frames in the generated output
 
-doclet.xusage.xdoclint-extended.parameters=(all|none|[-]<group>)
-# L10N: do not localize these words: all none accessibility html missing reference syntax
-doclet.xusage.xdoclint-extended.description=Enable or disable specific checks\n\
-\                                   for problems in javadoc comments, where \n\
-\                                   <group> is one of accessibility, html,\n\
-\                                   missing, reference, or syntax.\n
+doclet.usage.xdocrootparent.parameters=\
+    <url>
+doclet.usage.xdocrootparent.description=\
+    Replaces all @docRoot followed by /.. in doc comments with\n\
+    <url>
+
+doclet.usage.xdoclint.description=\
+    Enable recommended checks for problems in javadoc comments
 
-doclet.xusage.xdoclint-package.parameters=([-]<packages>)
-doclet.xusage.xdoclint-package.description=\n\
-\                                   Enable or disable checks in specific\n\
-\                                   packages. <packages> is a comma separated\n\
-\                                   list of package specifiers. Package\n\
-\                                   specifier is either a qualified name of a\n\
-\                                   package or a package name prefix followed\n\
-\                                   by .*, which expands to all sub-packages\n\
-\                                   of the given package. Prefix the package\n\
-\                                   specifier with - to disable checks for\n\
-\                                   the specified packages.\n
+doclet.usage.xdoclint-extended.parameters=\
+    (all|none|[-]<group>)
+# L10N: do not localize these words: all none accessibility html missing reference syntax
+doclet.usage.xdoclint-extended.description=\
+    Enable or disable specific checks for problems in javadoc\n\
+    comments, where <group> is one of accessibility, html,\n\
+    missing, reference, or syntax.
+
+doclet.usage.xdoclint-package.parameters=\
+    ([-]<packages>)
+doclet.usage.xdoclint-package.description=\
+    Enable or disable checks in specific packages. <packages> is a\n\
+    comma separated list of package specifiers. A package\n\
+    specifier is either a qualified name of a package or a package\n\
+    name prefix followed by .*, which expands to all sub-packages\n\
+    of the given package. Prefix the package specifier with - to\n\
+    disable checks for the specified packages.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java	Tue Oct 18 17:14:09 2016 +0000
@@ -40,7 +40,6 @@
 import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.InternalException;
 import jdk.javadoc.internal.doclets.toolkit.util.PackageListWriter;
 import jdk.javadoc.internal.doclets.toolkit.util.ResourceIOException;
@@ -112,8 +111,6 @@
             return false;
         }
 
-        boolean dumpOnError = false;  // set true to always show stack traces
-
         try {
             startGeneration(docEnv);
             return true;
@@ -128,16 +125,16 @@
                     messages.error("doclet.exception.write.file",
                             e.fileName.getPath(), e.getCause());
             }
-            dumpStack(dumpOnError, e);
+            dumpStack(configuration.dumpOnError, e);
 
         } catch (ResourceIOException e) {
             messages.error("doclet.exception.read.resource",
                     e.resource.getPath(), e.getCause());
-            dumpStack(dumpOnError, e);
+            dumpStack(configuration.dumpOnError, e);
 
         } catch (SimpleDocletException e) {
             configuration.reporter.print(ERROR, e.getMessage());
-            dumpStack(dumpOnError, e);
+            dumpStack(configuration.dumpOnError, e);
 
         } catch (InternalException e) {
             configuration.reporter.print(ERROR, e.getMessage());
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/CommentUtils.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/CommentUtils.java	Tue Oct 18 17:14:09 2016 +0000
@@ -108,27 +108,22 @@
         Utils utils = config.utils;
         String klassName = utils.getSimpleName(utils.getEnclosingTypeElement(e));
 
-        List<DocTree> fs = new ArrayList<>();
-        fs.add(treeFactory.newTextTree(config.getText("doclet.enum_values_doc.firstsentence")));
-
-        List<DocTree> body = new ArrayList<>();
-        body.add(treeFactory.newTextTree(config.getText("doclet.enum_values_doc.body", klassName)));
+        List<DocTree> fullBody = new ArrayList<>();
+        fullBody.add(treeFactory.newTextTree(config.getText("doclet.enum_values_doc.fullbody", klassName)));
 
         List<DocTree> descriptions = new ArrayList<>();
         descriptions.add(treeFactory.newTextTree(config.getText("doclet.enum_values_doc.return")));
 
         List<DocTree> tags = new ArrayList<>();
         tags.add(treeFactory.newReturnTree(descriptions));
-        DocCommentTree docTree = treeFactory.newDocCommentTree(fs, body, tags);
+        DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, tags);
         dcTreesMap.put(e, new DocCommentDuo(null, docTree));
     }
 
     public void setEnumValueOfTree(Configuration config, Element e) {
-        List<DocTree> fs = new ArrayList<>();
-        fs.add(treeFactory.newTextTree(config.getText("doclet.enum_valueof_doc.firstsentence")));
 
-        List<DocTree> body = new ArrayList<>();
-        body.add(treeFactory.newTextTree(config.getText("doclet.enum_valueof_doc.body")));
+        List<DocTree> fullBody = new ArrayList<>();
+        fullBody.add(treeFactory.newTextTree(config.getText("doclet.enum_valueof_doc.fullbody")));
 
         List<DocTree> tags = new ArrayList<>();
 
@@ -156,7 +151,7 @@
         ref = treeFactory.newReferenceTree("java.lang.NullPointerException");
         tags.add(treeFactory.newThrowsTree(ref, throwsDescs));
 
-        DocCommentTree docTree = treeFactory.newDocCommentTree(fs, body, tags);
+        DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, tags);
 
         dcTreesMap.put(e, new DocCommentDuo(null, docTree));
     }
@@ -190,11 +185,9 @@
         return new DocCommentDuo(treePath.getTreePath(), dcTree);
     }
 
-    public void setDocCommentTree(Element element, List<DocTree> firstSentence,
-            List<DocTree> bodyTags, List<DocTree> blockTags, Utils utils) {
-        DocCommentTree docTree = treeFactory.newDocCommentTree(firstSentence,
-                                                      bodyTags,
-                                                      blockTags);
+    public void setDocCommentTree(Element element, List<DocTree> fullBody,
+            List<DocTree> blockTags, Utils utils) {
+        DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, blockTags);
         dcTreesMap.put(element, new DocCommentDuo(null, docTree));
         // There maybe an entry with the original comments usually null,
         // therefore remove that entry if it exists, and allow a new one
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Tue Oct 18 17:14:09 2016 +0000
@@ -281,6 +281,8 @@
 
     private String pkglistUrlForLinkOffline;
 
+    public boolean dumpOnError = false;
+
     private List<GroupContainer> groups;
 
     public abstract Messages getMessages();
@@ -404,8 +406,9 @@
     }
 
     public Set<Doclet.Option> getSupportedOptions() {
+        Resources resources = getResources();
         Doclet.Option[] options = {
-            new Option(this, "-author") {
+            new Option(resources, "-author") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -413,7 +416,7 @@
                     return true;
                 }
             },
-            new Option(this, "-d", 1) {
+            new Option(resources, "-d", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -421,7 +424,7 @@
                     return true;
                 }
             },
-            new Option(this, "-docencoding", 1) {
+            new Option(resources, "-docencoding", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -429,7 +432,7 @@
                     return true;
                 }
             },
-            new Option(this, "-docfilessubdirs") {
+            new Option(resources, "-docfilessubdirs") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -437,7 +440,7 @@
                     return true;
                 }
             },
-            new Hidden(this, "-encoding", 1) {
+            new Hidden(resources, "-encoding", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -445,7 +448,7 @@
                     return true;
                 }
             },
-            new Option(this, "-excludedocfilessubdir", 1) {
+            new Option(resources, "-excludedocfilessubdir", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -453,7 +456,7 @@
                     return true;
                 }
             },
-            new Option(this, "-group", 2) {
+            new Option(resources, "-group", 2) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -461,7 +464,7 @@
                     return true;
                 }
             },
-            new Hidden(this, "-javafx") {
+            new Hidden(resources, "-javafx") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -469,7 +472,7 @@
                     return true;
                 }
             },
-            new Option(this, "-keywords") {
+            new Option(resources, "-keywords") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -477,7 +480,7 @@
                     return true;
                 }
             },
-            new Option(this, "-link", 1) {
+            new Option(resources, "-link", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -486,7 +489,7 @@
                     return true;
                 }
             },
-            new Option(this, "-linksource") {
+            new Option(resources, "-linksource") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -494,7 +497,7 @@
                     return true;
                 }
             },
-            new Option(this, "-linkoffline", 2) {
+            new Option(resources, "-linkoffline", 2) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -503,7 +506,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nocomment") {
+            new Option(resources, "-nocomment") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -511,7 +514,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nodeprecated") {
+            new Option(resources, "-nodeprecated") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -519,7 +522,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nosince") {
+            new Option(resources, "-nosince") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -527,7 +530,7 @@
                     return true;
                 }
             },
-            new Option(this, "-notimestamp") {
+            new Option(resources, "-notimestamp") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -535,7 +538,7 @@
                     return true;
                 }
             },
-            new Option(this, "-noqualifier", 1) {
+            new Option(resources, "-noqualifier", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -543,7 +546,7 @@
                     return true;
                 }
             },
-            new Hidden(this, "-quiet") {
+            new Hidden(resources, "-quiet") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -551,7 +554,7 @@
                     return true;
                 }
             },
-            new Option(this, "-serialwarn") {
+            new Option(resources, "-serialwarn") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -559,7 +562,7 @@
                     return true;
                 }
             },
-            new Option(this, "-sourcetab", 1) {
+            new Option(resources, "-sourcetab", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -578,7 +581,7 @@
                     return true;
                 }
             },
-            new Option(this, "-tag", 1) {
+            new Option(resources, "-tag", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -589,7 +592,7 @@
                     return true;
                 }
             },
-             new Option(this, "-taglet", 1) {
+             new Option(resources, "-taglet", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -600,7 +603,7 @@
                     return true;
                 }
             },
-            new Option(this, "-tagletpath", 1) {
+            new Option(resources, "-tagletpath", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -608,13 +611,20 @@
                     return true;
                 }
             },
-            new Option(this, "-version") {
+            new Option(resources, "-version") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
                     showversion = true;
                     return true;
                 }
+            },
+            new Hidden(resources, "--dump-on-error") {
+                @Override
+                public boolean process(String opt, ListIterator<String> args) {
+                    dumpOnError = true;
+                    return true;
+                }
             }
         };
         Set<Doclet.Option> set = new TreeSet<>();
@@ -1057,37 +1067,30 @@
         private final String description;
         private final int argCount;
 
-        protected final Configuration c;
+        protected Option(Resources resources, String name, int argCount) {
+            this(resources, "doclet.usage." + name.toLowerCase().replaceAll("^-*", ""), name, argCount);
+        }
 
-        protected Option(Configuration config, String keyName, String name, int argCount) {
-            c = config;
+        protected Option(Resources resources, String keyBase, String name, int argCount) {
             this.name = name;
-            String desc = getOptionsMessage(keyName + "description");
+            String desc = getOptionsMessage(resources, keyBase + ".description");
             if (desc.isEmpty()) {
                 this.description = "<MISSING KEY>";
                 this.parameters = "<MISSING KEY>";
             } else {
                 this.description = desc;
-                this.parameters = getOptionsMessage(keyName + "parameters");
+                this.parameters = getOptionsMessage(resources, keyBase + ".parameters");
             }
             this.argCount = argCount;
         }
 
-        protected Option(String prefix, Configuration config, String name, int argCount) {
-            this(config, prefix + name.toLowerCase().replaceAll("^-*", "") + ".", name, argCount);
-        }
-
-        protected Option(Configuration config, String name, int argCount) {
-            this("doclet.usage.", config,  name, argCount);
+        protected Option(Resources resources, String name) {
+            this(resources, name, 0);
         }
 
-        protected Option(Configuration config, String name) {
-            this(config, name, 0);
-        }
-
-        private String getOptionsMessage(String key) {
+        private String getOptionsMessage(Resources resources, String key) {
             try {
-                return c.getResources().getText(key);
+                return resources.getText(key);
             } catch (MissingResourceException ignore) {
                 return "";
             }
@@ -1113,19 +1116,9 @@
             return parameters;
         }
 
-        /**
-         * Maintains the formatting for javadoc -help. Note the space
-         * alignment.
-         */
         @Override
         public String toString() {
-            String opt = name + (name.endsWith(":") ? "" : " ") + parameters;
-            StringBuffer sb = new StringBuffer("  ").append(opt).append(" ");
-            for (int i = opt.length(); i < 32; i++) {
-                sb.append(" ");
-            }
-            sb.append(description);
-            return sb.toString();
+            return name;
         }
 
         @Override
@@ -1135,7 +1128,14 @@
 
         @Override
         public boolean matches(String option) {
-            return name.toLowerCase().equals(option.toLowerCase());
+            boolean matchCase = name.startsWith("--");
+            if (option.startsWith("--") && option.contains("=")) {
+                return name.equals(option.substring(option.indexOf("=") + 1));
+            } else if (matchCase) {
+                return name.equals(option);
+            } else {
+                return name.toLowerCase().equals(option.toLowerCase());
+            }
         }
 
         @Override
@@ -1146,16 +1146,16 @@
 
     public abstract class XOption extends Option {
 
-        public XOption(Configuration config, String keyname, String name, int argCount) {
-            super(config, keyname, name, argCount);
+        public XOption(Resources resources, String prefix, String name, int argCount) {
+            super(resources, prefix, name, argCount);
         }
 
-        public XOption(Configuration config, String name, int argCount) {
-            super("doclet.xusage.", config, name, argCount);
+        public XOption(Resources resources, String name, int argCount) {
+            super(resources, name, argCount);
         }
 
-        public XOption(Configuration config, String name) {
-            this(config, name, 0);
+        public XOption(Resources resources, String name) {
+            this(resources, name, 0);
         }
 
         @Override
@@ -1166,12 +1166,12 @@
 
     public abstract class Hidden extends Option {
 
-        public Hidden(Configuration config, String name, int argCount) {
-            super("doclet.xusage.", config, name, argCount);
+        public Hidden(Resources resources, String name, int argCount) {
+            super(resources, name, argCount);
         }
 
-        public Hidden(Configuration config, String name) {
-            this(config, name, 0);
+        public Hidden(Resources resources, String name) {
+            this(resources, name, 0);
         }
 
         @Override
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java	Tue Oct 18 17:14:09 2016 +0000
@@ -386,8 +386,8 @@
         CommentUtils cmtutils = configuration.cmtUtils;
         final boolean isSetter = isSetter(member);
         final boolean isGetter = isGetter(member);
-        List<DocTree> firstSentence = new ArrayList<>();
-        List<DocTree> bodyTags = new ArrayList<>();
+
+        List<DocTree> fullBody = new ArrayList<>();
         List<DocTree> blockTags = new ArrayList<>();
         if (isGetter || isSetter) {
             //add "[GS]ets the value of the property PROPERTY_NAME."
@@ -395,21 +395,21 @@
                 String text = MessageFormat.format(
                         configuration.getText("doclet.PropertySetterWithName"),
                         utils.propertyName((ExecutableElement)member));
-                firstSentence.addAll(cmtutils.makeFirstSentenceTree(text));
+                fullBody.addAll(cmtutils.makeFirstSentenceTree(text));
             }
             if (isGetter) {
                 String text = MessageFormat.format(
                         configuration.getText("doclet.PropertyGetterWithName"),
                         utils.propertyName((ExecutableElement) member));
-                firstSentence.addAll(cmtutils.makeFirstSentenceTree(text));
+                fullBody.addAll(cmtutils.makeFirstSentenceTree(text));
             }
             List<? extends DocTree> propertyTags = utils.getBlockTags(property, "propertyDescription");
             if (propertyTags.isEmpty()) {
-                List<? extends DocTree> comment = utils.getBody(property);
+                List<? extends DocTree> comment = utils.getFullBody(property);
                 blockTags.addAll(cmtutils.makePropertyDescriptionTree(comment));
             }
         } else {
-            firstSentence.addAll(utils.getBody(property));
+            fullBody.addAll(utils.getFullBody(property));
         }
 
         // copy certain tags
@@ -452,7 +452,7 @@
                 blockTags.add(cmtutils.makeSeeTree(sb.toString(), setter));
             }
         }
-        cmtutils.setDocCommentTree(member, firstSentence, bodyTags, blockTags, utils);
+        cmtutils.setDocCommentTree(member, fullBody, blockTags, utils);
     }
 
     /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java	Tue Oct 18 17:14:09 2016 +0000
@@ -210,7 +210,7 @@
     public void buildMethodComments(XMLNode node, Content methodDocTree) {
         if (!configuration.nocomment) {
             ExecutableElement method = currentMethod;
-            if (utils.getBody(currentMethod).isEmpty()) {
+            if (utils.getFullBody(currentMethod).isEmpty()) {
                 DocFinder.Output docs = DocFinder.search(configuration,
                         new DocFinder.Input(utils, currentMethod));
                 if (docs.inlineTags != null && !docs.inlineTags.isEmpty())
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml	Tue Oct 18 17:14:09 2016 +0000
@@ -42,6 +42,8 @@
 
     <PackageDoc>
         <Content>
+            <PackageDescription/>
+            <PackageTags/>
             <Summary>
                 <InterfaceSummary/>
                 <ClassSummary/>
@@ -50,8 +52,6 @@
                 <ErrorSummary/>
                 <AnnotationTypeSummary/>
             </Summary>
-            <PackageDescription/>
-            <PackageTags/>
         </Content>
     </PackageDoc>
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties	Tue Oct 18 17:14:09 2016 +0000
@@ -207,22 +207,21 @@
 doclet.0_and_1={0} and {1}
 
 #Documentation for Enums
-doclet.enum_values_doc.firstsentence=\
-Returns an array containing the constants of this enum type, in\n\
-the order they are declared.
-doclet.enum_values_doc.body=\  This method may be used to iterate\n\
+doclet.enum_values_doc.fullbody=\
+ Returns an array containing the constants of this enum type, in\n\
+ the order they are declared. This method may be used to iterate\n\
  over the constants as follows:\n\
  <pre>\n\
  for ({0} c : {0}.values())\n\
  &nbsp;   System.out.println(c);\n\
  </pre>
+
 doclet.enum_values_doc.return=\
 an array containing the constants of this enum type, in the order they are declared
 
-doclet.enum_valueof_doc.firstsentence=\
-Returns the enum constant of this type with the specified name.
-doclet.enum_valueof_doc.body=\n\
-The string must match <i>exactly</i> an identifier used to declare an\n\
+doclet.enum_valueof_doc.fullbody=\
+ Returns the enum constant of this type with the specified name.\n\
+ The string must match <i>exactly</i> an identifier used to declare an\n\
  enum constant in this type.  (Extraneous whitespace characters are \n\
  not permitted.)
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -221,7 +221,7 @@
             List<Taglet> taglets, TagletWriter writer, Content output) {
         Utils utils = writer.configuration().utils;
         tagletManager.checkTags(utils, element, utils.getBlockTags(element), false);
-        tagletManager.checkTags(utils, element, utils.getBody(element), true);
+        tagletManager.checkTags(utils, element, utils.getFullBody(element), true);
         for (Taglet taglet : taglets) {
             if (utils.isTypeElement(element) && taglet instanceof ParamTaglet) {
                 //The type parameters are documented in a special section away
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFinder.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFinder.java	Tue Oct 18 17:14:09 2016 +0000
@@ -251,7 +251,7 @@
             //We want overall documentation.
             output.inlineTags = input.isFirstSentence
                     ? utils.getFirstSentenceTrees(input.element)
-                    : utils.getBody(input.element);
+                    : utils.getFullBody(input.element);
             output.holder = input.element;
         } else {
             input.taglet.inherit(input, output);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1453,7 +1453,7 @@
     public void setEnumDocumentation(TypeElement elem) {
         for (Element e : getMethods(elem)) {
             ExecutableElement ee = (ExecutableElement)e;
-            if (!getBody(e).isEmpty()) // if already set skip it please
+            if (!getFullBody(e).isEmpty()) // ignore if already set
                 continue;
             if (ee.getSimpleName().contentEquals("values") && ee.getParameters().isEmpty()) {
                 configuration.cmtUtils.setEnumValuesTree(configuration, e);
@@ -2939,12 +2939,18 @@
         return dcTree;
     }
 
+    public List<? extends DocTree> getFullBody(Element element) {
+        DocCommentTree docCommentTree = getDocCommentTree(element);
+            return (docCommentTree == null)
+                    ? Collections.emptyList()
+                    : docCommentTree.getFullBody();
+    }
+
     public List<? extends DocTree> getBody(Element element) {
         DocCommentTree docCommentTree = getDocCommentTree(element);
-        if (docCommentTree == null)
-            return Collections.emptyList();
-
-        return docCommentTree.getFullBody();
+        return (docCommentTree == null)
+                ? Collections.emptyList()
+                : docCommentTree.getFullBody();
     }
 
     public List<? extends DocTree> getDeprecatedTrees(Element element) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java	Tue Oct 18 17:14:09 2016 +0000
@@ -75,6 +75,7 @@
 import jdk.javadoc.doclet.DocletEnvironment.ModuleMode;
 
 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
+import static jdk.javadoc.internal.tool.Main.Result.*;
 import static jdk.javadoc.internal.tool.JavadocTool.isValidClassName;
 
 /**
@@ -158,6 +159,7 @@
     private final Location location;
     private final Modules modules;
     private final Map<ToolOption, Object> opts;
+    private final Messager messager;
 
     private final Map<String, Entry> entries = new LinkedHashMap<>();
 
@@ -201,6 +203,8 @@
         this.fm = toolEnv.fileManager;
         this.modules = Modules.instance(context);
         this.opts = opts;
+        this.messager = Messager.instance0(context);
+
         this.location = modules.multiModuleMode
                 ? StandardLocation.MODULE_SOURCE_PATH
                 : toolEnv.fileManager.hasLocation(StandardLocation.SOURCE_PATH)
@@ -339,9 +343,9 @@
      * This is a terminal operation, thus no further modifications
      * are allowed to the specified data sets.
      *
-     * @throws IOException if an error occurs
+     * @throws ToolException if an error occurs
      */
-    void analyze() throws IOException {
+    void analyze() throws ToolException {
         // compute the specified element, by expanding module dependencies
         computeSpecifiedModules();
 
@@ -354,7 +358,6 @@
         // compute the packages belonging to all the specified modules
         Set<PackageElement> expandedModulePackages = computeModulePackages();
         initializeIncludedSets(expandedModulePackages);
-
     }
 
     ElementsTable classTrees(com.sun.tools.javac.util.List<JCCompilationUnit> classTrees) {
@@ -363,16 +366,17 @@
     }
 
     @SuppressWarnings("unchecked")
-    ElementsTable scanSpecifiedItems() throws IOException {
+    ElementsTable scanSpecifiedItems() throws ToolException {
 
         // scan modules specified on the command line
         List<String> moduleNames = (List<String>) opts.computeIfAbsent(ToolOption.MODULE,
                 s -> Collections.EMPTY_LIST);
         List<String> mlist = new ArrayList<>();
         for (String m : moduleNames) {
-            Location moduleLoc = fm.getModuleLocation(location, m);
+            Location moduleLoc = getModuleLocation(location, m);
             if (moduleLoc == null) {
-                toolEnv.error("main.module_not_found", m);
+                String text = messager.getText("main.module_not_found", m);
+                throw new ToolException(CMDERR, text);
             } else {
                 mlist.add(m);
                 ModuleSymbol msym = syms.enterModule(names.fromString(m));
@@ -457,7 +461,7 @@
     }
 
     @SuppressWarnings("unchecked")
-    private void computeSubpackages() throws IOException {
+    private void computeSubpackages() throws ToolException {
         ((List<String>) opts.computeIfAbsent(ToolOption.EXCLUDE, v -> Collections.EMPTY_LIST))
                 .stream()
                 .map((packageName) -> new ModulePackage(packageName))
@@ -469,7 +473,14 @@
 
         for (ModulePackage modpkg : subPackages) {
             Location packageLocn = getLocation(modpkg);
-            for (JavaFileObject fo : fm.list(packageLocn, modpkg.packageName, sourceKinds, true)) {
+            Iterable<JavaFileObject> list = null;
+            try {
+                list = fm.list(packageLocn, modpkg.packageName, sourceKinds, true);
+            } catch (IOException ioe) {
+                String text = messager.getText("main.file.manager.list", modpkg.packageName);
+                throw new ToolException(SYSERR, text, ioe);
+            }
+            for (JavaFileObject fo : list) {
                 String binaryName = fm.inferBinaryName(packageLocn, fo);
                 String pn = getPackageName(binaryName);
                 String simpleName = getSimpleName(binaryName);
@@ -554,22 +565,28 @@
         specifiedModuleElements = Collections.unmodifiableSet(result);
     }
 
-    private Set<PackageElement> getAllModulePackages(ModuleElement mdle) throws IOException {
+    private Set<PackageElement> getAllModulePackages(ModuleElement mdle) throws ToolException {
         Set<PackageElement> result = new HashSet<>();
-        ModuleSymbol msym = (ModuleSymbol)mdle;
-        Location msymloc = fm.getModuleLocation(location, msym.name.toString());
-        for (JavaFileObject fo : fm.list(msymloc, "", sourceKinds, true)) {
-            if (fo.getName().endsWith("module-info.java"))
-                continue;
-            String binaryName = fm.inferBinaryName(msymloc, fo);
-            String pn = getPackageName(binaryName);
-            PackageSymbol psym = syms.enterPackage(msym, names.fromString(pn));
-            result.add((PackageElement)psym);
+        ModuleSymbol msym = (ModuleSymbol) mdle;
+        Location msymloc = getModuleLocation(location, msym.name.toString());
+        try {
+            for (JavaFileObject fo : fm.list(msymloc, "", sourceKinds, true)) {
+                if (fo.getName().endsWith("module-info.java"))
+                    continue;
+                String binaryName = fm.inferBinaryName(msymloc, fo);
+                String pn = getPackageName(binaryName);
+                PackageSymbol psym = syms.enterPackage(msym, names.fromString(pn));
+                result.add((PackageElement) psym);
+            }
+
+        } catch (IOException ioe) {
+            String text = messager.getText("main.file.manager.list", msymloc.getName());
+            throw new ToolException(SYSERR, text, ioe);
         }
         return result;
     }
 
-    private Set<PackageElement> computeModulePackages() throws IOException {
+    private Set<PackageElement> computeModulePackages() throws ToolException {
         final AccessKind accessValue = accessFilter.getAccessValue(ElementKind.PACKAGE);
         final boolean documentAllModulePackages = (accessValue == AccessKind.PACKAGE ||
                 accessValue == AccessKind.PRIVATE);
@@ -662,10 +679,10 @@
         includedTypeElements = Collections.unmodifiableSet(iclasses);
     }
 
-    /**
+    /*
      * Computes the included packages and freezes the specified packages list.
      */
-    private void computeSpecifiedPackages() throws IOException {
+    private void computeSpecifiedPackages() throws ToolException {
 
         computeSubpackages();
 
@@ -683,7 +700,7 @@
             if (pkg != null) {
                 packlist.add(pkg);
             } else {
-                toolEnv.warning("main.package_not_found", modpkg.toString());
+                messager.printWarningUsingKey("main.package_not_found", modpkg.toString());
             }
         });
         specifiedPackageElements = Collections.unmodifiableSet(packlist);
@@ -693,7 +710,7 @@
      * Adds all classes as well as inner classes, to the specified
      * list.
      */
-    private void computeSpecifiedTypes() {
+    private void computeSpecifiedTypes() throws ToolException {
         Set<TypeElement> classes = new LinkedHashSet<>();
         classDecList.stream().filter((def) -> (shouldDocument(def.sym))).forEach((def) -> {
             TypeElement te = (TypeElement) def.sym;
@@ -701,24 +718,28 @@
                 addAllClasses(classes, te, true);
             }
         });
-        classArgList.forEach((className) -> {
+        for (String className : classArgList) {
             TypeElement te = toolEnv.loadClass(className);
             if (te == null) {
-                toolEnv.error("javadoc.class_not_found", className);
+                String text = messager.getText("javadoc.class_not_found", className);
+                throw new ToolException(CMDERR, text);
             } else {
                 addAllClasses(classes, te, true);
             }
-        });
+        }
         specifiedTypeElements = Collections.unmodifiableSet(classes);
     }
 
     private void addFilesForParser(Collection<JavaFileObject> result,
-            Collection<ModulePackage> collection, boolean recurse) throws IOException {
+            Collection<ModulePackage> collection,
+            boolean recurse) throws ToolException {
         for (ModulePackage modpkg : collection) {
             toolEnv.notice("main.Loading_source_files_for_package", modpkg.toString());
             List<JavaFileObject> files = getFiles(modpkg, recurse);
             if (files.isEmpty()) {
-                    toolEnv.error("main.no_source_files_for_package", modpkg.toString());
+                String text = messager.getText("main.no_source_files_for_package",
+                        modpkg.toString());
+                throw new ToolException(CMDERR, text);
             } else {
                 result.addAll(files);
             }
@@ -732,7 +753,7 @@
      * @return a list of java file objects
      * @throws IOException if an error occurs
      */
-    List<JavaFileObject> getFilesToParse() throws IOException {
+    List<JavaFileObject> getFilesToParse() throws ToolException {
         List<JavaFileObject> result = new ArrayList<>();
         addFilesForParser(result, cmdLinePackages, false);
         addFilesForParser(result, subPackages, true);
@@ -744,9 +765,10 @@
      *
      * @param packageName the specified package
      * @return the set of file objects for the specified package
-     * @throws IOException if an error occurs while accessing the files
+     * @throws ToolException if an error occurs while accessing the files
      */
-    private List<JavaFileObject> getFiles(ModulePackage modpkg, boolean recurse) throws IOException {
+    private List<JavaFileObject> getFiles(ModulePackage modpkg,
+            boolean recurse) throws ToolException {
         Entry e = getEntry(modpkg);
         // The files may have been found as a side effect of searching for subpackages
         if (e.files != null) {
@@ -759,12 +781,18 @@
             return Collections.emptyList();
         }
         String pname = modpkg.packageName;
-        for (JavaFileObject fo : fm.list(packageLocn, pname, sourceKinds, recurse)) {
-            String binaryName = fm.inferBinaryName(packageLocn, fo);
-            String simpleName = getSimpleName(binaryName);
-            if (isValidClassName(simpleName)) {
-                lb.append(fo);
+
+        try {
+            for (JavaFileObject fo : fm.list(packageLocn, pname, sourceKinds, recurse)) {
+                String binaryName = fm.inferBinaryName(packageLocn, fo);
+                String simpleName = getSimpleName(binaryName);
+                if (isValidClassName(simpleName)) {
+                    lb.append(fo);
+                }
             }
+        } catch (IOException ioe) {
+            String text = messager.getText("main.file.manager.list", pname);
+            throw new ToolException(SYSERR, text, ioe);
         }
 
         return lb.toList();
@@ -781,20 +809,30 @@
             return null;
     }
 
-    private Location getLocation(ModulePackage modpkg) throws IOException {
+    private Location getLocation(ModulePackage modpkg) throws ToolException {
         if (location != StandardLocation.MODULE_SOURCE_PATH) {
             return location;
         }
 
         if (modpkg.hasModule()) {
-            return fm.getModuleLocation(location, modpkg.moduleName);
+            return getModuleLocation(location, modpkg.moduleName);
         }
         // TODO: handle invalid results better.
         ModuleSymbol msym = findModuleOfPackageName(modpkg.packageName);
         if (msym == null) {
             return null;
         }
-        return fm.getModuleLocation(location, msym.name.toString());
+        return getModuleLocation(location, msym.name.toString());
+    }
+
+    private Location getModuleLocation(Location location, String msymName)
+            throws ToolException {
+        try {
+            return fm.getModuleLocation(location, msymName);
+        } catch (IOException ioe) {
+            String text = messager.getText("main.doclet_could_not_get_location", msymName);
+            throw new ToolException(ERROR, text, ioe);
+        }
     }
 
     private Entry getEntry(String name) {
@@ -841,7 +879,10 @@
                 }
             }
         } catch (CompletionFailure e) {
-            // quietly ignore completion failures
+            if (e.getMessage() != null)
+                messager.printWarning(e.getMessage());
+            else
+                messager.printWarningUsingKey("main.unexpected.exception", e);
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/IllegalOptionValue.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,52 @@
+/*
+ * 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.javadoc.internal.tool;
+
+import static jdk.javadoc.internal.tool.Main.Result.CMDERR;
+
+/**
+ * Provides a mechanism for the javadoc tool to indicate an option
+ * decoding issue, arising from command line error.
+ *
+ * <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>
+ */
+
+class IllegalOptionValue extends OptionException {
+
+    private static final long serialVersionUID = 0;
+
+    /**
+     * Constructs an object containing a runnable and a message.
+     * @param method a method to display suitable usage text
+     * @param message the detailed message
+     */
+    IllegalOptionValue(Runnable method, String message) {
+        super(CMDERR, method, message);
+    }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Tue Oct 18 17:14:09 2016 +0000
@@ -27,7 +27,6 @@
 
 
 import java.io.File;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
@@ -51,6 +50,8 @@
 import com.sun.tools.javac.util.Position;
 import jdk.javadoc.doclet.DocletEnvironment;
 
+import static jdk.javadoc.internal.tool.Main.Result.*;
+
 /**
  *  This class could be the main entry point for Javadoc when Javadoc is used as a
  *  component in a larger software system. It provides operations to
@@ -120,9 +121,10 @@
         }
     }
 
-    public DocletEnvironment getEnvironment(Map<ToolOption, Object> jdtoolOpts,
-                                      List<String> javaNames,
-                                      Iterable<? extends JavaFileObject> fileObjects) throws IOException {
+    public DocletEnvironment getEnvironment(Map<ToolOption,
+            Object> jdtoolOpts,
+            List<String> javaNames,
+            Iterable<? extends JavaFileObject> fileObjects) throws ToolException {
         toolEnv = ToolEnvironment.instance(context);
         toolEnv.initialize(jdtoolOpts);
         ElementsTable etable = new ElementsTable(context, jdtoolOpts);
@@ -133,10 +135,12 @@
         if (etable.xclasses) {
             // If -Xclasses is set, the args should be a list of class names
             for (String arg: javaNames) {
-                if (!isValidPackageName(arg)) // checks
-                    toolEnv.error("main.illegal_class_name", arg);
+                if (!isValidPackageName(arg)) { // checks
+                    String text = messager.getText("main.illegal_class_name", arg);
+                    throw new ToolException(CMDERR, text);
+                }
             }
-            if (messager.nerrors() != 0) {
+            if (messager.hasErrors()) {
                 return null;
             }
             etable.setClassArgList(javaNames);
@@ -157,19 +161,23 @@
             for (String arg: javaNames) {
                 if (fm != null && arg.endsWith(".java") && new File(arg).exists()) {
                     if (new File(arg).getName().equals("module-info.java")) {
-                        toolEnv.warning("main.file_ignored", arg);
+                        messager.printWarningUsingKey("main.file_ignored", arg);
                     } else {
                         parse(fm.getJavaFileObjects(arg), classTrees, true);
                     }
                 } else if (isValidPackageName(arg)) {
                     packageNames.add(arg);
                 } else if (arg.endsWith(".java")) {
-                    if (fm == null)
-                        throw new IllegalArgumentException();
-                    else
-                        toolEnv.error("main.file_not_found", arg);
+                    if (fm == null) {
+                        String text = messager.getText("main.assertion.error", "fm == null");
+                        throw new ToolException(ABNORMAL, text);
+                    } else {
+                        String text = messager.getText("main.file_not_found", arg);
+                        throw new ToolException(ERROR, text);
+                    }
                 } else {
-                    toolEnv.error("main.illegal_package_name", arg);
+                    String text = messager.getText("main.illegal_package_name", arg);
+                    throw new ToolException(CMDERR, text);
                 }
             }
 
@@ -185,7 +193,7 @@
             parse(etable.getFilesToParse(), packageTrees, false);
             modules.enter(packageTrees.toList(), null);
 
-            if (messager.nerrors() != 0) {
+            if (messager.hasErrors()) {
                 return null;
             }
 
@@ -197,10 +205,19 @@
             enterDone = true;
             etable.analyze();
         } catch (CompletionFailure cf) {
-            toolEnv.printError(cf.getMessage());
-        } catch (Abort ex) {}
+            throw new ToolException(ABNORMAL, cf.getMessage(), cf);
+        } catch (Abort abort) {
+            if (messager.hasErrors()) {
+                // presumably a message has been emitted, keep silent
+                throw new ToolException(ABNORMAL, "", abort);
+            } else {
+                String text = messager.getText("main.internal.error");
+                Throwable t = abort.getCause() == null ? abort : abort.getCause();
+                throw new ToolException(ABNORMAL, text, t);
+            }
+        }
 
-        if (messager.nerrors() != 0)
+        if (messager.hasErrors())
             return null;
 
         toolEnv.docEnv = new DocEnvImpl(toolEnv, etable);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocToolProvider.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,47 @@
+/*
+ * 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.javadoc.internal.tool;
+
+import java.io.PrintWriter;
+import java.util.spi.ToolProvider;
+
+/**
+ * An implementation of the {@link java.util.spi.ToolProvider ToolProvider} SPI,
+ * providing access to JDK documentation tool, javadoc.
+ *
+ * @since 9
+ */
+// This is currently a stand-alone top-level class so that it can easily be excluded
+// from interims builds of javadoc, used while building JDK.
+public class JavadocToolProvider implements ToolProvider {
+    public String name() {
+        return "javadoc";
+    }
+
+    public int run(PrintWriter out, PrintWriter err, String... args) {
+        return Main.execute(args, out, err);
+    }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Main.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Main.java	Tue Oct 18 17:14:09 2016 +0000
@@ -60,18 +60,61 @@
      */
     public static int execute(String... args) {
         Start jdoc = new Start();
-        return jdoc.begin(args);
+        return jdoc.begin(args).exitCode;
+    }
+
+    /**
+     * Programmatic interface.
+     *
+     * @param writer a stream for all output
+     * @param args The command line parameters.
+     * @return The return code.
+     */
+    public static int execute(String[] args, PrintWriter writer) {
+        Start jdoc = new Start(writer, writer);
+        return jdoc.begin(args).exitCode;
     }
 
     /**
      * Programmatic interface.
      *
-     * @param writer PrintWriter to receive notice messages.
+     * @param outWriter a stream for expected output
+     * @param errWriter a stream for diagnostic output
      * @param args The command line parameters.
      * @return The return code.
      */
-    public static int execute(String[] args, PrintWriter writer) {
-        Start jdoc = new Start(writer);
-        return jdoc.begin(args);
+    public static int execute(String[] args, PrintWriter outWriter, PrintWriter errWriter) {
+        Start jdoc = new Start(outWriter, errWriter);
+        return jdoc.begin(args).exitCode;
+    }
+
+    public static enum Result {
+        /** completed with no errors */
+        OK(0),
+        /** Completed with reported errors */
+        ERROR(1),
+        /** Bad command-line arguments */
+        CMDERR(2),
+        /** System error or resource exhaustion */
+        SYSERR(3),
+        /** Terminated abnormally */
+        ABNORMAL(4);
+
+        private static final long serialVersionUID = 1L;
+
+        Result(int exitCode) {
+            this.exitCode = exitCode;
+        }
+
+        public boolean isOK() {
+            return (exitCode == 0);
+        }
+
+        public final int exitCode;
+
+        @Override
+        public String toString() {
+            return name() + '(' + exitCode + ')';
+        }
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Messager.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Messager.java	Tue Oct 18 17:14:09 2016 +0000
@@ -48,10 +48,8 @@
 
 /**
  * Utility for integrating with javadoc tools and for localization.
- * Handle Resources. Access to error and warning counts.
- * Message formatting.
- * <br>
- * Also provides implementation for DocErrorReporter.
+ * Handle resources, access to error and warning counts and
+ * message formatting.
  *
  *  <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.
@@ -139,10 +137,6 @@
         }
     }
 
-    public static class ExitJavadoc extends Error {
-        private static final long serialVersionUID = 0;
-    }
-
     final String programName;
 
     private Locale locale;
@@ -165,8 +159,8 @@
     /**
      * Constructor
      * @param programName  Name of the program (for error messages).
-     * @param stdOut    Stream for notices etc.
-     * @param stdErr    Stream for errors and warnings
+     * @param outWriter    Stream for notices etc.
+     * @param errWriter    Stream for errors and warnings
      */
     @SuppressWarnings("deprecation")
     public Messager(Context context, String programName, PrintWriter outWriter, PrintWriter errWriter) {
@@ -240,7 +234,7 @@
             report(DiagnosticType.ERROR, prefix, msg);
             return;
         }
-        incrementErrorCount(prefix, msg);
+        printError(prefix, msg);
     }
 
     public void printError(Element e, String msg) {
@@ -249,13 +243,18 @@
             report(DiagnosticType.ERROR, prefix, msg);
             return;
         }
-        incrementErrorCount(prefix, msg);
+        printError(prefix, msg);
     }
 
-    private void incrementErrorCount(String prefix, String msg) {
+    public void printErrorUsingKey(String key, Object... args) {
+        printError((Element)null, getText(key, args));
+    }
+
+    // print the error and increment count
+    private void printError(String prefix, String msg) {
         if (nerrors < MaxErrors) {
             PrintWriter errWriter = getWriter(WriterKind.ERROR);
-            errWriter.println(prefix + ": " + getText("javadoc.error") + " - " + msg);
+            printRawLines(errWriter, prefix + ": " + getText("javadoc.error") + " - " + msg);
             errWriter.flush();
             prompt();
             nerrors++;
@@ -272,13 +271,21 @@
         printWarning((DocTreePath)null, msg);
     }
 
+    public void printWarningUsingKey(String key, Object... args) {
+        printWarning((Element)null, getText(key, args));
+    }
+
+    public void printWarning(Element e, String key, Object... args) {
+        printWarning(getText(key, args));
+    }
+
     public void printWarning(DocTreePath path, String msg) {
         String prefix = getDiagSource(path);
         if (diagListener != null) {
             report(DiagnosticType.WARNING, prefix, msg);
             return;
         }
-        incrementWarningCount(prefix, msg);
+        printWarning(prefix, msg);
     }
 
     public void printWarning(Element e, String msg) {
@@ -287,13 +294,14 @@
             report(DiagnosticType.WARNING, prefix, msg);
             return;
         }
-        incrementWarningCount(prefix, msg);
+        printWarning(prefix, msg);
     }
 
-    private void incrementWarningCount(String prefix, String msg) {
+    // print the warning and increment count
+    private void printWarning(String prefix, String msg) {
         if (nwarnings < MaxWarnings) {
             PrintWriter warnWriter = getWriter(WriterKind.WARNING);
-            warnWriter.println(prefix + ": " + getText("javadoc.warning") + " - " + msg);
+            printRawLines(warnWriter, prefix + ": " + getText("javadoc.warning") + " - " + msg);
             warnWriter.flush();
             nwarnings++;
         }
@@ -318,9 +326,9 @@
 
         PrintWriter noticeWriter = getWriter(WriterKind.NOTICE);
         if (path == null) {
-            noticeWriter.println(msg);
+            printRawLines(noticeWriter, msg);
         } else {
-            noticeWriter.println(prefix + ": " + msg);
+            printRawLines(noticeWriter, prefix + ": " + msg);
         }
         noticeWriter.flush();
     }
@@ -334,58 +342,14 @@
 
         PrintWriter noticeWriter = getWriter(WriterKind.NOTICE);
         if (e == null) {
-            noticeWriter.println(msg);
+            printRawLines(noticeWriter, msg);
         } else {
-            noticeWriter.println(pos + ": " + msg);
+            printRawLines(noticeWriter, pos + ": " + msg);
         }
         noticeWriter.flush();
     }
 
     /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     */
-    public void error(Element e, String key, Object... args) {
-        printError(e, getText(key, args));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     */
-    public void error(DocTreePath path, String key, Object... args) {
-        printError(path, getText(key, args));
-    }
-
-    public void error(String key, Object... args) {
-        printError((Element)null, getText(key, args));
-    }
-
-    public void warning(String key, Object... args) {
-        printWarning((Element)null, getText(key, args));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     */
-    public void warning(Element e, String key, Object... args) {
-        printWarning(e, getText(key, args));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     */
-    public void warning(DocTreePath path, String key, Object... args) {
-        printWarning(path, getText(key, args));
-    }
-
-    /**
      * Print a message.
      *
      * @param key selects message from resource
@@ -395,21 +359,23 @@
     }
 
     /**
-     * Return total number of errors, including those recorded
-     * in the compilation log.
+     * Returns true if errors have been recorded.
      */
-    public int nerrors() { return nerrors; }
+    public boolean hasErrors() {
+        return nerrors != 0;
+    }
 
     /**
-     * Return total number of warnings, including those recorded
-     * in the compilation log.
+     * Returns true if warnings have been recorded.
      */
-    public int nwarnings() { return nwarnings; }
+    public boolean hasWarnings() {
+        return nwarnings != 0;
+    }
 
     /**
      * Print exit message.
      */
-    public void exitNotice() {
+    public void printErrorWarningCounts() {
         if (nerrors > 0) {
             notice((nerrors > 1) ? "main.errors" : "main.error",
                    "" + nerrors);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/OptionException.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,80 @@
+/*
+ * 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.javadoc.internal.tool;
+
+import jdk.javadoc.internal.tool.Main.Result;
+
+/**
+ * Provides a general mechanism for the javadoc tool to indicate an option
+ * decoding issue.
+ *
+ * <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>
+ */
+
+class OptionException extends Exception {
+
+    private static final long serialVersionUID = 0;
+
+    public final Result result;
+    public final String message;
+    public final Runnable m;
+
+    /**
+     * Constructs an object with a result, runnable and a message
+     * to be printed out by the catcher. The runnable can be invoked
+     * by the catcher to display the usage text.
+     * @param result the exit code
+     * @param method the method to invoke
+     * @param message the detailed message
+     */
+    public OptionException(Result result, Runnable method, String message) {
+        this.result = result;
+        this.m = method;
+        this.message = message;
+        if (result == null || result.isOK() || method == null || message == null) {
+            throw new AssertionError("result == null || result.isOK() || " +
+                    "method == null || message == null");
+        }
+    }
+
+    /**
+     * Constructs an object with a result and a runnable.
+     * The runnable can be invoked by the catcher to display the usage text.
+     * @param result the exit code
+     * @param method the method to invoke
+     */
+    public OptionException(Result result, Runnable method) {
+        this.result = result;
+        this.m = method;
+        this.message = null;
+        if (result == null || method == null) {
+            throw new AssertionError("result == null || method == null");
+        }
+    }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,19 +26,22 @@
 package jdk.javadoc.internal.tool;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.nio.file.Path;
 import java.text.BreakIterator;
+import java.text.Collator;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Objects;
 import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
@@ -61,10 +64,12 @@
 import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.Doclet.Option;
 import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.internal.tool.Main.Result;
 
 import static javax.tools.DocumentationTool.Location.*;
 
 import static com.sun.tools.javac.main.Option.*;
+import static jdk.javadoc.internal.tool.Main.Result.*;
 
 /**
  * Main program of Javadoc.
@@ -114,20 +119,21 @@
     private JavaFileManager fileManager;
 
     Start() {
-        this(null, null, null, null, null);
+        this(null, null, null, null, null, null);
     }
 
-    Start(PrintWriter writer) {
-        this(null, null, writer, null, null);
+    Start(PrintWriter outWriter, PrintWriter errWriter) {
+        this(null, null, outWriter, errWriter, null, null);
     }
 
-    Start(Context context, String programName, PrintWriter writer,
+    Start(Context context, String programName,
+            PrintWriter outWriter, PrintWriter errWriter,
             String docletName, ClassLoader classLoader) {
         this.context = context == null ? new Context() : context;
         String pname = programName == null ? ProgramName : programName;
-        this.messager = writer == null
+        this.messager = (outWriter == null && errWriter == null)
                 ? new Messager(this.context, pname)
-                : new Messager(this.context, pname, writer, writer);
+                : new Messager(this.context, pname, outWriter, errWriter);
         this.docletName = docletName;
         this.classLoader = classLoader;
         this.docletClass = null;
@@ -164,41 +170,129 @@
      */
     @Override
     void usage() {
-        usage(true);
-    }
-
-    void usage(boolean exit) {
-        usage("main.usage", "-help", "main.usage.foot", exit);
+        usage("main.usage", OptionKind.STANDARD, "main.usage.foot");
     }
 
     @Override
     void Xusage() {
-        Xusage(true);
+        usage("main.Xusage", OptionKind.EXTENDED, "main.Xusage.foot");
     }
 
-    void Xusage(boolean exit) {
-        usage("main.Xusage", "-X", "main.Xusage.foot", exit);
-    }
+    private void usage(String headerKey, OptionKind kind, String footerKey) {
+        messager.notice(headerKey);
+        showToolOptions(kind);
 
-    private void usage(String main, String option, String foot, boolean exit) {
-        messager.notice(main);
-        // let doclet print usage information (does nothing on error)
+        // let doclet print usage information
         if (docletClass != null) {
             String name = doclet.getName();
-            Set<Option> supportedOptions = doclet.getSupportedOptions();
             messager.notice("main.doclet.usage.header", name);
-            Option.Kind myKind = option.equals("-X")
+            showDocletOptions(kind == OptionKind.EXTENDED
                     ? Option.Kind.EXTENDED
-                    : Option.Kind.STANDARD;
-            supportedOptions.stream()
-                    .filter(opt -> opt.getKind() == myKind)
-                    .forEach(opt -> messager.printNotice(opt.toString()));
+                    : Option.Kind.STANDARD);
+        }
+        if (footerKey != null)
+            messager.notice(footerKey);
+    }
+
+    void showToolOptions(OptionKind kind) {
+        Comparator<ToolOption> comp = new Comparator<ToolOption>() {
+            final Collator collator = Collator.getInstance(Locale.US);
+            { collator.setStrength(Collator.PRIMARY); }
+
+            @Override
+            public int compare(ToolOption o1, ToolOption o2) {
+                return collator.compare(o1.primaryName, o2.primaryName);
+            }
+        };
+
+        Stream.of(ToolOption.values())
+                    .filter(opt -> opt.kind == kind)
+                    .sorted(comp)
+                    .forEach(opt -> showToolOption(opt));
+    }
+
+    void showToolOption(ToolOption option) {
+        List<String> names = option.getNames();
+        String parameters;
+        if (option.hasArg || option.primaryName.endsWith(":")) {
+            String sep = (option == ToolOption.J) || option.primaryName.endsWith(":") ? "" : " ";
+            parameters = sep + option.getParameters(messager);
+        } else {
+            parameters = "";
         }
-        if (foot != null)
-            messager.notice(foot);
+        String description = option.getDescription(messager);
+        showUsage(names, parameters, description);
+    }
+
+    void showDocletOptions(Option.Kind kind) {
+        Comparator<Doclet.Option> comp = new Comparator<Doclet.Option>() {
+            final Collator collator = Collator.getInstance(Locale.US);
+            { collator.setStrength(Collator.PRIMARY); }
+
+            @Override
+            public int compare(Doclet.Option o1, Doclet.Option o2) {
+                return collator.compare(o1.getName(), o2.getName());
+            }
+        };
+
+        doclet.getSupportedOptions().stream()
+                .filter(opt -> opt.getKind() == kind)
+                .sorted(comp)
+                .forEach(opt -> showDocletOption(opt));
+    }
+
+    void showDocletOption(Doclet.Option option) {
+        List<String> names = Arrays.asList(option.getName());
+        String parameters;
+        if (option.getArgumentCount() > 0 || option.getName().endsWith(":")) {
+            String sep = option.getName().endsWith(":") ? "" : " ";
+            parameters = sep + option.getParameters();
+        } else {
+            parameters = "";
+        }
+        String description = option.getDescription();
+        showUsage(names, parameters, description);
+    }
+
+    // The following constants are intended to format the output to
+    // be similar to that of the java launcher: i.e. "java -help".
 
-        if (exit)
-            throw new Messager.ExitJavadoc();
+    /** The indent for the option synopsis. */
+    private static final String SMALL_INDENT = "    ";
+    /** The automatic indent for the description. */
+    private static final String LARGE_INDENT = "                  ";
+    /** The space allowed for the synopsis, if the description is to be shown on the same line. */
+    private static final int DEFAULT_SYNOPSIS_WIDTH = 13;
+    /** The nominal maximum line length, when seeing if text will fit on a line. */
+    private static final int DEFAULT_MAX_LINE_LENGTH = 80;
+    /** The format for a single-line help entry. */
+    private static final String COMPACT_FORMAT = SMALL_INDENT + "%-" + DEFAULT_SYNOPSIS_WIDTH + "s %s";
+
+    void showUsage(List<String> names, String parameters, String description) {
+        String synopses = names.stream()
+                .map(s -> s + parameters)
+                .collect(Collectors.joining(", "));
+        // If option synopses and description fit on a single line of reasonable length,
+        // display using COMPACT_FORMAT
+        if (synopses.length() < DEFAULT_SYNOPSIS_WIDTH
+                && !description.contains("\n")
+                && (SMALL_INDENT.length() + DEFAULT_SYNOPSIS_WIDTH + 1 + description.length() <= DEFAULT_MAX_LINE_LENGTH)) {
+            messager.printNotice(String.format(COMPACT_FORMAT, synopses, description));
+            return;
+        }
+
+        // If option synopses fit on a single line of reasonable length, show that;
+        // otherwise, show 1 per line
+        if (synopses.length() <= DEFAULT_MAX_LINE_LENGTH) {
+            messager.printNotice(SMALL_INDENT + synopses);
+        } else {
+            for (String name: names) {
+                messager.printNotice(SMALL_INDENT + name + parameters);
+            }
+        }
+
+        // Finally, show the description
+        messager.printNotice(LARGE_INDENT + description.replace("\n", "\n" + LARGE_INDENT));
     }
 
 
@@ -219,25 +313,23 @@
      * of class loader creation, needed to detect the doclet/taglet class variants.
      */
     @SuppressWarnings("deprecation")
-    int begin(String... argv) {
+    Result begin(String... argv) {
         // Preprocess @file arguments
         try {
             argv = CommandLine.parse(argv);
-        } catch (FileNotFoundException e) {
-            messager.error("main.cant.read", e.getMessage());
-            throw new Messager.ExitJavadoc();
         } catch (IOException e) {
-            e.printStackTrace(System.err);
-            throw new Messager.ExitJavadoc();
+            error("main.cant.read", e.getMessage());
+            return ERROR;
         }
 
         if (argv.length > 0 && "-Xold".equals(argv[0])) {
-            messager.warning("main.legacy_api");
+            warn("main.legacy_api");
             String[] nargv = Arrays.copyOfRange(argv, 1, argv.length);
-            return com.sun.tools.javadoc.Main.execute(nargv);
+            return com.sun.tools.javadoc.Main.execute(nargv) == 0
+                    ? OK
+                    : ERROR;
         }
-        boolean ok = begin(Arrays.asList(argv), Collections.<JavaFileObject> emptySet());
-        return ok ? 0 : 1;
+        return begin(Arrays.asList(argv), Collections.<JavaFileObject> emptySet());
     }
 
     // Called by 199 API.
@@ -249,11 +341,11 @@
         for (String opt: options)
             opts.add(opt);
 
-        return begin(opts, fileObjects);
+        return begin(opts, fileObjects).isOK();
     }
 
     @SuppressWarnings("deprecation")
-    private boolean begin(List<String> options, Iterable<? extends JavaFileObject> fileObjects) {
+    private Result begin(List<String> options, Iterable<? extends JavaFileObject> fileObjects) {
         fileManager = context.get(JavaFileManager.class);
         if (fileManager == null) {
             JavacFileManager.preRegister(context);
@@ -262,8 +354,28 @@
                 ((BaseFileManager) fileManager).autoClose = true;
             }
         }
+
         // locale, doclet and maybe taglet, needs to be determined first
-        docletClass = preProcess(fileManager, options);
+        try {
+            docletClass = preprocess(fileManager, options);
+        } catch (ToolException te) {
+            if (!te.result.isOK()) {
+                if (te.message != null) {
+                    messager.printError(te.message);
+                }
+                Throwable t = te.getCause();
+                dumpStack(t == null ? te : t);
+            }
+            return te.result;
+        } catch (OptionException oe) {
+            if (oe.message != null) {
+                messager.printError(oe.message);
+            }
+            oe.m.run();
+            Throwable t = oe.getCause();
+            dumpStack(t == null ? oe : t);
+            return oe.result;
+        }
         if (jdk.javadoc.doclet.Doclet.class.isAssignableFrom(docletClass)) {
             // no need to dispatch to old, safe to init now
             initMessager();
@@ -272,43 +384,62 @@
                 Object o = docletClass.getConstructor().newInstance();
                 doclet = (Doclet) o;
             } catch (ReflectiveOperationException exc) {
-                exc.printStackTrace();
-                if (!apiMode) {
-                    error("main.could_not_instantiate_class", docletClass);
-                    throw new Messager.ExitJavadoc();
+                if (apiMode) {
+                    throw new ClientCodeException(exc);
                 }
-                throw new ClientCodeException(exc);
+                error("main.could_not_instantiate_class", docletClass);
+                return ERROR;
             }
         } else {
-            if (this.apiMode) {
+            if (apiMode) {
                 com.sun.tools.javadoc.main.Start ostart
                         = new com.sun.tools.javadoc.main.Start(context);
-                return ostart.begin(docletClass, options, fileObjects);
+                return ostart.begin(docletClass, options, fileObjects)
+                        ? OK
+                        : ERROR;
             }
             warn("main.legacy_api");
             String[] array = options.toArray(new String[options.size()]);
-            return com.sun.tools.javadoc.Main.execute(array) == 0;
+            return com.sun.tools.javadoc.Main.execute(array) == 0
+                    ? OK
+                    : ERROR;
         }
 
-        boolean failed = false;
+        Result result = OK;
         try {
-            failed = !parseAndExecute(options, fileObjects);
-        } catch (Messager.ExitJavadoc exc) {
-            // ignore, we just exit this way
+            result = parseAndExecute(options, fileObjects)
+                    ? OK
+                    : ERROR;
+        } catch (OptionException toe) {
+            if (toe.message != null)
+                messager.printError(toe.message);
+
+            toe.m.run();
+            Throwable t = toe.getCause();
+            dumpStack(t == null ? toe : t);
+            return toe.result;
+        } catch (ToolException exc) {
+            if (exc.message != null) {
+                messager.printError(exc.message);
+            }
+            Throwable t = exc.getCause();
+            if (result == ABNORMAL) {
+                reportInternalError(t == null ? exc : t);
+            } else {
+                dumpStack(t == null ? exc : t);
+            }
+            return exc.result;
         } catch (OutOfMemoryError ee) {
-            messager.error("main.out.of.memory");
-            failed = true;
+            error("main.out.of.memory");
+            result = SYSERR;
+            dumpStack(ee);
         } catch (ClientCodeException e) {
             // simply rethrow these exceptions, to be caught and handled by JavadocTaskImpl
             throw e;
-        } catch (Error ee) {
-            ee.printStackTrace(System.err);
-            messager.error("main.fatal.error");
-            failed = true;
-        } catch (Exception ee) {
-            ee.printStackTrace(System.err);
-            messager.error("main.fatal.exception");
-            failed = true;
+        } catch (Error | Exception ee) {
+            error("main.fatal.error", ee);
+            reportInternalError(ee);
+            result = ABNORMAL;
         } finally {
             if (fileManager != null
                     && fileManager instanceof BaseFileManager
@@ -317,17 +448,34 @@
                     fileManager.close();
                 } catch (IOException ignore) {}
             }
-            boolean haveErrorWarnings = messager.nerrors() > 0 ||
-                    (rejectWarnings && messager.nwarnings() > 0);
-            if (failed && !haveErrorWarnings) {
+            boolean haveErrorWarnings = messager.hasErrors()
+                    || (rejectWarnings && messager.hasWarnings());
+            if (!result.isOK() && !haveErrorWarnings) {
                 // the doclet failed, but nothing reported, flag it!.
-                messager.error("main.unknown.error");
+                error("main.unknown.error");
             }
-            failed |= haveErrorWarnings;
-            messager.exitNotice();
+            if (haveErrorWarnings && result.isOK()) {
+                result = ERROR;
+            }
+            messager.printErrorWarningCounts();
             messager.flush();
         }
-        return !failed;
+        return result;
+    }
+
+    private void reportInternalError(Throwable t) {
+        messager.printErrorUsingKey("doclet.internal.report.bug");
+        dumpStack(true, t);
+    }
+
+    private void dumpStack(Throwable t) {
+        dumpStack(false, t);
+    }
+
+    private void dumpStack(boolean enabled, Throwable t) {
+        if (t != null && (enabled || dumpOnError)) {
+            t.printStackTrace(System.err);
+        }
     }
 
     /**
@@ -335,7 +483,7 @@
      */
     @SuppressWarnings("unchecked")
     private boolean parseAndExecute(List<String> argList,
-            Iterable<? extends JavaFileObject> fileObjects) throws IOException {
+            Iterable<? extends JavaFileObject> fileObjects) throws ToolException, OptionException {
         long tm = System.currentTimeMillis();
 
         List<String> javaNames = new ArrayList<>();
@@ -356,17 +504,21 @@
 
         if (platformString != null) {
             if (compOpts.isSet("-source")) {
-                usageError("main.release.bootclasspath.conflict", "-source");
+                String text = messager.getText("main.release.bootclasspath.conflict", "-source");
+                throw new ToolException(CMDERR, text);
             }
             if (fileManagerOpts.containsKey(BOOT_CLASS_PATH)) {
-                usageError("main.release.bootclasspath.conflict", BOOT_CLASS_PATH.getPrimaryName());
+                String text = messager.getText("main.release.bootclasspath.conflict",
+                        BOOT_CLASS_PATH.getPrimaryName());
+                throw new ToolException(CMDERR, text);
             }
 
             PlatformDescription platformDescription =
                     PlatformUtils.lookupPlatformDescription(platformString);
 
             if (platformDescription == null) {
-                usageError("main.unsupported.release.version", platformString);
+                String text = messager.getText("main.unsupported.release.version", platformString);
+                throw new IllegalArgumentException(text);
             }
 
             compOpts.put(SOURCE, platformDescription.getSourceVersion());
@@ -378,10 +530,15 @@
             if (platformCP != null) {
                 if (fileManager instanceof StandardJavaFileManager) {
                     StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
-
-                    sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP);
+                    try {
+                        sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP);
+                    } catch (IOException ioe) {
+                        throw new ToolException(SYSERR, ioe.getMessage(), ioe);
+                    }
                 } else {
-                    usageError("main.release.not.standard.file.manager", platformString);
+                    String text = messager.getText("main.release.not.standard.file.manager",
+                                                    platformString);
+                    throw new ToolException(ABNORMAL, text);
                 }
             }
         }
@@ -395,7 +552,8 @@
                     s -> Collections.EMPTY_LIST);
             if (subpkgs.isEmpty()) {
                 if (javaNames.isEmpty() && isEmpty(fileObjects)) {
-                    usageError("main.No_modules_packages_or_classes_specified");
+                    String text = messager.getText("main.No_modules_packages_or_classes_specified");
+                    throw new ToolException(CMDERR, text);
                 }
             }
         }
@@ -428,29 +586,57 @@
     }
 
     Set<Doclet.Option> docletOptions = null;
-    int handleDocletOptions(int idx, List<String> args, boolean isToolOption) {
+    int handleDocletOptions(int idx, List<String> args, boolean isToolOption)
+            throws OptionException {
         if (docletOptions == null) {
             docletOptions = doclet.getSupportedOptions();
         }
         String arg = args.get(idx);
-
+        String argBase, argVal;
+        if (arg.startsWith("--") && arg.contains("=")) {
+            int sep = arg.indexOf("=");
+            argBase = arg.substring(0, sep);
+            argVal = arg.substring(sep + 1);
+        } else {
+            argBase = arg;
+            argVal = null;
+        }
+        String text = null;
         for (Doclet.Option opt : docletOptions) {
-            if (opt.matches(arg)) {
-                if (args.size() - idx < opt.getArgumentCount()) {
-                    usageError("main.requires_argument", arg);
+            if (opt.matches(argBase)) {
+                if (argVal != null) {
+                    switch (opt.getArgumentCount()) {
+                        case 0:
+                            text = messager.getText("main.unnecessary_arg_provided", argBase);
+                            throw new OptionException(ERROR, this::usage, text);
+                        case 1:
+                            opt.process(arg, Arrays.asList(argVal).listIterator());
+                            break;
+                        default:
+                            text = messager.getText("main.only_one_argument_with_equals", argBase);
+                            throw new OptionException(ERROR, this::usage, text);
+                    }
+                } else {
+                    if (args.size() - idx -1 < opt.getArgumentCount()) {
+                        text = messager.getText("main.requires_argument", arg);
+                        throw new OptionException(ERROR, this::usage, text);
+                    }
+                    opt.process(arg, args.listIterator(idx + 1));
+                    idx += opt.getArgumentCount();
                 }
-                opt.process(arg, args.listIterator(idx + 1));
-                idx += opt.getArgumentCount();
                 return idx;
             }
         }
         // check if arg is accepted by the tool before emitting error
-        if (!isToolOption)
-            usageError("main.invalid_flag", arg);
+        if (!isToolOption) {
+            text = messager.getText("main.invalid_flag", arg);
+            throw new OptionException(ERROR, this::usage, text);
+        }
         return idx;
     }
 
-    private Class<?> preProcess(JavaFileManager jfm, List<String> argv) {
+    private Class<?> preprocess(JavaFileManager jfm,
+            List<String> argv) throws ToolException, OptionException {
         // doclet specifying arguments
         String userDocletPath = null;
         String userDocletName = null;
@@ -463,22 +649,34 @@
         // Step 1: loop through the args, set locale early on, if found.
         for (int i = 0 ; i < argv.size() ; i++) {
             String arg = argv.get(i);
-            if (arg.equals(ToolOption.LOCALE.opt)) {
+            if (arg.equals(ToolOption.DUMPONERROR.primaryName)) {
+                dumpOnError = true;
+            } else if (arg.equals(ToolOption.LOCALE.primaryName)) {
                 checkOneArg(argv, i++);
                 String lname = argv.get(i);
                 locale = getLocale(lname);
-            } else if (arg.equals(ToolOption.DOCLET.opt)) {
+            } else if (arg.equals(ToolOption.DOCLET.primaryName)) {
                 checkOneArg(argv, i++);
                 if (userDocletName != null) {
-                    usageError("main.more_than_one_doclet_specified_0_and_1",
+                    if (apiMode) {
+                        throw new IllegalArgumentException("More than one doclet specified (" +
+                                userDocletName + " and " + argv.get(i) + ").");
+                    }
+                    String text = messager.getText("main.more_than_one_doclet_specified_0_and_1",
                             userDocletName, argv.get(i));
+                    throw new ToolException(CMDERR, text);
                 }
                 if (docletName != null) {
-                    usageError("main.more_than_one_doclet_specified_0_and_1",
+                    if (apiMode) {
+                        throw new IllegalArgumentException("More than one doclet specified (" +
+                                docletName + " and " + argv.get(i) + ").");
+                    }
+                    String text = messager.getText("main.more_than_one_doclet_specified_0_and_1",
                             docletName, argv.get(i));
+                    throw new ToolException(CMDERR, text);
                 }
                 userDocletName = argv.get(i);
-            } else if (arg.equals(ToolOption.DOCLETPATH.opt)) {
+            } else if (arg.equals(ToolOption.DOCLETPATH.primaryName)) {
                 checkOneArg(argv, i++);
                 if (userDocletPath == null) {
                     userDocletPath = argv.get(i);
@@ -514,23 +712,37 @@
                     try {
                         ((StandardJavaFileManager)fileManager).setLocation(DOCLET_PATH, paths);
                     } catch (IOException ioe) {
-                        error("main.doclet_could_not_set_location", paths);
-                        throw new Messager.ExitJavadoc();
+                        if (apiMode) {
+                            throw new IllegalArgumentException("Could not set location for " +
+                                    userDocletPath, ioe);
+                        }
+                        String text = messager.getText("main.doclet_could_not_set_location",
+                                userDocletPath);
+                        throw new ToolException(CMDERR, text, ioe);
                     }
                 }
                 cl = fileManager.getClassLoader(DOCLET_PATH);
                 if (cl == null) {
                     // despite doclet specified on cmdline no classloader found!
-                    error("main.doclet_no_classloader_found", userDocletName);
-                    throw new Messager.ExitJavadoc();
+                    if (apiMode) {
+                        throw new IllegalArgumentException("Could not obtain classloader to load "
+                                + userDocletPath);
+                    }
+                    String text = messager.getText("main.doclet_no_classloader_found",
+                            userDocletName);
+                    throw new ToolException(CMDERR, text);
                 }
             }
             try {
                 Class<?> klass = cl.loadClass(userDocletName);
                 return klass;
             } catch (ClassNotFoundException cnfe) {
-                error("main.doclet_class_not_found", userDocletName);
-                throw new Messager.ExitJavadoc();
+                if (apiMode) {
+                    throw new IllegalArgumentException("Cannot find doclet class " + userDocletName,
+                            cnfe);
+                }
+                String text = messager.getText("main.doclet_class_not_found", userDocletName);
+                throw new ToolException(CMDERR, text, cnfe);
             }
         }
 
@@ -539,8 +751,11 @@
             try {
                 return Class.forName(docletName, true, getClass().getClassLoader());
             } catch (ClassNotFoundException cnfe) {
-                error("main.doclet_class_not_found", userDocletName);
-                throw new Messager.ExitJavadoc();
+                if (apiMode) {
+                    throw new IllegalArgumentException("Cannot find doclet class " + userDocletName);
+                }
+                String text = messager.getText("main.doclet_class_not_found", userDocletName);
+                throw new ToolException(CMDERR, text, cnfe);
             }
         }
 
@@ -560,20 +775,20 @@
      * nature to take its own course.
      */
     @SuppressWarnings("deprecation")
-    private boolean hasOldTaglet(List<String> tagletNames, List<File> tagletPaths) {
+    private boolean hasOldTaglet(List<String> tagletNames, List<File> tagletPaths) throws ToolException {
         if (!fileManager.hasLocation(TAGLET_PATH)) {
             try {
                 ((StandardJavaFileManager) fileManager).setLocation(TAGLET_PATH, tagletPaths);
             } catch (IOException ioe) {
-                error("main.doclet_could_not_set_location", tagletPaths);
-                throw new Messager.ExitJavadoc();
+                String text = messager.getText("main.doclet_could_not_set_location", tagletPaths);
+                throw new ToolException(CMDERR, text, ioe);
             }
         }
         ClassLoader cl = fileManager.getClassLoader(TAGLET_PATH);
         if (cl == null) {
             // no classloader found!
-            error("main.doclet_no_classloader_found", tagletNames.get(0));
-            throw new Messager.ExitJavadoc();
+            String text = messager.getText("main.doclet_no_classloader_found", tagletNames.get(0));
+            throw new ToolException(CMDERR, text);
         }
         for (String tagletName : tagletNames) {
             try {
@@ -582,14 +797,15 @@
                     return true;
                 }
             } catch (ClassNotFoundException cnfe) {
-                error("main.doclet_class_not_found", tagletName);
-                throw new Messager.ExitJavadoc();
+                String text = messager.getText("main.doclet_class_not_found", tagletName);
+                throw new ToolException(CMDERR, text, cnfe);
             }
         }
         return false;
     }
 
-    private void parseArgs(List<String> args, List<String> javaNames) {
+    private void parseArgs(List<String> args, List<String> javaNames) throws ToolException,
+            OptionException {
         for (int i = 0 ; i < args.size() ; i++) {
             String arg = args.get(i);
             ToolOption o = ToolOption.get(arg);
@@ -597,10 +813,13 @@
                 // handle a doclet argument that may be needed however
                 // don't increment the index, and allow the tool to consume args
                 handleDocletOptions(i, args, true);
-
                 if (o.hasArg) {
-                    checkOneArg(args, i++);
-                    o.process(this, args.get(i));
+                    if (arg.startsWith("--") && arg.contains("=")) {
+                        o.process(this, arg.substring(arg.indexOf('=') + 1));
+                    } else {
+                        checkOneArg(args, i++);
+                        o.process(this, args.get(i));
+                    }
                 } else if (o.hasSuffix) {
                     o.process(this, arg);
                 } else {
@@ -629,24 +848,19 @@
      * Check the one arg option.
      * Error and exit if one argument is not provided.
      */
-    private void checkOneArg(List<String> args, int index) {
+    private void checkOneArg(List<String> args, int index) throws OptionException {
         if ((index + 1) >= args.size() || args.get(index + 1).startsWith("-d")) {
-            usageError("main.requires_argument", args.get(index));
+            String text = messager.getText("main.requires_argument", args.get(index));
+            throw new OptionException(CMDERR, this::usage, text);
         }
     }
 
-    @Override
-    void usageError(String key, Object... args) {
-        error(key, args);
-        usage(true);
-    }
-
     void error(String key, Object... args) {
-        messager.error(key, args);
+        messager.printErrorUsingKey(key, args);
     }
 
     void warn(String key, Object... args)  {
-        messager.warning(key, args);
+        messager.printWarningUsingKey(key, args);
     }
 
     /**
@@ -654,7 +868,7 @@
      * else return null and if locale option is not used
      * then return default locale.
      */
-    private Locale getLocale(String localeName) {
+    private Locale getLocale(String localeName) throws ToolException {
         Locale userlocale = null;
         if (localeName == null || localeName.isEmpty()) {
             return Locale.getDefault();
@@ -670,8 +884,8 @@
             if (seconduscore > 0) {
                 if (seconduscore != firstuscore + 3
                         || localeName.length() <= seconduscore + 1) {
-                    usageError("main.malformed_locale_name", localeName);
-                    return null;
+                    String text = messager.getText("main.malformed_locale_name", localeName);
+                    throw new ToolException(CMDERR, text);
                 }
                 country = localeName.substring(firstuscore + 1,
                         seconduscore);
@@ -679,19 +893,19 @@
             } else if (localeName.length() == firstuscore + 3) {
                 country = localeName.substring(firstuscore + 1);
             } else {
-                usageError("main.malformed_locale_name", localeName);
-                return null;
+                String text = messager.getText("main.malformed_locale_name", localeName);
+                throw new ToolException(CMDERR, text);
             }
         } else if (firstuscore == -1 && localeName.length() == 2) {
             language = localeName;
         } else {
-            usageError("main.malformed_locale_name", localeName);
-            return null;
+            String text = messager.getText("main.malformed_locale_name", localeName);
+            throw new ToolException(CMDERR, text);
         }
         userlocale = searchLocale(language, country, variant);
         if (userlocale == null) {
-            usageError("main.illegal_locale_name", localeName);
-            return null;
+            String text = messager.getText("main.illegal_locale_name", localeName);
+            throw new ToolException(CMDERR, text);
         } else {
             return userlocale;
         }
@@ -727,4 +941,9 @@
             }
         };
     }
+
+    @Override
+    String getLocalizedMessage(String msg, Object... args) {
+        return messager.getText(msg, args);
+    }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java	Tue Oct 18 17:14:09 2016 +0000
@@ -87,7 +87,7 @@
         return instance;
     }
 
-    private final Messager messager;
+    final Messager messager;
 
     /** Predefined symbols known to the compiler. */
     public final Symtab syms;
@@ -204,182 +204,8 @@
         return path != null;
     }
 
-    //---------------- print forwarders ----------------//
-
-    // ERRORS
     /**
-     * Print error message, increment error count.
-     *
-     * @param msg message to print.
-     */
-    public void printError(String msg) {
-        messager.printError(msg);
-    }
-
-//    /**
-//     * Print error message, increment error count.
-//     *
-//     * @param key selects message from resource
-//     */
-//    public void error(Element element, String key) {
-//        if (element == null)
-//            messager.error(key);
-//        else
-//            messager.error(element, key);
-//    }
-//
-//    public void error(String prefix, String key) {
-//        printError(prefix + ":" + messager.getText(key));
-//    }
-//
-//    /**
-//     * Print error message, increment error count.
-//     *
-//     * @param path the path to the source
-//     * @param key selects message from resource
-//     */
-//    public void error(DocTreePath path, String key) {
-//        messager.error(path, key);
-//    }
-//
-//    /**
-//     * Print error message, increment error count.
-//     *
-//     * @param path the path to the source
-//     * @param msg message to print.
-//     */
-//    public void printError(DocTreePath path, String msg) {
-//        messager.printError(path, msg);
-//    }
-//
-//    /**
-//     * Print error message, increment error count.
-//     * @param e the target element
-//     * @param msg message to print.
-//     */
-//    public void printError(Element e, String msg) {
-//        messager.printError(e, msg);
-//    }
-
-    /**
-     * Print error message, increment error count.
-     * @param key selects message from resource
-     * @param args replacement arguments
-     */
-    public void error(String key, String... args) {
-        error(null, key, args);
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param element the source element
-     * @param key selects message from resource
-     * @param args replacement arguments
-     */
-    public void error(Element element, String key, String... args) {
-        if (element == null)
-            messager.error(key, (Object[]) args);
-        else
-            messager.error(element, key, (Object[]) args);
-    }
-
-    // WARNINGS
-
-//    /**
-//     * Print warning message, increment warning count.
-//     *
-//     * @param msg message to print.
-//     */
-//    public void printWarning(String msg) {
-//        messager.printWarning(msg);
-//    }
-//
-//    public void warning(String key) {
-//        warning((Element)null, key);
-//    }
-
-    public void warning(String key, String... args) {
-        warning((Element)null, key, args);
-    }
-
-//    /**
-//     * Print warning message, increment warning count.
-//     *
-//     * @param element the source element
-//     * @param key selects message from resource
-//     */
-//    public void warning(Element element, String key) {
-//        if (element == null)
-//            messager.warning(key);
-//        else
-//            messager.warning(element, key);
-//    }
-//
-//    /**
-//     * Print warning message, increment warning count.
-//     *
-//     * @param path the path to the source
-//     * @param msg message to print.
-//     */
-//    public void printWarning(DocTreePath path, String msg) {
-//        messager.printWarning(path, msg);
-//    }
-//
-//    /**
-//     * Print warning message, increment warning count.
-//     *
-//     * @param e  the source element
-//     * @param msg message to print.
-//     */
-//    public void printWarning(Element e, String msg) {
-//        messager.printWarning(e, msg);
-//    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param e    the source element
-     * @param key  selects message from resource
-     * @param args the replace arguments
-     */
-    public void warning(Element e, String key, String... args) {
-        if (e == null)
-            messager.warning(key, (Object[]) args);
-        else
-            messager.warning(e, key, (Object[]) args);
-    }
-
-//    Note: no longer required
-//    /**
-//     * Print a message.
-//     *
-//     * @param msg message to print.
-//     */
-//    public void printNotice(String msg) {
-//        if (quiet) {
-//            return;
-//        }
-//        messager.printNotice(msg);
-//    }
-
-//  Note: no longer required
-//    /**
-//     * Print a message.
-//     *
-//     * @param e the source element
-//     * @param msg message to print.
-//     */
-//    public void printNotice(Element e, String msg) {
-//        if (quiet) {
-//            return;
-//        }
-//        messager.printNotice(e, msg);
-//    }
-
-    //  NOTICES
-    /**
-     * Print a message.
+     * Print a notice, iff <em>quiet</em> is not specified.
      *
      * @param key selects message from resource
      */
@@ -390,22 +216,8 @@
         messager.notice(key);
     }
 
-//    Note: not used anymore
-//    /**
-//     * Print a message.
-//     *
-//     * @param path the path to the source
-//     * @param msg message to print.
-//     */
-//    public void printNotice(DocTreePath path, String msg) {
-//        if (quiet) {
-//            return;
-//        }
-//        messager.printNotice(path, msg);
-//    }
-
     /**
-     * Print a message.
+     * Print a notice, iff <em>quiet</em> is not specified.
      *
      * @param key selects message from resource
      * @param a1 first argument
@@ -417,48 +229,6 @@
         messager.notice(key, a1);
     }
 
-//    Note: not used anymore
-//    /**
-//     * Print a message.
-//     *
-//     * @param key selects message from resource
-//     * @param a1 first argument
-//     * @param a2 second argument
-//     */
-//    public void notice(String key, String a1, String a2) {
-//        if (quiet) {
-//            return;
-//        }
-//        messager.notice(key, a1, a2);
-//    }
-//
-
-//    Note: not used anymore
-//    /**
-//     * Print a message.
-//     *
-//     * @param key selects message from resource
-//     * @param a1 first argument
-//     * @param a2 second argument
-//     * @param a3 third argument
-//     */
-//    public void notice(String key, String a1, String a2, String a3) {
-//        if (quiet) {
-//            return;
-//        }
-//        messager.notice(key, a1, a2, a3);
-//    }
-
-    /**
-     * Exit, reporting errors and warnings.
-     */
-    public void exit() {
-        // Messager should be replaced by a more general
-        // compilation environment.  This can probably
-        // subsume DocEnv as well.
-        throw new Messager.ExitJavadoc();
-    }
-
     TreePath getTreePath(JCCompilationUnit tree) {
         TreePath p = treePaths.get(tree);
         if (p == null)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolException.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,79 @@
+/*
+ * 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.javadoc.internal.tool;
+
+import jdk.javadoc.internal.tool.Main.Result;
+
+/**
+ * Provides a mechanism for the javadoc tool to terminate execution.
+ * This class is constructed with a result and an error message,
+ * that can be printed out before termination, a cause can also
+ * be wrapped to supply extended information about the exception.
+ *
+ * <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>
+ */
+
+class ToolException extends Exception {
+
+    private static final long serialVersionUID = 0;
+
+    final String message;
+
+    final Result result;
+
+    /**
+     * Constructs an object containing a result and a message to be
+     * printed out by the catcher.
+     * @param result the exit code
+     * @param message the detailed message
+     */
+    ToolException(Result result, String message) {
+        this.message = message;
+        this.result = result;
+        if (result == null || result.isOK() || message == null) {
+            throw new AssertionError("result == null || result.isOK() || message == null");
+        }
+    }
+
+    /**
+     * Constructs an object containing a result, a messages and an underlying cause.
+     * @param result the exit code
+     * @param message the detailed message
+     * @param cause the underlying cause
+     */
+    ToolException(Result result, String message, Throwable cause) {
+        super(cause);
+        this.message = message;
+        this.result = result;
+        if (result == null || message == null || cause == null || result.isOK()) {
+            throw new AssertionError("result == null || message == null"
+                    + " || cause == null || result.isOK()");
+        }
+    }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -35,9 +35,13 @@
 import javax.lang.model.element.ElementKind;
 
 import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.main.Option.OptionKind;
 import com.sun.tools.javac.main.OptionHelper;
 import com.sun.tools.javac.util.Options;
 
+import static com.sun.tools.javac.main.Option.OptionKind.*;
+import static jdk.javadoc.internal.tool.Main.Result.*;
+
 /**
  * javadoc tool options.
  *
@@ -50,197 +54,169 @@
 
     // ----- options for underlying compiler -----
 
-    BOOTCLASSPATH("-bootclasspath", true) {
+    BOOTCLASSPATH("-bootclasspath", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
         }
     },
 
-    CLASSPATH("-classpath", true) {
+    CLASS_PATH("--class-path -classpath -cp", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.CLASS_PATH, arg);
         }
     },
 
-    CP("-cp", true) {
-        @Override
-        public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.CLASS_PATH, arg);
-        }
-    },
-
-    CLASS_PATH("--class-path", true) {
-        @Override
-        public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.CLASS_PATH, arg);
-        }
-    },
-
-    EXTDIRS("-extdirs", true) {
+    EXTDIRS("-extdirs", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.EXTDIRS, arg);
         }
     },
 
-    SOURCEPATH("-sourcepath", true) {
+    SOURCE_PATH("--source-path -sourcepath", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
         }
     },
 
-    SOURCE_PATH("--source-path", true) {
-        @Override
-        public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
-        }
-    },
-
-    SYSCLASSPATH("-sysclasspath", true) {
+    SYSCLASSPATH("-sysclasspath", HIDDEN, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
         }
     },
 
-    MODULE_SOURCE_PATH("--module-source-path", true) {
+    MODULE_SOURCE_PATH("--module-source-path", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
         }
     },
 
-    UPGRADE_MODULE_PATH("--upgrade-module-path", true) {
+    UPGRADE_MODULE_PATH("--upgrade-module-path", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
         }
     },
 
-    SYSTEM("--system", true) {
+    SYSTEM("--system", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.SYSTEM, arg);
         }
     },
 
-    MODULE_PATH("--module-path", true) {
-        @Override
-        public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.MODULE_PATH, arg);
-        }
-    },
-
-    P("-p", true) {
+    MODULE_PATH("--module-path -p", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.MODULE_PATH, arg);
         }
     },
 
-    ADD_MODULES("--add-modules", true) {
+    ADD_MODULES("--add-modules", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg);
+            Option.ADD_MODULES.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    LIMIT_MODULES("--limit-modules", true) {
+    LIMIT_MODULES("--limit-modules", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg);
+            Option.LIMIT_MODULES.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    MODULE("--module", true) {
+    MODULE("--module", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.addToList(this, ",", arg);
         }
     },
 
-    ENCODING("-encoding", true) {
+    ENCODING("-encoding", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.ENCODING, arg);
         }
     },
 
-    RELEASE("--release", true) {
+    RELEASE("--release", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.RELEASE.process(helper.getOptionHelper(), opt, arg);
+            Option.RELEASE.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    SOURCE("-source", true) {
+    SOURCE("-source", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.SOURCE.process(helper.getOptionHelper(), opt, arg);
+            Option.SOURCE.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    XMAXERRS("-Xmaxerrs", true) {
+    XMAXERRS("-Xmaxerrs", EXTENDED, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.XMAXERRS.process(helper.getOptionHelper(), opt, arg);
+            Option.XMAXERRS.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    XMAXWARNS("-Xmaxwarns", true) {
+    XMAXWARNS("-Xmaxwarns", EXTENDED, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.XMAXWARNS.process(helper.getOptionHelper(), opt, arg);
+            Option.XMAXWARNS.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    ADD_READS("--add-reads", true) {
+    ADD_READS("--add-reads", EXTENDED, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.ADD_READS.process(helper.getOptionHelper(), opt, arg);
+            Option.ADD_READS.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    ADD_EXPORTS("--add-exports", true) {
+    ADD_EXPORTS("--add-exports", EXTENDED, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.ADD_EXPORTS.process(helper.getOptionHelper(), opt, arg);
+            Option.ADD_EXPORTS.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    XMODULE("-Xmodule:", false) {
+    XMODULE("-Xmodule:", EXTENDED, false) {
         @Override
         public void process(Helper helper, String arg) {
             Option.XMODULE.process(helper.getOptionHelper(), arg);
         }
     },
 
-    PATCH_MODULE("--patch-module", true) {
+    PATCH_MODULE("--patch-module", EXTENDED, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.PATCH_MODULE.process(helper.getOptionHelper(), opt, arg);
+            Option.PATCH_MODULE.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
     // ----- doclet options -----
 
-    DOCLET("-doclet", true), // handled in setDocletInvoker
+    DOCLET("-doclet", STANDARD, true), // handled in setDocletInvoker
 
-    DOCLETPATH("-docletpath", true), // handled in setDocletInvoker
+    DOCLETPATH("-docletpath", STANDARD, true), // handled in setDocletInvoker
 
     // ----- selection options -----
 
-    SUBPACKAGES("-subpackages", true) {
+    SUBPACKAGES("-subpackages", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.addToList(this, ":", arg);
         }
     },
 
-    EXCLUDE("-exclude", true) {
+    EXCLUDE("-exclude", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.addToList(this, ":", arg);
@@ -249,72 +225,72 @@
 
     // ----- filtering options -----
 
-    PACKAGE("-package") {
+    PACKAGE("-package", STANDARD) {
         @Override
-        public void process(Helper helper) {
+        public void process(Helper helper) throws OptionException {
             helper.setSimpleFilter("package");
         }
     },
 
-    PRIVATE("-private") {
+    PRIVATE("-private", STANDARD) {
         @Override
-        public void process(Helper helper) {
+        public void process(Helper helper) throws OptionException {
             helper.setSimpleFilter("private");
         }
     },
 
-    PROTECTED("-protected") {
+    PROTECTED("-protected", STANDARD) {
         @Override
-        public void process(Helper helper) {
+        public void process(Helper helper) throws OptionException {
             helper.setSimpleFilter("protected");
         }
     },
 
-    PUBLIC("-public") {
+    PUBLIC("-public", STANDARD) {
         @Override
-        public void process(Helper helper) {
+        public void process(Helper helper) throws OptionException {
             helper.setSimpleFilter("public");
         }
     },
 
-    SHOW_MEMBERS("--show-members:") {
+    SHOW_MEMBERS("--show-members", STANDARD, true) {
         @Override
-        public void process(Helper helper, String arg) {
+        public void process(Helper helper, String arg) throws OptionException {
             helper.setFilter(this, arg);
         }
     },
 
-    SHOW_TYPES("--show-types:") {
+    SHOW_TYPES("--show-types", STANDARD, true) {
         @Override
-        public void process(Helper helper, String arg) {
+        public void process(Helper helper, String arg) throws OptionException {
             helper.setFilter(this, arg);
         }
     },
 
-    SHOW_PACKAGES("--show-packages:") {
+    SHOW_PACKAGES("--show-packages", STANDARD, true) {
         @Override
-        public void process(Helper helper, String arg) {
-            helper.setShowPackageAccess(SHOW_PACKAGES, helper.getOptionArgumentValue(arg));
+        public void process(Helper helper, String arg) throws OptionException {
+            helper.setShowPackageAccess(SHOW_PACKAGES, arg);
         }
     },
 
-    SHOW_MODULE_CONTENTS("--show-module-contents:") {
+    SHOW_MODULE_CONTENTS("--show-module-contents", STANDARD, true) {
         @Override
-        public void process(Helper helper, String arg) {
-            helper.setShowModuleContents(SHOW_MODULE_CONTENTS, helper.getOptionArgumentValue(arg));
+        public void process(Helper helper, String arg) throws OptionException {
+            helper.setShowModuleContents(SHOW_MODULE_CONTENTS, arg);
         }
     },
 
-    EXPAND_REQUIRES("--expand-requires:") {
+    EXPAND_REQUIRES("--expand-requires", STANDARD, true) {
         @Override
-        public void process(Helper helper, String arg) {
-            helper.setExpandRequires(EXPAND_REQUIRES, helper.getOptionArgumentValue(arg));
+        public void process(Helper helper, String arg) throws OptionException {
+            helper.setExpandRequires(EXPAND_REQUIRES, arg);
         }
     },
 
     // ----- output control options -----
 
-    PROMPT("-prompt") {
+    PROMPT("-prompt", HIDDEN) {
         @Override
         public void process(Helper helper) {
             helper.compOpts.put("-prompt", "-prompt");
@@ -322,21 +298,21 @@
         }
     },
 
-    QUIET("-quiet") {
+    QUIET("-quiet", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.jdtoolOpts.put(QUIET, true);
         }
     },
 
-    VERBOSE("-verbose") {
+    VERBOSE("-verbose", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.compOpts.put("-verbose", "");
         }
     },
 
-    XWERROR("-Xwerror") {
+    XWERROR("-Xwerror", HIDDEN) {
         @Override
         public void process(Helper helper) {
             helper.rejectWarnings = true;
@@ -346,72 +322,127 @@
 
     // ----- other options -----
 
-    BREAKITERATOR("-breakiterator") {
+    BREAKITERATOR("-breakiterator", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.breakiterator = true;
         }
     },
 
-    LOCALE("-locale", true) {
+    LOCALE("-locale", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.docLocale = arg;
         }
     },
 
-    XCLASSES("-Xclasses") {
+    XCLASSES("-Xclasses", HIDDEN) {
         @Override
         public void process(Helper helper) {
             helper.jdtoolOpts.put(XCLASSES, true);
         }
     },
 
+    DUMPONERROR("--dump-on-error", HIDDEN) {
+        @Override
+        public void process(Helper helper) {
+            helper.dumpOnError = true;
+        }
+    },
+
     // ----- help options -----
 
-    HELP("-help") {
+    HELP("--help -help", STANDARD) {
         @Override
-        public void process(Helper helper) {
-            helper.usage();
+        public void process(Helper helper) throws OptionException {
+            throw new OptionException(OK, helper::usage);
         }
     },
 
-    X("-X") {
+    X("-X", STANDARD) {
+        @Override
+        public void process(Helper helper) throws OptionException {
+           throw new OptionException(OK, helper::Xusage);
+        }
+    },
+
+    // This option exists only for the purpose of documenting itself.
+    // It's actually implemented by the launcher.
+    J("-J", STANDARD, true) {
         @Override
         public void process(Helper helper) {
-            helper.Xusage();
+            throw new AssertionError("the -J flag should be caught by the launcher.");
+        }
+    },
+
+    // This option exists only for the purpose of documenting itself.
+    // It's actually implemented ahead of the normal option decoding loop.
+    Xold("-Xold", EXTENDED) {
+        @Override
+        public void process(Helper helper) {
+            throw new AssertionError("the -Xold flag should be handled earlier.");
         }
     };
 
-    public final String opt;
+    public final String primaryName;
+    public final List<String> names;
+    public final OptionKind kind;
     public final boolean hasArg;
     public final boolean hasSuffix; // ex: foo:bar or -foo=bar
 
-    ToolOption(String opt) {
-        this(opt, false);
+    ToolOption(String opt, OptionKind kind) {
+        this(opt, kind, false);
     }
 
-    ToolOption(String opt, boolean hasArg) {
-        this.opt = opt;
+    ToolOption(String names, OptionKind kind, boolean hasArg) {
+        this.names = Arrays.asList(names.split("\\s+"));
+        this.primaryName = this.names.get(0);
+        this.kind = kind;
         this.hasArg = hasArg;
-        char lastChar = opt.charAt(opt.length() - 1);
+        char lastChar = names.charAt(names.length() - 1);
         this.hasSuffix = lastChar == ':' || lastChar == '=';
     }
 
-    void process(Helper helper, String arg) { }
+    void process(Helper helper, String arg) throws OptionException { }
+
+    void process(Helper helper) throws OptionException { }
+
+    List<String> getNames() {
+        return names;
+    }
+
+    String getParameters(Messager messager) {
+        return (hasArg || primaryName.endsWith(":"))
+                ? messager.getText(getKey(primaryName, ".arg"))
+                : null;
+    }
 
-    void process(Helper helper) { }
+    String getDescription(Messager messager) {
+        return messager.getText(getKey(primaryName, ".desc"));
+    }
+
+    private String getKey(String optionName, String suffix) {
+        return "main.opt."
+                + optionName
+                .replaceAll("^-*", "")              // remove leading '-'
+                .replaceAll("[^A-Za-z0-9]+$", "")   // remove trailing non-alphanumeric
+                .replaceAll("[^A-Za-z0-9]", ".")    // replace internal non-alphanumeric
+                + suffix;
+    }
+
 
     static ToolOption get(String name) {
         String oname = name;
         if (name.contains(":")) {
             oname = name.substring(0, name.indexOf(':') + 1);
         } else if (name.contains("=")) {
-            oname = name.substring(0, name.indexOf('=') + 1);
+            oname = name.substring(0, name.indexOf('='));
         }
         for (ToolOption o : values()) {
-            if (oname.equals(o.opt)) {
-                return o;
+            for (String n : o.names) {
+                if (oname.equals(n)) {
+                    return o;
+                }
             }
         }
         return null;
@@ -428,6 +459,9 @@
         /** Javadoc tool options */
         final Map<ToolOption, Object> jdtoolOpts = new EnumMap<>(ToolOption.class);
 
+        /** dump stack traces for debugging etc.*/
+        boolean dumpOnError = false;
+
         /** Set by -breakiterator. */
         boolean breakiterator = false;
 
@@ -447,7 +481,8 @@
         abstract void usage();
         abstract void Xusage();
 
-        abstract void usageError(String msg, Object... args);
+        abstract String getLocalizedMessage(String msg, Object... args);
+
         abstract OptionHelper getOptionHelper();
 
         @SuppressWarnings("unchecked")
@@ -457,12 +492,7 @@
             jdtoolOpts.put(opt, list);
         }
 
-        String getOptionArgumentValue(String in) {
-            String[] values = in.trim().split(":");
-            return values[1];
-        }
-
-        void setExpandRequires(ToolOption opt, String arg) {
+        void setExpandRequires(ToolOption opt, String arg) throws OptionException {
             switch (arg) {
                 case "public":
                     jdtoolOpts.put(opt, AccessKind.PUBLIC);
@@ -471,11 +501,12 @@
                     jdtoolOpts.put(opt, AccessKind.PRIVATE);
                     break;
                 default:
-                    usageError("main.illegal_option_value", arg);
+                    String text = getLocalizedMessage("main.illegal_option_value", arg);
+                    throw new IllegalOptionValue(this::usage, text);
             }
         }
 
-        void setShowModuleContents(ToolOption opt, String arg) {
+        void setShowModuleContents(ToolOption opt, String arg) throws OptionException {
             switch (arg) {
                 case "api":
                     jdtoolOpts.put(opt, AccessKind.PUBLIC);
@@ -484,11 +515,12 @@
                     jdtoolOpts.put(opt, AccessKind.PRIVATE);
                     break;
                 default:
-                    usageError("main.illegal_option_value", arg);
+                    String text = getLocalizedMessage("main.illegal_option_value", arg);
+                    throw new IllegalOptionValue(this::usage, text);
             }
         }
 
-        void setShowPackageAccess(ToolOption opt, String arg) {
+        void setShowPackageAccess(ToolOption opt, String arg) throws OptionException {
             switch (arg) {
                 case "exported":
                     jdtoolOpts.put(opt, AccessKind.PUBLIC);
@@ -497,16 +529,17 @@
                     jdtoolOpts.put(opt, AccessKind.PRIVATE);
                     break;
                 default:
-                    usageError("main.illegal_option_value", arg);
+                    String text = getLocalizedMessage("main.illegal_option_value", arg);
+                    throw new IllegalOptionValue(this::usage, text);
             }
         }
 
 
-        void setFilter(ToolOption opt, String arg) {
+        void setFilter(ToolOption opt, String arg) throws OptionException {
             jdtoolOpts.put(opt, getAccessValue(arg));
         }
 
-        void setSimpleFilter(String arg) {
+        void setSimpleFilter(String arg) throws OptionException {
             handleSimpleOption(arg);
         }
 
@@ -514,7 +547,7 @@
             fileManagerOpts.put(opt, arg);
         }
 
-        void handleSimpleOption(String arg) {
+        void handleSimpleOption(String arg) throws OptionException {
             populateSimpleAccessMap(getAccessValue(arg));
         }
 
@@ -523,7 +556,7 @@
          * -private, so on, in addition to the new ones such as
          * --show-types:public and so on.
          */
-        private AccessKind getAccessValue(String arg) {
+        private AccessKind getAccessValue(String arg) throws OptionException {
             int colon = arg.indexOf(':');
             String value = (colon > 0)
                     ? arg.substring(colon + 1)
@@ -538,8 +571,8 @@
                 case "private":
                     return AccessKind.PRIVATE;
                 default:
-                    usageError("main.illegal_option_value", value);
-                    return null;
+                    String text = getLocalizedMessage("main.illegal_option_value", value);
+                    throw new IllegalOptionValue(this::usage, text);
             }
         }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Tue Oct 18 17:14:09 2016 +0000
@@ -28,112 +28,234 @@
 main.warnings={0} warnings
 main.warning={0} warning
 
-main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\
-\  -overview <file>                 Read overview documentation from HTML file\n\
-\  -public                          Show only public classes and members\n\
-\  -protected                       Show protected/public classes and \n\
-\                                   members (default)\n\
-\  -package                         Show package/protected/public classes\n\
-\                                   and members\n\
-\  -private                         Show all classes and members\n\
-\  --show-members:value             Specifies which members (fields, methods\n\
-\                                   etc.) will be documented, where value can\n\
-\                                   be one of "public", "protected", "package"\n\
-\                                   or "private".\n\
-\                                   Default is protected, will show public and\n\
-\                                   protected members, "public" will show only\n\
-\                                   public members, "package" will show public,\n\
-\                                   protected and package members and \n\
-\                                   "private" will show all  members\n\
-\  --show-types:value               Specifies which types (classes, interfaces\n\
-\                                   etc.) will be documented, where value can be\n\
-\                                   one of "public", "protected", "package" or\n\
-\                                   "private".\n\
-\                                   Default is "protected", show public and\n\
-\                                   protected types, "package" will show public,\n\
-\                                   protected and package types and "private"\n\
-\                                   will show all types\n\
-\  --show-packages:value            Specifies which module's packages will be\n\
-\                                   documented. Possible values are "exported"\n\
-\                                   or "all" packages\n\
-\  --show-module-contents:value     Specifies the documentation granularity of\n\
-\                                   module declarations.\n\
-\                                   Possible values are "api" or "all".\n\
-\  --expand-requires:value          Instructs the tool to expand the "requires"\n\
-\                                   module dependencies "public" expands all the\n\
-\                                   "requires public" edges of the module graph.\n\
-\                                   "all" expands all the "requires" edges of\n\
-\                                   the module graph by default only the\n\
-\                                   specified modules will be considered.\n\
-\  -help                            Display command line options and exit\n\
-\  --module m1, m2..                Document the specified module(s)\n\
-\  -doclet <class>                  Generate output via alternate doclet\n\
-\  -docletpath <path>               Specify where to find doclet class files\n\
-\  --module-source-path <path>      Specify where to find input source files\n\
-\                                   for multiple modules\n\
-\  --upgrade-module-path <path>     Override location of upgradeable modules\n\
-\  --module-path <path>, -p <path>  Specify where to find application modules\n\
-\  --add-modules <module>(,<module>)*\n\
-\                                   Root modules to resolve in addition to the\n\
-\                                   initial modules,\n\
-\                                   or all modules on the module path if\n\
-\                                   <module> is ALL-MODULE-PATH.\n\
-\  --limit-modules <module>(,<module>)*\n\
-\                                   Limit the universe of observable modules\n\
-\  --source-path <path>             Specify where to find source files\n\
-\  -sourcepath <path>               Specify where to find source files\n\
-\  --class-path <path>              Specify where to find user class files\n\
-\  -classpath <path>                Specify where to find user class files\n\
-\  -cp <path>                       Specify where to find user class files\n\
-\  -exclude <pkglist>               Specify a list of packages to exclude\n\
-\  -subpackages <subpkglist>        Specify subpackages to recursively load\n\
-\  -breakiterator                   Compute first sentence with BreakIterator\n\
-\  -bootclasspath <path>            Override location of platform class files\n\
-\                                   used for non-modular releases\n\
-\  --system <jdk>                   Override location of system modules used\n\
-\                                   for modular releases.\n\
-\  --release <release>              Provide source compatibility with\n\
-\                                   specified release\n\
-\  -source <release>                Provide source compatibility with\n\
-\                                   specified release\n\
-\  -extdirs <dirlist>               Override location of installed extensions\n\
-\  -verbose                         Output messages about what Javadoc is doing\n\
-\  -locale <name>                   Locale to be used, e.g. en_US or en_US_WIN\n\
-\  -encoding <name>                 Source file encoding name\n\
-\  -quiet                           Do not display status messages\n\
-\  -J<flag>                         Pass <flag> directly to the runtime system\n\
-\  -X                               Print a synopsis of nonstandard\n\
-\                                   options and exit\n
+main.usage=Usage:\n\
+\    javadoc [options] [packagenames] [sourcefiles] [@files]\n\
+where options include:
+
+main.opt.public.desc=\
+    Show only public classes and members
+
+main.opt.protected.desc=\
+    Show protected/public classes and members (default)
+
+main.opt.package.desc=\
+    Show package/protected/public classes and members
+
+main.opt.private.desc=\
+    Show all classes and members
+
+main.opt.show.members.arg=\
+    <value>
+main.opt.show.members.desc=\
+    Specifies which members (fields, methods, etc.) will be\n\
+    documented, where value can be one of "public", "protected",\n\
+    "package" or "private". The default is "protected", which will\n\
+    show public and protected members, "public" will show only\n\
+    public members, "package" will show public, protected and\n\
+    package members and "private" will show all members.
+
+main.opt.show.types.arg=\
+    <value>
+main.opt.show.types.desc=\
+    Specifies which types (classes, interfaces, etc.) will be\n\
+    documented, where value can be one of "public", "protected",\n\
+    "package" or "private". The default is "protected", which will\n\
+    show public and protected types, "public" will show only\n\
+    public types, "package" will show public, protected and\n\
+    package types and "private" will show all types.
+
+main.opt.show.packages.arg=\
+    <value>
+main.opt.show.packages.desc=\
+    Specifies which module's packages will be documented. Possible\n\
+    values are "exported" or "all" packages.
+
+main.opt.show.module.contents.arg=\
+    <value>
+main.opt.show.module.contents.desc=\
+    Specifies the documentation granularity of module\n\
+    declarations. Possible values are "api" or "all".
+
+main.opt.expand.requires.arg=\
+    <value>
+main.opt.expand.requires.desc=\
+    Instructs the tool to expand the set of modules to be\n\
+    documented. By default, only the modules given explicitly on\n\
+    the command line will be documented. A value of "public" will\n\
+    additionally include all "requires public" dependencies of\n\
+    those modules. A value of "all" will include all dependencies\n\
+    of those modules.
+
+main.opt.help.desc=\
+    Display command line options and exit
+
+main.opt.module.arg=\
+    <module>(,<module>)*
+main.opt.module.desc=\
+    Document the specified module(s)
+
+main.opt.doclet.arg=\
+    <class>
+main.opt.doclet.desc=\
+    Generate output via alternate doclet
+
+main.opt.docletpath.arg=\
+    <path>
+main.opt.docletpath.desc=\
+    Specify where to find doclet class files
+
+main.opt.module.source.path.arg=\
+    <path>
+main.opt.module.source.path.desc=\
+    Specify where to find input source files for multiple modules
+
+main.opt.upgrade.module.path.arg=\
+    <path>
+main.opt.upgrade.module.path.desc=\
+    Override location of upgradeable modules
+
+main.opt.module.path.arg=\
+    <path>
+main.opt.module.path.desc=\
+    Specify where to find application modules
+
+main.opt.add.modules.arg=\
+    <module>(,<module>)*
+main.opt.add.modules.desc=\
+    Root modules to resolve in addition to the initial modules,\n\
+    or all modules on the module path if <module> is\n\
+    ALL-MODULE-PATH.
+
+main.opt.limit.modules.arg=\
+    <module>(,<module>)*
+main.opt.limit.modules.desc=\
+    Limit the universe of observable modules
+
+main.opt.source.path.arg=\
+    <path>
+main.opt.source.path.desc=\
+    Specify where to find source files
+
+main.opt.class.path.arg=\
+    <path>
+main.opt.class.path.desc=\
+    Specify where to find user class files
+
+main.opt.exclude.arg=\
+    <pkglist>
+main.opt.exclude.desc=\
+    Specify a list of packages to exclude
+
+main.opt.subpackages.arg=\
+    <subpkglist>
+main.opt.subpackages.desc=\
+    Specify subpackages to recursively load
+
+main.opt.breakiterator.desc=\
+    Compute first sentence with BreakIterator
+
+main.opt.bootclasspath.arg=\
+    <path>
+main.opt.bootclasspath.desc=\
+    Override location of platform class files used for non-modular\n\
+    releases
+
+main.opt.system.arg=\
+    <jdk>
+main.opt.system.desc=\
+    Override location of system modules used for modular releases
+
+main.opt.release.arg=\
+    <release>
+main.opt.release.desc=\
+    Provide source compatibility with specified release
+
+main.opt.source.arg=\
+    <release>
+main.opt.source.desc=\
+    Provide source compatibility with specified release
+
+main.opt.extdirs.arg=\
+    <dirlist>
+main.opt.extdirs.desc=\
+    Override location of installed extensions
+
+main.opt.verbose.desc=\
+    Output messages about what Javadoc is doing
+
+main.opt.locale.arg=\
+    <name>
+main.opt.locale.desc=\
+    Locale to be used, e.g. en_US or en_US_WIN
+
+main.opt.encoding.arg=\
+    <name>
+main.opt.encoding.desc=\
+    Source file encoding name
+
+main.opt.quiet.desc=\
+    Do not display status messages
+
+main.opt.J.arg=\
+    <flag>
+main.opt.J.desc=\
+    Pass <flag> directly to the runtime system
+
+main.opt.X.desc=\
+    Print a synopsis of nonstandard options and exit
 
 main.usage.foot=\n\
 GNU-style options may use '=' instead of whitespace to separate the name of an\n\
 option from its value.\n
 
-main.Xusage=\
-\  -Xmaxerrs <number>               Set the maximum number of errors to print\n\
-\  -Xmaxwarns <number>              Set the maximum number of warnings to print\n\
-\  --add-exports <module>/<package>=<other-module>(,<other-module>)*\n\
-\                                   Specify a package to be considered as exported\n\
-\                                   from its defining module to additional modules,\n\
-\                                   or to all unnamed modules if <other-module> is\n\
-\                                   ALL-UNNAMED.\n\
-\  --add-reads <module>=<other-module>(,<other-module>)*\n\
-\                                   Specify additional modules to be considered as\n\
-\                                   required by a given module. <other-module> may be\n\
-\                                   ALL-UNNAMED to require the unnamed module.\n\
-\  -Xmodule:<module-name>           Specify a module to which the classes being\n\
-\                                   compiled belong.\n\
-\  --patch-module <module>=<file>(:<file>)*\n\
-\                                   Override or augment a module with classes\n\
-\                                   and resources in JAR files or directories\n\
-\  -Xold                            Invoke the legacy javadoc tool\n
+main.Xusage=
+
+main.opt.Xmaxerrs.arg=\
+    <number>
+main.opt.Xmaxerrs.desc=\
+    Set the maximum number of errors to print
+
+main.opt.Xmaxwarns.arg=\
+    <number>
+main.opt.Xmaxwarns.desc=\
+    Set the maximum number of warnings to print
+
+main.opt.add.exports.arg=\
+    <module>/<package>=<other-module>(,<other-module>)*
+main.opt.add.exports.desc=\
+    Specify a package to be considered as exported from its\n\
+    defining module to additional modules, or to all unnamed\n\
+    modules if <other-module> is ALL-UNNAMED
 
-main.Xusage.foot=\
+main.opt.add.reads.arg=\
+    <module>=<other-module>(,<other-module>)*
+main.opt.add.reads.desc=\
+    Specify additional modules to be considered as required by a\n\
+    given module. <other-module> may be ALL-UNNAMED to require\n\
+    the unnamed module.
+
+main.opt.Xmodule.arg=\
+    <module-name>
+main.opt.Xmodule.desc=\
+    Specify a module to which the classes being compiled belong
+
+main.opt.patch.module.arg=\
+    <module>=<file>(:<file>)*
+main.opt.patch.module.desc=\
+    Override or augment a module with classes and resources in\n\
+    JAR files or directories
+
+main.opt.Xold.desc=\
+    Invoke the legacy javadoc tool
+
+main.Xusage.foot=\n\
 These options are non-standard and subject to change without notice.
 
-main.doclet.usage.header=Provided by the {0} doclet:
+main.doclet.usage.header=\nProvided by the {0} doclet:
 
 main.requires_argument=option {0} requires an argument.
+main.unnecessary_arg_provided=option {0} does not require an argument
+main.only_one_argument_with_equals=cannot use ''='' syntax for options that require multiple arguments
 main.invalid_flag=invalid flag: {0}
 main.No_modules_packages_or_classes_specified=No modules, packages or classes specified.
 main.module_not_found=module {0} not found.\n
@@ -143,13 +265,13 @@
 main.Building_tree=Constructing Javadoc information...
 main.no_source_files_for_package=No source files for package {0}
 main.package_not_found=Package {0} not found
-main.fatal.error=fatal error
-main.fatal.exception=fatal exception
+main.fatal.error=fatal error encountered: {0}
 main.out.of.memory=java.lang.OutOfMemoryError: Please increase memory.\n\
 For example, on the JDK Classic or HotSpot VMs, add the option -J-Xmx\n\
 such as -J-Xmx32m.
 main.done_in=[done in {0} ms]
 main.more_than_one_doclet_specified_0_and_1=More than one doclet specified ({0} and {1}).
+main.doclet_could_not_get_location=Could not get location for {0}
 main.doclet_could_not_set_location=Could not set location for {0}
 main.doclet_no_classloader_found=Could not obtain classloader to load {0}
 main.could_not_instantiate_class=Could not instantiate class {0}
@@ -164,7 +286,15 @@
 main.release.bootclasspath.conflict=option {0} cannot be used together with -release
 main.unsupported.release.version=release version {0} not supported
 main.release.not.standard.file.manager=-release option specified, but the provided JavaFileManager is not a StandardJavaFileManager.
+main.file.manager.list=FileManager error listing files: "{0}"
+main.assertion.error=assertion failed: "{0}}"
 main.unknown.error=an unknown error has occurred
+main.internal.error=an internal error has occurred
+main.unexpected.exception=an unexpected exception was caught: {0}
+doclet.internal.report.bug=\
+Please file a bug against the javadoc tool via the Java bug reporting page\n\
+(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)\n\
+for duplicates. Include error messages and the following diagnostic in your report. Thank you.
 main.legacy_api=The old Doclet and Taglet APIs in the packages\n\
     com.sun.javadoc, com.sun.tools.doclets and their implementations\n\
     are planned to be removed in a future JDK release. These\n\
--- a/langtools/src/jdk.javadoc/share/classes/module-info.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -41,6 +41,9 @@
     exports jdk.javadoc.doclet.taglet;
     exports jdk.javadoc.doclets;
 
+    provides java.util.spi.ToolProvider
+        with jdk.javadoc.internal.tool.JavadocToolProvider;
+
     provides javax.tools.DocumentationTool
         with jdk.javadoc.internal.api.JavadocTool;
 }
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/Main.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/Main.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.tools.javap;
 
 import java.io.PrintWriter;
+import java.util.spi.ToolProvider;
 
 /**
  *  Main entry point.
@@ -58,4 +59,14 @@
         t.setLog(out);
         return t.run(args);
     }
+
+    public static class JavapToolProvider implements ToolProvider {
+        public String name() {
+            return "javap";
+        }
+
+        public int run(PrintWriter out, PrintWriter err, String... args) {
+            return Main.run(args, out);
+        }
+    }
 }
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java	Tue Oct 18 17:14:09 2016 +0000
@@ -89,8 +89,6 @@
  *  - multi-version jar
  */
 public class Main implements DiagnosticListener<JavaFileObject> {
-    public static Main instance;
-
     final PrintStream out;
     final PrintStream err;
     final List<File> bootClassPath = new ArrayList<>();
@@ -415,13 +413,6 @@
     }
 
     /**
-     * Prints a usage message to the err stream.
-     */
-    void usage() {
-
-    }
-
-    /**
      * An enum denoting the mode in which the tool is running.
      * Different modes correspond to the different process* methods.
      * The exception is UNKNOWN, which indicates that a mode wasn't
@@ -504,7 +495,6 @@
                     args.remove();
                     switch (a) {
                         case "--class-path":
-                        case "-cp":
                             classPath.clear();
                             Arrays.stream(args.remove().split(File.pathSeparator))
                                   .map(File::new)
@@ -699,12 +689,7 @@
      * @return true on success, false otherwise
      */
     public static boolean call(PrintStream out, PrintStream err, String... args) {
-        try {
-            instance = new Main(out, err);
-            return instance.run(args);
-        } finally {
-            instance = null;
-        }
+        return new Main(out, err).run(args);
     }
 
     /**
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md	Tue Oct 18 17:14:09 2016 +0000
@@ -39,7 +39,6 @@
 
 **OPTIONS**
 
-        -cp PATH
         --class-path PATH
 
             Sets the classpath to PATH.
@@ -103,7 +102,7 @@
 
         java.lang.Thread$State
 
-The `--class-path` and `-cp` options specify the classpath used for
+The `--class-path` option specifies the classpath used for
 class searching. The classpath is used for classes named on the
 command line, as well as for dependencies of the classes in jar file
 or directory hierarchy to be scanned.
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties	Tue Oct 18 17:14:09 2016 +0000
@@ -2,7 +2,7 @@
 Usage: jdeprscan [options] '{dir|jar|class}' ...\n\
 \n\
 options:\n\
-\  -cp  --class-path PATH\n\
+\       --class-path PATH\n\
 \       --for-removal\n\
 \       --full-version\n\
 \  -h   --help\n\
@@ -20,7 +20,7 @@
 \n\
 \    java.lang.Thread$State\n\
 \n\
-The --class-path (-cp) option provides a search path for resolution\n\
+The --class-path option provides a search path for resolution\n\
 of dependent classes.\n\
 \n\
 The --for-removal option limits scanning or listing to APIs that are\n\
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -63,7 +63,7 @@
      * Returns a ClassFileReader instance of a given path.
      */
     public static ClassFileReader newInstance(Path path) throws IOException {
-        return newInstance(path, JarFile.baseVersion());
+        return newInstance(path, null);
     }
 
     /**
@@ -438,7 +438,10 @@
                     cf = reader.readClassFile(jf, nextEntry);
                     return true;
                 } catch (ClassFileError | IOException ex) {
-                    skippedEntries.add(nextEntry.getName());
+                    skippedEntries.add(String.format("%s: %s (%s)",
+                                                     ex.getMessage(),
+                                                     nextEntry.getName(),
+                                                     jf.getName()));
                 }
                 nextEntry = nextEntry();
             }
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Tue Oct 18 17:14:09 2016 +0000
@@ -150,7 +150,7 @@
                 task.options.help = true;
             }
         },
-        new Option(true, "-dotoutput") {
+        new Option(true, "-dotoutput", "--dot-output") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 Path p = Paths.get(arg);
                 if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) {
@@ -191,7 +191,7 @@
                 }
             }
         },
-        new Option(false, "-apionly") {
+        new Option(false, "-apionly", "--api-only") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.apiOnly = true;
             }
@@ -203,7 +203,7 @@
                 task.options.addmods.addAll(mods);
             }
         },
-        new Option(true, "--gen-module-info") {
+        new Option(true, "--generate-module-info") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 Path p = Paths.get(arg);
                 if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) {
@@ -212,7 +212,7 @@
                 task.options.genModuleInfo = Paths.get(arg);
             }
         },
-        new Option(false, "-jdkinternals") {
+        new Option(false, "-jdkinternals", "--jdk-internals") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.findJDKInternals = true;
                 task.options.verbose = CLASS;
@@ -263,19 +263,36 @@
                 task.options.addmods.add(arg);
             }
         },
+        new Option(true, "--multi-release") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                if (arg.equalsIgnoreCase("base")) {
+                    task.options.multiRelease = JarFile.baseVersion();
+                } else {
+                    try {
+                        int v = Integer.parseInt(arg);
+                        if (v < 9) {
+                            throw new BadArgs("err.invalid.arg.for.option", arg);
+                        }
+                    } catch (NumberFormatException x) {
+                        throw new BadArgs("err.invalid.arg.for.option", arg);
+                    }
+                    task.options.multiRelease = Runtime.Version.parse(arg);
+                }
+            }
+        },
 
         // ---- Target filtering options ----
-        new Option(true, "-p", "-package") {
+        new Option(true, "-p", "-package", "--package") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.packageNames.add(arg);
             }
         },
-        new Option(true, "-e", "-regex") {
+        new Option(true, "-e", "-regex", "--regex") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.regex = Pattern.compile(arg);
             }
         },
-        new Option(true, "-requires") {
+        new Option(true, "--require") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.requires.add(arg);
             }
@@ -336,7 +353,7 @@
             }
         },
 
-        new Option(false, "-I", "-inverse") {
+        new Option(false, "-I", "--inverse") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.inverse = true;
                 // equivalent to the inverse of compile-time view analysis
@@ -361,7 +378,7 @@
             }
         },
 
-        new Option(false, "-version") {
+        new Option(false, "-version", "--version") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.version = true;
             }
@@ -390,23 +407,6 @@
                 }
             }
         },
-        new Option(true, "--multi-release") {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                if (arg.equalsIgnoreCase("base")) {
-                    task.options.multiRelease = JarFile.baseVersion();
-                } else {
-                    try {
-                        int v = Integer.parseInt(arg);
-                        if (v < 9) {
-                            throw new BadArgs("err.invalid.arg.for.option", arg);
-                        }
-                    } catch (NumberFormatException x) {
-                        throw new BadArgs("err.invalid.arg.for.option", arg);
-                    }
-                    task.options.multiRelease = Runtime.Version.parse(arg);
-                }
-            }
-        },
     };
 
     private static final String PROGNAME = "jdeps";
@@ -483,6 +483,7 @@
             }
             if (options.checkModuleDeps != null && !inputArgs.isEmpty()) {
                 reportError("err.invalid.module.option", inputArgs, "--check");
+                return EXIT_CMDERR;
             }
 
             boolean ok = run();
@@ -604,11 +605,12 @@
         boolean ok = analyzer.run(options.compileTimeView, options.depth);
 
         // print skipped entries, if any
-        analyzer.archives()
-            .forEach(archive -> archive.reader()
-                .skippedEntries().stream()
-                .forEach(name -> warning("warn.skipped.entry",
-                                         name, archive.getPathName())));
+        if (!options.nowarning) {
+            analyzer.archives()
+                .forEach(archive -> archive.reader()
+                    .skippedEntries().stream()
+                    .forEach(name -> warning("warn.skipped.entry", name)));
+        }
 
         if (options.findJDKInternals && !options.nowarning) {
             Map<String, String> jdkInternals = new TreeMap<>();
@@ -676,17 +678,29 @@
     }
 
     private boolean genModuleInfo(JdepsConfiguration config) throws IOException {
+        // check if any JAR file contains unnamed package
+        for (String arg : inputArgs) {
+            Optional<String> classInUnnamedPackage =
+                ClassFileReader.newInstance(Paths.get(arg))
+                    .entries().stream()
+                    .filter(n -> n.endsWith(".class"))
+                    .filter(cn -> toPackageName(cn).isEmpty())
+                    .findFirst();
+
+            if (classInUnnamedPackage.isPresent()) {
+                if (classInUnnamedPackage.get().equals("module-info.class")) {
+                    reportError("err.genmoduleinfo.not.jarfile", arg);
+                } else {
+                    reportError("err.genmoduleinfo.unnamed.package", arg);
+                }
+                return false;
+            }
+        }
+
         ModuleInfoBuilder builder
             = new ModuleInfoBuilder(config, inputArgs, options.genModuleInfo);
         boolean ok = builder.run();
 
-        builder.modules().forEach(module -> {
-            if (module.packages().contains("")) {
-                reportError("ERROR: %s contains unnamed package.  " +
-                    "module-info.java not generated%n", module.getPathName());
-            }
-        });
-
         if (!ok && !options.nowarning) {
             log.println("ERROR: missing dependencies");
             builder.visitMissingDeps(
@@ -703,6 +717,11 @@
         return ok;
     }
 
+    private String toPackageName(String name) {
+        int i = name.lastIndexOf('/');
+        return i > 0 ? name.replace('/', '.').substring(0, i) : "";
+    }
+
     /**
      * Returns a filter used during dependency analysis
      */
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Main.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Main.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.tools.jdeps;
 
 import java.io.*;
+import java.util.spi.ToolProvider;
 
 /**
  *
@@ -62,4 +63,14 @@
         t.setLog(out);
         return t.run(args);
     }
+
+    public static class JDepsToolProvider implements ToolProvider {
+        public String name() {
+            return "jdeps";
+        }
+
+        public int run(PrintWriter out, PrintWriter err, String... args) {
+            return Main.run(args, out);
+        }
+    }
 }
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Tue Oct 18 17:14:09 2016 +0000
@@ -13,172 +13,180 @@
 
 main.opt.h=\
 \  -h -? -help\n\
-\  --help                            Print this usage message
+\  --help                        Print this usage message
 
 main.opt.version=\
-\  -version                          Version information
+\  -version --version            Version information
 
 main.opt.v=\
-\  -v           -verbose             Print all class level dependencies\n\
-\                                    Equivalent to -verbose:class -filter:none.\n\
-\  -verbose:package                  Print package-level dependencies excluding\n\
-\                                    dependencies within the same package by default\n\
-\  -verbose:class                    Print class-level dependencies excluding\n\
-\                                    dependencies within the same package by default
+\  -v       -verbose             Print all class level dependences\n\
+\                                Equivalent to -verbose:class -filter:none.\n\
+\  -verbose:package              Print package-level dependences excluding\n\
+\                                dependences within the same package by default\n\
+\  -verbose:class                Print class-level dependences excluding\n\
+\                                dependences within the same package by default
 
 main.opt.s=\
-\  -s           -summary             Print dependency summary only.
+\  -s       -summary             Print dependency summary only.
 
 main.opt.f=\
-\  -f <regex>  -filter <regex>       Filter dependences matching the given\n\
-\                                    pattern. If given multiple times, the last\n\
-\                                    one will be used.\n\
-\  -filter:package                   Filter dependences within the same package.\n\
-\                                    This is the default.\n\
-\  -filter:archive                   Filter dependences within the same archive.\n\
-\  -filter:module                    Filter dependences within the same module.\n\
-\  -filter:none                      No -filter:package and -filter:archive\n\
-\                                    filtering.  Filtering specified via the\n\
-\                                    -filter option still applies.\n\
+\  -f <regex> -filter <regex>    Filter dependences matching the given\n\
+\                                pattern. If given multiple times, the last\n\
+\                                one will be used.\n\
+\  -filter:package               Filter dependences within the same package.\n\
+\                                This is the default.\n\
+\  -filter:archive               Filter dependences within the same archive.\n\
+\  -filter:module                Filter dependences within the same module.\n\
+\  -filter:none                  No -filter:package and -filter:archive\n\
+\                                filtering.  Filtering specified via the\n\
+\                                -filter option still applies.\n\
 
 main.opt.p=\n\
-\Options to filter dependencies:\n\
-\  -p <pkgname> -package <pkgname>   Finds dependences matching the given package\n\
-\                                    name (may be given multiple times).
+\Options to filter dependences:\n\
+\  -p <pkg>\n\
+\  -package <pkg>\n\
+\  --package <pkg>               Finds dependences matching the given package\n\
+\                                name (may be given multiple times).
 
 main.opt.e=\
-\  -e <regex> -regex <regex>         Finds dependences matching the given pattern.
+\  -e <regex>\n\
+\  -regex <regex>\n\
+\  --regex <regex>               Finds dependences matching the given pattern.
 
-main.opt.requires=\
-\  -requires <module-name>           Finds dependences matching the given module\n\
-\                                    name (may be given multiple times).\n\
-\                                    -package, -regex, -requires are mutual exclusive.
+main.opt.require=\
+\  --require <module-name>       Finds dependences matching the given module\n\
+\                                name (may be given multiple times). --package,\n\
+\                                --regex, --require are mutual exclusive.
 
 main.opt.include=\n\
  \Options to filter classes to be analyzed:\n\
-\  -include <regex>                  Restrict analysis to classes matching pattern\n\
-\                                    This option filters the list of classes to\n\
-\                                    be analyzed.  It can be used together with\n\
-\                                    -p and -e which apply pattern to the dependences
+\  -include <regex>              Restrict analysis to classes matching pattern\n\
+\                                This option filters the list of classes to\n\
+\                                be analyzed.  It can be used together with\n\
+\                                -p and -e which apply pattern to the dependences
 
 main.opt.P=\
-\  -P           -profile             Show profile containing a package
+\  -P       -profile             Show profile containing a package
 
 main.opt.cp=\
 \  -cp <path>\n\
 \  -classpath <path>\n\
-\  --class-path <path>               Specify where to find class files
+\  --class-path <path>           Specify where to find class files
 
 main.opt.module-path=\
-\  --module-path <module path>...    Specify module path
+\  --module-path <module path>   Specify module path
 
 main.opt.upgrade-module-path=\
-\  --upgrade-module-path <module path>...  Specify upgrade module path
+\  --upgrade-module-path <module path>  Specify upgrade module path
 
 main.opt.system=\
-\  --system <java-home>              Specify an alternate system module path
+\  --system <java-home>          Specify an alternate system module path
 
 main.opt.add-modules=\
 \  --add-modules <module-name>[,<module-name>...]\n\
-\                                    Adds modules to the root set for analysis
+\                                Adds modules to the root set for analysis
 
 main.opt.m=\
 \  -m <module-name>\n\
-\  --module <module-name>            Specify the root module for analysis
+\  --module <module-name>        Specify the root module for analysis
 
 main.opt.R=\
-\  -R           -recursive           Recursively traverse all run-time dependencies.\n\
-\                                    The -R option implies -filter:none.  If -p,\n\
-\                                    -e, -foption is specified, only the matching\n\
-\                                    dependences are analyzed.
+\  -R       -recursive           Recursively traverse all run-time dependences.\n\
+\                                The -R option implies -filter:none.  If -p,\n\
+\                                -e, -foption is specified, only the matching\n\
+\                                dependences are analyzed.
 
 main.opt.I=\
-\  -I           -inverse             Analyzes the dependences per other given options\n\
-\                                    and then find all artifacts that directly\n\
-\                                    and indirectly depend on the matching nodes.\n\
-\                                    This is equivalent to the inverse of\n\
-\                                    compile-time view analysis and print\n\
-\                                    dependency summary.  This option must use\n\
-\                                    with -requires, -package or -regex option.
+\  -I       --inverse            Analyzes the dependences per other given options\n\
+\                                and then find all artifacts that directly\n\
+\                                and indirectly depend on the matching nodes.\n\
+\                                This is equivalent to the inverse of\n\
+\                                compile-time view analysis and print\n\
+\                                dependency summary.  This option must use\n\
+\                                with --require, --package or --regex option.
 
 main.opt.compile-time=\
-\  --compile-time                    Compile-time view of transitive dependencies\n\
-\                                    i.e. compile-time view of -R option.\n\
-\                                    Analyzes the dependences per other given options\n\
-\                                    If a dependence is found from a directory,\n\
-\                                    a JAR file or a module, all classes in that \n\
-\                                    containing archive are analyzed.
+\  --compile-time                Compile-time view of transitive dependences\n\
+\                                i.e. compile-time view of -R option.\n\
+\                                Analyzes the dependences per other given options\n\
+\                                If a dependence is found from a directory,\n\
+\                                a JAR file or a module, all classes in that \n\
+\                                containing archive are analyzed.
 
 main.opt.apionly=\
-\  -apionly                          Restrict analysis to APIs i.e. dependences\n\
-\                                    from the signature of public and protected\n\
-\                                    members of public classes including field\n\
-\                                    type, method parameter types, returned type,\n\
-\                                    checked exception types etc.
+\  -apionly\n\
+\  --api-only                    Restrict analysis to APIs i.e. dependences\n\
+\                                from the signature of public and protected\n\
+\                                members of public classes including field\n\
+\                                type, method parameter types, returned type,\n\
+\                                checked exception types etc.
 
-main.opt.gen-module-info=\
-\  --gen-module-info <dir>           Generate module-info.java under the specified\n\
-\                                    directory. The specified JAR files will be\n\
-\                                    analyzed. This option cannot be used with\n\
-\                                    -dotoutput or -cp.
+main.opt.generate-module-info=\
+\  --generate-module-info <dir>  Generate module-info.java under the specified\n\
+\                                directory. The specified JAR files will be\n\
+\                                analyzed. This option cannot be used with\n\
+\                                --dot-output or --class-path.
 
 main.opt.check=\
 \  --check <module-name>[,<module-name>...\n\
-\                                    Analyze the dependence of the specified modules\n\
-\                                    It prints the module descriptor, the resulting\n\
-\                                    module dependences after analysis and the\n\
-\                                    graph after transition reduction.  It also\n\
-\                                    identifies any unused qualified exports.
+\                                Analyze the dependence of the specified modules\n\
+\                                It prints the module descriptor, the resulting\n\
+\                                module dependences after analysis and the\n\
+\                                graph after transition reduction.  It also\n\
+\                                identifies any unused qualified exports.
 
 
 main.opt.dotoutput=\
-\  -dotoutput <dir>                  Destination directory for DOT file output
+\  -dotoutput <dir>\n\
+\  --dot-output <dir>            Destination directory for DOT file output
 
 main.opt.jdkinternals=\
-\  -jdkinternals                     Finds class-level dependences on JDK internal\n\
-\                                    APIs. By default, it analyzes all classes\n\
-\                                    on -classpath and input files unless -include\n\
-\                                    option is specified. This option cannot be\n\
-\                                    used with -p, -e and -s options.\n\
-\                                    WARNING: JDK internal APIs are inaccessible.
+\  -jdkinternals\n\
+\  --jdk-internals               Finds class-level dependences on JDK internal\n\
+\                                APIs. By default, it analyzes all classes\n\
+\                                on --class-path and input files unless -include\n\
+\                                option is specified. This option cannot be\n\
+\                                used with -p, -e and -s options.\n\
+\                                WARNING: JDK internal APIs are inaccessible.
 
 main.opt.depth=\
-\  -depth=<depth>                    Specify the depth of the transitive\n\
-\                                    dependency analysis
+\  -depth=<depth>                Specify the depth of the transitive\n\
+\                                dependency analysis
 
 main.opt.q=\
-\  -q           -quiet               Do not show missing dependencies from \n\
-\                                    -genmoduleinfo output.
+\  -q       -quiet               Do not show missing dependences from \n\
+\                                --generate-module-info output.
 
 main.opt.multi-release=\
-\  --multi-release <version>         Specifies the version when processing\n\
-\                                    multi-release jar files.  <version> should\n\
-\                                    be integer >= 9 or base.
+\  --multi-release <version>     Specifies the version when processing\n\
+\                                multi-release jar files.  <version> should\n\
+\                                be integer >= 9 or base.
 
 err.unknown.option=unknown option: {0}
 err.missing.arg=no value given for {0}
 err.invalid.arg.for.option=invalid argument for option: {0}
 err.option.after.class=option must be specified before classes: {0}
-err.genmoduleinfo.not.jarfile={0} not valid for --gen-module-info option (must be non-modular JAR file)
+err.genmoduleinfo.not.jarfile={0} is a modular JAR file that cannot be specified with the --generate-module-info option
+err.genmoduleinfo.unnamed.package={0} contains an unnamed package that is not allowed in a module
 err.profiles.msg=No profile information
 err.exception.message={0}
 err.invalid.path=invalid path: {0}
 err.invalid.module.option=Cannot set {0} with {1} option.
-err.invalid.filters=Only one of -package (-p), -regex (-e), -requires option can be set
+err.invalid.filters=Only one of --package (-p), --regex (-e), --require option can be set
 err.module.not.found=module not found: {0}
 err.root.module.not.set=root module set empty
-err.invalid.inverse.option={0} cannot be used with -inverse option
-err.inverse.filter.not.set={0} cannot be used with -inverse option
+err.invalid.inverse.option={0} cannot be used with --inverse option
 err.multirelease.option.exists={0} is not a multi-release jar file, but the --multi-release option is set
 err.multirelease.option.notfound={0} is a multi-release jar file, but the --multi-release option is not set
 err.multirelease.version.associated=class {0} already associated with version {1}, trying to add version {2}
 err.multirelease.jar.malformed=malformed multi-release jar, {0}, bad entry: {1}
 warn.invalid.arg=Path does not exist: {0}
+warn.skipped.entry={0}
 warn.split.package=package {0} defined in {1} {2}
 warn.replace.useJDKInternals=\
 JDK internal APIs are unsupported and private to JDK implementation that are\n\
 subject to be removed or changed incompatibly and could break your application.\n\
-Please modify your code to eliminate dependency on any JDK internal APIs.\n\
+Please modify your code to eliminate dependence on any JDK internal APIs.\n\
 For the most recent update on JDK internal API replacements, please check:\n\
 {0}
 
--- a/langtools/src/jdk.jdeps/share/classes/module-info.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -32,4 +32,10 @@
     requires jdk.compiler;
     exports com.sun.tools.classfile to
         jdk.jlink;
+
+    provides java.util.spi.ToolProvider
+        with com.sun.tools.javap.Main.JavapToolProvider;
+
+    provides java.util.spi.ToolProvider
+        with com.sun.tools.jdeps.Main.JDepsToolProvider;
 }
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Tue Oct 18 17:14:09 2016 +0000
@@ -199,6 +199,7 @@
     private boolean feedbackInitialized = false;
     private String commandLineFeedbackMode = null;
     private List<String> remoteVMOptions = new ArrayList<>();
+    private List<String> compilerOptions = new ArrayList<>();
 
     SourceCodeAnalysis analysis;
     JShell state = null;
@@ -558,9 +559,14 @@
         parser.accepts("s");
         parser.accepts("v");
         OptionSpec<String> r = parser.accepts("R").withRequiredArg();
+        OptionSpec<String> c = parser.accepts("C").withRequiredArg();
         parser.acceptsAll(asList("h", "help"));
         parser.accepts("version");
         parser.accepts("full-version");
+
+        parser.accepts("X");
+        OptionSpec<String> addExports = parser.accepts("add-exports").withRequiredArg();
+
         NonOptionArgumentSpec<String> loadFileSpec = parser.nonOptions();
 
         OptionSet options;
@@ -585,6 +591,10 @@
             printUsage();
             return null;
         }
+        if (options.has("X")) {
+            printUsageX();
+            return null;
+        }
         if (options.has("version")) {
             cmdout.printf("jshell %s\n", version());
             return null;
@@ -630,7 +640,19 @@
             commandLineFeedbackMode = "verbose";
         }
         if (options.has(r)) {
-            remoteVMOptions = options.valuesOf(r);
+            remoteVMOptions.addAll(options.valuesOf(r));
+        }
+        if (options.has(c)) {
+            compilerOptions.addAll(options.valuesOf(c));
+        }
+
+        if (options.has(addExports)) {
+            List<String> exports = options.valuesOf(addExports).stream()
+                    .map(mp -> mp + "=ALL-UNNAMED")
+                    .flatMap(mp -> Stream.of("--add-exports", mp))
+                    .collect(toList());
+            remoteVMOptions.addAll(exports);
+            compilerOptions.addAll(exports);
         }
 
         return options.valuesOf(loadFileSpec);
@@ -640,6 +662,10 @@
         cmdout.print(getResourceString("help.usage"));
     }
 
+    private void printUsageX() {
+        cmdout.print(getResourceString("help.usage.x"));
+    }
+
     /**
      * Message handler to use during initial start-up.
      */
@@ -683,7 +709,8 @@
                 .idGenerator((sn, i) -> (currentNameSpace == startNamespace || state.status(sn).isActive())
                         ? currentNameSpace.tid(sn)
                         : errorNamespace.tid(sn))
-                .remoteVMOptions(remoteVMOptions.toArray(new String[remoteVMOptions.size()]))
+                .remoteVMOptions(remoteVMOptions.stream().toArray(String[]::new))
+                .compilerOptions(compilerOptions.stream().toArray(String[]::new))
                 .build();
         shutdownSubscription = state.onShutdown((JShell deadState) -> {
             if (deadState == state) {
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Tue Oct 18 17:14:09 2016 +0000
@@ -164,8 +164,15 @@
 \                            Use one -J for each runtime flag or flag argument\n\
 \    -R<flag>              Pass <flag> to the remote runtime system.\n\
 \                            Use one -R for each remote flag or flag argument\n\
+\    -C<flag>              Pass <flag> to the compiler.\n\
+\                            Use one -C for each compiler flag or flag argument\n\
 \    --help                Print this synopsis of standard options\n\
-\    --version             Version information\n
+\    --version             Version information\n\
+\    -X                    Print help on non-standard options\n
+help.usage.x = \
+\    --add-exports <module>/<package>   Export specified module-private package to snippets\n\
+\    \n\
+\These options are non-standard and subject to change without notice.\n
 
 help.list.summary = list the source you have typed
 help.list.args = [<name or id>|-all|-start]
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java	Tue Oct 18 17:14:09 2016 +0000
@@ -166,6 +166,7 @@
     private static final int XTERM         = 0b100000000;               // Can terminate (last before EOF)
     private static final int XSTART        = 0b1000000000;              // Boundary, must be XTERM before
     private static final int XERRO         = 0b10000000000;             // Is an error
+    private static final int XBRACESNEEDED = 0b100000000000;            // Expect {ANY} LBRACE
 
     /**
      * An extension of the compiler's TokenKind which adds our combined/processed
@@ -190,7 +191,7 @@
         ERROR(TokenKind.ERROR, XERRO),  //
         IDENTIFIER(TokenKind.IDENTIFIER, XEXPR1|XDECL1|XTERM),  //
         UNDERSCORE(TokenKind.UNDERSCORE, XERRO),  //  _
-        CLASS(TokenKind.CLASS, XEXPR|XDECL1),  //  class decl (MAPPED: DOTCLASS)
+        CLASS(TokenKind.CLASS, XEXPR|XDECL1|XBRACESNEEDED),  //  class decl (MAPPED: DOTCLASS)
         MONKEYS_AT(TokenKind.MONKEYS_AT, XEXPR|XDECL1),  //  @
         IMPORT(TokenKind.IMPORT, XDECL1|XSTART),  //  import -- consider declaration
         SEMI(TokenKind.SEMI, XSTMT1|XTERM|XSTART),  //  ;
@@ -202,10 +203,10 @@
         CUSTOM(TokenKind.CUSTOM, XERRO),  // No uses
 
         // Declarations
-        ENUM(TokenKind.ENUM, XDECL1),  //  enum
+        ENUM(TokenKind.ENUM, XDECL1|XBRACESNEEDED),  //  enum
         IMPLEMENTS(TokenKind.IMPLEMENTS, XDECL),  //  implements
-        INTERFACE(TokenKind.INTERFACE, XDECL1),  //  interface
-        THROWS(TokenKind.THROWS, XDECL),  //  throws
+        INTERFACE(TokenKind.INTERFACE, XDECL1|XBRACESNEEDED),  //  interface
+        THROWS(TokenKind.THROWS, XDECL|XBRACESNEEDED),  //  throws
 
         // Primarive type names
         BOOLEAN(TokenKind.BOOLEAN, XEXPR1|XDECL1),  //  boolean
@@ -381,6 +382,10 @@
             return (belongs & XSTART) != 0;
         }
 
+        boolean isBracesNeeded() {
+            return (belongs & XBRACESNEEDED) != 0;
+        }
+
         /**
          * After construction, check that all compiler TokenKind values have
          * corresponding TK values.
@@ -641,7 +646,9 @@
 
         public Completeness parseDeclaration() {
             boolean isImport = token.kind == IMPORT;
+            boolean isBracesNeeded = false;
             while (token.kind.isDeclaration()) {
+                isBracesNeeded |= token.kind.isBracesNeeded();
                 nextToken();
             }
             switch (token.kind) {
@@ -666,6 +673,9 @@
                         case SEMI:
                             return Completeness.COMPLETE;
                         case IDENTIFIER:
+                            return isBracesNeeded
+                                    ? Completeness.DEFINITELY_INCOMPLETE
+                                    : Completeness.COMPLETE_WITH_SEMI;
                         case BRACKETS:
                             return Completeness.COMPLETE_WITH_SEMI;
                         case DOTSTAR:
--- a/langtools/test/Makefile	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/Makefile	Tue Oct 18 17:14:09 2016 +0000
@@ -157,6 +157,15 @@
 	-refvmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH)
 endif
 
+ifeq ($(ARCH_DATA_MODEL),32)
+  # Set the GC options for test vms
+  JTREG_GC_OPTION = -vmoption:-XX:+UseSerialGC
+  JTREG_OPTIONS += $(JTREG_GC_OPTION)
+endif
+# Set the max memory for jtreg target test JVMs
+JTREG_TESTVM_MEMORY_OPTION = -vmoption:-Xmx768m
+JTREG_OPTIONS += $(JTREG_TESTVM_MEMORY_OPTION)
+
 ifdef EXTRA_JTREG_OPTIONS
   JTREG_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 endif
@@ -304,8 +313,6 @@
 	    $(JTREG_OUTPUT_DIR)/diff.html $(JTREG_OUTPUT_DIR)/status.txt
 	@mkdir -p $(JTREG_OUTPUT_DIR)
 	JT_JAVA=$(JT_JAVA) $(JTREG) \
-	  -J-Xmx512m \
-	  -vmoption:-Xmx768m \
 	  -a -ignore:quiet $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE)) \
 	  -r:$(JTREG_OUTPUT_DIR)/JTreport \
 	  -w:$(JTREG_OUTPUT_DIR)/JTwork \
--- a/langtools/test/jdk/javadoc/doclet/T6735320/T6735320.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/T6735320/T6735320.java	Tue Oct 18 17:14:09 2016 +0000
@@ -42,7 +42,7 @@
     void test() {
         javadoc("-d", "out",
                 testSrc("SerialFieldTest.java"));
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
         checkOutput(Output.STDERR, false,
                 "OutOfBoundsException");
     }
--- a/langtools/test/jdk/javadoc/doclet/dupThrowsTags/TestDupThrowsTags.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/dupThrowsTags/TestDupThrowsTags.java	Tue Oct 18 17:14:09 2016 +0000
@@ -42,7 +42,7 @@
     void test() {
         javadoc("-d", "out",
                 testSrc("TestDupThrowsTags.java"));
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
 
         checkOutput("TestDupThrowsTags.html", true,
                 "Test 1 passes",
--- a/langtools/test/jdk/javadoc/doclet/lib/JavadocTester.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/lib/JavadocTester.java	Tue Oct 18 17:14:09 2016 +0000
@@ -41,6 +41,7 @@
 import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.EnumMap;
 import java.util.HashMap;
 import java.util.List;
@@ -326,15 +327,27 @@
         outputDirectoryCheck = c;
     }
 
+    /**
+     * The exit codes returned by the javadoc tool.
+     * @see jdk.javadoc.internal.tool.Main.Result
+     */
     public enum Exit {
-        OK(0),
-        FAILED(1);
+        OK(0),        // Javadoc completed with no errors.
+        ERROR(1),     // Completed but reported errors.
+        CMDERR(2),    // Bad command-line arguments
+        SYSERR(3),    // System error or resource exhaustion.
+        ABNORMAL(4);  // Javadoc terminated abnormally
 
         Exit(int code) {
             this.code = code;
         }
 
         final int code;
+
+        @Override
+        public String toString() {
+            return name() + '(' + code + ')';
+        }
     }
 
     /**
@@ -348,7 +361,7 @@
         if (exitCode == expected.code) {
             passed("return code " + exitCode);
         } else {
-            failed("return code " + exitCode +"; expected " + expected.code + " (" + expected + ")");
+            failed("return code " + exitCode +"; expected " + expected);
         }
     }
 
@@ -410,6 +423,23 @@
     }
 
     /**
+     * Get the content of the one of the output streams written by
+     * javadoc.
+     */
+    public String getOutput(Output output) {
+        return outputMap.get(output);
+    }
+
+    /**
+     * Get the content of the one of the output streams written by
+     * javadoc.
+     */
+    public List<String> getOutputLines(Output output) {
+        String text = outputMap.get(output);
+        return (text == null) ? Collections.emptyList() : Arrays.asList(text.split(NL));
+    }
+
+    /**
      * Check for files in (or not in) the generated output.
      * @param expectedFound true if all of the files are expected
      *  to be found, or false if all of the files are expected to be
--- a/langtools/test/jdk/javadoc/doclet/testBadSourceFile/TestBadSourceFile.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testBadSourceFile/TestBadSourceFile.java	Tue Oct 18 17:14:09 2016 +0000
@@ -50,6 +50,6 @@
         javadoc("-Xdoclint:none",
                 "-d", "out",
                 testSrc("C2.java"));
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testConstantValuesPage/TestConstantValuesPage.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testConstantValuesPage/TestConstantValuesPage.java	Tue Oct 18 17:14:09 2016 +0000
@@ -45,7 +45,7 @@
         javadoc("-d", "out",
                 "-sourcepath", testSrc,
                 "foo");
-        checkExit(Exit.FAILED);
+        checkExit(Exit.CMDERR);
 
         checkOutput(Output.OUT, false,
                 "constant-values.html...");
--- a/langtools/test/jdk/javadoc/doclet/testDocErrorReporter/TestDocErrorReporter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testDocErrorReporter/TestDocErrorReporter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -52,6 +52,8 @@
                 "-encoding", "xyz",
                 testSrc("TestDocErrorReporter.java"));
 
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
+
+        checkOutput(Output.OUT, true, "error: unsupported encoding: xyz");
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -32,6 +32,9 @@
  * @run main TestHelpOption
  */
 
+import java.util.*;
+import java.util.stream.*;
+
 public class TestHelpOption extends JavadocTester {
 
     public static void main(String... args) throws Exception {
@@ -40,6 +43,26 @@
     }
 
     @Test
+    void testLineLengths() {
+        javadoc("-d", "out1",
+                "-sourcepath", testSrc,
+                "-X",
+                testSrc("TestXOption.java"));
+        checkExit(Exit.OK);
+        List<String> longLines = getOutputLines(Output.OUT).stream()
+                .filter(s -> s.length() > 80)
+                .collect(Collectors.toList());
+        checking("line lengths");
+        if (longLines.isEmpty()) {
+            passed("all lines OK");
+        } else {
+            out.println("long lines:");
+            longLines.stream().forEach(s -> out.println(">>>" + s + "<<<"));
+            failed(longLines.size() + " long lines");
+        }
+    }
+
+    @Test
     void testWithOption() {
         javadoc("-d", "out1",
                 "-sourcepath", testSrc,
@@ -88,7 +111,7 @@
                 "-helpfile", testSrc("test-help.html"),
                 "-helpfile", testSrc("test-help.html"),
                 testSrc("Sample.java"));
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
     }
 
     @Test
@@ -98,7 +121,7 @@
                 "-helpfile", testSrc("test-help.html"),
                 "-nohelp",
                 testSrc("Sample.java"));
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
     }
 
     private void checkOutput(boolean withOption) {
@@ -107,7 +130,7 @@
                 "-use ",
                 "-version ",
                 "-author ",
-                "-docfilessubdirs ",
+                "-docfilessubdirs\n",
                 "-splitindex ",
                 "-windowtitle ",
                 "-doctitle ",
@@ -119,11 +142,11 @@
                 "-excludedocfilessubdir ",
                 "-group ",
                 "-nocomment ",
-                "-nodeprecated ",
+                "-nodeprecated\n",
                 "-noqualifier ",
                 "-nosince ",
                 "-notimestamp ",
-                "-nodeprecatedlist ",
+                "-nodeprecatedlist\n",
                 "-notree ",
                 "-noindex ",
                 "-nohelp ",
--- a/langtools/test/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java	Tue Oct 18 17:14:09 2016 +0000
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6786682
+ * @bug 6786682 4649116
  * @summary This test verifies the use of lang attribute by <HTML>.
  * @author Bhavesh Patel
  * @library ../lib
@@ -106,7 +106,7 @@
         checkExit(Exit.OK);
 
         checkOutput("pkg3/package-summary.html", true,
-                "<h2 title=\"Package pkg3 Description\">Package pkg3 Description</h2>\n"
+                "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\"><p>This is the first line."
                 + " Note the newlines before the &lt;p&gt; is relevant.</div>");
 
--- a/langtools/test/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java	Tue Oct 18 17:14:09 2016 +0000
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8072945 8081854 8141492 8148985 8150188
+ * @bug 8072945 8081854 8141492 8148985 8150188 4649116
  * @summary Test the version of HTML generated by the javadoc tool.
  * @author bpatel
  * @library ../lib
@@ -162,10 +162,17 @@
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
                 "<section role=\"region\">\n"
-                + "<h2 title=\"Package pkg Description\">Package pkg Description</h2>\n",
+                + "<div class=\"block\">Test package.</div>",
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">\n"
                 + "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
+        // No package description
+        checkOutput("pkg1/package-summary.html", true,
+                "<div class=\"contentContainer\">\n"
+                + "<ul class=\"blockList\">\n"
+                + "<li class=\"blockList\">\n"
+                + "<table class=\"typeSummary\">\n"
+                + "<caption><span>Class Summary</span><span class=\"tabEnd\">&nbsp;</span></caption>");
 
         // Test for package-tree page
         checkOutput("pkg/package-tree.html", true,
@@ -662,6 +669,8 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
+                "<section role=\"region\">\n"
+                + "<h2 title=\"Package pkg Description\">Package pkg Description</h2>\n",
                 "<table class=\"typeSummary\" summary=\"Interface Summary table, listing interfaces, and an explanation\">",
                 "<table class=\"typeSummary\" summary=\"Class Summary table, listing classes, and an explanation\">",
                 "<table class=\"typeSummary\" summary=\"Enum Summary table, listing enums, and an explanation\">",
@@ -1060,12 +1069,21 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
+                "<div class=\"contentContainer\">\n"
+                + "<div class=\"block\">Test package.</div>",
                 "<table class=\"typeSummary\" summary=\"Interface Summary table, listing interfaces, and an explanation\">",
                 "<table class=\"typeSummary\" summary=\"Class Summary table, listing classes, and an explanation\">",
                 "<table class=\"typeSummary\" summary=\"Enum Summary table, listing enums, and an explanation\">",
                 "<table class=\"typeSummary\" summary=\"Exception Summary table, listing exceptions, and an explanation\">",
                 "<table class=\"typeSummary\" summary=\"Error Summary table, listing errors, and an explanation\">",
                 "<table class=\"typeSummary\" summary=\"Annotation Types Summary table, listing annotation types, and an explanation\">");
+        // No Package description
+        checkOutput("pkg1/package-summary.html", true,
+                "<div class=\"contentContainer\">\n"
+                + "<ul class=\"blockList\">\n"
+                + "<li class=\"blockList\">\n"
+                + "<table class=\"typeSummary\" summary=\"Class Summary table, listing classes, and an explanation\">\n"
+                + "<caption><span>Class Summary</span><span class=\"tabEnd\">&nbsp;</span></caption>");
 
         // Test for package-tree page
         checkOutput("pkg/package-tree.html", true,
@@ -1485,8 +1503,7 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
-                + "<h2 title=\"Package pkg Description\">Package pkg Description</h2>\n",
+                "<h2 title=\"Package pkg Description\">Package pkg Description</h2>\n",
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">\n"
                 + "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
--- a/langtools/test/jdk/javadoc/doclet/testIOException/TestIOException.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testIOException/TestIOException.java	Tue Oct 18 17:14:09 2016 +0000
@@ -57,7 +57,7 @@
         try {
             javadoc("-d", outDir.toString(),
                     new File(testSrc, "TestIOException.java").getPath());
-            checkExit(Exit.FAILED);
+            checkExit(Exit.ERROR);
             checkOutput(Output.OUT, true,
                 "Destination directory not writable: " + outDir);
         } finally {
@@ -85,7 +85,7 @@
             javadoc("-d", outDir.toString(),
                     new File(testSrc, "TestIOException.java").getPath());
 
-            checkExit(Exit.FAILED);
+            checkExit(Exit.ERROR);
             checkOutput(Output.OUT, true,
                 "Error writing file: " + index);
         } finally {
@@ -123,7 +123,7 @@
             setOutputDirectoryCheck(DirectoryCheck.NONE);
             javadoc("-d", outDir.toString(),
                     src_p_C.getPath());
-            checkExit(Exit.FAILED);
+            checkExit(Exit.ERROR);
             checkOutput(Output.OUT, true,
                 "Error writing file: " + new File(pkgOutDir, "C.html"));
         } finally {
@@ -167,7 +167,7 @@
             javadoc("-d", outDir.toString(),
                     "-sourcepath", srcDir.getPath(),
                     "p");
-            checkExit(Exit.FAILED);
+            checkExit(Exit.ERROR);
             checkOutput(Output.OUT, true,
                 "Error writing file: " + new File(docFilesOutDir, "info.txt"));
         } finally {
--- a/langtools/test/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java	Tue Oct 18 17:14:09 2016 +0000
@@ -61,8 +61,14 @@
                     + "<div class=\"block\">Gets the value of the property rate.</div>\n"
                     + "<dl>\n"
                     + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>",
-                "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
-                    + "<a href=\"../pkg1/C.html#rateProperty\">rate</a></span></code>",
+                "<td class=\"colFirst\"><code><a href=\"../pkg1/C.DoubleProperty.html\" "
+                    + "title=\"class in pkg1\">C.DoubleProperty</a></code></td>\n"
+                    + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
+                    + "<a href=\"../pkg1/C.html#rateProperty\">rate</a></span></code></th>\n"
+                    + "<td class=\"colLast\">\n"
+                    + "<div class=\"block\">Defines the direction/speed at which the "
+                    + "<code>Timeline</code> is expected to\n"
+                    + " be played.</div>\n</td>",
                 "<span class=\"simpleTagLabel\">Default value:</span>",
                 "<span class=\"simpleTagLabel\">Since:</span></dt>\n"
                     + "<dd>JavaFX 8.0</dd>",
@@ -72,13 +78,70 @@
                 "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
                     + "<a href=\"../pkg1/C.html#setTestMethodProperty--\">"
                     + "setTestMethodProperty</a></span>()</code></th>",
+                "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
+                    + "<a href=\"../pkg1/C.html#pausedProperty\">paused</a></span></code></th>\n"
+                    + "<td class=\"colLast\">\n"
+                    + "<div class=\"block\">Defines if paused.</div>",
+                "<h4>paused</h4>\n"
+                    + "<pre>public final&nbsp;<a href=\"../pkg1/C.BooleanProperty.html\" "
+                    + "title=\"class in pkg1\">C.BooleanProperty</a> pausedProperty</pre>\n"
+                    + "<div class=\"block\">Defines if paused. The second line.</div>",
+                "<h4>isPaused</h4>\n"
+                    + "<pre>public final&nbsp;double&nbsp;isPaused()</pre>\n"
+                    + "<div class=\"block\">Gets the value of the property paused.</div>",
+                "<h4>setPaused</h4>\n"
+                    + "<pre>public final&nbsp;void&nbsp;setPaused(boolean&nbsp;value)</pre>\n"
+                    + "<div class=\"block\">Sets the value of the property paused.</div>\n"
+                    + "<dl>\n"
+                    + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
+                    + "<dd>Defines if paused. The second line.</dd>\n"
+                    + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
+                    + "<dd>false</dd>",
                 "<h4>isPaused</h4>\n"
                     + "<pre>public final&nbsp;double&nbsp;isPaused()</pre>\n"
-                    + "<div class=\"block\">Gets the value of the property paused.</div>");
+                    + "<div class=\"block\">Gets the value of the property paused.</div>\n"
+                    + "<dl>\n"
+                    + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
+                    + "<dd>Defines if paused. The second line.</dd>\n"
+                    + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
+                    + "<dd>false</dd>",
+                "<h4>rate</h4>\n"
+                    + "<pre>public final&nbsp;<a href=\"../pkg1/C.DoubleProperty.html\" "
+                    + "title=\"class in pkg1\">C.DoubleProperty</a> rateProperty</pre>\n"
+                    + "<div class=\"block\">Defines the direction/speed at which the "
+                    + "<code>Timeline</code> is expected to\n"
+                    + " be played. This is the second line.</div>",
+                "<h4>setRate</h4>\n"
+                    + "<pre>public final&nbsp;void&nbsp;setRate(double&nbsp;value)</pre>\n"
+                    + "<div class=\"block\">Sets the value of the property rate.</div>\n"
+                    + "<dl>\n"
+                    + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
+                    + "<dd>Defines the direction/speed at which the <code>Timeline</code> is expected to\n"
+                    + " be played. This is the second line.</dd>\n"
+                    + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
+                    + "<dd>11</dd>\n"
+                    + "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+                    + "<dd>JavaFX 8.0</dd>",
+                "<h4>getRate</h4>\n"
+                    + "<pre>public final&nbsp;double&nbsp;getRate()</pre>\n"
+                    + "<div class=\"block\">Gets the value of the property rate.</div>\n"
+                    + "<dl>\n"
+                    + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
+                    + "<dd>Defines the direction/speed at which the <code>Timeline</code> is expected to\n"
+                    + " be played. This is the second line.</dd>\n"
+                    + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
+                    + "<dd>11</dd>\n"
+                    + "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+                    + "<dd>JavaFX 8.0</dd>",
+                "");
 
         checkOutput("pkg1/C.html", false,
                 "A()");
 
+        checkOutput("index-all.html", true,
+                "<div class=\"block\">Gets the value of the property paused.</div>",
+                "<div class=\"block\">Defines if paused.</div>");
+
         checkOutput("pkg1/D.html", true,
                 "<h3>Properties inherited from class&nbsp;pkg1."
                     + "<a href=\"../pkg1/C.html\" title=\"class in pkg1\">C</a></h3>\n"
--- a/langtools/test/jdk/javadoc/doclet/testJavaFX/pkg1/C.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testJavaFX/pkg1/C.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@
 
     /**
      * Defines the direction/speed at which the {@code Timeline} is expected to
-     * be played.
+     * be played. This is the second line.
      * @defaultValue 11
      * @since JavaFX 8.0
      */
@@ -71,7 +71,7 @@
     public final double isPaused() {}
 
     /**
-     * Defines if paused
+     * Defines if paused. The second line.
      * @defaultValue false
      */
     public final BooleanProperty pausedProperty() {}
@@ -87,7 +87,7 @@
 
         /**
          * Defines the direction/speed at which the {@code Timeline} is expected to
-         * be played.
+         * be played. This is the second line.
          * @defaultValue 11
          */
         private DoubleProperty rate;
--- a/langtools/test/jdk/javadoc/doclet/testPackageHtml/TestPackageHtml.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testPackageHtml/TestPackageHtml.java	Tue Oct 18 17:14:09 2016 +0000
@@ -42,7 +42,7 @@
         javadoc("-d", "out-pkg-html",
                 "-sourcepath", testSrc,
                 "pkg1");
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
         checkOutput(Output.OUT, true, "package.html:10: error: bad use of '>'");
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testParamTaglet/TestParamTaglet.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testParamTaglet/TestParamTaglet.java	Tue Oct 18 17:14:09 2016 +0000
@@ -46,7 +46,7 @@
         javadoc("-d", "out",
                 "-sourcepath", testSrc,
                 "pkg");
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
 
         checkOutput("pkg/C.html", true,
                 //Regular param tags.
--- a/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java	Tue Oct 18 17:14:09 2016 +0000
@@ -73,7 +73,7 @@
     void test2a() {
         javadoc("-d", "out-2a", "-Xdoclint:all", "-sourcepath", testSrc,
                 "-use", "pkg", "pkg1", "pkg2", "pkg3");
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
         checkDocLintErrors();
         checkSearchOutput(true);
         checkSingleIndex(true);
--- a/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java	Tue Oct 18 17:14:09 2016 +0000
@@ -44,7 +44,7 @@
         javadoc("-d", "out-default",
                 "-sourcepath", testSrc,
                 "pkg1");
-        checkExit(Exit.FAILED); // TODO: should be OK
+        checkExit(Exit.OK);
 
         checkCommentDeprecated(true);
         checkNoComment(false);
@@ -56,7 +56,7 @@
                 "-nocomment",
                 "-sourcepath", testSrc,
                 "pkg1");
-        checkExit(Exit.FAILED); // TODO: should be OK
+        checkExit(Exit.OK);
 
         checkNoComment(true);
         checkCommentDeprecated(false);
@@ -68,7 +68,7 @@
                 "-nodeprecated",
                 "-sourcepath", testSrc,
                 "pkg1");
-        checkExit(Exit.FAILED); // TODO: should be OK
+        checkExit(Exit.OK);
 
         checkNoDeprecated(true);
         checkNoCommentNoDeprecated(false);
@@ -81,7 +81,7 @@
                 "-nodeprecated",
                 "-sourcepath", testSrc,
                 "pkg1");
-        checkExit(Exit.FAILED); // TODO: should be OK
+        checkExit(Exit.OK);
         checkNoCommentNoDeprecated(true);
         checkNoDeprecated(false);
     }
@@ -93,7 +93,7 @@
                 "<dl>\n"
                 + "<dt><span class=\"throwsLabel\">Throws:</span></dt>\n"
                 + "<dd><code>"
-                + "java.io.IOException</code></dd>\n"
+                + "java.io.IOException</code> - on error</dd>\n"
                 + "<dt><span class=\"seeLabel\">See Also:</span>"
                 + "</dt>\n"
                 + "<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">"
@@ -121,7 +121,7 @@
                 + "<div class=\"block\">Reads the object stream.</div>\n"
                 + "<dl>\n"
                 + "<dt><span class=\"throwsLabel\">Throws:</span></dt>\n"
-                + "<dd><code>java.io.IOException</code></dd>\n"
+                + "<dd><code>java.io.IOException</code> - on error</dd>\n"
                 + "</dl>",
                 "<span class=\"deprecatedLabel\">Deprecated.</span>"
                 + "&nbsp;</div>\n"
--- a/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/pkg1/C1.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/pkg1/C1.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -75,7 +75,6 @@
      * @param test boolean value
      * @exception IllegalArgumentException if the <code>owner</code>'s
      *     <code>GraphicsConfiguration</code> is not from a screen device
-     * @exception HeadlessException
      */
      public C1(String title, boolean test) {
 
@@ -98,6 +97,7 @@
     }
 
     /**
+     * @throws java.io.IOException on error
      * @see #setUndecorated(boolean)
      */
     public void readObject() throws IOException {
--- a/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/pkg1/C2.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testSerializedFormDeprecationInfo/pkg1/C2.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,7 @@
      * Reads the object stream.
      *
      * @param s ObjectInputStream
-     * @throws IOException
+     * @throws IOException on error
      * @deprecated As of JDK version 1.5, replaced by
      * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
      */
--- a/langtools/test/jdk/javadoc/doclet/testSinceTag/TestSinceTag.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testSinceTag/TestSinceTag.java	Tue Oct 18 17:14:09 2016 +0000
@@ -45,7 +45,7 @@
         javadoc("-d", "out-since",
                 "-sourcepath", testSrc,
                 "pkg1");
-        checkExit(Exit.FAILED); // TODO: investigate
+        checkExit(Exit.OK);
 
         checkSince(true);
     }
@@ -56,7 +56,7 @@
                 "-sourcepath", testSrc,
                 "-nosince",
                 "pkg1");
-        checkExit(Exit.FAILED); // TODO: investigate
+        checkExit(Exit.OK);
 
         checkSince(false);
     }
--- a/langtools/test/jdk/javadoc/doclet/testSinceTag/pkg1/C1.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testSinceTag/pkg1/C1.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,7 +72,6 @@
      * @param test boolean value
      * @exception IllegalArgumentException if the <code>owner</code>'s
      *     <code>GraphicsConfiguration</code> is not from a screen device
-     * @exception HeadlessException
      */
     public C1(String title, boolean test) {
     }
@@ -93,6 +92,7 @@
     }
 
     /**
+     * @throws java.io.IOException on error
      * @see #setUndecorated(boolean)
      */
     public void readObject() throws IOException {
--- a/langtools/test/jdk/javadoc/doclet/testSupplementary/TestSupplementary.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testSupplementary/TestSupplementary.java	Tue Oct 18 17:14:09 2016 +0000
@@ -52,7 +52,7 @@
         javadoc("-locale", "en_US",
                 "-d", "out",
                 testSrc("C.java"));
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
 
         checkOutput(Output.OUT, true,
             "C.java:36: error: unexpected text",
--- a/langtools/test/jdk/javadoc/doclet/testThrowsTag/TestThrowsTag.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testThrowsTag/TestThrowsTag.java	Tue Oct 18 17:14:09 2016 +0000
@@ -45,7 +45,7 @@
         javadoc("-d", "out",
                 "-sourcepath", testSrc,
                 "pkg");
-        checkExit(Exit.FAILED);  // TODO: investigate why failed
+        checkExit(Exit.OK);
 
         checkOutput("pkg/C.html", true,
             "<dd><code><a href=\"../pkg/T1.html\" title=\"class in pkg\">T1</a></code> - the first throws tag.</dd>\n" +
--- a/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T1.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T1.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 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,4 +23,4 @@
 
 package pkg;
 
-public class T1 extends Exception {}
+public class T1 extends RuntimeException {}
--- a/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T2.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T2.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 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,4 +23,4 @@
 
 package pkg;
 
-public class T2 extends Exception {}
+public class T2 extends RuntimeException {}
--- a/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T3.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T3.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 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,4 +23,4 @@
 
 package pkg;
 
-public class T3 extends Exception {}
+public class T3 extends RuntimeException {}
--- a/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T4.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testThrowsTag/pkg/T4.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 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,4 +23,4 @@
 
 package pkg;
 
-public class T4 extends Exception {}
+public class T4 extends RuntimeException {}
--- a/langtools/test/jdk/javadoc/doclet/testValueTag/TestValueTag.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testValueTag/TestValueTag.java	Tue Oct 18 17:14:09 2016 +0000
@@ -46,7 +46,7 @@
                 "-sourcepath", testSrc,
                 "-tag", "todo",
                 "pkg1", "pkg2");
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
 
         checkOutput("pkg1/Class1.html", true,
                 // Base case:  using @value on a constant.
--- a/langtools/test/jdk/javadoc/doclet/testWarnings/TestWarnings.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testWarnings/TestWarnings.java	Tue Oct 18 17:14:09 2016 +0000
@@ -47,7 +47,7 @@
         javadoc("-d", "out-default",
                 "-sourcepath", testSrc,
                 "pkg");
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
 
         checkOutput(Output.OUT, true,
                 "X.java:23: error: self-closing element not allowed");
@@ -75,7 +75,7 @@
                 "-private",
                 "-sourcepath", testSrc,
                 "pkg");
-        checkExit(Exit.FAILED);
+        checkExit(Exit.ERROR);
 
         checkOutput("pkg/X.html", true,
             "<a href=\"../pkg/X.html#m--\"><code>m()</code></a><br/>",
--- a/langtools/test/jdk/javadoc/doclet/testXOption/TestXOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testXOption/TestXOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -31,6 +31,9 @@
  * @run main TestXOption
  */
 
+import java.util.*;
+import java.util.stream.*;
+
 public class TestXOption extends JavadocTester {
 
     public static void main(String... args) throws Exception {
@@ -39,6 +42,26 @@
     }
 
     @Test
+    void testLineLengths() {
+        javadoc("-d", "out1",
+                "-sourcepath", testSrc,
+                "-X",
+                testSrc("TestXOption.java"));
+        checkExit(Exit.OK);
+        List<String> longLines = getOutputLines(Output.OUT).stream()
+                .filter(s -> s.length() > 80)
+                .collect(Collectors.toList());
+        checking("line lengths");
+        if (longLines.isEmpty()) {
+            passed("all lines OK");
+        } else {
+            out.println("long lines:");
+            longLines.stream().forEach(s -> out.println(">>>" + s + "<<<"));
+            failed(longLines.size() + " long lines");
+        }
+    }
+
+    @Test
     void testWithOption() {
         javadoc("-d", "out1",
                 "-sourcepath", testSrc,
@@ -58,14 +81,9 @@
     }
 
     private void checkOutput(boolean expectFound) {
-        // TODO: It's an ugly hidden side-effect of the current doclet API
-        // that the -X output from the tool and the -X output from the doclet
-        // come out on different streams!
-        // When we clean up the doclet API, this should be rationalized.
         checkOutput(Output.OUT, expectFound,
                 "-Xmaxerrs ",
-                "-Xmaxwarns ");
-        checkOutput(Output.OUT, expectFound,
+                "-Xmaxwarns ",
                 "-Xdocrootparent ",
                 "-Xdoclint ",
                 "-Xdoclint:");
--- a/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java	Tue Oct 18 17:14:09 2016 +0000
@@ -145,6 +145,9 @@
             // ignore these synthesized keys, tested by usageTests
             if (rk.startsWith("doclet.usage.") || rk.startsWith("doclet.xusage"))
                 continue;
+            // ignore these synthesized keys, tested by usageTests
+            if (rk.matches("main\\.opt\\..*\\.(arg|desc)"))
+                continue;
             if (codeKeys.contains(rk))
                 continue;
 
@@ -161,6 +164,9 @@
             // ignore these synthesized keys, tested by usageTests
             if (ck.startsWith("doclet.usage.") || ck.startsWith("doclet.xusage."))
                 continue;
+            // ignore this partial key, tested by usageTests
+            if (ck.equals("main.opt."))
+                continue;
             if (resourceKeys.contains(ck))
                 continue;
             error("No resource for \"" + ck + "\"");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/OptionSyntaxTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8166144
+ * @summary support new-style options
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * @modules jdk.compiler/com.sun.tools.javac.main
+ * @modules jdk.javadoc/jdk.javadoc.internal.api
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @library /tools/lib
+ * @build toolbox.JavacTask toolbox.JavadocTask toolbox.ModuleBuilder toolbox.TestRunner toolbox.ToolBox
+ * @run main OptionSyntaxTest
+ */
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Locale;
+import java.util.Objects;
+import java.util.Set;
+
+import javax.lang.model.SourceVersion;
+
+import jdk.javadoc.doclet.Doclet;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Reporter;
+
+import toolbox.JavadocTask;
+import toolbox.ModuleBuilder;
+import toolbox.Task;
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+
+public class OptionSyntaxTest extends TestRunner {
+    public static class TestDoclet implements Doclet {
+        @Override
+        public boolean run(DocletEnvironment root) {
+            System.out.println("TestDoclet.run");
+            return true;
+        }
+
+        @Override
+        public String getName() {
+            return "Test";
+        }
+
+        @Override
+        public Set<Option> getSupportedOptions() {
+            return options;
+        }
+
+        @Override
+        public SourceVersion getSupportedSourceVersion() {
+            return SourceVersion.latest();
+        }
+
+        @Override
+        public void init(Locale locale, Reporter reporter) {
+        }
+
+        private final Set<Doclet.Option> options = new HashSet<>(Arrays.asList(
+                new DOption("-old", 0),
+                new DOption("-oldWithArg", 1),
+                new DOption("-oldWithArgs", 2),
+                new DOption("--new", 0),
+                new DOption("--newWithArg", 1),
+                new DOption("--newWithArgs", 2)
+        ));
+
+    }
+
+    static class DOption implements Doclet.Option {
+        private final String name;
+        private final int argCount;
+
+        DOption(String name, int argCount) {
+            this.name = name;
+            this.argCount = argCount;
+        }
+
+        @Override
+        public int getArgumentCount() {
+            return argCount;
+        }
+
+        @Override
+        public String getDescription() {
+            return "description[" + name + "]";
+        }
+
+        @Override
+        public Kind getKind() {
+            return Doclet.Option.Kind.STANDARD;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public String getParameters() {
+            return argCount > 0 ? "parameters[" + name + "," + argCount + "]" : null;
+        }
+
+        @Override
+        public boolean matches(String option) {
+            return option.equals(name);
+        }
+
+        @Override
+        public boolean process(String option, ListIterator<String> arguments) {
+            List<String> args = new ArrayList<>();
+            for (int i = 0; i < argCount && arguments.hasNext(); i++) {
+                args.add(arguments.next());
+            }
+            System.out.println("process " + option + " " + args);
+            return args.stream().filter(s -> s.startsWith("arg")).count() == argCount;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        OptionSyntaxTest t = new OptionSyntaxTest();
+        t.runTests();
+    }
+
+    private final ToolBox tb = new ToolBox();
+    private final Path src = Paths.get("src");
+    private final Path modules = Paths.get("modules");
+
+    OptionSyntaxTest() throws IOException {
+        super(System.err);
+        initModules();
+    }
+
+    void initModules() throws IOException {
+        new ModuleBuilder(tb, "m1")
+                .exports("p1")
+                .classes("package p1; public class C1 { }")
+                .write(src);
+
+        new ModuleBuilder(tb, "m2")
+                .exports("p2")
+                .classes("package p2; public class C2 { }")
+                .build(modules);
+
+    }
+
+    @Test
+    public void testBasic() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testNewSourcePath() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "--source-path", "src/m1",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testNewSourcePathEquals() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "--source-path=src/m1",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testOldDocletArgs() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "-old",
+                       "-oldWithArg", "arg",
+                       "-oldWithArgs", "arg1", "arg2",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testNewDocletArgs() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "--new",
+                       "--newWithArg", "arg",
+                       "--newWithArgs", "arg1", "arg2",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testNewDocletArgsEquals() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "--new", "--newWithArg=arg",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testNewDocletArgsMissingArgs() throws Exception {
+        String log = new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "--newWithArg")
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+        if (!log.contains("option --newWithArg requires an argument"))
+            throw new Exception("expected output not found");
+    }
+
+    @Test
+    public void testNewDocletArgsExtraArgs() throws Exception {
+        String log = new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "--new=arg",
+                       "p1")
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+        if (!log.contains("option --new does not require an argument"))
+            throw new Exception("expected output not found");
+    }
+
+    @Test
+    public void testNewDocletArgsExtraArgs2() throws Exception {
+        String log = new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "--newWithArgs=arg1 arg2",
+                       "p1")
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+        if (!log.contains("cannot use '=' syntax for options that require multiple arguments"))
+            throw new Exception("expected output not found");
+    }
+
+}
--- a/langtools/test/jdk/javadoc/tool/ReleaseOption.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/tool/ReleaseOption.java	Tue Oct 18 17:14:09 2016 +0000
@@ -28,7 +28,11 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.function.Predicate;
+
 import jdk.javadoc.internal.tool.Main;
+import jdk.javadoc.internal.tool.Main.Result;
+
+import static jdk.javadoc.internal.tool.Main.Result.*;
 
 /**
  * @test
@@ -43,13 +47,13 @@
     }
 
     void run() {
-        doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7");
-        doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8");
-        doRunTest(1, out -> true, "--release", "7", "-source", "7");
-        doRunTest(1, out -> true, "--release", "7", "-bootclasspath", "any");
+        doRunTest(OK, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7");
+        doRunTest(OK, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8");
+        doRunTest(CMDERR, out -> true, "--release", "7", "-source", "7");
+        doRunTest(CMDERR, out -> true, "--release", "7", "-bootclasspath", "any");
     }
 
-    void doRunTest(int expectedResult, Predicate<String> validate, String... args) {
+    void doRunTest(Result expectedResult, Predicate<String> validate, String... args) {
         System.err.println("running with args: " + Arrays.asList(args));
         List<String> options = new ArrayList<>();
         options.addAll(Arrays.asList(args));
@@ -60,7 +64,7 @@
         int actualResult = Main.execute(options.toArray(new String[0]), pw);
         System.err.println("actual result=" + actualResult);
         System.err.println("actual output=" + out.toString());
-        if (actualResult != expectedResult)
+        if (actualResult != expectedResult.exitCode)
             throw new Error("Exit code not as expected");
         if (!validate.test(out.toString())) {
             throw new Error("Output not as expected");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/ToolProviderTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,133 @@
+/*
+ * 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 8159855
+ * @summary test javadoc's ToolProvider
+ * @library /tools/lib
+ * @build toolbox.TestRunner toolbox.ToolBox
+ * @run main ToolProviderTest
+ */
+
+import java.io.*;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.spi.ToolProvider;
+
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+public class ToolProviderTest extends TestRunner {
+    public static void main(String... args) throws Exception {
+        new ToolProviderTest().runTests();
+    }
+
+    ToolBox tb = new ToolBox();
+    ToolProvider javadoc;
+
+    ToolProviderTest() {
+        super(System.err);
+        javadoc = ToolProvider.findFirst("javadoc").get();
+    }
+
+    @Test
+    public void testProviders() throws Exception {
+        Map<String, ToolProvider> providers = new LinkedHashMap<>();
+        for (ToolProvider tp : ServiceLoader.load(ToolProvider.class,
+                ClassLoader.getSystemClassLoader())) {
+            System.out.println("Provider: " + tp.name() + ": " + tp.getClass().getName());
+            providers.put(tp.name(), tp);
+        }
+        if (!providers.containsKey("javadoc")) {
+            error("javadoc ToolProvider not found");
+        }
+    }
+
+    @Test
+    public void testOneStream() throws Exception {
+        StringWriter sw = new StringWriter();
+        try (PrintWriter pw = new PrintWriter(sw)) {
+            int rc = javadoc.run(pw, pw, "-help");
+            if (rc != 0) {
+                error("unexpected exit code: " + rc);
+            }
+        }
+        String out = sw.toString();
+        if (!out.contains("Usage:")) {
+            error("expected output not found");
+        }
+    }
+
+    @Test
+    public void testTwoStreamsOut() throws Exception {
+        StringWriter swOut = new StringWriter();
+        StringWriter swErr = new StringWriter();
+        try (PrintWriter pwOut = new PrintWriter(swOut);
+                PrintWriter pwErr = new PrintWriter(swErr)) {
+            int rc = javadoc.run(pwOut, pwErr, "-help");
+            if (rc != 0) {
+                error("unexpected exit code: " + rc);
+            }
+        }
+        String out = swOut.toString();
+        String err = swErr.toString();
+        if (!out.contains("Usage:")) {
+            error("stdout: expected output not found");
+        }
+        if (!err.isEmpty()) {
+            error("stderr: unexpected output");
+        }
+    }
+
+    @Test
+    public void testTwoStreamsErr() throws Exception {
+        Path src = Paths.get("src");
+        Path classes = Paths.get("classes");
+        tb.writeJavaFiles(src,
+            "import java.util.*; class C { # }");
+
+        StringWriter swOut = new StringWriter();
+        StringWriter swErr = new StringWriter();
+        try (PrintWriter pwOut = new PrintWriter(swOut);
+                PrintWriter pwErr = new PrintWriter(swErr)) {
+            int rc = javadoc.run(pwOut, pwErr,
+                "-d", classes.toString(),
+                src.resolve("C.java").toString());
+            if (rc != 1) {
+                error("unexpected exit code: " + rc);
+            }
+        }
+
+        String out = swOut.toString();
+        String err = swErr.toString();
+
+        if (!out.contains("Loading")) {
+            error("stdout: unexpected output");
+        }
+        if (!err.contains("illegal character")) {
+            error("stderr: expected output not found");
+        }
+    }
+}
--- a/langtools/test/jdk/javadoc/tool/api/basic/IsSupportedOptionTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/tool/api/basic/IsSupportedOptionTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 import javax.tools.ToolProvider;
 
 /**
- * Tests for DocumentationTool.usSupportedOption method.
+ * Tests for DocumentationTool.isSupportedOption method.
  */
 public class IsSupportedOptionTest extends APITest {
     public static void main(String... args) throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/exceptionHandling/TestExceptionHandling.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,146 @@
+/*
+ * 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 8151102
+ * @summary verify that option --dump-on-error functions correctly
+ * @library /tools/lib
+ * @modules
+ *      jdk.javadoc/jdk.javadoc.internal.api
+ *      jdk.javadoc/jdk.javadoc.internal.tool
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.TestRunner
+ * @run main TestExceptionHandling
+ */
+
+import java.io.File;
+import java.io.PrintStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+import toolbox.*;
+
+/**
+ * This class tests if stack traces printed when
+ * --dump-on-error. The standard doclet is used,
+ * to test the doclet as well as the tool.
+ */
+public class TestExceptionHandling  extends TestRunner {
+
+    final ToolBox tb;
+    final File testSrcFile;
+    final PrintStream ostream;
+    final JavadocTask cmdTask;
+    final JavadocTask apiTask;
+
+    public static void main(String... args) throws Exception {
+        TestExceptionHandling tester = new TestExceptionHandling();
+        tester.runTests();
+    }
+
+    TestExceptionHandling() {
+        super(System.err);
+        tb = new ToolBox();
+        ostream = System.err;
+        testSrcFile = new File(System.getProperty("test.src"), "TestExceptionHandling.java");
+        cmdTask = new JavadocTask(tb, Task.Mode.CMDLINE);
+        apiTask = new JavadocTask(tb, Task.Mode.API);
+    }
+
+    @Test
+    public void testDocletTrace() throws Exception {
+        Path out = Paths.get("out");
+        // create a file with the same name as the output
+        out.toFile().createNewFile();
+        cmdTask.outdir(out);
+        cmdTask.options("--dump-on-error");
+        cmdTask.files(testSrcFile.getAbsolutePath());
+        Task.Result tr = cmdTask.run(Task.Expect.FAIL);
+
+        String errString = "Destination directory is not a directory: " + out.toString();
+        // check the regular message
+        assertPresent("javadoc: error - " + errString, tr.getOutputLines(Task.OutputKind.DIRECT));
+        // check that first line of the stack trace is present
+        assertPresent("jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException: " +
+                errString, tr.getOutputLines(Task.OutputKind.STDERR));
+
+    }
+
+    @Test
+    public void testToolTrace() throws Exception {
+        Path out = Paths.get("out.dir");
+        cmdTask.options("--dump-on-error", "-doclet", "NonExistentDoclet");
+        cmdTask.outdir(out);
+        cmdTask.files(testSrcFile.getAbsolutePath());
+        Task.Result tr = cmdTask.run(Task.Expect.FAIL);
+
+        // check the regular message
+        assertPresent("javadoc: error - Cannot find doclet class NonExistentDoclet",
+                tr.getOutputLines(Task.OutputKind.DIRECT));
+
+        // check that first line of the stack trace is present
+        assertPresent("java.lang.ClassNotFoundException: NonExistentDoclet",
+                tr.getOutputLines(Task.OutputKind.STDERR));
+
+    }
+
+    @Test
+    public void testApiModeMissingDoclet() throws Exception {
+        apiTask.options("-doclet", "MissingDoclet");
+        try {
+            Task.Result result = apiTask.run(Task.Expect.FAIL);
+        } catch (IllegalArgumentException iae) {
+            // ok got the right exception
+            return;
+        }
+        throw new Exception("expected exception/error not found");
+    }
+
+    @Test
+    public void testApiModeMultipleDoclets() throws Exception {
+        apiTask.options("-doclet", "MissingDoclet",
+                "-doclet", "SomeDoclet");
+        try {
+            Task.Result result = apiTask.run(Task.Expect.FAIL);
+        } catch (IllegalArgumentException iae) {
+            // ok got the right exception
+            return;
+        }
+        throw new Exception("expected exception/error not found");
+    }
+
+    void assertPresent(String regex, List<String> output) throws Exception {
+        List<String> gresult = tb.grep(regex, output);
+        if (gresult.isEmpty()) {
+            ostream.println("Expected: " + regex);
+            ostream.println("Output: ");
+            output.forEach(s -> {
+                ostream.println(s);
+            });
+            throw new Exception("Test fails expected output not found: " + regex);
+        }
+    }
+}
--- a/langtools/test/jdk/javadoc/tool/modules/FilterOptions.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/FilterOptions.java	Tue Oct 18 17:14:09 2016 +0000
@@ -70,7 +70,7 @@
     @Test
     public void testModuleModeApi(Path base) throws Exception {
         execTask("--module-source-path", src,
-                "--module", "m1", "--show-module-contents:api");
+                "--module", "m1", "--show-module-contents", "api");
 
         checkModuleMode("API");
     }
@@ -78,7 +78,7 @@
     @Test
     public void testModuleModeAll(Path base) throws Exception {
         execTask("--module-source-path", src,
-                "--module", "m1", "--show-module-contents:all");
+                "--module", "m1", "--show-module-contents", "all");
 
         checkModuleMode("ALL");
     }
@@ -87,7 +87,7 @@
     public void testShowPackagesExported(Path base)  throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-packages:exported"); // default
+                "--show-packages", "exported"); // default
 
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
@@ -99,7 +99,7 @@
     public void testShowPackagesAll(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-packages:all");
+                "--show-packages", "all");
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
         checkPackagesIncluded("pub", "pro");
@@ -112,7 +112,7 @@
     public void testShowTypesPrivate(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-types:private");
+                "--show-types", "private");
 
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
@@ -129,7 +129,7 @@
     public void testShowTypesPackage(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-types:package");
+                "--show-types", "package");
 
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
@@ -145,7 +145,7 @@
     public void testShowTypesProtected(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-types:protected");
+                "--show-types", "protected");
 
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
@@ -162,7 +162,7 @@
     public void testShowTypesPublic(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-types:public");
+                "--show-types", "public");
 
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
@@ -179,7 +179,7 @@
     public void testShowMembersPrivate(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-members:private");
+                "--show-members", "private");
 
         checkMembers(Visibility.PRIVATE);
     }
@@ -188,7 +188,7 @@
     public void testShowMembersPackage(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-members:package");
+                "--show-members", "package");
 
         checkMembers(Visibility.PACKAGE);
     }
@@ -197,7 +197,7 @@
     public void testShowMembersProtected(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-members:protected");
+                "--show-members", "protected");
 
         checkMembers(Visibility.PROTECTED);
     }
@@ -206,7 +206,7 @@
     public void testShowMembersPublic(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-members:public");
+                "--show-members", "public");
 
         checkMembers(Visibility.PUBLIC);
     }
--- a/langtools/test/jdk/javadoc/tool/modules/Modules.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/Modules.java	Tue Oct 18 17:14:09 2016 +0000
@@ -440,7 +440,7 @@
 
         execTask("--module-source-path", src.toString(),
                 "--module", "M",
-                "--expand-requires:public");
+                "--expand-requires", "public");
 
         checkModulesSpecified("M", "N", "O");
         checkModulesIncluded("M", "N", "O");
@@ -465,7 +465,7 @@
 
         execTask("--module-source-path", src.toString(),
                 "--module", "M",
-                "--expand-requires:all");
+                "--expand-requires", "all");
 
         checkModulesSpecified("M", "java.base", "N", "L", "O");
         checkModulesIncluded("M", "java.base", "N", "L", "O");
@@ -493,7 +493,7 @@
 
         execNegativeTask("--module-source-path", src.toString(),
                 "--module", "MIA",
-                "--expand-requires:all");
+                "--expand-requires", "all");
 
         assertErrorPresent("javadoc: error - module MIA not found.");
     }
@@ -515,7 +515,7 @@
 
         execNegativeTask("--module-source-path", src.toString(),
                 "--module", "M,N,L,MIA,O,P",
-                "--expand-requires:all");
+                "--expand-requires", "all");
 
         assertErrorPresent("javadoc: error - module MIA not found");
     }
--- a/langtools/test/jdk/jshell/CompletenessTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/jshell/CompletenessTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8149524 8131024 8165211 8080071 8130454
+ * @bug 8149524 8131024 8165211 8080071 8130454 8167343
  * @summary Test SourceCodeAnalysis
  * @build KullaTesting TestingInputStream
  * @run testng CompletenessTest
@@ -117,6 +117,7 @@
         "bar: g()",
         "baz: while (true) if (t()) printf('-'); else break baz",
         "java.util.function.IntFunction<int[]> ggg = int[]::new",
+        "List<? extends Object> l",
     };
 
     static final String[] considered_incomplete = new String[] {
@@ -162,7 +163,19 @@
         "enum TK { EOF(TokenKind.EOF, 0),",
         "enum TK { EOF(TokenKind.EOF, 0), NEW_MIDDLE(XEXPR1|XTERM)",
         "enum TK { EOF(TokenKind.EOF, 0), NEW_MIDDLE(XEXPR1|XTERM); ",
-        "enum Tt { FOO, BAR, BAZ,;"
+        "enum Tt { FOO, BAR, BAZ,;",
+        "class C",
+        "class C extends D",
+        "class C implements D",
+        "class C implements D, E",
+        "interface I extends D",
+        "interface I extends D, E",
+        "enum E",
+        "enum E implements I1",
+        "enum E implements I1, I2",
+        "@interface Anno",
+        "void f()",
+        "void f() throws E",
     };
 
     static final String[] unknown = new String[] {
--- a/langtools/test/jdk/jshell/HistoryTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/jshell/HistoryTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8166744
  * @summary Test Completion
  * @modules jdk.internal.le/jdk.internal.jline.extra
  *          jdk.jshell/jdk.internal.jshell.tool
@@ -75,6 +76,44 @@
              });
     }
 
+    public void test8166744() {
+        test(
+             a -> {if (!a) setCommandInput("class C {\n");},
+             a -> {if (!a) setCommandInput("void f() {\n");},
+             a -> {if (!a) setCommandInput("}\n");},
+             a -> {assertCommand(a, "}", "|  created class C");},
+             a -> {
+                 if (!a) {
+                     try {
+                         previousAndAssert(getHistory(), "}");
+                         previousAndAssert(getHistory(), "}");
+                         previousAndAssert(getHistory(), "void f() {");
+                         previousAndAssert(getHistory(), "class C {");
+                         getHistory().add("class C{");
+                     } catch (Exception ex) {
+                         throw new IllegalStateException(ex);
+                     }
+                 }
+                 assertCommand(a, "int dummy;", "dummy ==> 0");
+             });
+        test(
+             a -> {if (!a) setCommandInput("class C {\n");},
+             a -> {if (!a) setCommandInput("void f() {\n");},
+             a -> {if (!a) setCommandInput("}\n");},
+             a -> {assertCommand(a, "}", "|  created class C");},
+             a -> {
+                 if (!a) {
+                     try {
+                         previousSnippetAndAssert(getHistory(), "class C {");
+                         getHistory().add("class C{");
+                     } catch (Exception ex) {
+                         throw new IllegalStateException(ex);
+                     }
+                 }
+                 assertCommand(a, "int dummy;", "dummy ==> 0");
+             });
+    }
+
     private EditingHistory getHistory() throws Exception {
         Field input = repl.getClass().getDeclaredField("input");
         input.setAccessible(true);
--- a/langtools/test/jdk/jshell/ToolBasicTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347
+ * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714
  * @summary Tests for Basic tests for REPL tool
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -574,4 +574,20 @@
         }
     }
 
+    public void testAddExports() {
+        test(false, new String[]{"--no-startup"},
+                a -> assertCommandOutputStartsWith(a, "import jdk.internal.misc.VM;", "|  Error:")
+        );
+        test(false, new String[]{"--no-startup",
+            "-R--add-exports", "-Rjava.base/jdk.internal.misc=ALL-UNNAMED",
+            "-C--add-exports", "-Cjava.base/jdk.internal.misc=ALL-UNNAMED"},
+                a -> assertImport(a, "import jdk.internal.misc.VM;", "", "jdk.internal.misc.VM"),
+                a -> assertCommand(a, "System.err.println(VM.isBooted())", "", "", null, "", "true\n")
+        );
+        test(false, new String[]{"--no-startup", "--add-exports", "java.base/jdk.internal.misc"},
+                a -> assertImport(a, "import jdk.internal.misc.VM;", "", "jdk.internal.misc.VM"),
+                a -> assertCommand(a, "System.err.println(VM.isBooted())", "", "", null, "", "true\n")
+        );
+    }
+
 }
--- a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java	Tue Oct 18 17:14:09 2016 +0000
@@ -118,6 +118,8 @@
                 "loadMethod");
         ignore("com/sun/tools/javac/util/JDK9Wrappers$VMHelper",
                 "vmClass", "getRuntimeArgumentsMethod");
+        ignore("com/sun/tools/javac/util/JDK9Wrappers$JmodFile",
+                "jmodFileClass", "checkMagicMethod");
     }
 
     private final List<String> errors = new ArrayList<>();
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt	Tue Oct 18 17:14:09 2016 +0000
@@ -66,6 +66,7 @@
 compiler.misc.kindname.type.variable.bound
 compiler.misc.kindname.value
 compiler.misc.incompatible.eq.lower.bounds              # cannot happen?
+compiler.misc.module.name.mismatch
 compiler.misc.no.unique.minimal.instance.exists
 compiler.misc.no.unique.maximal.instance.exists         # cannot happen?
 compiler.misc.resume.abort                              # prompt for a response
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessible/LeaksNotAccessible.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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.warn.leaks.not.accessible
+// options: -Xlint:exports
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessible/modulesourcepath/m1/api/Api.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,32 @@
+/*
+ * 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 Impl getImpl() {
+         return null;
+     }
+}
+
+class Impl {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessible/modulesourcepath/m1/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 m1 {
+     exports api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleNotRequiredPublic/LeaksNotAccessibleNotRequiredPublic.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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.warn.leaks.not.accessible.not.required.public
+// options: -Xlint:exports
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleNotRequiredPublic/modulesourcepath/m1/api1/Api1.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 api1;
+
+public class Api1 {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleNotRequiredPublic/modulesourcepath/m1/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 m1 {
+     exports api1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleNotRequiredPublic/modulesourcepath/m2/api2/Api2.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 api2;
+
+public class Api2 {
+     public api1.Api1 getApi1() {
+         return null;
+     }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleNotRequiredPublic/modulesourcepath/m2/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 m2 {
+     requires m1;
+     exports api2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexported/LeaksNotAccessibleUnexported.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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.warn.leaks.not.accessible.unexported
+// options: -Xlint:exports
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexported/modulesourcepath/m1/api/Api.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 api;
+
+public class Api {
+     public impl.Impl getImpl() {
+         return null;
+     }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexported/modulesourcepath/m1/impl/Impl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 impl;
+
+public class Impl {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexported/modulesourcepath/m1/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 m1 {
+     exports api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexportedQualified/LeaksNotAccessibleUnexportedQualified.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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.warn.leaks.not.accessible.unexported.qualified
+// options: -Xlint:exports
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexportedQualified/modulesourcepath/m1/api/Api.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 api;
+
+public class Api {
+     public qapi.QApi get() {
+         return null;
+     }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexportedQualified/modulesourcepath/m1/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 m1 {
+     exports api;
+     exports qapi to m2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexportedQualified/modulesourcepath/m1/qapi/QApi.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 qapi;
+
+public class QApi {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LeaksNotAccessibleUnexportedQualified/modulesourcepath/m2/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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 m2 {
+     requires m1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/bridges/ReorderedBoundsTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8166363
+ * @summary Method with reordered type parameter bounds compiles with Override annotation but does not actually override superclass method.
+ * @run main ReorderedBoundsTest
+ */
+
+import java.io.Serializable;
+
+public class ReorderedBoundsTest {
+  public static class Parent {
+    public <T extends Appendable & Serializable> String printClassName(T t) {
+      return "Parent";
+    }
+  }
+
+  public static class OrderedChild extends Parent {
+    @Override
+    public <T extends Appendable & Serializable> String printClassName(T t) {
+      return "OrderedChild";
+    }
+  }
+
+  public static class ReorderedChild extends Parent {
+    @Override
+    public <T extends Serializable & Appendable> String printClassName(T t) {
+      return "ReorderedChild";
+    }
+  }
+
+  public static void main(String[] args) {
+
+    String s;
+    Parent p = new OrderedChild();
+    if (!(s = p.printClassName(new StringBuilder())).equals("OrderedChild"))
+        throw new AssertionError("Bad output: " + s);
+
+    p = new ReorderedChild();
+    if (!(s = p.printClassName(new StringBuilder())).equals("ReorderedChild"))
+        throw new AssertionError("Bad output: " + s);
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/main/AtFileTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,112 @@
+/*
+ * 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 8166472 8162810
+ * @summary Align javac support for at-files with launcher support
+ * @modules jdk.compiler/com.sun.tools.javac.main
+ */
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.sun.tools.javac.main.CommandLine.Tokenizer;
+
+public class AtFileTest {
+
+    public static void main(String... args) throws IOException {
+        AtFileTest t = new AtFileTest();
+        if (args.length > 0) {
+            System.out.println(String.join(" ", args));
+        } else {
+            t.run();
+        }
+    }
+
+    void run() throws IOException {
+        test("-version -cp \"c:\\\\java libs\\\\one.jar\" \n",
+                "-version", "-cp", "c:\\java libs\\one.jar");
+
+        // note the open quote at the end
+        test("com.foo.Panda \"Furious 5\"\fand\t'Shi Fu' \"escape\tprison",
+                "com.foo.Panda", "Furious 5", "and", "Shi Fu", "escape\tprison");
+
+        test("escaped chars testing \"\\a\\b\\c\\f\\n\\r\\t\\v\\9\\6\\23\\82\\28\\377\\477\\278\\287\"",
+                "escaped", "chars", "testing", "abc\f\n\r\tv96238228377477278287");
+
+        test("\"mix 'single quote' in double\" 'mix \"double quote\" in single' partial\"quote me\"this",
+                "mix 'single quote' in double", "mix \"double quote\" in single", "partialquote methis");
+
+        test("line one #comment\n'line #2' #rest are comment\r\n#comment on line 3\nline 4 #comment to eof",
+                "line", "one", "line #2", "line", "4");
+
+        test("This is an \"open quote \n    across line\n\t, note for WS.",
+                "This", "is", "an", "open quote ", "across", "line", ",", "note", "for", "WS.");
+
+        test("Try \"this \\\\\\\\ escape\\n double quote \\\" in open quote",
+                "Try", "this \\\\ escape\n double quote \" in open quote");
+
+        test("'-Dmy.quote.single'='Property in single quote. Here a double quote\" Add some slashes \\\\/'",
+                "-Dmy.quote.single=Property in single quote. Here a double quote\" Add some slashes \\/");
+
+        test("\"Open quote to \n  new \"line \\\n\r   third\\\n\r\\\tand\ffourth\"",
+                "Open quote to ", "new", "line third\tand\ffourth");
+
+        test("c:\\\"partial quote\"\\lib",
+                "c:\\partial quote\\lib");
+    }
+
+    void test(String full, String... expect) throws IOException {
+        System.out.println("test: >>>" + full + "<<<");
+        List<String> found = expand(full);
+        if (found.equals(Arrays.asList(expect))) {
+            System.out.println("OK");
+        } else {
+            for (int i = 0; i < Math.max(found.size(), expect.length); i++) {
+                if (i < found.size()) {
+                    System.out.println("found[" + i + "]:  >>>" + found.get(i) + "<<<");
+                }
+                if (i < expect.length) {
+                    System.out.println("expect[" + i + "]: >>>" + expect[i] + "<<<");
+                }
+            }
+        }
+        System.out.println();
+    }
+
+    List<String> expand(String full) throws IOException {
+        Tokenizer t = new Tokenizer(new StringReader(full));
+        List<String> result = new ArrayList<>();
+        String s;
+        while ((s = t.nextToken()) != null) {
+//            System.err.println("token: " + s);
+            result.add(s);
+        }
+        return result;
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/main/ToolProviderTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,132 @@
+/*
+ * 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 8159855
+ * @summary test javac's ToolProvider
+ * @library /tools/lib
+ * @build toolbox.TestRunner toolbox.ToolBox
+ * @run main ToolProviderTest
+ */
+
+import java.io.*;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.spi.ToolProvider;
+
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+public class ToolProviderTest extends TestRunner {
+    public static void main(String... args) throws Exception {
+        new ToolProviderTest().runTests();
+    }
+
+    ToolBox tb = new ToolBox();
+    ToolProvider javac;
+
+    ToolProviderTest() {
+        super(System.err);
+        javac = ToolProvider.findFirst("javac").get();
+    }
+
+    @Test
+    public void testProviders() throws Exception {
+        Map<String, ToolProvider> providers = new LinkedHashMap<>();
+        for (ToolProvider tp : ServiceLoader.load(ToolProvider.class,
+                ClassLoader.getSystemClassLoader())) {
+            System.out.println("Provider: " + tp.name() + ": " + tp.getClass().getName());
+            providers.put(tp.name(), tp);
+        }
+        if (!providers.containsKey("javac")) {
+            error("javac ToolProvider not found");
+        }
+    }
+
+    @Test
+    public void testOneStream() throws Exception {
+        StringWriter sw = new StringWriter();
+        try (PrintWriter pw = new PrintWriter(sw)) {
+            int rc = javac.run(pw, pw, "-help");
+            if (rc != 0) {
+                error("unexpected exit code: " + rc);
+            }
+        }
+        String out = sw.toString();
+        if (!out.contains("Usage:")) {
+            error("expected output not found");
+        }
+    }
+
+    @Test
+    public void testTwoStreamsOut() throws Exception {
+        StringWriter swOut = new StringWriter();
+        StringWriter swErr = new StringWriter();
+        try (PrintWriter pwOut = new PrintWriter(swOut);
+                PrintWriter pwErr = new PrintWriter(swErr)) {
+            int rc = javac.run(pwOut, pwErr, "-help");
+            if (rc != 0) {
+                error("unexpected exit code: " + rc);
+            }
+        }
+        String out = swOut.toString();
+        String err = swErr.toString();
+        if (!out.contains("Usage:")) {
+            error("stdout: expected output not found");
+        }
+        if (!err.isEmpty()) {
+            error("stderr: unexpected output");
+        }
+    }
+
+    @Test
+    public void testTwoStreamsErr() throws Exception {
+        Path src = Paths.get("src");
+        Path classes = Paths.get("classes");
+        tb.writeJavaFiles(src,
+            "import java.util.*; class C { # }");
+
+        StringWriter swOut = new StringWriter();
+        StringWriter swErr = new StringWriter();
+        try (PrintWriter pwOut = new PrintWriter(swOut);
+                PrintWriter pwErr = new PrintWriter(swErr)) {
+            int rc = javac.run(pwOut, pwErr,
+                "-d", classes.toString(),
+                src.resolve("C.java").toString());
+            if (rc != 1) {
+                error("unexpected exit code: " + rc);
+            }
+        }
+
+        String out = swOut.toString();
+        String err = swErr.toString();
+        if (!out.isEmpty()) {
+            error("stdout: unexpected output");
+        }
+        if (!err.contains("illegal character")) {
+            error("stderr: expected output not found");
+        }
+    }
+}
--- a/langtools/test/tools/javac/modules/AddLimitMods.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/javac/modules/AddLimitMods.java	Tue Oct 18 17:14:09 2016 +0000
@@ -345,6 +345,7 @@
 
         Files.createDirectories(classpathOut);
 
+        System.err.println("Compiling classpath-src files:");
         new JavacTask(tb)
                 .outdir(classpathOut)
                 .files(findJavaFiles(classpathSrc))
@@ -360,6 +361,7 @@
 
         Files.createDirectories(automaticOut);
 
+        System.err.println("Compiling automatic-src files:");
         new JavacTask(tb)
                 .outdir(automaticOut)
                 .files(findJavaFiles(automaticSrc))
@@ -373,6 +375,7 @@
 
         Path automaticJar = modulePath.resolve("automatic.jar");
 
+        System.err.println("Creating automatic.jar:");
         new JarTask(tb, automaticJar)
           .baseDir(automaticOut)
           .files("automatic/Automatic.class")
@@ -385,6 +388,7 @@
                           "module m1 { exports api; }",
                           "package api; public class Api { public void test() { } }");
 
+        System.err.println("Compiling module-src files:");
         new JavacTask(tb)
                 .options("--module-source-path", moduleSrc.toString())
                 .outdir(modulePath)
@@ -399,7 +403,7 @@
             for (String[] options : OPTIONS_VARIANTS) {
                 index++;
 
-                System.err.println("running check: " + moduleInfo + "; " + Arrays.asList(options));
+                System.err.println("Running check: " + moduleInfo + "; " + Arrays.asList(options));
 
                 Path m2Runtime = base.resolve(index + "-runtime").resolve("m2");
                 Path out = base.resolve(index + "-runtime").resolve("out").resolve("m2");
@@ -427,6 +431,7 @@
 
                 tb.writeJavaFiles(m2Runtime, moduleInfo, testClassNamed.toString());
 
+                System.err.println("Compiling " + m2Runtime + " files:");
                 new JavacTask(tb)
                    .options("--module-path", modulePath.toString())
                    .outdir(out)
@@ -438,6 +443,7 @@
                 String output;
 
                 try {
+                    System.err.println("Running m2/test.Test:");
                     output = new JavaTask(tb)
                        .vmOptions(augmentOptions(options,
                                                  Collections.emptyList(),
@@ -468,6 +474,8 @@
                     "-Aoutput=" + output,
                     "-XDaccessInternalAPI=true"
                 ) : Collections.emptyList();
+
+                System.err.println("Compiling/processing m2 files:");
                 new JavacTask(tb)
                    .options(augmentOptions(options,
                                            auxOptions,
@@ -510,8 +518,6 @@
         MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("m1", "api.Api");
         MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("m2", "test.Test");
         MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("java.base", "java.lang.Object");
-        MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("java.compiler", "javax.tools.ToolProvider");
-        MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("jdk.compiler", "com.sun.tools.javac.Main");
     };
 
     @SupportedAnnotationTypes("*")
@@ -573,8 +579,7 @@
 
     private static final String[] MODULE_INFO_VARIANTS = {
         "module m2 { exports test; }",
-        "module m2 { requires m1; exports test; }",
-        "module m2 { requires jdk.compiler; exports test; }",
+        "module m2 { requires m1; exports test; }"
     };
 
     private static final String[][] OPTIONS_VARIANTS = {
--- a/langtools/test/tools/javac/modules/EdgeCases.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/javac/modules/EdgeCases.java	Tue Oct 18 17:14:09 2016 +0000
@@ -58,6 +58,8 @@
 import toolbox.JarTask;
 import toolbox.JavacTask;
 import toolbox.Task;
+import toolbox.Task.Expect;
+import toolbox.Task.OutputKind;
 
 public class EdgeCases extends ModuleTestBase {
 
@@ -304,4 +306,147 @@
         }
     }
 
+    @Test
+    public void testImplicitJavaBase(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_java_base = src.resolve("java.base");
+        Files.createDirectories(src_java_base);
+        tb.writeJavaFiles(src_java_base, "module java.base { exports java.lang; }");
+        tb.writeJavaFiles(src_java_base,
+                          "package java.lang; public class Object {}");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        //module-info from source:
+        new JavacTask(tb)
+            .options("-sourcepath", src_java_base.toString())
+            .outdir(classes)
+            .files(findJavaFiles(src_java_base.resolve("java").resolve("lang").resolve("Object.java")))
+            .run()
+            .writeAll();
+
+        //module-info from class:
+        if (!Files.exists(classes.resolve("module-info.class"))) {
+            throw new AssertionError("module-info.class not created!");
+        }
+
+        new JavacTask(tb)
+            .outdir(classes)
+            .files(findJavaFiles(src_java_base.resolve("java").resolve("lang").resolve("Object.java")))
+            .run()
+            .writeAll();
+
+        //broken module-info.class:
+        Files.newOutputStream(classes.resolve("module-info.class")).close();
+
+        List<String> log = new JavacTask(tb)
+            .options("-XDrawDiagnostics")
+            .outdir(classes)
+            .files(findJavaFiles(src_java_base.resolve("java").resolve("lang").resolve("Object.java")))
+            .run(Expect.FAIL)
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "- compiler.err.cant.access: <error>.module-info, (compiler.misc.bad.class.file.header: module-info.class, (compiler.misc.illegal.start.of.class.file))",
+                "1 error");
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+
+        //broken module-info.java:
+        Files.delete(classes.resolve("module-info.class"));
+
+        try (Writer out = Files.newBufferedWriter(src_java_base.resolve("module-info.java"))) {
+            out.write("class Broken {}");
+        }
+
+        log = new JavacTask(tb)
+            .options("-sourcepath", src_java_base.toString(),
+                                "-XDrawDiagnostics")
+            .outdir(classes)
+            .files(findJavaFiles(src_java_base.resolve("java").resolve("lang").resolve("Object.java")))
+            .run(Expect.FAIL)
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        expected = Arrays.asList("X");
+
+        if (expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+
+    @Test
+    public void testModuleInfoNameMismatchSource(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m1 = src.resolve("m1");
+        Files.createDirectories(m1);
+        tb.writeJavaFiles(m1, "module other { }",
+                              "package test; public class Test {}");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+            .options("--module-source-path", src.toString(),
+                     "-XDrawDiagnostics")
+            .outdir(classes)
+            .files(findJavaFiles(m1.resolve("test").resolve("Test.java")))
+            .run(Expect.FAIL)
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "module-info.java:1:1: compiler.err.module.name.mismatch: other, m1",
+                "- compiler.err.cant.access: m1.module-info, (compiler.misc.cant.resolve.modules)",
+                "2 errors");
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+
+    @Test
+    public void testModuleInfoNameMismatchClass(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Files.createDirectories(src);
+        tb.writeJavaFiles(src, "module other { }",
+                               "package test; public class Test {}");
+        Path classes = base.resolve("classes");
+        Path m1Classes = classes.resolve("m1");
+        tb.createDirectories(m1Classes);
+
+        new JavacTask(tb)
+            .outdir(m1Classes)
+            .files(findJavaFiles(src))
+            .run()
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        Path src2 = base.resolve("src2");
+        Files.createDirectories(src2);
+        tb.writeJavaFiles(src2, "module use { requires m1; }");
+
+        Path classes2 = base.resolve("classes2");
+        tb.createDirectories(classes2);
+
+        List<String> log = new JavacTask(tb)
+            .options("--module-path", classes.toString(),
+                     "-XDrawDiagnostics")
+            .outdir(classes2)
+            .files(findJavaFiles(src2))
+            .run(Expect.FAIL)
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "- compiler.err.cant.access: m1.module-info, (compiler.misc.bad.class.file.header: module-info.class, (compiler.misc.module.name.mismatch: other, m1))",
+                "1 error");
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/ExportsUnexported.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,375 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary tests for module declarations
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
+ * @run main ExportsUnexported
+ */
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+
+public class ExportsUnexported extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        ExportsUnexported t = new ExportsUnexported();
+        t.runTests();
+    }
+
+    @Test
+    public void testLocations(Path base) throws Exception {
+        String warningsTest = "package api;\n" +
+                      "import impl.impl.*;\n" +
+                      "@impl.impl^.DocAnn\n" +
+                      "public abstract class Api<T extends impl.impl^.Cls&impl.impl^.Intf> extends impl.impl^.Cls implements impl.impl^.Intf, impl.impl^.NonDocAnn, impl.impl^.DocAnn {\n" +
+                      "    public static <E extends impl.impl^.Cls&impl.impl^.Intf> impl.impl^.Cls m(impl.impl^.Intf i, impl.impl^.Cls c) throws impl.impl^.Exc { return null; }\n" +
+                      "    public static impl.impl^.Cls f;\n" +
+                      "}";
+        String noWarningsTest = "package api;\n" +
+                      "import impl.impl.*;\n" +
+                      "@impl.impl.NonDocAnn\n" +
+                      "public abstract class Api {\n" +
+                      "    private static abstract class I <T extends impl.impl.Cls&impl.impl.Intf> extends impl.impl.Cls implements impl.impl.Intf, impl.impl.NonDocAnn, impl.impl.DocAnn {\n" +
+                      "        public static abstract class II <T extends impl.impl.Cls&impl.impl.Intf> extends impl.impl.Cls implements impl.impl.Intf, impl.impl.NonDocAnn, impl.impl.DocAnn { }\n" +
+                      "        public static <E extends impl.impl.Cls&impl.impl.Intf> impl.impl.Cls m(impl.impl.Intf i, impl.impl.Cls c) throws impl.impl.Exc { return null; }\n" +
+                      "        public static impl.impl.Cls f;\n" +
+                      "    }\n" +
+                      "    private static <E extends impl.impl.Cls&impl.impl.Intf> impl.impl.Cls m(impl.impl.Intf i, impl.impl.Cls c) throws impl.impl.Exc { return null; }\n" +
+                      "    private static impl.impl.Cls f1;\n" +
+                      "    public static void m() { new impl.impl.Cls(); }\n" +
+                      "    public static Object f2 = new impl.impl.Cls();\n" +
+                      "}";
+        for (String genericTest : new String[] {warningsTest, noWarningsTest}) {
+            for (String test : new String[] {genericTest, genericTest.replaceAll("impl\\.impl\\^.([A-Za-z])", "^$1").replaceAll("impl\\.impl\\.([A-Za-z])", "$1")}) {
+                System.err.println("testing: " + test);
+
+                Path src = base.resolve("src");
+                Path src_m1 = src.resolve("m1");
+                StringBuilder testCode = new StringBuilder();
+                List<String> expectedLog = new ArrayList<>();
+                int line = 1;
+                int col  = 1;
+
+                for (int i = 0; i < test.length(); i++) {
+                    char c = test.charAt(i);
+
+                    if (c == '^') {
+                        StringBuilder typeName = new StringBuilder();
+                        for (int j = i + 1 + (test.charAt(i + 1) == '.' ? 1 : 0);
+                             j < test.length() && Character.isJavaIdentifierPart(test.charAt(j));
+                             j++) {
+                            typeName.append(test.charAt(j));
+                        }
+                        String kindName;
+                        switch (typeName.toString()) {
+                            case "Exc": case "DocAnn": case "NonDocAnn":
+                            case "Cls": kindName = "kindname.class"; break;
+                            case "Intf": kindName = "kindname.interface"; break;
+                            default:
+                                throw new AssertionError(typeName.toString());
+                        }
+                        expectedLog.add("Api.java:" + line + ":" + col + ": compiler.warn.leaks.not.accessible.unexported: " + kindName + ", impl.impl." + typeName + ", m1");
+                        continue;
+                    }
+
+                    if (c == '\n') {
+                        line++;
+                        col = 0;
+                    }
+
+                    testCode.append(c);
+                    col++;
+                }
+
+                if (!expectedLog.isEmpty()) {
+                    expectedLog.add("" + expectedLog.size() + " warning" + (expectedLog.size() == 1 ? "" : "s"));
+                    expectedLog.add("- compiler.err.warnings.and.werror");
+                    expectedLog.add("1 error");
+                }
+
+                Collections.sort(expectedLog);
+
+                tb.writeJavaFiles(src_m1,
+                                  "module m1 { exports api; }",
+                                  testCode.toString(),
+                                  "package impl.impl; public class Cls { }",
+                                  "package impl.impl; public class Exc extends Exception { }",
+                                  "package impl.impl; public interface Intf { }",
+                                  "package impl.impl; @java.lang.annotation.Documented public @interface DocAnn { }",
+                                  "package impl.impl; public @interface NonDocAnn { }");
+                Path classes = base.resolve("classes");
+                tb.createDirectories(classes);
+
+                List<String> log = new JavacTask(tb)
+                        .options("-XDrawDiagnostics",
+                                 "-Werror",
+                                 "--module-source-path", src.toString(),
+                                 "-Xlint:exports")
+                        .outdir(classes)
+                        .files(findJavaFiles(src))
+                        .run(expectedLog.isEmpty() ? Task.Expect.SUCCESS : Task.Expect.FAIL)
+                        .writeAll()
+                        .getOutputLines(Task.OutputKind.DIRECT);
+
+                log = new ArrayList<>(log);
+                Collections.sort(log);
+
+                if (expectedLog.isEmpty() ? !log.equals(Arrays.asList("")) : !log.equals(expectedLog)) {
+                    throw new Exception("expected output not found in: " + log + "; " + expectedLog);
+                }
+            }
+        }
+    }
+
+    @Test
+    public void testAccessibleToSpecificOrAll(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_lib1 = src.resolve("lib1");
+        tb.writeJavaFiles(src_lib1,
+                          "module lib1 { exports lib1; }",
+                          "package lib1; public class Lib1 {}");
+        Path src_lib2 = src.resolve("lib2");
+        tb.writeJavaFiles(src_lib2,
+                          "module lib2 { exports lib2; }",
+                          "package lib2; public class Lib2 {}");
+        Path src_api = src.resolve("api");
+        tb.writeJavaFiles(src_api,
+                          "module api {\n" +
+                          "    exports api;\n" +
+                          "    exports qapi1 to qual1;\n" +
+                          "    exports qapi2 to qual1, qual2;\n" +
+                          "    requires public lib1;\n" +
+                          "    requires lib2;\n" +
+                          "}\n",
+                          "package api;\n" +
+                          "public class Api {\n" +
+                          "    public lib1.Lib1 lib1;\n" +
+                          "    public lib2.Lib2 lib2;\n" +
+                          "    public qapi1.QApi1 qapi1;\n" +
+                          "    public impl.Impl impl;\n" +
+                          "}",
+                          "package qapi1;\n" +
+                          "public class QApi1 {\n" +
+                          "    public qapi2.QApi2 qapi2;\n" +
+                          "}",
+                          "package qapi2;\n" +
+                          "public class QApi2 {\n" +
+                          "    public qapi1.QApi1 qapi1;\n" +
+                          "}",
+                          "package impl;\n" +
+                          "public class Impl {\n" +
+                          "}");
+        Path src_qual1 = src.resolve("qual1");
+        tb.writeJavaFiles(src_qual1, "module qual1 { }");
+        Path src_qual2 = src.resolve("qual2");
+        tb.writeJavaFiles(src_qual2, "module qual2 { }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "-Werror",
+                         "--module-source-path", src.toString(),
+                         "-Xlint:exports")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+            "Api.java:4:16: compiler.warn.leaks.not.accessible.not.required.public: kindname.class, lib2.Lib2, lib2",
+            "Api.java:5:17: compiler.warn.leaks.not.accessible.unexported.qualified: kindname.class, qapi1.QApi1, api",
+            "Api.java:6:16: compiler.warn.leaks.not.accessible.unexported: kindname.class, impl.Impl, api",
+            "- compiler.err.warnings.and.werror",
+            "1 error",
+            "3 warnings"
+        );
+
+        if (!log.equals(expected))
+            throw new Exception("expected output not found");
+    }
+
+    @Test
+    public void testNestedClasses(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_api = src.resolve("api");
+        tb.writeJavaFiles(src_api,
+                          "module api {\n" +
+                          "    exports api;\n" +
+                          "}\n",
+                          "package api;\n" +
+                          "import impl.Impl.Nested;\n" +
+                          "public class Api {\n" +
+                          "    public impl.Impl impl1;\n" +
+                          "    public impl.Impl.Nested impl2;\n" +
+                          "    public Nested impl3;\n" +
+                          "}",
+                          "package impl;\n" +
+                          "public class Impl {\n" +
+                          "    public static class Nested {\n" +
+                          "    }\n" +
+                          "}");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "-Werror",
+                         "--module-source-path", src.toString(),
+                         "-Xlint:exports")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+            "Api.java:4:16: compiler.warn.leaks.not.accessible.unexported: kindname.class, impl.Impl, api",
+            "Api.java:5:16: compiler.warn.leaks.not.accessible.unexported: kindname.class, impl.Impl, api",
+            "Api.java:6:12: compiler.warn.leaks.not.accessible.unexported: kindname.class, impl.Impl.Nested, api",
+            "- compiler.err.warnings.and.werror",
+            "1 error",
+            "3 warnings"
+        );
+
+        if (!log.equals(expected))
+            throw new Exception("expected output not found");
+    }
+
+    @Test
+    public void testProtectedAndInaccessible(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_api = src.resolve("api");
+        tb.writeJavaFiles(src_api,
+                          "module api {\n" +
+                          "    exports api;\n" +
+                          "}\n",
+                          "package api;\n" +
+                          "public class Api extends PackagePrivateClass<PackagePrivateInterface> implements PackagePrivateInterface<PackagePrivateClass> {\n" +
+                          "    protected PackagePrivateClass<?> f1;\n" +
+                          "    protected PackagePrivateInterface<?> f2;\n" +
+                          "    protected Inner f3;\n" +
+                          "    protected PrivateInner f4;\n" +
+                          "    protected impl.Impl f5;\n" +
+                          "    public static class InnerClass extends PrivateInner {}\n" +
+                          "    protected static class Inner {}\n" +
+                          "    private static class PrivateInner {}\n" +
+                          "}\n" +
+                          "class PackagePrivateClass<T> {}\n" +
+                          "interface PackagePrivateInterface<T> {}",
+                          "package impl;\n" +
+                          "public class Impl {\n" +
+                          "}");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "-Werror",
+                         "--module-source-path", src.toString(),
+                         "-Xlint:exports")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+            "Api.java:2:46: compiler.warn.leaks.not.accessible: kindname.interface, api.PackagePrivateInterface, api",
+            "Api.java:2:106: compiler.warn.leaks.not.accessible: kindname.class, api.PackagePrivateClass, api",
+            "Api.java:3:15: compiler.warn.leaks.not.accessible: kindname.class, api.PackagePrivateClass, api",
+            "Api.java:4:15: compiler.warn.leaks.not.accessible: kindname.interface, api.PackagePrivateInterface, api",
+            "Api.java:6:15: compiler.warn.leaks.not.accessible: kindname.class, api.Api.PrivateInner, api",
+            "Api.java:7:19: compiler.warn.leaks.not.accessible.unexported: kindname.class, impl.Impl, api",
+            "- compiler.err.warnings.and.werror",
+            "1 error",
+            "6 warnings"
+        );
+
+        if (!log.equals(expected))
+            throw new Exception("expected output not found");
+    }
+
+    @Test
+    public void testSuppressResetProperly(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_api = src.resolve("api");
+        tb.writeJavaFiles(src_api,
+                          "module api {\n" +
+                          "    exports api;\n" +
+                          "}\n",
+                          "package api;\n" +
+                          "public class Api {\n" +
+                          "    @SuppressWarnings(\"exports\")\n" +
+                          "    public PackagePrivateClass f1;\n" +
+                          "    public PackagePrivateClass f2;\n" +
+                          "    @SuppressWarnings(\"exports\")\n" +
+                          "    public void t() {}\n" +
+                          "    public PackagePrivateClass f3;\n" +
+                          "    @SuppressWarnings(\"exports\")\n" +
+                          "    public static class C {\n" +
+                          "        public PackagePrivateClass f4;\n" +
+                          "    }\n" +
+                          "    public PackagePrivateClass f5;\n" +
+                          "}\n" +
+                          "class PackagePrivateClass<T> {}\n");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "-Werror",
+                         "--module-source-path", src.toString(),
+                         "-Xlint:exports")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+            "Api.java:5:12: compiler.warn.leaks.not.accessible: kindname.class, api.PackagePrivateClass, api",
+            "Api.java:8:12: compiler.warn.leaks.not.accessible: kindname.class, api.PackagePrivateClass, api",
+            "Api.java:13:12: compiler.warn.leaks.not.accessible: kindname.class, api.PackagePrivateClass, api",
+            "- compiler.err.warnings.and.werror",
+            "1 error",
+            "3 warnings"
+        );
+
+        if (!log.equals(expected))
+            throw new Exception("expected output not found");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/StopAfterError/StopAfterError.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,61 @@
+/*
+ * 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 8073844
+ * @summary If an error is produced by an annotation processor, the code should not be Attred, \
+ *          unless requested
+ * @modules jdk.compiler
+ * @compile StopAfterError.java
+ * @compile/fail/ref=StopAfterError.out -XDrawDiagnostics -processor StopAfterError StopAfterErrorAux.java
+ * @compile/fail/ref=StopAfterError.out -XDshould-stop.ifError=PROCESS -XDrawDiagnostics -processor StopAfterError StopAfterErrorAux.java
+ * @compile/fail/ref=StopAfterErrorContinue.out -XDshould-stop.ifError=ATTR -XDrawDiagnostics -processor StopAfterError StopAfterErrorAux.java
+ */
+
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+
+@SupportedAnnotationTypes("*")
+public class StopAfterError extends AbstractProcessor {
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        if (roundEnv.processingOver()) {
+            processingEnv.getMessager().printMessage(Kind.ERROR, "Stop!");
+        }
+        return false;
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latestSupported();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/StopAfterError/StopAfterError.out	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,2 @@
+- compiler.err.proc.messager: Stop!
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/StopAfterError/StopAfterErrorAux.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,6 @@
+/* /nodynamiccopyright/ */
+class StopAfterErrorAux {
+    public void test() {
+        should not; get here;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/StopAfterError/StopAfterErrorContinue.out	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,4 @@
+- compiler.err.proc.messager: Stop!
+StopAfterErrorAux.java:4:9: compiler.err.cant.resolve.location: kindname.class, should, , , (compiler.misc.location: kindname.class, StopAfterErrorAux, null)
+StopAfterErrorAux.java:4:21: compiler.err.cant.resolve.location: kindname.class, get, , , (compiler.misc.location: kindname.class, StopAfterErrorAux, null)
+3 errors
--- a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java	Tue Oct 18 17:14:09 2016 +0000
@@ -74,7 +74,7 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         try (PrintStream out = new PrintStream(baos, false, "UTF-8")) {
             boolean r = Main.call(out, System.err,
-                "-cp", deprcases, "--Xload-dir", deprcases, deprusage);
+                "--class-path", deprcases, "--Xload-dir", deprcases, deprusage);
             assertTrue(r);
         }
         byte[] bytes = baos.toByteArray();
--- a/langtools/test/tools/jdeps/APIDeps.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/jdeps/APIDeps.java	Tue Oct 18 17:14:09 2016 +0000
@@ -135,7 +135,7 @@
                            "java.util.Set",
                            "c.C", "d.D", "c.I", "e.E", "m.Bar"},
              new String[] {"compact1", testDirBasename, mDir.getName()},
-             new String[] {"-classpath", testDir.getPath(), "-verbose", "-P", "-apionly"});
+             new String[] {"-classpath", testDir.getPath(), "-verbose", "-P", "--api-only"});
         return errors;
     }
 
--- a/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,7 +26,7 @@
  * @bug 8153042
  * @summary Tests JDK internal APIs that have been removed.
  * @library ../lib
- * @build CompilerUtils JdepsUtil ModuleMetaData
+ * @build CompilerUtils JdepsRunner JdepsUtil ModuleMetaData
  * @modules jdk.jdeps/com.sun.tools.jdeps
  * @run testng RemovedJDKInternals
  */
@@ -123,7 +123,8 @@
 
     @Test
     public void checkReplacement() {
-        String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.toString());
+        JdepsRunner jdeps = JdepsRunner.run("-jdkinternals", CLASSES_DIR.toString());
+        String[] output = jdeps.output();
         int i = 0;
         while (!output[i].contains("Suggested Replacement")) {
             i++;
--- a/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java	Tue Oct 18 17:14:09 2016 +0000
@@ -70,7 +70,8 @@
     @Test
     public void withReplacement() {
         Path file = Paths.get("q", "WithRepl.class");
-        String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString());
+        JdepsRunner jdeps = JdepsRunner.run("-jdkinternals", CLASSES_DIR.resolve(file).toString());
+        String[] output = jdeps.output();
         int i = 0;
         while (!output[i].contains("Suggested Replacement")) {
             i++;
@@ -99,7 +100,8 @@
     @Test
     public void noReplacement() {
         Path file = Paths.get("q", "NoRepl.class");
-        String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString());
+        JdepsRunner jdeps = JdepsRunner.run("-jdkinternals", CLASSES_DIR.resolve(file).toString());
+        String[] output = jdeps.output();
         int i = 0;
         // expect no replacement
         while (i < output.length && !output[i].contains("Suggested Replacement")) {
@@ -116,7 +118,8 @@
     @Test
     public void removedPackage() {
         Path file = Paths.get("q", "RemovedPackage.class");
-        String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString());
+        JdepsRunner jdeps = JdepsRunner.run("--jdk-internals", CLASSES_DIR.resolve(file).toString());
+        String[] output = jdeps.output();
         int i = 0;
         // expect no replacement
         while (i < output.length && !output[i].contains("Suggested Replacement")) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/jdeps/lib/JdepsRunner.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,88 @@
+/*
+ * 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.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * JdepsRunner class to invoke jdeps with the given command line argument
+ */
+public class JdepsRunner {
+    public static JdepsRunner run(String... args) {
+        JdepsRunner jdeps = new JdepsRunner(args);
+        int rc = jdeps.run();
+        jdeps.printStdout(System.err);
+        if (rc != 0)
+           throw new Error("jdeps failed: rc=" + rc);
+        return jdeps;
+    }
+
+    final StringWriter stdout = new StringWriter();
+    final StringWriter stderr = new StringWriter();
+    final String[] args;
+    public JdepsRunner(String... args) {
+        System.err.println("jdeps " + Arrays.stream(args)
+                                            .collect(Collectors.joining(" ")));
+        this.args = args;
+    }
+
+    public JdepsRunner(List<String> args) {
+        this(args.toArray(new String[0]));
+    }
+
+    public int run() {
+        return run(false);
+    }
+
+    public int run(boolean showOutput) {
+        try (PrintWriter pw = new PrintWriter(stdout)) {
+            int rc = com.sun.tools.jdeps.Main.run(args, pw);
+            if (showOutput) {
+                System.err.println(stdout.toString());
+            }
+            return rc;
+        }
+    }
+
+    public boolean outputContains(String s) {
+        return stdout.toString().contains(s);
+    }
+
+    public void printStdout(PrintStream stream) {
+        stream.println(stdout.toString());
+    }
+
+    public void printStderr(PrintStream stream) {
+        stream.println(stderr.toString());
+    }
+
+    public String[] output() {
+        String lineSep = System.getProperty("line.separator");
+        return stdout.toString().split(lineSep);
+    }
+}
--- a/langtools/test/tools/jdeps/lib/JdepsUtil.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/jdeps/lib/JdepsUtil.java	Tue Oct 18 17:14:09 2016 +0000
@@ -39,37 +39,17 @@
 import java.lang.module.ModuleDescriptor;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
 import java.util.regex.Pattern;
-import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 /**
  * Utilities to run jdeps command
  */
 public final class JdepsUtil {
-    /*
-     * Runs jdeps with the given arguments
-     */
-    public static String[] jdeps(String... args) {
-        String lineSep =     System.getProperty("line.separator");
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        System.err.println("jdeps " + Arrays.stream(args).collect(Collectors.joining(" ")));
-        int rc = com.sun.tools.jdeps.Main.run(args, pw);
-        pw.close();
-        String out = sw.toString();
-        if (!out.isEmpty())
-            System.err.println(out);
-        if (rc != 0)
-            throw new Error("jdeps failed: rc=" + rc);
-        return out.split(lineSep);
-    }
-
     public static Command newCommand(String cmd) {
         return new Command(cmd);
     }
--- a/langtools/test/tools/jdeps/modules/GenModuleInfo.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/jdeps/modules/GenModuleInfo.java	Tue Oct 18 17:14:09 2016 +0000
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @summary Tests jdeps --gen-module-info option
+ * @summary Tests jdeps --generate-module-info option
  * @library ../lib
- * @build CompilerUtils JdepsUtil
+ * @build CompilerUtils JdepsUtil JdepsRunner
  * @modules jdk.jdeps/com.sun.tools.jdeps
  * @run testng GenModuleInfo
  */
@@ -97,7 +97,7 @@
         Stream<String> files = Arrays.stream(modules)
                 .map(mn -> LIBS_DIR.resolve(mn + ".jar"))
                 .map(Path::toString);
-        JdepsUtil.jdeps(Stream.concat(Stream.of("-cp"), files).toArray(String[]::new));
+        JdepsRunner.run(Stream.concat(Stream.of("-cp"), files).toArray(String[]::new));
     }
 
     @Test
@@ -106,7 +106,7 @@
                 .map(mn -> LIBS_DIR.resolve(mn + ".jar"))
                 .map(Path::toString);
 
-        JdepsUtil.jdeps(Stream.concat(Stream.of("--gen-module-info", DEST_DIR.toString()),
+        JdepsRunner.run(Stream.concat(Stream.of("--generate-module-info", DEST_DIR.toString()),
                                       files).toArray(String[]::new));
 
         // check file exists
--- a/langtools/test/tools/jdeps/modules/InverseDeps.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/jdeps/modules/InverseDeps.java	Tue Oct 18 17:14:09 2016 +0000
@@ -91,7 +91,7 @@
     @DataProvider(name = "testrequires")
     public Object[][] expected1() {
         return new Object[][] {
-            // -requires and result
+            // --require and result
             { "java.sql", new String[][] {
                     new String[] { "java.sql", "m5" },
                 }
@@ -117,7 +117,7 @@
 
     @Test(dataProvider = "testrequires")
     public void testrequires(String name, String[][] expected) throws Exception {
-        String cmd1 = String.format("jdeps -inverse --module-path %s -requires %s --add-modules %s%n",
+        String cmd1 = String.format("jdeps --inverse --module-path %s --require %s --add-modules %s%n",
                 MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
 
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
@@ -128,7 +128,7 @@
             runJdeps(jdeps, expected);
         }
 
-        String cmd2 = String.format("jdeps -inverse --module-path %s -requires %s" +
+        String cmd2 = String.format("jdeps --inverse --module-path %s --require %s" +
             " --add-modules ALL-MODULE-PATH%n", LIBS_DIR, name);
 
             // automatic module
@@ -164,7 +164,7 @@
 
     @Test(dataProvider = "testpackage")
     public void testpackage(String name, String[][] expected) throws Exception {
-        String cmd = String.format("jdeps -inverse --module-path %s -package %s --add-modules %s%n",
+        String cmd = String.format("jdeps --inverse --module-path %s -package %s --add-modules %s%n",
             MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
             jdeps.appModulePath(MODS_DIR.toString())
@@ -195,7 +195,7 @@
 
     @Test(dataProvider = "testregex")
     public void testregex(String name, String[][] expected) throws Exception {
-        String cmd = String.format("jdeps -inverse --module-path %s -regex %s --add-modules %s%n",
+        String cmd = String.format("jdeps --inverse --module-path %s -regex %s --add-modules %s%n",
                 MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
 
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
@@ -240,7 +240,7 @@
 
         Path jarfile = LIBS_DIR.resolve("m7.jar");
 
-        String cmd1 = String.format("jdeps -inverse -classpath %s -regex %s %s%n",
+        String cmd1 = String.format("jdeps --inverse -classpath %s -regex %s %s%n",
             cpath, name, jarfile);
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
             jdeps.verbose("-verbose:class")
@@ -253,7 +253,7 @@
         Set<Path> paths = modules.stream()
                                  .map(mn -> LIBS_DIR.resolve(mn + ".jar"))
                                  .collect(Collectors.toSet());
-        String cmd2 = String.format("jdeps -inverse -regex %s %s%n", name, paths);
+        String cmd2 = String.format("jdeps --inverse -regex %s %s%n", name, paths);
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) {
             jdeps.verbose("-verbose:class").regex(name);
             paths.forEach(jdeps::addRoot);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/jdeps/modules/UnnamedPackage.java	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,60 @@
+/*
+ * 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 8166846
+ * @summary Tests --generate-module-info on invalid JAR file
+ * @modules jdk.jdeps/com.sun.tools.jdeps
+ * @library ../lib
+ * @build JdepsRunner JdepsUtil
+ * @run main UnnamedPackage
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.stream.Stream;
+
+public class UnnamedPackage {
+    private static final Path TEST_CLASSES = Paths.get(System.getProperty("test.classes"));
+    private static final Path FOO_JAR_FILE = Paths.get("foo.jar");
+
+    public static void main(String... args) throws Exception {
+        // create foo.jar with unnamed package
+        Path name = TEST_CLASSES.resolve("UnnamedPackage.class");
+        JdepsUtil.createJar(FOO_JAR_FILE, TEST_CLASSES, Stream.of(name));
+
+        // run jdeps --generate-module-info
+        JdepsRunner jdeps = new JdepsRunner("--generate-module-info",
+                                            "tmp", FOO_JAR_FILE.toString());
+        // should fail to generate module-info.java
+        int exitValue = jdeps.run();
+        if (exitValue == 0) {
+            throw new RuntimeException("expected non-zero exitValue");
+        }
+        if (!jdeps.outputContains("foo.jar contains an unnamed package")) {
+            jdeps.printStdout(System.out);
+            throw new RuntimeException("expected error message not found");
+        }
+    }
+}
--- a/langtools/test/tools/jdeps/modules/src/m3/module-info.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/langtools/test/tools/jdeps/modules/src/m3/module-info.java	Tue Oct 18 17:14:09 2016 +0000
@@ -24,7 +24,7 @@
 module m3 {
     requires public java.sql;
     requires public m2;
-    requires java.logging;   // TODO: --gen-module-info to do transitive reduction
+    requires java.logging;   // TODO: --generate-module-info to do transitive reduction
     requires public m1;
     exports p3;
 }
--- a/make/CompileJavaModules.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/CompileJavaModules.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -95,7 +95,7 @@
 ################################################################################
 
 java.desktop_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference \
-    '-Xdoclint/package:java.*,javax.*' -Xlint:-deprecation 
+    '-Xdoclint/package:java.*,javax.*' -Xlint:-deprecation,-exports
 java.desktop_COPY := .gif .png .wav .txt .xml .css .pf
 java.desktop_CLEAN := iio-plugin.properties cursors.properties
 
@@ -316,7 +316,7 @@
 
 ################################################################################
 
-java.naming_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*'
+java.naming_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' -Xlint:-exports
 java.naming_CLEAN := jndiprovider.properties
 
 ################################################################################
@@ -344,6 +344,10 @@
 
 ################################################################################
 
+jdk.accessibility_ADD_JAVAC_FLAGS := -Xlint:-exports
+
+################################################################################
+
 jdk.compiler_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:-com.sun.tools.*' \
     -XDstringConcat=inline
 jdk.compiler_CLEAN_FILES := $(wildcard \
@@ -352,6 +356,10 @@
 
 ################################################################################
 
+jdk.jshell_ADD_JAVAC_FLAGS := -Xlint:-exports
+
+################################################################################
+
 jdk.hotspot.agent_ADD_JAVAC_FLAGS := $(DISABLE_WARNINGS),-overrides
 jdk.hotspot.agent_COPY := .gif .png sa.js .properties
 
@@ -428,6 +436,10 @@
 
 ################################################################################
 
+jdk.jsobject_ADD_JAVAC_FLAGS := -Xlint:-exports
+
+################################################################################
+
 jdk.dev_CLEAN_FILES := $(wildcard \
     $(patsubst %, $(JDK_TOPDIR)/src/jdk.dev/share/classes/%/*.properties, \
         com/sun/tools/script/shell))
@@ -440,6 +452,10 @@
 
 ################################################################################
 
+jdk.vm.ci_ADD_JAVAC_FLAGS := -Xlint:-exports
+
+################################################################################
+
 jdk.xml.bind_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
 jdk.xml.bind_CLEAN := .properties
 jdk.xml.bind_COPY := .xsd JAXBContextFactory.java ZeroOneBooleanAdapter.java
--- a/make/CopyImportModules.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/CopyImportModules.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -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
@@ -59,9 +59,24 @@
     $(eval $(call SetupCopyFiles, COPY_LIBS, \
         SRC := $(LIBS_DIR), \
         DEST := $(JDK_OUTPUTDIR)/lib, \
-        FILES := $(call CacheFind, $(LIBS_DIR)), \
+        FILES := $(filter %$(SHARED_LIBRARY_SUFFIX), $(call CacheFind, $(LIBS_DIR))), \
     ))
-    TARGETS += $(COPY_LIBS)
+
+    # Use relative links if the import dir is inside the OUTPUT_ROOT, otherwise
+    # copy to avoid having automated systems following symlinks when deleting files,
+    # or risk invalidating the build output from external changes.
+    ifeq ($(filter $(OUTPUT_ROOT)/%, $(LIBS_DIR)), )
+      LINK_MACRO := install-file
+    else
+      LINK_MACRO := link-file-relative
+    endif
+    $(eval $(call SetupCopyFiles, LINK_LIBS, \
+        SRC := $(LIBS_DIR), \
+        DEST := $(JDK_OUTPUTDIR)/lib, \
+        FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), $(call CacheFind, $(LIBS_DIR))), \
+        MACRO := $(LINK_MACRO), \
+    ))
+    TARGETS += $(COPY_LIBS) $(LINK_LIBS)
   endif
 endif
 
--- a/make/CreateJmods.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/CreateJmods.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -38,9 +38,9 @@
 JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
 
 LIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
-    $(SUPPORT_OUTPUTDIR)/modules_libs-stripped $(IMPORT_MODULES_LIBS))))
+    $(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
 CMDS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
-    $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped $(IMPORT_MODULES_CMDS))))
+    $(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS))))
 CONF_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF))))
 CLASSES_DIR := $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
@@ -103,7 +103,7 @@
             --os-arch $(OPENJDK_TARGET_CPU_LEGACY) \
             --os-version $(REQUIRED_OS_VERSION) \
             --module-path $(JMODS_DIR) \
-            --exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.pdb,*.map}' \
+            --exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
 	    $(JMOD_FLAGS) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
 	$(MV) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) $@
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/ExplodedImageOptimize.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,49 @@
+#
+# 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.
+#
+
+# Runs a tool on the exploded image to improve performance
+
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+include $(JDK_TOPDIR)/make/ModuleTools.gmk
+
+################################################################################
+
+PACKAGES_ATTRIBUTE_TARGET := $(JDK_OUTPUTDIR)/_packages_attribute.done
+ALL_MODULEINFO_CLASSES := $(wildcard $(JDK_OUTPUTDIR)/modules/*/module_info.class)
+
+$(PACKAGES_ATTRIBUTE_TARGET): $(ALL_MODULEINFO_CLASSES) $(BUILD_JIGSAW_CLASSES)
+	$(call LogInfo, Optimizing the exploded image)
+	$(TOOL_ADD_PACKAGES_ATTRIBUTE) $(JDK_OUTPUTDIR)
+
+TARGETS := $(PACKAGES_ATTRIBUTE_TARGET)
+
+################################################################################
+
+all: $(TARGETS)
+
+.PHONY: all default
--- a/make/Help.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/Help.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,8 @@
 	$(info $(_) make [default]         # Compile all modules in langtools, hotspot, jdk, jaxws,)
 	$(info $(_)                        # jaxp and corba, and create a runnable "exploded" image)
 	$(info $(_) make all               # Compile everything, all repos, docs and images)
-	$(info $(_) make images            # Create complete jdk and jre images)
+	$(info $(_) make images            # Create complete jdk and jre images (alias for product-images))
+	$(info $(_) make <name>-image      # Build just the image (jdk, jre, test, docs etc))
 	$(info $(_) make <phase>           # Build the specified phase and everything it depends on)
 	$(info $(_)                        # (gensrc, java, copy, libs, launchers, gendata, rmic))
 	$(info $(_) make *-only            # Applies to most targets and disables compling the)
--- a/make/Images.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/Images.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -382,14 +382,28 @@
 
 ################################################################################
 # /demo dir
-ifneq ($(findstring images, $(MAKECMDGOALS)), )
+# Avoid doing the expensive find unless called with "jdk" as target.
+ifneq ($(filter jdk, $(MAKECMDGOALS)), )
+
+  DEMO_FILES := \
+      $(if $(wildcard $(SUPPORT_OUTPUTDIR)/demos/image), \
+        $(call DoubleDollar, $(call DoubleDollar, \
+        $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/demos/image \
+            -type f -a ! \( -name "_the*" -o -name "javac_state" \) ))) \
+      )
+
+  ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
+    ifeq ($(OPENJDK_TARGET_OS), macosx)
+      DEMO_FILES := $(call not-containing, .dSYM, $(DEMO_FILES))
+    else
+      DEMO_FILES := $(filter-out %.debuginfo %.pdb %.map, $(DEMO_FILES))
+    endif
+  endif
+
   $(eval $(call SetupCopyFiles, JDK_COPY_DEMOS, \
       SRC := $(SUPPORT_OUTPUTDIR)/demos/image, \
       DEST := $(JDK_IMAGE_DIR)/demo, \
-      FILES := $(if $(wildcard $(SUPPORT_OUTPUTDIR)/demos/image), \
-          $(call DoubleDollar, $(call DoubleDollar, \
-      $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/demos/image \
-          -type f -a ! \( -name "_the*" -o -name "javac_state" \) )))), \
+      FILES := $(DEMO_FILES), \
   ))
 
   JDK_TARGETS += $(JDK_COPY_DEMOS)
@@ -454,21 +468,25 @@
   LIBS_TARGET_SUBDIR := lib
 endif
 
-DEBUGINFO_SUFFIXES := .diz .debuginfo .pdb .map
-
 # Param 1 - dir to find debuginfo files in
 FindDebuginfoFiles = \
     $(wildcard $(addprefix $1/*, $(DEBUGINFO_SUFFIXES)) \
         $(addprefix $1/*/*, $(DEBUGINFO_SUFFIXES)) \
         $(addprefix $1/*/*/*, $(DEBUGINFO_SUFFIXES)))
 
-# On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM
-# dirs.
-ifeq ($(OPENJDK_TARGET_OS)-$(ZIP_EXTERNAL_DEBUG_SYMBOLS), macosx-false)
-  $(eval $(call FillCacheFind, \
-      $(SUPPORT_OUTPUTDIR)/modules_cmds $(SUPPORT_OUTPUTDIR)/modules_libs/))
-  FindDebuginfoFiles = \
-      $(if $(wildcard $1), $(call containing, .dSYM/, $(call CacheFind, $1)))
+# Pick the correct debug info files to copy, either zipped or not.
+ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
+  DEBUGINFO_SUFFIXES += .diz
+else
+  DEBUGINFO_SUFFIXES := .debuginfo .pdb .map
+  # On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM
+  # dirs.
+  ifeq ($(OPENJDK_TARGET_OS), macosx)
+    $(eval $(call FillCacheFind, \
+        $(SUPPORT_OUTPUTDIR)/modules_cmds $(SUPPORT_OUTPUTDIR)/modules_libs))
+    FindDebuginfoFiles = \
+        $(if $(wildcard $1), $(call containing, .dSYM/, $(call CacheFind, $1)))
+  endif
 endif
 
 # Param 1 - either JDK or JRE
@@ -499,8 +517,11 @@
 $(JRE_TARGETS): $(TOOL_JRE_TARGETS)
 $(JDK_TARGETS): $(TOOL_JDK_TARGETS)
 
-jimages: $(TOOL_JRE_TARGETS) $(TOOL_JDK_TARGETS) $(JRE_TARGETS) $(JDK_TARGETS) \
-    $(SYMBOLS_TARGETS)
+jdk: $(JDK_TARGETS)
+jre: $(JRE_TARGETS)
+symbols: $(SYMBOLS_TARGETS)
+
+all: jdk jre symbols
 
 $(JRE_COMPACT1_TARGETS): $(TOOL_JRE_COMPACT1_TARGETS)
 $(JRE_COMPACT2_TARGETS): $(TOOL_JRE_COMPACT2_TARGETS)
@@ -513,4 +534,4 @@
     $(JRE_COMPACT2_TARGETS) \
     $(JRE_COMPACT3_TARGETS)
 
-.PHONY: default all jimages profiles
+.PHONY: default all jdk jre symbols profiles
--- a/make/Javadoc.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/Javadoc.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -773,19 +773,17 @@
 # jvmtidocs
 #
 
-ALL_OTHER_TARGETS += jvmtidocs
-
-JVMTI_DOCDIR = $(PLATFORM_DOCSDIR)/jvmti
-JVMTI_HTML = $(HOTSPOT_DIST)/docs/platform/jvmti/jvmti.html
+JVMTI_DOCDIR := $(PLATFORM_DOCSDIR)/jvmti
+# Pick jvmti.html from any jvm variant, they are all the same.
+JVMTI_HTML := $(firstword \
+    $(wildcard $(HOTSPOT_OUTPUTDIR)/variant-*/gensrc/jvmtifiles/jvmti.html))
 
-jvmtidocs: $(JVMTI_DOCDIR)/jvmti.html
-$(JVMTI_DOCDIR)/jvmti.html:
-	@$(prep-javadoc)
-	@if [ -f $(JVMTI_HTML) ] ; then \
-	  $(CP) $(JVMTI_HTML) $@; \
-	else \
-	  $(ECHO) "WARNING: Generated file does not exist: $(JVMTI_HTML)"; \
-	fi
+$(eval $(call SetupCopyFiles, COPY_JVMTI_HTML, \
+    FILES := $(JVMTI_HTML), \
+    DEST := $(PLATFORM_DOCSDIR)/jvmti, \
+))
+
+jvmtidocs: $(COPY_JVMTI_HTML)
 
 #############################################################
 #
@@ -1575,7 +1573,7 @@
 $(JACCESSAPI_INDEX_HTML): $(JACCESSAPI_OPTIONS_FILE) $(JACCESSAPI_PACKAGES_FILE) $(COREAPI_INDEX_FILE)
 	$(prep-javadoc)
 	$(call JavadocSummary,$(JACCESSAPI_OPTIONS_FILE),$(JACCESSAPI_PACKAGES_FILE))
-	$(JAVADOC_CMD) -d $(@D) \
+	$(JAVADOC_CMD_SMALL) -d $(@D) \
 	    @$(JACCESSAPI_OPTIONS_FILE) @$(JACCESSAPI_PACKAGES_FILE)
 
 # Create file with javadoc options in it
--- a/make/Main.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/Main.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -82,24 +82,24 @@
 
   buildtools-jdk:
 	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk)
+
+  buildtools-modules:
+	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileModuleTools.gmk)
 endif
 
 ALL_TARGETS += buildtools-langtools interim-langtools \
-    interim-rmic interim-cldrconverter buildtools-jdk
+    interim-rmic interim-cldrconverter buildtools-jdk buildtools-modules
 
 ################################################################################
 # Special targets for certain modules
 
-import-hotspot:
-	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Import.gmk)
-
 unpack-sec:
 	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f UnpackSecurity.gmk)
 
 generate-exported-symbols:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildStatic.gmk)
 
-ALL_TARGETS += import-hotspot unpack-sec generate-exported-symbols
+ALL_TARGETS += unpack-sec generate-exported-symbols
 
 ################################################################################
 # Gensrc targets, generating source before java compilation can be done
@@ -266,23 +266,6 @@
 ALL_TARGETS += generate-summary
 
 ################################################################################
-# Strip binaries targets
-
-STRIP_MODULES := $(sort $(LIBS_MODULES) $(LAUNCHER_MODULES) $(COPY_MODULES) \
-    $(GENDATA_MODULES))
-STRIP_TARGETS := $(addsuffix -strip, $(STRIP_MODULES))
-
-define DeclareStripRecipe
-  $1-strip:
-	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f StripBinaries.gmk \
-	    MODULE=$1)
-endef
-
-$(foreach m, $(STRIP_MODULES), $(eval $(call DeclareStripRecipe,$m)))
-
-ALL_TARGETS += $(STRIP_TARGETS)
-
-################################################################################
 # Jmod targets
 
 JMOD_MODULES := $(ALL_MODULES)
@@ -331,8 +314,14 @@
 jrtfs-jar:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f JrtfsJar.gmk)
 
-jimages:
-	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jimages)
+jdk-image:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jdk)
+
+jre-image:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jre)
+
+symbols-image:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk symbols)
 
 profiles:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles)
@@ -340,8 +329,13 @@
 mac-bundles-jdk:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk)
 
+exploded-image-optimize:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ExplodedImageOptimize.gmk)
+
 ALL_TARGETS += source-tips create-hgtip-files bootcycle-images zip-security \
-     zip-source jrtfs-jar jimages profiles mac-bundles-jdk
+    zip-source jrtfs-jar jdk-image jre-image \
+    symbols-image profiles mac-bundles-jdk \
+    exploded-image-optimize
 
 ################################################################################
 # Docs targets
@@ -379,7 +373,7 @@
 ALL_TARGETS += create-buildjdk-copy create-buildjdk-interim-image
 
 ################################################################################
-# The interim-image is a small jlinked image that is used to generate artifacts 
+# The interim-image is a small jlinked image that is used to generate artifacts
 # at build time for use when linking the real images.
 
 interim-image:
@@ -521,6 +515,8 @@
 
   buildtools-jdk: interim-langtools interim-cldrconverter
 
+  buildtools-modules: exploded-image-base
+
   $(CORBA_GENSRC_TARGETS): interim-langtools
 
   $(HOTSPOT_GENSRC_TARGETS): interim-langtools
@@ -539,11 +535,9 @@
 
   hotspot-ide-project: hotspot exploded-image
 
-  import-hotspot: hotspot
-
   generate-exported-symbols: java.base-libs jdk.jdwp.agent-libs
 
-  $(LIBS_TARGETS): import-hotspot
+  $(LIBS_TARGETS): hotspot
 
   $(LAUNCHER_TARGETS): java.base-libs
 
@@ -598,17 +592,8 @@
   # Explicitly add dependencies for special targets
   java.base-java: unpack-sec
 
-  # The copy target copies files generated by gensrc
-  java.base-copy-hotspot: java.base-gensrc-hotspot
-
   jdk.jdeps-gendata: java rmic
 
-  # Declare dependencies from <module>-strip to libs, launchers, gendata and copy
-  $(foreach m, $(LIBS_MODULES), $(eval $m-strip: $m-libs))
-  $(foreach m, $(LAUNCHER_MODULES), $(eval $m-strip: $m-launchers))
-  $(foreach m, $(GENDATA_MODULES), $(eval $m-strip: $m-gendata))
-  $(foreach m, $(COPY_MODULES), $(eval $m-strip: $m-copy))
-
   # Declare dependencies between jmod targets. Only java.base jmod needs access
   # to the other jmods to be built.
   # When creating a BUILDJDK, we don't need to add hashes to java.base, thus
@@ -619,7 +604,6 @@
   endif
 
   # Declare dependencies from <module>-jmod to all other module targets
-  $(foreach m, $(STRIP_MODULES), $(eval $m-jmod: $m-strip))
   # When creating a BUILDJDK, the java compilation has already been done by the
   # normal build and copied in.
   ifneq ($(CREATING_BUILDJDK), true)
@@ -631,22 +615,33 @@
   $(foreach m, $(LAUNCHER_MODULES), $(eval $m-jmod: $m-launchers))
   $(foreach m, $(COPY_MODULES), $(eval $m-jmod: $m-copy))
 
-  # Jmods cannot be created until we have the jlink tool ready to run, which requires
-  # all java modules to be compiled and jdk.jlink-launchers.
-  # And we also need to copy jvm.cfg (done in java.base-copy) and tzdb.dat (done in
-  # java.base-gendata) to the appropriate location otherwise jimage, jlink and jmod won't start.
-  $(JMOD_TARGETS): java.base-libs java.base-copy java.base-gendata jdk.jlink-launchers
-  # When creating a BUILDJDK, the java compilation has already been done by the
-  # normal build and copied in.
-  ifneq ($(CREATING_BUILDJDK), true)
-    $(JMOD_TARGETS): java
-  endif
-
+  # Jmods cannot be created until we have the jmod tool ready to run. During
+  # a normal build we run it from the exploded image, but when cross compiling
+  # it's run from the buildjdk, which is either created at build time or user
+  # supplied.
+  #
+  # For the exploded image to be runnable, all java modules and
+  # jdk.jlink-launchers need to be built. We also need to copy jvm.cfg (done
+  # in java.base-copy) and tzdb.dat (done in java.base-gendata) to the
+  # appropriate location otherwise jimage, jlink and jmod won't start. This
+  # also applies when creating the buildjdk.
+  DEFAULT_JMOD_DEPS := java.base-libs java.base-copy java.base-gendata \
+      jdk.jlink-launchers
+  # When cross compiling and buildjdk is to be created, depend on creating the
+  # buildjdk instead of the default dependencies.
   ifeq ($(CREATE_BUILDJDK), true)
-    # Avoid calling create-buildjdk from within a create-buildjdk call
+    # Avoid calling create-buildjdk from within a create-buildjdk call.
     ifneq ($(CREATING_BUILDJDK), true)
       $(JMOD_TARGETS): create-buildjdk
+      buildtools-modules: create-buildjdk
+    else
+      # While actually creating the buildjdk, the default deps applies.
+      $(JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
     endif
+  else
+    # The normal non cross compilation case uses the default deps.
+    # To avoid races with the optimize target, that also needs to happen first.
+    $(JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) exploded-image-optimize
   endif
 
   zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
@@ -668,16 +663,23 @@
     endif
     generate-classlist: buildtools-jdk
 
-    jimages: generate-classlist
+    jdk-image jre-image: generate-classlist
   endif
 
-  jimages: jmods zip-source source-tips demos samples jrtfs-jar
+  jdk-image: jmods zip-source source-tips demos samples jrtfs-jar
+  jre-image: jmods source-tips jrtfs-jar
 
   profiles: jmods zip-source source-tips jrtfs-jar
 
-  mac-bundles-jdk: jimages
+  mac-bundles-jdk: jdk-image jre-image
 
-  bootcycle-images: jimages
+  # The optimize target can run as soon as the modules dir has been completely
+  # populated (java, copy and gendata targets) and the basic libs and launchers
+  # have been built.
+  exploded-image-optimize: java copy gendata java.base-libs java.base-launchers \
+      buildtools-modules
+
+  bootcycle-images: jdk-image
 
   docs-javadoc: $(GENSRC_TARGETS) rmic
 
@@ -685,7 +687,7 @@
 
   zip-docs: docs-javadoc docs-jvmtidoc
 
-  test: jimages test-image
+  test: jdk-image test-image
 
   create-buildjdk-copy: jdk.jlink-java java.base-gendata \
       $(addsuffix -java, $(INTERIM_IMAGE_MODULES))
@@ -704,7 +706,7 @@
 
   test-image-failure-handler: build-test-failure-handler
 
-  build-test-hotspot-jtreg-native: buildtools-jdk import-hotspot
+  build-test-hotspot-jtreg-native: buildtools-jdk hotspot
 
   build-test-jdk-jtreg-native: buildtools-jdk
 
@@ -716,7 +718,7 @@
 
   test-hotspot-internal: exploded-image
 
-  test-hotspot-jtreg: jimages test-image
+  test-hotspot-jtreg: jdk-image test-image
 
   test-hotspot-gtest: exploded-image test-image-hotspot-gtest
 
@@ -728,7 +730,7 @@
 
   docs-bundles: docs-image
 
-  generate-summary: jmods
+  generate-summary: jmods buildtools-modules
 
 endif
 
@@ -754,8 +756,6 @@
 
 jmods: $(JMOD_TARGETS)
 
-strip-binaries: $(STRIP_TARGETS)
-
 # Explicitly declare dependency for virtual target jdk.jdwp.agent-gensrc which
 # is actually handled by jdk.jdi-gensrc
 jdk.jdwp.agent-gensrc: jdk.jdi-gensrc
@@ -774,7 +774,13 @@
 samples: samples-jdk
 
 # The "exploded image" is a locally runnable JDK in $(BUILD_OUTPUT)/jdk.
-exploded-image: $(ALL_MODULES)
+exploded-image-base: $(ALL_MODULES)
+exploded-image: exploded-image-base
+# When cross compiling, no need to optimize the exploded image since it won't
+# be runnable on the host platform anyway.
+ifneq ($(COMPILE_TYPE), cross)
+  exploded-image: exploded-image-optimize
+endif
 
 create-buildjdk: create-buildjdk-copy create-buildjdk-interim-image
 
@@ -785,7 +791,11 @@
 
 # This target builds the product images, e.g. the JRE and JDK image
 # (and possibly other, more specific versions)
-product-images: jimages demos samples zip-security exploded-image
+product-images: jdk-image jre-image symbols-image exploded-image
+
+# zip-security is actually a bundle, but for now it needs to be considered
+# an image until this can be cleaned up properly.
+product-images: zip-security
 
 # The module summary cannot be run when:
 # * Cross compiling and building a partial BUILDJDK for the build host
@@ -815,7 +825,8 @@
 all-bundles: product-bundles test-bundles docs-bundles
 
 ALL_TARGETS += buildtools gensrc gendata copy java rmic libs launchers jmods \
-    jdk.jdwp.agent-gensrc $(ALL_MODULES) demos samples exploded-image \
+    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 \
     all-bundles
 
--- a/make/MainSupport.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/MainSupport.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -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
@@ -88,9 +88,7 @@
 	@$(PRINTF) "\n" $(LOG_DEBUG)
 	$(RM) -r $(SUPPORT_OUTPUTDIR)/native/$(strip $1)
 	$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
-	$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs-stripped/$(strip $1)
 	$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1)
-	$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped/$(strip $1)
 	@$(PRINTF) " done\n"
 endef
 
@@ -137,7 +135,6 @@
 define DeclareRecipeForModuleMakefile
   ifeq ($$($1_MULTIPLE_MAKEFILES), true)
     $2-$$($1_TARGET_SUFFIX): $2-$$($1_TARGET_SUFFIX)-$$(notdir $3)
-    $1 += $2-$$($1_TARGET_SUFFIX)-$$(notdir $3)
 
     $2-$$($1_TARGET_SUFFIX)-$$(notdir $3):
   else
@@ -173,6 +170,12 @@
 
   # Only declare recipes if there are makefiles to call
   ifneq ($$($1_$2_TOPDIRS), )
+    # Add the top dir specific target to target list regardless of if recipe
+    # generation is disabled.
+    ifeq ($$($1_MULTIPLE_MAKEFILES), true)
+      $$(foreach d, $$($1_$2_TOPDIRS), \
+        $$(eval $1 += $2-$$($1_TARGET_SUFFIX)-$$(notdir $$d)))
+    endif
     ifeq ($(NO_RECIPES),)
       $$(foreach d, $$($1_$2_TOPDIRS), \
           $$(eval $$(call DeclareRecipeForModuleMakefile,$1,$2,$$d)))
--- a/make/ModuleWrapper.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/ModuleWrapper.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -45,44 +45,59 @@
 ifeq ($(OPENJDK_TARGET_OS), windows)
   TO_BIN_FILTER := %$(SHARED_LIBRARY_SUFFIX) %.diz %.pdb %.map
 
-  $(eval $(call SetupCopyFiles,COPY_LIBS_TO_BIN, \
+  $(eval $(call SetupCopyFiles, COPY_LIBS_TO_BIN, \
       SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
       DEST := $(JDK_OUTPUTDIR)/bin, \
       FILES := $(filter $(TO_BIN_FILTER), \
           $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/%, \
-          $(TARGETS)))))
+          $(TARGETS))), \
+  ))
 
-  $(eval $(call SetupCopyFiles,COPY_LIBS_TO_LIB, \
+  $(eval $(call SetupCopyFiles, COPY_LIBS_TO_LIB, \
       SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
       DEST := $(JDK_OUTPUTDIR)/lib, \
       FILES := $(filter-out $(TO_BIN_FILTER), \
           $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/%, \
-          $(TARGETS)))))
+          $(TARGETS))), \
+  ))
 
 else
-  $(eval $(call SetupCopyFiles,COPY_LIBS_TO_LIB, \
+  $(eval $(call SetupCopyFiles, COPY_LIBS_TO_LIB, \
       SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
       DEST := $(JDK_OUTPUTDIR)/lib, \
-      FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/%, \
-          $(TARGETS))))
+      FILES := $(filter %$(SHARED_LIBRARY_SUFFIX), \
+          $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/%, \
+          $(TARGETS))), \
+  ))
+  $(eval $(call SetupCopyFiles, LINK_LIBS_TO_LIB, \
+      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
+      DEST := $(JDK_OUTPUTDIR)/lib, \
+      FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), \
+          $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/%, \
+          $(TARGETS))), \
+      MACRO := link-file-relative, \
+  ))
 endif
 
-$(eval $(call SetupCopyFiles,COPY_INCLUDE, \
+$(eval $(call SetupCopyFiles, COPY_INCLUDE, \
     SRC := $(SUPPORT_OUTPUTDIR)/modules_include/$(MODULE), \
     DEST := $(JDK_OUTPUTDIR)/include, \
     FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_include/$(MODULE)/%, \
-          $(TARGETS))))
+        $(TARGETS)), \
+))
 
-$(eval $(call SetupCopyFiles,COPY_CMDS, \
+$(eval $(call SetupCopyFiles, COPY_CMDS, \
     SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE), \
     DEST := $(JDK_OUTPUTDIR)/bin, \
-    FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)/%, $(TARGETS))))
+    FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)/%, $(TARGETS)), \
+))
 
-$(eval $(call SetupCopyFiles,COPY_CONF, \
+$(eval $(call SetupCopyFiles, COPY_CONF, \
     SRC := $(SUPPORT_OUTPUTDIR)/modules_conf/$(MODULE), \
     DEST := $(JDK_OUTPUTDIR)/conf, \
     FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_conf/$(MODULE)/%, \
-          $(TARGETS))))
+        $(TARGETS)), \
+))
 
 all: $(TARGETS) $(COPY_LIBS_TO_BIN) $(COPY_LIBS_TO_LIB) \
-    $(COPY_INCLUDE) $(COPY_CMDS) $(COPY_CONF)
+    $(COPY_INCLUDE) $(COPY_CMDS) $(COPY_CONF) $(LINK_LIBS_TO_LIB)
--- a/make/StripBinaries.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-#
-# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  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.
-#
-
-default: all
-
-include $(SPEC)
-include MakeBase.gmk
-
-# Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , StripBinaries.gmk))
-
-################################################################################
-# Copy native libraries and executables to a secondary location to strip them
-# and filter out files that shouldn't go into the image.
-
-MODULES_CMDS_STRIPPED := $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped
-MODULES_LIBS_STRIPPED := $(SUPPORT_OUTPUTDIR)/modules_libs-stripped
-
-ifneq ($(STRIP), )
-  define StripRecipe
-	$(call LogInfo, Stripping $(patsubst $(OUTPUT_ROOT)/%,%,$<))
-	$(call MakeDir, $(@D))
-	$(CP) $< $@.tmp
-	$(CHMOD) u+w $@.tmp
-	$(STRIP) $(STRIPFLAGS) $@.tmp
-	$(CHMOD) go-w $@.tmp
-	$(MV) $@.tmp $@
-  endef
-else
-  define StripRecipe
-    $(call install-file)
-  endef
-endif
-
-NO_STRIP_CMDS_FILTER += %.cgi
-
-# Don't include debug info for executables.
-ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)), )
-  # OS X stores symbol information in a .dylib file inside a .dSYM directory -
-  # that file should not be stripped, so we prune the tree at the .dSYM directory.
-  ALL_CMDS_SRC := $(filter-out %.bc %.debuginfo %.diz %.map %.pdb, \
-      $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE) \( -type f -o -type l \) \
-      -print -o -name "*.dSYM" -prune))
-  COPY_CMDS_SRC := $(filter $(NO_STRIP_CMDS_FILTER), $(ALL_CMDS_SRC))
-  STRIP_CMDS_SRC := $(filter-out $(NO_STRIP_CMDS_FILTER), $(ALL_CMDS_SRC))
-endif
-
-ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)), )
-  # OS X stores symbol information in a .dylib file inside a .dSYM directory -
-  # that file should not be stripped, so we prune the tree at the .dSYM directory.
-  # Example: support/modules_libs/java.base/libjsig.dylib.dSYM/Contents/Resources/DWARF/libjsig.dylib
-  STRIP_LIBS_SRC := \
-      $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE) \
-        -name '*$(SHARED_LIBRARY_SUFFIX)' -type f -print -o -name "*.dSYM" -prune)
-
-  # Make sure symbolic links are copied and not stripped.
-  COPY_LIBS_SRC := \
-      $(filter-out $(STRIP_LIBS_SRC), \
-      $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE) -type f -o -type l))
-endif
-
-$(eval $(call SetupCopyFiles,STRIP_MODULES_CMDS, \
-    SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
-    DEST := $(MODULES_CMDS_STRIPPED), \
-    FILES := $(STRIP_CMDS_SRC), \
-    MACRO := StripRecipe))
-
-$(eval $(call SetupCopyFiles,COPY_MODULES_CMDS, \
-    SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
-    DEST := $(MODULES_CMDS_STRIPPED), \
-    FILES := $(COPY_CMDS_SRC)))
-
-$(eval $(call SetupCopyFiles,STRIP_MODULES_LIBS, \
-    SRC := $(SUPPORT_OUTPUTDIR)/modules_libs, \
-    DEST := $(MODULES_LIBS_STRIPPED), \
-    FILES := $(STRIP_LIBS_SRC), \
-    MACRO := StripRecipe))
-
-$(eval $(call SetupCopyFiles,COPY_MODULES_LIBS, \
-    SRC := $(SUPPORT_OUTPUTDIR)/modules_libs, \
-    DEST := $(MODULES_LIBS_STRIPPED), \
-    FILES := $(COPY_LIBS_SRC)))
-
-TARGETS += $(STRIP_MODULES_CMDS) $(COPY_MODULES_CMDS) \
-    $(STRIP_MODULES_LIBS) $(COPY_MODULES_LIBS)
-
-all: $(TARGETS)
--- a/make/common/MakeBase.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/common/MakeBase.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -535,6 +535,67 @@
 endif
 
 ################################################################################
+# Take two paths and return the path of the last common directory.
+# Ex: /foo/bar/baz, /foo/bar/banan -> /foo/bar
+#     foo/bar/baz, /foo/bar -> <empty>
+#
+# The x prefix is used to preserve the presence of the initial slash
+#
+# $1 - Path to compare
+# $2 - Other path to compare
+FindCommonPathPrefix = \
+    $(patsubst x%,%,$(subst $(SPACE),/,$(strip \
+        $(call FindCommonPathPrefixHelper, \
+            $(subst /,$(SPACE),x$(strip $1)), $(subst /,$(SPACE),x$(strip $2))) \
+    )))
+
+FindCommonPathPrefixHelper = \
+    $(if $(call equals, $(firstword $1), $(firstword $2)), \
+      $(firstword $1) \
+      $(call FindCommonPathPrefixHelper, \
+          $(wordlist 2, $(words $1), $1), $(wordlist 2, $(words $2), $2) \
+      ) \
+    )
+
+# Convert a partial path into as many directory levels of ../, removing
+# leading and following /.
+# Ex: foo/bar/baz/ -> ../../..
+#     foo/bar -> ../..
+#     /foo -> ..
+DirToDotDot = \
+    $(subst $(SPACE),/,$(foreach d, $(subst /,$(SPACE),$1),..))
+
+# Computes the relative path from a directory to a file
+# $1 - File to compute the relative path to
+# $2 - Directory to compute the relative path from
+RelativePath = \
+    $(eval $1_prefix := $(call FindCommonPathPrefix, $1, $2)) \
+    $(eval $1_dotdots := $(call DirToDotDot, $(patsubst $($(strip $1)_prefix)/%, %, $2))) \
+    $(eval $1_suffix := $(patsubst $($(strip $1)_prefix)/%, %, $1)) \
+    $($(strip $1)_dotdots)/$($(strip $1)_suffix)
+
+################################################################################
+# link-file-* works similarly to install file but creates a symlink instead on
+# platforms that support it. There are two versions, either creating a relative
+# or an absolute link.
+ifeq ($(OPENJDK_BUILD_OS), windows)
+  link-file-absolute = $(install-file)
+  link-file-relative = $(install-file)
+else
+  define link-file-relative
+	$(call MakeDir, $(@D))
+	$(RM) $@
+	$(LN) -s $(call RelativePath, $<, $(@D)) $@
+  endef
+
+  define link-file-absolute
+	$(call MakeDir, $(@D))
+	$(RM) $@
+	$(LN) -s $< $@
+  endef
+endif
+
+################################################################################
 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
 uniq = \
     $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
--- a/make/common/NativeCompilation.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/common/NativeCompilation.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -346,6 +346,7 @@
 #   LIBS the libraries to link to
 #   ARFLAGS the archiver flags to be used
 #   OBJECT_DIR the directory where we store the object files
+#   OUTPUT_DIR the directory where the resulting binary is put
 #   LIBRARY the resulting library file
 #   PROGRAM the resulting exec file
 #   INCLUDES only pick source from these directories
@@ -829,67 +830,58 @@
     ifneq ($$($1_DEBUG_SYMBOLS), false)
       # Only copy debug symbols for dynamic libraries and programs.
       ifeq ($$($1_STATIC_LIBRARY), )
-        ifneq ($$($1_OUTPUT_DIR), $$($1_OBJECT_DIR))
-          # The dependency on TARGET is needed on windows for debuginfo files
-          # to be rebuilt properly.
-          $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET)
-                # Use cp -r since on macosx, the dSYM is a directory
-		$(CP) -r $$< $$@
-        endif
-
         # Generate debuginfo files.
         ifeq ($(OPENJDK_TARGET_OS), windows)
-          $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
-              "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
-          $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
-              $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
+          $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \
+              "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map"
+          $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \
+              $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map
           # No separate command is needed for debuginfo on windows, instead
           # touch target to make sure it has a later time stamp than the debug
           # symbol files to avoid unnecessary relinking on rebuild.
           $1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
 
         else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
-          $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
+          $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo
           # Setup the command line creating debuginfo files, to be run after linking.
           # It cannot be run separately since it updates the original target file
           $1_CREATE_DEBUGINFO_CMDS := \
-            $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
-            $(CD) $$($1_OUTPUT_DIR) && \
-                $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
+              $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
+              $(CD) $$($1_OUTPUT_DIR) && \
+                  $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
 
         else ifeq ($(OPENJDK_TARGET_OS), macosx)
-          $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_BASENAME).dSYM
+          $1_DEBUGINFO_FILES := \
+              $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
+              $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
           # On Macosx, the debuginfo generation doesn't touch the linked binary, but
           # to avoid always relinking, touch it anyway to force a later timestamp than
           # the dSYM files.
           $1_CREATE_DEBUGINFO_CMDS := \
-              $(DSYMUTIL) --out $$($1_DEBUGINFO_FILES) $$($1_TARGET) $$(NEWLINE) \
+              $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET) $$(NEWLINE) \
               $(TOUCH) $$($1_TARGET)
         endif # OPENJDK_TARGET_OS
 
-        # This dependency dance ensures that debug info files get rebuilt
-        # properly if deleted.
-        $$($1_TARGET): $$($1_DEBUGINFO_FILES)
-        $$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS)
+        $$($1_DEBUGINFO_FILES): $$($1_TARGET)
+
+        $1 += $$($1_DEBUGINFO_FILES)
 
         ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
-          $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
-          $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
+          $1_DEBUGINFO_ZIP := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).diz
+          $1 += $$($1_DEBUGINFO_ZIP)
 
           # The dependency on TARGET is needed for debuginfo files
           # to be rebuilt properly.
           $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
-		$(CD) $$($1_OBJECT_DIR) \
-		&& $(ZIP) -q -r $$@ $$(notdir $$($1_DEBUGINFO_FILES))
+		$(CD) $$($1_OUTPUT_DIR) && \
+		    $(ZIP) -q -r $$@ $$(subst $$($1_OUTPUT_DIR)/,, $$($1_DEBUGINFO_FILES))
 
-        else
-          $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES))
         endif
-      endif # !STATIC_LIBRARY
+       endif # !STATIC_LIBRARY
     endif # $1_DEBUG_SYMBOLS != false
   endif # COPY_DEBUG_SYMBOLS
 
-  ifeq ($$($1_STRIP_SYMBOLS), true)
+  ifneq ($$($1_STRIP_SYMBOLS), false)
     ifneq ($$($1_STRIP), )
       # Default to using the global STRIPFLAGS. Allow for overriding with an empty value
       $1_STRIPFLAGS ?= $(STRIPFLAGS)
@@ -902,6 +894,8 @@
     $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
     ifeq ($(OPENJDK_TARGET_OS), windows)
       $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"
+      # Create a rule for the import lib so that other rules may depend on it
+      $$($1_OBJECT_DIR)/$$($1_LIBRARY).lib: $$($1_TARGET)
     endif
 
     # Create loadmap on AIX. Helps in diagnosing some problems.
--- a/make/common/SetupJavaCompilers.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/common/SetupJavaCompilers.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -38,7 +38,10 @@
 # and the interim javac, to be run by the boot jdk.
 $(eval $(call SetupJavaCompiler,BOOT_JAVAC, \
     JAVAC := $(JAVAC), \
-    FLAGS := $(BOOT_JDK_SOURCETARGET) -XDignore.symbol.file=true -g \
+    FLAGS := \
+        $(JAVA_TOOL_FLAGS_SMALL) \
+        $(BOOT_JDK_SOURCETARGET) \
+        -XDignore.symbol.file=true -g \
         -Xlint:all$(COMMA)-deprecation$(COMMA)-options -Werror, \
     DISABLE_SJAVAC := true, \
 ))
--- a/make/common/TestFilesCompilation.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/common/TestFilesCompilation.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -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
@@ -88,6 +88,8 @@
         LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$($1_PREFIX)$$(name)), \
         LIBS := $$($1_LIBS_$$($1_PREFIX)$$(name)), \
         OPTIMIZATION := LOW, \
+        COPY_DEBUG_SYMBOLS := false, \
+        STRIP_SYMBOLS := false, \
     )) \
     $$(eval $1 += $$(BUILD_TEST_$$(name)) )  \
   )
--- a/make/common/TextFileProcessing.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/make/common/TextFileProcessing.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
--- a/nashorn/.hgtags	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/.hgtags	Tue Oct 18 17:14:09 2016 +0000
@@ -371,3 +371,5 @@
 cb00d5ef023a18a66fcb4311ed4474d4145c66e9 jdk-9+135
 f11b8f5c4ccbf9c87d283815abac6c0117fba3c0 jdk-9+136
 17ed43add2f9e3528686cd786ae2ed49c8ed36e9 jdk-9+137
+4a6ee1185fc821df063e4d1537fa7ad2ebe9eb02 jdk-9+138
+e3b11296395b39bfeb3364f26c2ef77fa652e300 jdk-9+139
--- a/nashorn/ASSEMBLY_EXCEPTION	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/ASSEMBLY_EXCEPTION	Tue Oct 18 17:14:09 2016 +0000
@@ -1,27 +1,27 @@
 
 OPENJDK ASSEMBLY EXCEPTION
 
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
 only ("GPL2"), with the following clarification and special exception.
 
     Linking this OpenJDK Code statically or dynamically with other code
     is making a combined work based on this library.  Thus, the terms
     and conditions of GPL2 cover the whole combination.
 
-    As a special exception, Sun gives you permission to link this
-    OpenJDK Code with certain code licensed by Sun as indicated at
+    As a special exception, Oracle gives you permission to link this
+    OpenJDK Code with certain code licensed by Oracle as indicated at
     http://openjdk.java.net/legal/exception-modules-2007-05-08.html
     ("Designated Exception Modules") to produce an executable,
     regardless of the license terms of the Designated Exception Modules,
     and to copy and distribute the resulting executable under GPL2,
     provided that the Designated Exception Modules continue to be
-    governed by the licenses under which they were offered by Sun.
+    governed by the licenses under which they were offered by Oracle.
 
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception).  If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception).  If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java	Tue Oct 18 17:14:09 2016 +0000
@@ -574,7 +574,7 @@
 
     String getDocumentationKey(final String objName) {
         if (kind == Kind.FUNCTION) {
-            StringBuilder buf = new StringBuilder(objName);
+            final StringBuilder buf = new StringBuilder(objName);
             switch (where) {
                 case CONSTRUCTOR:
                     break;
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java	Tue Oct 18 17:14:09 2016 +0000
@@ -42,7 +42,7 @@
  *
  */
 public final class ScriptClassInfo {
-    private static String getTypeDescriptor(String pkg, String name) {
+    private static String getTypeDescriptor(final String pkg, final String name) {
         return "L" + pkg + name + ";";
     }
 
--- a/nashorn/make/BuildNashorn.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/make/BuildNashorn.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -26,7 +26,7 @@
 # This must be the first rule
 default: all
 
--include $(SPEC)
+include $(SPEC)
 include MakeBase.gmk
 include JarArchive.gmk
 include JavaCompilation.gmk
@@ -42,7 +42,7 @@
 
 # Need to use source and target 8 for nasgen to work.
 $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG, \
-    JVM := $(JAVA), \
+    JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
     FLAGS := -g -source 9 -target 9 --upgrade-module-path "$(JDK_OUTPUTDIR)/modules/" \
          --system none --module-source-path "$(MODULESOURCEPATH)", \
@@ -91,7 +91,7 @@
 	$(MKDIR) -p $(@D)
 	$(RM) -rf $(@D)/jdk $(@D)/netscape
 	$(CP) -R -p $(SUPPORT_OUTPUTDIR)/special_classes/jdk.scripting.nashorn/* $(@D)/
-	$(JAVA) $(NASGEN_OPTIONS) \
+	$(JAVA_SMALL) $(NASGEN_OPTIONS) \
 	    jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D)
 	$(TOUCH) $@
 
--- a/nashorn/make/project.properties	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/make/project.properties	Tue Oct 18 17:14:09 2016 +0000
@@ -36,7 +36,7 @@
 javac.target=1.9
 
 javadoc.option=\
-    -tag "implSpec:a:Implementation Requirements:"\
+    -tag "implSpec:a:Implementation Requirements:" \
     -tag "implNote:a:Implementation Note:"
 
 # nashorn version information
--- a/nashorn/samples/dynalink/ArrayStreamLinkerExporter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/samples/dynalink/ArrayStreamLinkerExporter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -30,7 +30,6 @@
  */
 
 import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import java.util.ArrayList;
 import java.util.List;
@@ -43,12 +42,12 @@
 import jdk.dynalink.NamedOperation;
 import jdk.dynalink.Operation;
 import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.GuardingDynamicLinker;
 import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
-import jdk.dynalink.linker.GuardedInvocation;
-import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
 import jdk.dynalink.linker.LinkRequest;
 import jdk.dynalink.linker.LinkerServices;
+import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
 import jdk.dynalink.linker.support.Guards;
 import jdk.dynalink.linker.support.Lookup;
 
@@ -65,7 +64,7 @@
         System.out.println("pluggable dynalink array stream linker loaded");
     }
 
-    public static Object arrayToStream(Object array) {
+    public static Object arrayToStream(final Object array) {
         if (array instanceof int[]) {
             return IntStream.of((int[])array);
         } else if (array instanceof long[]) {
@@ -95,17 +94,17 @@
             }
 
             @Override
-            public GuardedInvocation getGuardedInvocation(LinkRequest request,
-                LinkerServices linkerServices) throws Exception {
+            public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+                final LinkerServices linkerServices) throws Exception {
                 final Object self = request.getReceiver();
                 if (self == null || !canLinkType(self.getClass())) {
                     return null;
                 }
 
-                CallSiteDescriptor desc = request.getCallSiteDescriptor();
-                Operation op = desc.getOperation();
-                Object name = NamedOperation.getName(op);
-                boolean getProp = CompositeOperation.contains(
+                final CallSiteDescriptor desc = request.getCallSiteDescriptor();
+                final Operation op = desc.getOperation();
+                final Object name = NamedOperation.getName(op);
+                final boolean getProp = CompositeOperation.contains(
                         NamedOperation.getBaseOperation(op),
                         StandardOperation.GET_PROPERTY);
                 if (getProp && "stream".equals(name)) {
--- a/nashorn/samples/dynalink/BufferIndexingLinkerExporter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/samples/dynalink/BufferIndexingLinkerExporter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -30,10 +30,7 @@
  */
 
 import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
-import java.util.ArrayList;
-import java.util.List;
 import java.nio.Buffer;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
@@ -42,17 +39,19 @@
 import java.nio.IntBuffer;
 import java.nio.LongBuffer;
 import java.nio.ShortBuffer;
+import java.util.ArrayList;
+import java.util.List;
 import jdk.dynalink.CallSiteDescriptor;
 import jdk.dynalink.CompositeOperation;
 import jdk.dynalink.NamedOperation;
 import jdk.dynalink.Operation;
 import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.GuardingDynamicLinker;
 import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
-import jdk.dynalink.linker.GuardedInvocation;
-import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
 import jdk.dynalink.linker.LinkRequest;
 import jdk.dynalink.linker.LinkerServices;
+import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
 import jdk.dynalink.linker.support.Guards;
 import jdk.dynalink.linker.support.Lookup;
 
@@ -94,7 +93,7 @@
     private static final MethodType GUARD_TYPE;
 
     static {
-        Lookup look = Lookup.PUBLIC;
+        final Lookup look = Lookup.PUBLIC;
         BUFFER_LIMIT = look.findVirtual(Buffer.class, "limit", MethodType.methodType(int.class));
         BYTEBUFFER_GET = look.findVirtual(ByteBuffer.class, "get",
                 MethodType.methodType(byte.class, int.class));
@@ -163,15 +162,15 @@
             }
 
             @Override
-            public GuardedInvocation getGuardedInvocation(LinkRequest request,
-                LinkerServices linkerServices) throws Exception {
+            public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+                final LinkerServices linkerServices) throws Exception {
                 final Object self = request.getReceiver();
                 if (self == null || !canLinkType(self.getClass())) {
                     return null;
                 }
 
-                CallSiteDescriptor desc = request.getCallSiteDescriptor();
-                StandardOperation op = getFirstStandardOperation(desc);
+                final CallSiteDescriptor desc = request.getCallSiteDescriptor();
+                final StandardOperation op = getFirstStandardOperation(desc);
                 if (op == null) {
                     return null;
                 }
@@ -182,7 +181,7 @@
                     case SET_ELEMENT:
                         return linkSetElement(self);
                     case GET_PROPERTY: {
-                        Object name = NamedOperation.getName(desc.getOperation());
+                        final Object name = NamedOperation.getName(desc.getOperation());
                         if ("length".equals(name)) {
                             return linkLength();
                         }
@@ -195,7 +194,7 @@
         return linkers;
     }
 
-    private static GuardedInvocation linkGetElement(Object self) {
+    private static GuardedInvocation linkGetElement(final Object self) {
         MethodHandle method = null;
         MethodHandle guard = null;
         if (self instanceof ByteBuffer) {
@@ -224,7 +223,7 @@
         return method != null? new GuardedInvocation(method, guard) : null;
     }
 
-    private static GuardedInvocation linkSetElement(Object self) {
+    private static GuardedInvocation linkSetElement(final Object self) {
         MethodHandle method = null;
         MethodHandle guard = null;
         if (self instanceof ByteBuffer) {
--- a/nashorn/samples/dynalink/DOMLinkerExporter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/samples/dynalink/DOMLinkerExporter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -39,18 +39,17 @@
 import jdk.dynalink.NamedOperation;
 import jdk.dynalink.Operation;
 import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.GuardingDynamicLinker;
 import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
-import jdk.dynalink.linker.GuardedInvocation;
-import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
 import jdk.dynalink.linker.LinkRequest;
 import jdk.dynalink.linker.LinkerServices;
+import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
 import jdk.dynalink.linker.support.Guards;
 import jdk.dynalink.linker.support.Lookup;
-import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-import org.w3c.dom.Element;
 
 /**
  * This is a dynalink pluggable linker (see http://openjdk.java.net/jeps/276).
@@ -65,12 +64,12 @@
     }
 
     // return List of child Elements of the given Element matching the given name.
-    private static List<Element> getChildElements(Element elem, String name) {
-        NodeList nodeList = elem.getChildNodes();
-        List<Element> childElems = new ArrayList<>();
-        int len = nodeList.getLength();
+    private static List<Element> getChildElements(final Element elem, final String name) {
+        final NodeList nodeList = elem.getChildNodes();
+        final List<Element> childElems = new ArrayList<>();
+        final int len = nodeList.getLength();
         for (int i = 0; i < len; i++) {
-            Node node = nodeList.item(i);
+            final Node node = nodeList.item(i);
             if (node.getNodeType() == Node.ELEMENT_NODE &&
                 ((Element)node).getTagName().equals(name)) {
                 childElems.add((Element)node);
@@ -81,18 +80,18 @@
 
     // method that returns either unique child element matching given name
     // or a list of child elements of that name (if there are more than one matches).
-    public static Object getElementsByName(Object elem, final String name) {
-        List<Element> elems = getChildElements((Element)elem, name);
+    public static Object getElementsByName(final Object elem, final String name) {
+        final List<Element> elems = getChildElements((Element)elem, name);
         return elems.size() == 1? elems.get(0) : elems;
     }
 
     // method to extract text context under a given DOM Element
-    public static Object getElementText(Object elem) {
-        NodeList nodeList = ((Element)elem).getChildNodes();
-        int len = nodeList.getLength();
-        StringBuilder text = new StringBuilder();
+    public static Object getElementText(final Object elem) {
+        final NodeList nodeList = ((Element)elem).getChildNodes();
+        final int len = nodeList.getLength();
+        final StringBuilder text = new StringBuilder();
         for (int i = 0; i < len; i++) {
-            Node node = nodeList.item(i);
+            final Node node = nodeList.item(i);
             if (node.getNodeType() == Node.TEXT_NODE) {
                 text.append(node.getNodeValue());
             }
@@ -123,21 +122,21 @@
             }
 
             @Override
-            public GuardedInvocation getGuardedInvocation(LinkRequest request,
-                LinkerServices linkerServices) throws Exception {
+            public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+                final LinkerServices linkerServices) throws Exception {
                 final Object self = request.getReceiver();
                 if (! (self instanceof Element)) {
                     return null;
                 }
 
-                CallSiteDescriptor desc = request.getCallSiteDescriptor();
-                Operation op = desc.getOperation();
-                Object name = NamedOperation.getName(op);
-                boolean getProp = CompositeOperation.contains(
+                final CallSiteDescriptor desc = request.getCallSiteDescriptor();
+                final Operation op = desc.getOperation();
+                final Object name = NamedOperation.getName(op);
+                final boolean getProp = CompositeOperation.contains(
                         NamedOperation.getBaseOperation(op),
                         StandardOperation.GET_PROPERTY);
                 if (getProp && name instanceof String) {
-                    String nameStr = (String)name;
+                    final String nameStr = (String)name;
 
                     // Treat names starting with "_" as special names.
                     // Everything else is linked other dynalink bean linker!
--- a/nashorn/samples/dynalink/MissingMethodExample.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/samples/dynalink/MissingMethodExample.java	Tue Oct 18 17:14:09 2016 +0000
@@ -37,13 +37,13 @@
         implements MissingMethodHandler {
 
     @Override
-    public Object doesNotUnderstand(String name, Object... args) {
+    public Object doesNotUnderstand(final String name, final Object... args) {
         // This simple doesNotUnderstand just prints method name and args.
         // You can put useful method routing logic here.
         System.out.println("you called " + name);
         if (args.length != 0) {
             System.out.println("arguments are: ");
-            for (Object arg : args) {
+            for (final Object arg : args) {
                 System.out.println("    " + arg);
             }
         }
--- a/nashorn/samples/dynalink/MissingMethodLinkerExporter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/samples/dynalink/MissingMethodLinkerExporter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -40,12 +40,12 @@
 import jdk.dynalink.Operation;
 import jdk.dynalink.StandardOperation;
 import jdk.dynalink.beans.BeansLinker;
+import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.GuardingDynamicLinker;
 import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
-import jdk.dynalink.linker.GuardedInvocation;
-import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
 import jdk.dynalink.linker.LinkRequest;
 import jdk.dynalink.linker.LinkerServices;
+import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
 import jdk.dynalink.linker.support.Guards;
 import jdk.dynalink.linker.support.Lookup;
 
@@ -65,7 +65,7 @@
     public static class MissingMethod {
         private final String name;
 
-        public MissingMethod(String name) {
+        public MissingMethod(final String name) {
             this.name = name;
         }
 
@@ -130,20 +130,20 @@
             }
 
             @Override
-            public GuardedInvocation getGuardedInvocation(LinkRequest request,
-                LinkerServices linkerServices) throws Exception {
+            public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+                final LinkerServices linkerServices) throws Exception {
                 final Object self = request.getReceiver();
-                CallSiteDescriptor desc = request.getCallSiteDescriptor();
+                final CallSiteDescriptor desc = request.getCallSiteDescriptor();
 
                 // any method call is done by two steps. Step (1) GET_METHOD and (2) is CALL
                 // For step (1), we check if GET_METHOD can succeed by Java linker, if so
                 // we return that method object. If not, we return a MissingMethod object.
                 if (self instanceof MissingMethodHandler) {
                     // Check if this is a named GET_METHOD first.
-                    boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
-                    Object name = NamedOperation.getName(desc.getOperation());
+                    final boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
+                    final Object name = NamedOperation.getName(desc.getOperation());
                     if (isGetMethod && name instanceof String) {
-                        GuardingDynamicLinker javaLinker = beansLinker.getLinkerForClass(self.getClass());
+                        final GuardingDynamicLinker javaLinker = beansLinker.getLinkerForClass(self.getClass());
                         GuardedInvocation inv;
                         try {
                             inv = javaLinker.getGuardedInvocation(request, linkerServices);
@@ -151,11 +151,11 @@
                             inv = null;
                         }
 
-                        String nameStr = name.toString();
+                        final String nameStr = name.toString();
                         if (inv == null) {
                             // use "this" for just guard and drop it -- return a constant Method handle
                             // that returns a newly created MissingMethod object
-                            MethodHandle mh = MethodHandles.constant(Object.class, new MissingMethod(nameStr));
+                            final MethodHandle mh = MethodHandles.constant(Object.class, new MissingMethod(nameStr));
                             inv = new GuardedInvocation(
                                 MethodHandles.dropArguments(mh, 0, Object.class),
                                 Guards.isOfClass(self.getClass(), MethodType.methodType(Boolean.TYPE, Object.class)));
@@ -166,7 +166,7 @@
                 } else if (self instanceof MissingMethod) {
                     // This is step (2). We call MissingMethodHandler.doesNotUnderstand here
                     // Check if this is this a CALL first.
-                    boolean isCall = getFirstStandardOperation(desc) == StandardOperation.CALL;
+                    final boolean isCall = getFirstStandardOperation(desc) == StandardOperation.CALL;
                     if (isCall) {
                         MethodHandle mh = DOES_NOT_UNDERSTAND;
 
--- a/nashorn/samples/dynalink/UnderscoreNameLinkerExporter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/samples/dynalink/UnderscoreNameLinkerExporter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -29,22 +29,18 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import java.util.regex.Matcher;
 import jdk.dynalink.CallSiteDescriptor;
 import jdk.dynalink.CompositeOperation;
 import jdk.dynalink.NamedOperation;
 import jdk.dynalink.Operation;
-import jdk.dynalink.CompositeOperation;
 import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.GuardingDynamicLinker;
 import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
-import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.LinkRequest;
 import jdk.dynalink.linker.LinkerServices;
 import jdk.dynalink.linker.support.SimpleLinkRequest;
@@ -62,9 +58,9 @@
     private static final Pattern UNDERSCORE_NAME = Pattern.compile("_(.)");
 
     // translate underscore_separated name as a CamelCase name
-    private static String translateToCamelCase(String name) {
-        Matcher m = UNDERSCORE_NAME.matcher(name);
-        StringBuilder buf = new StringBuilder();
+    private static String translateToCamelCase(final String name) {
+        final Matcher m = UNDERSCORE_NAME.matcher(name);
+        final StringBuilder buf = new StringBuilder();
         while (m.find()) {
             m.appendReplacement(buf, m.group(1).toUpperCase());
         }
@@ -94,28 +90,28 @@
         final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>();
         linkers.add(new GuardingDynamicLinker() {
             @Override
-            public GuardedInvocation getGuardedInvocation(LinkRequest request,
-                LinkerServices linkerServices) throws Exception {
+            public GuardedInvocation getGuardedInvocation(final LinkRequest request,
+                final LinkerServices linkerServices) throws Exception {
                 final Object self = request.getReceiver();
-                CallSiteDescriptor desc = request.getCallSiteDescriptor();
-                Operation op = desc.getOperation();
-                Object name = NamedOperation.getName(op);
+                final CallSiteDescriptor desc = request.getCallSiteDescriptor();
+                final Operation op = desc.getOperation();
+                final Object name = NamedOperation.getName(op);
                 // is this a named GET_METHOD?
-                boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
+                final boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
                 if (isGetMethod && name instanceof String) {
-                    String str = (String)name;
+                    final String str = (String)name;
                     if (str.indexOf('_') == -1) {
                         return null;
                     }
 
-                    String nameStr = translateToCamelCase(str);
+                    final String nameStr = translateToCamelCase(str);
                     // create a new call descriptor to use translated name
-                    CallSiteDescriptor newDesc = new CallSiteDescriptor(
+                    final CallSiteDescriptor newDesc = new CallSiteDescriptor(
                         desc.getLookup(),
                         new NamedOperation(NamedOperation.getBaseOperation(op), nameStr),
                         desc.getMethodType());
                     // create a new Link request to link the call site with translated name
-                    LinkRequest newRequest = new SimpleLinkRequest(newDesc,
+                    final LinkRequest newRequest = new SimpleLinkRequest(newDesc,
                         request.isCallSiteUnstable(), request.getArguments());
                     // return guarded invocation linking the translated request
                     return linkerServices.getGuardedInvocation(newRequest);
--- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/PackagesHelper.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/PackagesHelper.java	Tue Oct 18 17:14:09 2016 +0000
@@ -75,6 +75,7 @@
     }
 
     private final Context context;
+    private final boolean modulePathSet;
     private final StandardJavaFileManager fm;
     private final Set<JavaFileObject.Kind> fileKinds;
     private final FileSystem jrtfs;
@@ -86,11 +87,17 @@
      */
     PackagesHelper(final Context context) throws IOException {
         this.context = context;
-        final String classPath = context.getEnv()._classpath;
+        final String modulePath = context.getEnv()._module_path;
+        this.modulePathSet = modulePath != null && !modulePath.isEmpty();
         if (isJavacAvailable()) {
+            final String classPath = context.getEnv()._classpath;
             fm = compiler.getStandardFileManager(null, null, null);
             fileKinds = EnumSet.of(JavaFileObject.Kind.CLASS);
 
+            if (this.modulePathSet) {
+                fm.setLocation(StandardLocation.MODULE_PATH, getFiles(modulePath));
+            }
+
             if (classPath != null && !classPath.isEmpty()) {
                 fm.setLocation(StandardLocation.CLASS_PATH, getFiles(classPath));
             } else {
@@ -155,6 +162,13 @@
         final Set<String> props = new HashSet<>();
         if (fm != null) {
             listPackage(StandardLocation.PLATFORM_CLASS_PATH, pkg, props);
+            if (this.modulePathSet) {
+                for (Set<Location> locs : fm.listModuleLocations(StandardLocation.MODULE_PATH)) {
+                    for (Location loc : locs) {
+                        listPackage(loc, pkg, props);
+                    }
+                }
+            }
             listPackage(StandardLocation.CLASS_PATH, pkg, props);
         } else if (jrtfs != null) {
             // look for the /packages/<package_name> directory
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DestructuringDeclTreeImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DestructuringDeclTreeImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -36,7 +36,7 @@
     private final ExpressionTree lhs;
     private final ExpressionTree init;
 
-    DestructuringDeclTreeImpl(ExpressionStatement exprStat, final ExpressionTree lhs, final ExpressionTree init) {
+    DestructuringDeclTreeImpl(final ExpressionStatement exprStat, final ExpressionTree lhs, final ExpressionTree init) {
         super(exprStat);
         assert exprStat.destructuringDeclarationType() != null : "expecting a destructuring decl. statement";
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExportEntryTreeImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExportEntryTreeImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -39,10 +39,10 @@
     private final IdentifierTree localName;
 
     private ExportEntryTreeImpl(final long startPos, final long endPos,
-            IdentifierTree exportName,
-            IdentifierTree moduleRequest,
-            IdentifierTree importName,
-            IdentifierTree localName) {
+            final IdentifierTree exportName,
+            final IdentifierTree moduleRequest,
+            final IdentifierTree importName,
+            final IdentifierTree localName) {
         super(null); // no underlying Node!
         this.startPos = startPos;
         this.endPos = endPos;
@@ -52,7 +52,7 @@
         this.localName = localName;
     }
 
-    private static ExportEntryTreeImpl createExportEntry(Module.ExportEntry entry) {
+    private static ExportEntryTreeImpl createExportEntry(final Module.ExportEntry entry) {
         return new ExportEntryTreeImpl(entry.getStartPosition(),
                 entry.getEndPosition(),
                 identOrNull(entry.getExportName()),
@@ -61,7 +61,7 @@
                 identOrNull(entry.getLocalName()));
     }
 
-    static List<ExportEntryTreeImpl> createExportList(List<Module.ExportEntry> exportList) {
+    static List<ExportEntryTreeImpl> createExportList(final List<Module.ExportEntry> exportList) {
         return exportList.stream().
             map(ExportEntryTreeImpl::createExportEntry).
             collect(Collectors.toList());
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTreeImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTreeImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -51,7 +51,7 @@
 
         this.params = params;
         if (node.getFlag(FunctionNode.HAS_EXPRESSION_BODY)) {
-            StatementTree first = body.getStatements().get(0);
+            final StatementTree first = body.getStatements().get(0);
             assert first instanceof ReturnTree : "consise func. expression should have a return statement";
             this.body = ((ReturnTree)first).getExpression();
         } else {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IRTranslator.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IRTranslator.java	Tue Oct 18 17:14:09 2016 +0000
@@ -191,9 +191,9 @@
     @Override
     public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) {
         if (expressionStatement.destructuringDeclarationType() != null) {
-            ExpressionTree expr = translateExpr(expressionStatement.getExpression());
+            final ExpressionTree expr = translateExpr(expressionStatement.getExpression());
             assert expr instanceof AssignmentTree : "destructuring decl. statement does not have assignment";
-            AssignmentTree assign = (AssignmentTree)expr;
+            final AssignmentTree assign = (AssignmentTree)expr;
             curStat = new DestructuringDeclTreeImpl(expressionStatement, assign.getVariable(), assign.getExpression());
         } else {
             curStat = new ExpressionStatementTreeImpl(expressionStatement,
@@ -544,12 +544,12 @@
     }
 
     private List<? extends ExpressionTree> translateParameters(final FunctionNode func) {
-        Map<IdentNode, Expression> paramExprs = func.getParameterExpressions();
+        final Map<IdentNode, Expression> paramExprs = func.getParameterExpressions();
         if (paramExprs != null) {
-            List<IdentNode> params = func.getParameters();
+            final List<IdentNode> params = func.getParameters();
             final List<ExpressionTreeImpl> exprTrees = new ArrayList<>(params.size());
             for (final IdentNode ident : params) {
-                Expression expr = paramExprs.containsKey(ident)? paramExprs.get(ident) : ident;
+                final Expression expr = paramExprs.containsKey(ident)? paramExprs.get(ident) : ident;
                 curExpr = null;
                 expr.accept(this);
                 assert curExpr != null;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ImportEntryTreeImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ImportEntryTreeImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -38,9 +38,9 @@
     private final IdentifierTree localName;
 
     private ImportEntryTreeImpl(final long startPos, final long endPos,
-            IdentifierTree moduleRequest,
-            IdentifierTree importName,
-            IdentifierTree localName) {
+            final IdentifierTree moduleRequest,
+            final IdentifierTree importName,
+            final IdentifierTree localName) {
         super(null); // No underlying Node!
         this.startPos = startPos;
         this.endPos = endPos;
@@ -49,7 +49,7 @@
         this.localName = localName;
     }
 
-    private static ImportEntryTreeImpl createImportEntry(Module.ImportEntry entry) {
+    private static ImportEntryTreeImpl createImportEntry(final Module.ImportEntry entry) {
         return new ImportEntryTreeImpl(entry.getStartPosition(),
                 entry.getEndPosition(),
                 identOrNull(entry.getModuleRequest()),
@@ -57,7 +57,7 @@
                 identOrNull(entry.getLocalName()));
     }
 
-    static List<ImportEntryTreeImpl> createImportList(List<Module.ImportEntry> importList) {
+    static List<ImportEntryTreeImpl> createImportList(final List<Module.ImportEntry> importList) {
         return importList.stream().
             map(ImportEntryTreeImpl::createImportEntry).
             collect(Collectors.toList());
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Parser.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Parser.java	Tue Oct 18 17:14:09 2016 +0000
@@ -140,7 +140,7 @@
      */
     public static Parser create(final String... options) throws IllegalArgumentException {
         options.getClass();
-        for (String opt : options) {
+        for (final String opt : options) {
             switch (opt) {
                 case "--const-as-var":
                 case "-dump-on-error":
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParserImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParserImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -73,9 +73,9 @@
 
         // append "--parse-only to signal to the Nashorn that it
         // is being used in "parse only" mode.
-        String[] newArgs = Arrays.copyOf(args, args.length + 1, String[].class);
+        final String[] newArgs = Arrays.copyOf(args, args.length + 1, String[].class);
         newArgs[args.length] = "--parse-only";
-        Options options = new Options("nashorn");
+        final Options options = new Options("nashorn");
         options.process(newArgs);
         this.env = new ScriptEnvironment(options,
                 new PrintWriter(System.out), new PrintWriter(System.err));
@@ -142,32 +142,32 @@
         }
     }
 
-    private CompilationUnitTree parseModule(File file, DiagnosticListener listener) throws IOException, NashornException {
+    private CompilationUnitTree parseModule(final File file, final DiagnosticListener listener) throws IOException, NashornException {
         final Source src = Source.sourceFor(Objects.requireNonNull(file).getName(), file);
         return makeModule(src, listener);
     }
 
-    private CompilationUnitTree parseModule(Path path, DiagnosticListener listener) throws IOException, NashornException {
+    private CompilationUnitTree parseModule(final Path path, final DiagnosticListener listener) throws IOException, NashornException {
         final Source src = Source.sourceFor(Objects.requireNonNull(path).toString(), path);
         return makeModule(src, listener);
     }
 
-    private CompilationUnitTree parseModule(URL url, DiagnosticListener listener) throws IOException, NashornException {
+    private CompilationUnitTree parseModule(final URL url, final DiagnosticListener listener) throws IOException, NashornException {
         final Source src = Source.sourceFor(url.toString(), url);
         return makeModule(src, listener);
     }
 
-    private CompilationUnitTree parseModule(String name, Reader reader, DiagnosticListener listener) throws IOException, NashornException {
+    private CompilationUnitTree parseModule(final String name, final Reader reader, final DiagnosticListener listener) throws IOException, NashornException {
         final Source src = Source.sourceFor(Objects.requireNonNull(name), Objects.requireNonNull(reader));
         return makeModule(src, listener);
     }
 
-    private CompilationUnitTree parseModule(String name, String code, DiagnosticListener listener) throws NashornException {
+    private CompilationUnitTree parseModule(final String name, final String code, final DiagnosticListener listener) throws NashornException {
         final Source src = Source.sourceFor(name, code);
         return makeModule(src, listener);
     }
 
-    private CompilationUnitTree parseModule(ScriptObjectMirror scriptObj, DiagnosticListener listener) throws NashornException {
+    private CompilationUnitTree parseModule(final ScriptObjectMirror scriptObj, final DiagnosticListener listener) throws NashornException {
         final Map<?, ?> map = Objects.requireNonNull(scriptObj);
         if (map.containsKey("script") && map.containsKey("name")) {
             final String script = JSType.toString(map.get("script"));
@@ -179,7 +179,7 @@
         }
     }
 
-    private CompilationUnitTree makeModule(Source src, DiagnosticListener listener) {
+    private CompilationUnitTree makeModule(final Source src, final DiagnosticListener listener) {
         final FunctionNode modFunc = makeParser(src, listener).parseModule(src.getName());
         return new IRTranslator().translate(modFunc);
     }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES5_1.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES5_1.java	Tue Oct 18 17:14:09 2016 +0000
@@ -70,7 +70,7 @@
      * @return the result of {@code visitUnknown}
      */
     @Override
-    public R visitModule(ModuleTree node, P p) {
+    public R visitModule(final ModuleTree node, final P p) {
         return visitUnknown(node, p);
     }
 
@@ -83,7 +83,7 @@
      * @return the result of {@code visitUnknown}
      */
     @Override
-    public R visitExportEntry(ExportEntryTree node, P p) {
+    public R visitExportEntry(final ExportEntryTree node, final P p) {
         return visitUnknown(node, p);
     }
 
@@ -96,7 +96,7 @@
      * @return the result of {@code visitUnknown}
      */
     @Override
-    public R visitImportEntry(ImportEntryTree node, P p) {
+    public R visitImportEntry(final ImportEntryTree node, final P p) {
         return visitUnknown(node, p);
     }
 
@@ -153,7 +153,7 @@
      * @return the result of {@code visitUnknown}
      */
     @Override
-    public R visitClassDeclaration(ClassDeclarationTree node, P p) {
+    public R visitClassDeclaration(final ClassDeclarationTree node, final P p) {
         return visitUnknown(node, p);
     }
 
@@ -166,7 +166,7 @@
      * @return the result of {@code visitUnknown}
      */
     @Override
-    public R visitClassExpression(ClassExpressionTree node, P p) {
+    public R visitClassExpression(final ClassExpressionTree node, final P p) {
         return visitUnknown(node, p);
     }
 
@@ -247,7 +247,7 @@
      * @return the result of {@code visitUnknown}
      */
     @Override
-    public R visitForOfLoop(ForOfLoopTree node, P p) {
+    public R visitForOfLoop(final ForOfLoopTree node, final P p) {
         return visitUnknown(node, p);
     }
 
@@ -357,21 +357,21 @@
 
     @Override
     public R visitProperty(final PropertyTree node, final P r) {
-        FunctionExpressionTree getter = node.getGetter();
+        final FunctionExpressionTree getter = node.getGetter();
         if (getter != null) {
             getter.accept(this, r);
         }
-        ExpressionTree key = node.getKey();
+        final ExpressionTree key = node.getKey();
         if (key != null) {
             key.accept(this, r);
         }
 
-        FunctionExpressionTree setter = node.getSetter();
+        final FunctionExpressionTree setter = node.getSetter();
         if (setter != null) {
             setter.accept(this, r);
         }
 
-        ExpressionTree value = node.getValue();
+        final ExpressionTree value = node.getValue();
         if (value != null) {
             value.accept(this, r);
         }
@@ -392,7 +392,7 @@
      * @return the result of {@code visitUnknown}
      */
     @Override
-    public R visitTemplateLiteral(TemplateLiteralTree node, P p) {
+    public R visitTemplateLiteral(final TemplateLiteralTree node, final P p) {
         return visitUnknown(node, p);
     }
 
@@ -410,7 +410,7 @@
      * @return the result of {@code visitUnknown}
      */
     @Override
-    public R visitSpread(SpreadTree node, P p) {
+    public R visitSpread(final SpreadTree node, final P p) {
         return visitUnknown(node, p);
     }
 
@@ -495,7 +495,7 @@
      * @return the result of {@code visitUnknown}
      */
     @Override
-    public R visitYield(YieldTree node, P p) {
+    public R visitYield(final YieldTree node, final P p) {
         return visitUnknown(node, p);
     }
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES6.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES6.java	Tue Oct 18 17:14:09 2016 +0000
@@ -66,7 +66,7 @@
      * @return value from the visitor
      */
     @Override
-    public R visitModule(ModuleTree node, P p) {
+    public R visitModule(final ModuleTree node, final P p) {
         node.getImportEntries().forEach(e -> visitImportEntry(e, p));
         node.getLocalExportEntries().forEach(e -> visitExportEntry(e, p));
         node.getIndirectExportEntries().forEach(e -> visitExportEntry(e, p));
@@ -82,7 +82,7 @@
      * @return value from the visitor
      */
     @Override
-    public R visitExportEntry(ExportEntryTree node, P p) {
+    public R visitExportEntry(final ExportEntryTree node, final P p) {
         return null;
     }
 
@@ -94,7 +94,7 @@
      * @return value from the visitor
      */
     @Override
-    public R visitImportEntry(ImportEntryTree node, P p) {
+    public R visitImportEntry(final ImportEntryTree node, final P p) {
         return null;
     }
 
@@ -106,7 +106,7 @@
     * @return value from the visitor
     */
     @Override
-    public R visitClassDeclaration(ClassDeclarationTree node, P p) {
+    public R visitClassDeclaration(final ClassDeclarationTree node, final P p) {
         node.getName().accept(this, p);
         final ExpressionTree heritage = node.getClassHeritage();
         if (heritage != null) {
@@ -118,7 +118,7 @@
         }
         final List<? extends PropertyTree> elements = node.getClassElements();
         if (elements != null) {
-            for (PropertyTree prop : elements) {
+            for (final PropertyTree prop : elements) {
                 prop.accept(this, p);
             }
         }
@@ -134,7 +134,7 @@
      * @return value from the visitor
      */
     @Override
-    public R visitClassExpression(ClassExpressionTree node, P p) {
+    public R visitClassExpression(final ClassExpressionTree node, final P p) {
         node.getName().accept(this, p);
         final ExpressionTree heritage = node.getClassHeritage();
         if (heritage != null) {
@@ -146,7 +146,7 @@
         }
         final List<? extends PropertyTree> elements = node.getClassElements();
         if (elements != null) {
-            for (PropertyTree prop : elements) {
+            for (final PropertyTree prop : elements) {
                 prop.accept(this, p);
             }
         }
@@ -180,7 +180,7 @@
      * @return value from the visitor
      */
     @Override
-    public R visitYield(YieldTree node, P p) {
+    public R visitYield(final YieldTree node, final P p) {
         node.getExpression().accept(this, p);
         return null;
     }
@@ -193,7 +193,7 @@
      * @return value from the visitor
      */
     @Override
-    public R visitSpread(SpreadTree node, P p) {
+    public R visitSpread(final SpreadTree node, final P p) {
         node.getExpression().accept(this, p);
         return null;
     }
@@ -206,9 +206,9 @@
     * @return value from the visitor
     */
     @Override
-    public R visitTemplateLiteral(TemplateLiteralTree node, P p) {
+    public R visitTemplateLiteral(final TemplateLiteralTree node, final P p) {
         final List<? extends ExpressionTree> expressions = node.getExpressions();
-        for (ExpressionTree expr : expressions) {
+        for (final ExpressionTree expr : expressions) {
             expr.accept(this, p);
         }
         return null;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SwitchTreeImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SwitchTreeImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -33,7 +33,7 @@
     private final List<? extends CaseTree> cases;
     SwitchTreeImpl(final SwitchNode node,
             final ExpressionTree expr,
-            List<? extends CaseTree> cases) {
+            final List<? extends CaseTree> cases) {
         super(node);
         this.expr = expr;
         this.cases = cases;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TemplateLiteralTreeImpl.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TemplateLiteralTreeImpl.java	Tue Oct 18 17:14:09 2016 +0000
@@ -33,7 +33,7 @@
 
     private final List<? extends ExpressionTree> expressions;
 
-    TemplateLiteralTreeImpl(Expression node, List<? extends ExpressionTree> expressions) {
+    TemplateLiteralTreeImpl(final Expression node, final List<? extends ExpressionTree> expressions) {
         super(node);
         this.expressions = expressions;
     }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Tree.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Tree.java	Tue Oct 18 17:14:09 2016 +0000
@@ -566,7 +566,7 @@
          */
         OTHER(null);
 
-        Kind(Class<? extends Tree> intf) {
+        Kind(final Class<? extends Tree> intf) {
             associatedInterface = intf;
         }
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/UnknownTreeException.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/UnknownTreeException.java	Tue Oct 18 17:14:09 2016 +0000
@@ -52,7 +52,7 @@
      * @param t the unknown tree, may be {@code null}
      * @param p an additional parameter, may be {@code null}
      */
-    public UnknownTreeException(Tree t, Object p) {
+    public UnknownTreeException(final Tree t, final Object p) {
         super("Unknown tree: " + t);
         this.tree = t;
         this.parameter = p;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java	Tue Oct 18 17:14:09 2016 +0000
@@ -258,7 +258,7 @@
     private final int[] continuationEntryPoints;
 
     // Scope object creators needed for for-of and for-in loops
-    private Deque<FieldObjectCreator<?>> scopeObjectCreators = new ArrayDeque<>();
+    private final Deque<FieldObjectCreator<?>> scopeObjectCreators = new ArrayDeque<>();
 
     /**
      * Constructor.
@@ -2486,11 +2486,6 @@
                     }
 
                     @Override
-                    public boolean enterObjectNode(final ObjectNode objectNode) {
-                        return false;
-                    }
-
-                    @Override
                     public boolean enterDefault(final Node node) {
                         if (contains) {
                             return false;
@@ -2562,7 +2557,8 @@
             oc = new FieldObjectCreator<Expression>(this, tuples) {
                 @Override
                 protected void loadValue(final Expression node, final Type type) {
-                    loadExpressionAsType(node, type);
+                    // Use generic type in order to avoid conversion between object types
+                    loadExpressionAsType(node, Type.generic(type));
                 }};
         }
 
@@ -2578,10 +2574,7 @@
         //handler
         if (restOfProperty) {
             final ContinuationInfo ci = getContinuationInfo();
-            // Can be set at most once for a single rest-of method
-            assert ci.getObjectLiteralMap() == null;
-            ci.setObjectLiteralMap(oc.getMap());
-            ci.setObjectLiteralStackDepth(method.getStackSize());
+            ci.setObjectLiteralMap(method.getStackSize(), oc.getMap());
         }
 
         method.dup();
@@ -5309,10 +5302,8 @@
         private Type[] stackTypes;
         // If non-null, this node should perform the requisite type conversion
         private Type returnValueType;
-        // If we are in the middle of an object literal initialization, we need to update the map
-        private PropertyMap objectLiteralMap;
-        // Object literal stack depth for object literal - not necessarily top if property is a tree
-        private int objectLiteralStackDepth = -1;
+        // If we are in the middle of an object literal initialization, we need to update the property maps
+        private Map<Integer, PropertyMap> objectLiteralMaps;
         // The line number at the continuation point
         private int lineNumber;
         // The active catch label, in case the continuation point is in a try/catch block
@@ -5364,20 +5355,15 @@
             this.returnValueType = returnValueType;
         }
 
-        int getObjectLiteralStackDepth() {
-            return objectLiteralStackDepth;
-        }
-
-        void setObjectLiteralStackDepth(final int objectLiteralStackDepth) {
-            this.objectLiteralStackDepth = objectLiteralStackDepth;
-        }
-
-        PropertyMap getObjectLiteralMap() {
-            return objectLiteralMap;
-        }
-
-        void setObjectLiteralMap(final PropertyMap objectLiteralMap) {
-            this.objectLiteralMap = objectLiteralMap;
+        void setObjectLiteralMap(final int objectLiteralStackDepth, final PropertyMap objectLiteralMap) {
+            if (objectLiteralMaps == null) {
+                objectLiteralMaps = new HashMap<>();
+            }
+            objectLiteralMaps.put(objectLiteralStackDepth, objectLiteralMap);
+        }
+
+        PropertyMap getObjectLiteralMap(final int stackDepth) {
+            return objectLiteralMaps == null ? null : objectLiteralMaps.get(stackDepth);
         }
 
         @Override
@@ -5467,10 +5453,9 @@
         final int[]   stackStoreSpec = ci.getStackStoreSpec();
         final Type[]  stackTypes     = ci.getStackTypes();
         final boolean isStackEmpty   = stackStoreSpec.length == 0;
-        boolean replacedObjectLiteralMap = false;
+        int replacedObjectLiteralMaps = 0;
         if(!isStackEmpty) {
             // Load arguments on the stack
-            final int objectLiteralStackDepth = ci.getObjectLiteralStackDepth();
             for(int i = 0; i < stackStoreSpec.length; ++i) {
                 final int slot = stackStoreSpec[i];
                 method.load(lvarTypes.get(slot), slot);
@@ -5478,18 +5463,18 @@
                 // stack: s0=object literal being initialized
                 // change map of s0 so that the property we are initializing when we failed
                 // is now ci.returnValueType
-                if (i == objectLiteralStackDepth) {
+                final PropertyMap map = ci.getObjectLiteralMap(i);
+                if (map != null) {
                     method.dup();
-                    assert ci.getObjectLiteralMap() != null;
                     assert ScriptObject.class.isAssignableFrom(method.peekType().getTypeClass()) : method.peekType().getTypeClass() + " is not a script object";
-                    loadConstant(ci.getObjectLiteralMap());
+                    loadConstant(map);
                     method.invoke(ScriptObject.SET_MAP);
-                    replacedObjectLiteralMap = true;
+                    replacedObjectLiteralMaps++;
                 }
             }
         }
-        // Must have emitted the code for replacing the map of an object literal if we have a set object literal stack depth
-        assert ci.getObjectLiteralStackDepth() == -1 || replacedObjectLiteralMap;
+        // Must have emitted the code for replacing all object literal maps
+        assert ci.objectLiteralMaps == null || ci.objectLiteralMaps.size() == replacedObjectLiteralMaps;
         // Load RewriteException back.
         method.load(rewriteExceptionType, lvarCount);
         // Get rid of the stored reference
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java	Tue Oct 18 17:14:09 2016 +0000
@@ -189,7 +189,8 @@
 
     @Override
     protected void loadValue(final Expression expr, final Type type) {
-        codegen.loadExpressionAsType(expr, type);
+        // Use generic type in order to avoid conversion between object types
+        codegen.loadExpressionAsType(expr, Type.generic(type));
     }
 
     @Override
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SplitIntoFunctions.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SplitIntoFunctions.java	Tue Oct 18 17:14:09 2016 +0000
@@ -102,7 +102,7 @@
         super(new BlockLexicalContext() {
             @Override
             protected Block afterSetStatements(final Block block) {
-                for(Statement stmt: block.getStatements()) {
+                for(final Statement stmt: block.getStatements()) {
                     assert !(stmt instanceof SplitNode);
                 }
                 return block;
@@ -145,7 +145,7 @@
         final FunctionState fnState = getCurrentFunctionState();
 
         final String name = splitNode.getName();
-        Block body = splitNode.getBody();
+        final Block body = splitNode.getBody();
         final int firstLineNumber = body.getFirstStatementLineNumber();
         final long token = body.getToken();
         final int finish = body.getFinish();
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ExpressionList.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ExpressionList.java	Tue Oct 18 17:14:09 2016 +0000
@@ -71,10 +71,10 @@
     }
 
     @Override
-    public void toString(StringBuilder sb, boolean printType) {
+    public void toString(final StringBuilder sb, final boolean printType) {
         sb.append("(");
         boolean first = true;
-        for (Expression expression : expressions) {
+        for (final Expression expression : expressions) {
             if (first) {
                 first = false;
             } else {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/LiteralNode.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/LiteralNode.java	Tue Oct 18 17:14:09 2016 +0000
@@ -635,6 +635,12 @@
         /** Ranges for splitting up large literals in code generation */
         private final List<Splittable.SplitRange> splitRanges;
 
+        /** Does this array literal have a spread element? */
+        private final boolean hasSpread;
+
+        /** Does this array literal have a trailing comma?*/
+        private final boolean hasTrailingComma;
+
         @Override
         public boolean isArray() {
             return true;
@@ -791,11 +797,26 @@
          * @param value   array literal value, a Node array
          */
         protected ArrayLiteralNode(final long token, final int finish, final Expression[] value) {
+            this(token, finish, value, false, false);
+        }
+
+        /**
+         * Constructor
+         *
+         * @param token   token
+         * @param finish  finish
+         * @param value   array literal value, a Node array
+         * @param hasSpread true if the array has a spread element
+         * @param hasTrailingComma true if the array literal has a comma after the last element
+         */
+        protected ArrayLiteralNode(final long token, final int finish, final Expression[] value, final boolean hasSpread, final boolean hasTrailingComma) {
             super(Token.recast(token, TokenType.ARRAY), finish, value);
             this.elementType = Type.UNKNOWN;
             this.presets     = null;
             this.postsets    = null;
             this.splitRanges = null;
+            this.hasSpread        = hasSpread;
+            this.hasTrailingComma = hasTrailingComma;
         }
 
         /**
@@ -808,6 +829,24 @@
             this.postsets    = postsets;
             this.presets     = presets;
             this.splitRanges = splitRanges;
+            this.hasSpread        = node.hasSpread;
+            this.hasTrailingComma = node.hasTrailingComma;
+        }
+
+        /**
+         * Returns {@code true} if this array literal has a spread element.
+         * @return true if this literal has a spread element
+         */
+        public boolean hasSpread() {
+            return hasSpread;
+        }
+
+        /**
+         * Returns {@code true} if this array literal has a trailing comma.
+         * @return true if this literal has a trailing comma
+         */
+        public boolean hasTrailingComma() {
+             return hasTrailingComma;
         }
 
         /**
@@ -989,6 +1028,23 @@
         return new ArrayLiteralNode(parent.getToken(), parent.getFinish(), valueToArray(value));
     }
 
+    /*
+     * Create a new array literal of Nodes from a list of Node values
+     *
+     * @param token token
+     * @param finish finish
+     * @param value literal value list
+     * @param hasSpread true if the array has a spread element
+     * @param hasTrailingComma true if the array literal has a comma after the last element
+     *
+     * @return the new literal node
+     */
+    public static LiteralNode<Expression[]> newInstance(final long token, final int finish, final List<Expression> value,
+                                                        final boolean hasSpread, final boolean hasTrailingComma) {
+        return new ArrayLiteralNode(token, finish, valueToArray(value), hasSpread, hasTrailingComma);
+    }
+
+
     /**
      * Create a new array literal of Nodes
      *
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/TemplateLiteral.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/TemplateLiteral.java	Tue Oct 18 17:14:09 2016 +0000
@@ -51,7 +51,7 @@
     }
 
     @Override
-    public Node accept(NodeVisitor<? extends LexicalContext> visitor) {
+    public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
         if (visitor.enterTemplateLiteral(this)) {
             return visitor.leaveTemplateLiteral(this);
         }
@@ -60,8 +60,8 @@
     }
 
     @Override
-    public void toString(StringBuilder sb, boolean printType) {
-        for (Expression expr : exprs) {
+    public void toString(final StringBuilder sb, final boolean printType) {
+        for (final Expression expr : exprs) {
             sb.append(expr);
         }
     }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java	Tue Oct 18 17:14:09 2016 +0000
@@ -2474,7 +2474,7 @@
     }
 
     @Override
-    protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) {
+    protected FindProperty findProperty(final Object key, final boolean deep, final boolean isScope, final ScriptObject start) {
         if (lexicalScope != null && isScope) {
             final FindProperty find = lexicalScope.findProperty(key, false);
             if (find != null) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSAdapter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSAdapter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -473,22 +473,6 @@
     }
 
     @Override
-    protected GuardedInvocation findCallMethodMethod(final CallSiteDescriptor desc, final LinkRequest request) {
-        if (overrides && super.hasOwnProperty(NashornCallSiteDescriptor.getOperand(desc))) {
-            try {
-                final GuardedInvocation inv = super.findCallMethodMethod(desc, request);
-                if (inv != null) {
-                    return inv;
-                }
-            } catch (final Exception e) {
-                //ignored
-            }
-        }
-
-        return findHook(desc, __call__);
-    }
-
-    @Override
     protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final StandardOperation operation) {
         final String name = NashornCallSiteDescriptor.getOperand(desc);
         if (overrides && super.hasOwnProperty(name)) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java	Tue Oct 18 17:14:09 2016 +0000
@@ -473,7 +473,7 @@
         if (holder instanceof ScriptObject) {
             return ((ScriptObject)holder).get(key);
         } else if (holder instanceof JSObject) {
-            JSObject jsObj = (JSObject)holder;
+            final JSObject jsObj = (JSObject)holder;
             if (key instanceof Integer) {
                 return jsObj.getSlot((Integer)key);
             } else {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java	Tue Oct 18 17:14:09 2016 +0000
@@ -408,7 +408,7 @@
     /**
      * Test if char is a template literal delimiter ('`').
      */
-    private static boolean isTemplateDelimiter(char ch) {
+    private static boolean isTemplateDelimiter(final char ch) {
         return ch == '`';
     }
 
@@ -1077,7 +1077,7 @@
                 add(type == TEMPLATE ? TEMPLATE_HEAD : type, stringState.position, stringState.limit);
 
                 // scan to RBRACE
-                Lexer expressionLexer = new Lexer(this, saveState());
+                final Lexer expressionLexer = new Lexer(this, saveState());
                 expressionLexer.templateExpressionOpenBraces = 1;
                 expressionLexer.lexify();
                 restoreState(expressionLexer.saveState());
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java	Tue Oct 18 17:14:09 2016 +0000
@@ -632,7 +632,7 @@
         return getStatement(false);
     }
 
-    private Block getStatement(boolean labelledStatement) {
+    private Block getStatement(final boolean labelledStatement) {
         if (type == LBRACE) {
             return getBlock(true);
         }
@@ -746,58 +746,25 @@
         return new BinaryNode(op, lhs, rhs);
     }
 
-    private boolean isDestructuringLhs(Expression lhs) {
+    private boolean isDestructuringLhs(final Expression lhs) {
         if (lhs instanceof ObjectNode || lhs instanceof LiteralNode.ArrayLiteralNode) {
             return isES6();
         }
         return false;
     }
 
-    private void verifyDestructuringAssignmentPattern(Expression pattern, String contextString) {
+    private void verifyDestructuringAssignmentPattern(final Expression pattern, final String contextString) {
         assert pattern instanceof ObjectNode || pattern instanceof LiteralNode.ArrayLiteralNode;
-        pattern.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
+        pattern.accept(new VerifyDestructuringPatternNodeVisitor(new LexicalContext()) {
             @Override
-            public boolean enterLiteralNode(LiteralNode<?> literalNode) {
-                if (literalNode.isArray()) {
-                    boolean restElement = false;
-                    for (Expression element : literalNode.getElementExpressions()) {
-                        if (element != null) {
-                            if (restElement) {
-                                throw error(String.format("Unexpected element after rest element"), element.getToken());
-                            }
-                            if (element.isTokenType(SPREAD_ARRAY)) {
-                                restElement = true;
-                                Expression lvalue = ((UnaryNode) element).getExpression();
-                                if (!checkValidLValue(lvalue, contextString)) {
-                                    throw error(AbstractParser.message("invalid.lvalue"), lvalue.getToken());
-                                }
-                            }
-                            element.accept(this);
-                        }
-                    }
-                    return false;
-                } else {
-                    return enterDefault(literalNode);
+            protected void verifySpreadElement(final Expression lvalue) {
+                if (!checkValidLValue(lvalue, contextString)) {
+                    throw error(AbstractParser.message("invalid.lvalue"), lvalue.getToken());
                 }
             }
 
             @Override
-            public boolean enterObjectNode(ObjectNode objectNode) {
-                return true;
-            }
-
-            @Override
-            public boolean enterPropertyNode(PropertyNode propertyNode) {
-                if (propertyNode.getValue() != null) {
-                    propertyNode.getValue().accept(this);
-                    return false;
-                } else {
-                    return enterDefault(propertyNode);
-                }
-            }
-
-            @Override
-            public boolean enterIdentNode(IdentNode identNode) {
+            public boolean enterIdentNode(final IdentNode identNode) {
                 verifyIdent(identNode, contextString);
                 if (!checkIdentLValue(identNode)) {
                     referenceError(identNode, null, true);
@@ -807,38 +774,17 @@
             }
 
             @Override
-            public boolean enterAccessNode(AccessNode accessNode) {
-                return false;
-            }
-
-            @Override
-            public boolean enterIndexNode(IndexNode indexNode) {
+            public boolean enterAccessNode(final AccessNode accessNode) {
                 return false;
             }
 
             @Override
-            public boolean enterBinaryNode(BinaryNode binaryNode) {
-                if (binaryNode.isTokenType(ASSIGN)) {
-                    binaryNode.lhs().accept(this);
-                    // Initializer(rhs) can be any AssignmentExpression
-                    return false;
-                } else {
-                    return enterDefault(binaryNode);
-                }
+            public boolean enterIndexNode(final IndexNode indexNode) {
+                return false;
             }
 
             @Override
-            public boolean enterUnaryNode(UnaryNode unaryNode) {
-                if (unaryNode.isTokenType(SPREAD_ARRAY)) {
-                    // rest element
-                    return true;
-                } else {
-                    return enterDefault(unaryNode);
-                }
-            }
-
-            @Override
-            protected boolean enterDefault(Node node) {
+            protected boolean enterDefault(final Node node) {
                 throw error(String.format("unexpected node in AssignmentPattern: %s", node));
             }
         });
@@ -1221,13 +1167,13 @@
      *   class BindingIdentifier[?Yield] ClassTail[?Yield]
      *   [+Default] class ClassTail[?Yield]
      */
-    private ClassNode classDeclaration(boolean isDefault) {
-        int classLineNumber = line;
-
-        ClassNode classExpression = classExpression(!isDefault);
+    private ClassNode classDeclaration(final boolean isDefault) {
+        final int classLineNumber = line;
+
+        final ClassNode classExpression = classExpression(!isDefault);
 
         if (!isDefault) {
-            VarNode classVar = new VarNode(classLineNumber, classExpression.getToken(), classExpression.getIdent().getFinish(), classExpression.getIdent(), classExpression, VarNode.IS_CONST);
+            final VarNode classVar = new VarNode(classLineNumber, classExpression.getToken(), classExpression.getIdent().getFinish(), classExpression.getIdent(), classExpression, VarNode.IS_CONST);
             appendStatement(classVar);
         }
         return classExpression;
@@ -1237,10 +1183,10 @@
      * ClassExpression[Yield] :
      *   class BindingIdentifier[?Yield]opt ClassTail[?Yield]
      */
-    private ClassNode classExpression(boolean isStatement) {
+    private ClassNode classExpression(final boolean isStatement) {
         assert type == CLASS;
-        int classLineNumber = line;
-        long classToken = token;
+        final int classLineNumber = line;
+        final long classToken = token;
         next();
 
         IdentNode className = null;
@@ -1255,7 +1201,7 @@
         private final boolean isStatic;
         private final String propertyName;
 
-        private ClassElementKey(boolean isStatic, String propertyName) {
+        private ClassElementKey(final boolean isStatic, final String propertyName) {
             this.isStatic = isStatic;
             this.propertyName = propertyName;
         }
@@ -1270,9 +1216,9 @@
         }
 
         @Override
-        public boolean equals(Object obj) {
+        public boolean equals(final Object obj) {
             if (obj instanceof ClassElementKey) {
-                ClassElementKey other = (ClassElementKey) obj;
+                final ClassElementKey other = (ClassElementKey) obj;
                 return this.isStatic == other.isStatic && Objects.equals(this.propertyName, other.propertyName);
             }
             return false;
@@ -1386,7 +1332,7 @@
         }
     }
 
-    private PropertyNode createDefaultClassConstructor(int classLineNumber, long classToken, long lastToken, IdentNode className, boolean subclass) {
+    private PropertyNode createDefaultClassConstructor(final int classLineNumber, final long classToken, final long lastToken, final IdentNode className, final boolean subclass) {
         final int ctorFinish = finish;
         final List<Statement> statements;
         final List<IdentNode> parameters;
@@ -1579,7 +1525,50 @@
         variableDeclarationList(varType, true, -1);
     }
 
-    private List<Expression> variableDeclarationList(final TokenType varType, final boolean isStatement, final int sourceOrder) {
+    private static final class ForVariableDeclarationListResult {
+        /** First missing const or binding pattern initializer. */
+        Expression missingAssignment;
+        /** First declaration with an initializer. */
+        long declarationWithInitializerToken;
+        /** Destructuring assignments. */
+        Expression init;
+        Expression firstBinding;
+        Expression secondBinding;
+
+        void recordMissingAssignment(final Expression binding) {
+            if (missingAssignment == null) {
+                missingAssignment = binding;
+            }
+        }
+
+        void recordDeclarationWithInitializer(final long token) {
+            if (declarationWithInitializerToken == 0L) {
+                declarationWithInitializerToken = token;
+            }
+        }
+
+        void addBinding(final Expression binding) {
+            if (firstBinding == null) {
+                firstBinding = binding;
+            } else if (secondBinding == null)  {
+                secondBinding = binding;
+            }
+            // ignore the rest
+        }
+
+        void addAssignment(final Expression assignment) {
+            if (init == null) {
+                init = assignment;
+            } else {
+                init = new BinaryNode(Token.recast(init.getToken(), COMMARIGHT), init, assignment);
+            }
+        }
+    }
+
+    /**
+     * @param isStatement {@code true} if a VariableStatement, {@code false} if a {@code for} loop VariableDeclarationList
+     */
+    private ForVariableDeclarationListResult variableDeclarationList(final TokenType varType, final boolean isStatement, final int sourceOrder) {
         // VAR tested in caller.
         assert varType == VAR || varType == LET || varType == CONST;
         final int varLine = line;
@@ -1587,7 +1576,6 @@
 
         next();
 
-        final List<Expression> bindings = new ArrayList<>();
         int varFlags = 0;
         if (varType == LET) {
             varFlags |= VarNode.IS_LET;
@@ -1595,7 +1583,7 @@
             varFlags |= VarNode.IS_CONST;
         }
 
-        Expression missingAssignment = null;
+        final ForVariableDeclarationListResult forResult = isStatement ? null : new ForVariableDeclarationListResult();
         while (true) {
             // Get name of var.
             if (type == YIELD && inGeneratorFunction()) {
@@ -1603,7 +1591,7 @@
             }
 
             final String contextString = "variable name";
-            Expression binding = bindingIdentifierOrPattern(contextString);
+            final Expression binding = bindingIdentifierOrPattern(contextString);
             final boolean isDestructuring = !(binding instanceof IdentNode);
             if (isDestructuring) {
                 final int finalVarFlags = varFlags;
@@ -1625,6 +1613,9 @@
 
             // Look for initializer assignment.
             if (type == ASSIGN) {
+                if (!isStatement) {
+                    forResult.recordDeclarationWithInitializer(varToken);
+                }
                 next();
 
                 // Get initializer expression. Suppress IN if not statement.
@@ -1655,26 +1646,29 @@
                 }
                 // Only set declaration flag on lexically scoped let/const as it adds runtime overhead.
                 final IdentNode name = varType == LET || varType == CONST ? ident.setIsDeclaredHere() : ident;
-                binding = name;
+                if (!isStatement) {
+                    if (init == null && varType == CONST) {
+                        forResult.recordMissingAssignment(name);
+                    }
+                    forResult.addBinding(new IdentNode(name));
+                }
                 final VarNode var = new VarNode(varLine, varToken, sourceOrder, finish, name, init, varFlags);
                 appendStatement(var);
-                if (init == null && varType == CONST) {
-                    if (missingAssignment == null) {
-                        missingAssignment = binding;
-                    }
-                }
             } else {
                 assert init != null || !isStatement;
-                binding = init == null ? binding : verifyAssignment(Token.recast(varToken, ASSIGN), binding, init);
-                if (isStatement) {
-                    appendStatement(new ExpressionStatement(varLine, binding.getToken(), finish, binding, varType));
-                } else if (init == null) {
-                    if (missingAssignment == null) {
-                        missingAssignment = binding;
+                if (init != null) {
+                    final Expression assignment = verifyAssignment(Token.recast(varToken, ASSIGN), binding, init);
+                    if (isStatement) {
+                        appendStatement(new ExpressionStatement(varLine, assignment.getToken(), finish, assignment, varType));
+                    } else {
+                        forResult.addAssignment(assignment);
+                        forResult.addBinding(assignment);
                     }
+                } else if (!isStatement) {
+                    forResult.recordMissingAssignment(binding);
+                    forResult.addBinding(binding);
                 }
             }
-            bindings.add(binding);
 
             if (type != COMMARIGHT) {
                 break;
@@ -1685,20 +1679,9 @@
         // If is a statement then handle end of line.
         if (isStatement) {
             endOfLine();
-        } else {
-            if (type == SEMICOLON) {
-                // late check for missing assignment, now we know it's a for (init; test; modify) loop
-                if (missingAssignment != null) {
-                    if (missingAssignment instanceof IdentNode) {
-                        throw error(AbstractParser.message("missing.const.assignment", ((IdentNode)missingAssignment).getName()));
-                    } else {
-                        throw error(AbstractParser.message("missing.destructuring.assignment"), missingAssignment.getToken());
-                    }
-                }
-            }
         }
 
-        return bindings;
+        return forResult;
     }
 
     private boolean isBindingIdentifier() {
@@ -1729,50 +1712,91 @@
         }
     }
 
+    private abstract class VerifyDestructuringPatternNodeVisitor extends NodeVisitor<LexicalContext> {
+        VerifyDestructuringPatternNodeVisitor(final LexicalContext lc) {
+            super(lc);
+        }
+
+        @Override
+        public boolean enterLiteralNode(final LiteralNode<?> literalNode) {
+            if (literalNode.isArray()) {
+                if (((LiteralNode.ArrayLiteralNode)literalNode).hasSpread() && ((LiteralNode.ArrayLiteralNode)literalNode).hasTrailingComma()) {
+                    throw error("Rest element must be last", literalNode.getElementExpressions().get(literalNode.getElementExpressions().size() - 1).getToken());
+                }
+                boolean restElement = false;
+                for (final Expression element : literalNode.getElementExpressions()) {
+                    if (element != null) {
+                        if (restElement) {
+                            throw error("Unexpected element after rest element", element.getToken());
+                        }
+                        if (element.isTokenType(SPREAD_ARRAY)) {
+                            restElement = true;
+                            final Expression lvalue = ((UnaryNode) element).getExpression();
+                            verifySpreadElement(lvalue);
+                        }
+                        element.accept(this);
+                    }
+                }
+                return false;
+            } else {
+                return enterDefault(literalNode);
+            }
+        }
+
+        protected abstract void verifySpreadElement(Expression lvalue);
+
+        @Override
+        public boolean enterObjectNode(final ObjectNode objectNode) {
+            return true;
+        }
+
+        @Override
+        public boolean enterPropertyNode(final PropertyNode propertyNode) {
+            if (propertyNode.getValue() != null) {
+                propertyNode.getValue().accept(this);
+                return false;
+            } else {
+                return enterDefault(propertyNode);
+            }
+        }
+
+        @Override
+        public boolean enterBinaryNode(final BinaryNode binaryNode) {
+            if (binaryNode.isTokenType(ASSIGN)) {
+                binaryNode.lhs().accept(this);
+                // Initializer(rhs) can be any AssignmentExpression
+                return false;
+            } else {
+                return enterDefault(binaryNode);
+            }
+        }
+
+        @Override
+        public boolean enterUnaryNode(final UnaryNode unaryNode) {
+            if (unaryNode.isTokenType(SPREAD_ARRAY)) {
+                // rest element
+                return true;
+            } else {
+                return enterDefault(unaryNode);
+            }
+        }
+    }
+
     /**
      * Verify destructuring variable declaration binding pattern and extract bound variable declarations.
      */
     private void verifyDestructuringBindingPattern(final Expression pattern, final Consumer<IdentNode> identifierCallback) {
-        assert (pattern instanceof BinaryNode && ((BinaryNode)pattern).isTokenType(ASSIGN)) ||
+        assert (pattern instanceof BinaryNode && pattern.isTokenType(ASSIGN)) ||
                 pattern instanceof ObjectNode || pattern instanceof LiteralNode.ArrayLiteralNode;
-        pattern.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
+        pattern.accept(new VerifyDestructuringPatternNodeVisitor(new LexicalContext()) {
             @Override
-            public boolean enterLiteralNode(final LiteralNode<?> literalNode) {
-                if (literalNode.isArray()) {
-                    boolean restElement = false;
-                    for (final Expression element : literalNode.getElementExpressions()) {
-                        if (restElement) {
-                            throw error(String.format("Unexpected element after rest element"), element.getToken());
-                        }
-                        if (element != null) {
-                            if (element.isTokenType(SPREAD_ARRAY)) {
-                                restElement = true;
-                                if (!(((UnaryNode) element).getExpression() instanceof IdentNode)) {
-                                    throw error(String.format("Expected a valid binding identifier"), element.getToken());
-
-                                }
-                            }
-                            element.accept(this);
-                        }
-                    }
-                    return false;
+            protected void verifySpreadElement(final Expression lvalue) {
+                if (lvalue instanceof IdentNode) {
+                    // checked in identifierCallback
+                } else if (isDestructuringLhs(lvalue)) {
+                    verifyDestructuringBindingPattern(lvalue, identifierCallback);
                 } else {
-                    return enterDefault(literalNode);
-                }
-            }
-
-            @Override
-            public boolean enterObjectNode(final ObjectNode objectNode) {
-                return true;
-            }
-
-            @Override
-            public boolean enterPropertyNode(final PropertyNode propertyNode) {
-                if (propertyNode.getValue() != null) {
-                    propertyNode.getValue().accept(this);
-                    return false;
-                } else {
-                    return enterDefault(propertyNode);
+                    throw error("Expected a valid binding identifier", lvalue.getToken());
                 }
             }
 
@@ -1783,27 +1807,6 @@
             }
 
             @Override
-            public boolean enterBinaryNode(final BinaryNode binaryNode) {
-                if (binaryNode.isTokenType(ASSIGN)) {
-                    binaryNode.lhs().accept(this);
-                    // Initializer(rhs) can be any AssignmentExpression
-                    return false;
-                } else {
-                    return enterDefault(binaryNode);
-                }
-            }
-
-            @Override
-            public boolean enterUnaryNode(final UnaryNode unaryNode) {
-                if (unaryNode.isTokenType(SPREAD_ARRAY)) {
-                    // rest element
-                    return true;
-                } else {
-                    return enterDefault(unaryNode);
-                }
-            }
-
-            @Override
             protected boolean enterDefault(final Node node) {
                 throw error(String.format("unexpected node in BindingPattern: %s", node));
             }
@@ -1844,7 +1847,7 @@
         final Expression expression = expression();
 
         if (expression != null) {
-            ExpressionStatement expressionStatement = new ExpressionStatement(expressionLine, expressionToken, finish, expression);
+            final ExpressionStatement expressionStatement = new ExpressionStatement(expressionLine, expressionToken, finish, expression);
             appendStatement(expressionStatement);
         } else {
             expect(null);
@@ -1910,10 +1913,10 @@
         final ParserContextLoopNode forNode = new ParserContextLoopNode();
         lc.push(forNode);
         Block body = null;
-        List<Expression> vars = null;
         Expression init = null;
         JoinPredecessorExpression test = null;
         JoinPredecessorExpression modify = null;
+        ForVariableDeclarationListResult varDeclList = null;
 
         int flags = 0;
         boolean isForOf = false;
@@ -1931,10 +1934,11 @@
 
             expect(LPAREN);
 
+            TokenType varType = null;
             switch (type) {
             case VAR:
                 // Var declaration captured in for outer block.
-                vars = variableDeclarationList(type, false, forStart);
+                varDeclList = variableDeclarationList(varType = type, false, forStart);
                 break;
             case SEMICOLON:
                 break;
@@ -1942,12 +1946,12 @@
                 if (useBlockScope() && (type == LET && lookaheadIsLetDeclaration(true) || type == CONST)) {
                     flags |= ForNode.PER_ITERATION_SCOPE;
                     // LET/CONST declaration captured in container block created above.
-                    vars = variableDeclarationList(type, false, forStart);
+                    varDeclList = variableDeclarationList(varType = type, false, forStart);
                     break;
                 }
                 if (env._const_as_var && type == CONST) {
                     // Var declaration captured in for outer block.
-                    vars = variableDeclarationList(TokenType.VAR, false, forStart);
+                    varDeclList = variableDeclarationList(varType = TokenType.VAR, false, forStart);
                     break;
                 }
 
@@ -1983,38 +1987,30 @@
                     break;
                 }
             case IN:
-
                 flags |= isForOf ? ForNode.IS_FOR_OF : ForNode.IS_FOR_IN;
                 test = new JoinPredecessorExpression();
-                if (vars != null) {
-                    // for (var i in obj)
-                    if (vars.size() == 1) {
-                        init = new IdentNode((IdentNode)vars.get(0));
-                        if (init.isTokenType(ASSIGN)) {
-                            throw error(AbstractParser.message("for.in.loop.initializer"), init.getToken());
-                        }
-                        assert init instanceof IdentNode || isDestructuringLhs(init);
-                    } else {
+                if (varDeclList != null) {
+                    // for (var|let|const ForBinding in|of expression)
+                    if (varDeclList.secondBinding != null) {
                         // for (var i, j in obj) is invalid
-                        throw error(AbstractParser.message("many.vars.in.for.in.loop", isForOf ? "of" : "in"), vars.get(1).getToken());
+                        throw error(AbstractParser.message("many.vars.in.for.in.loop", isForOf ? "of" : "in"), varDeclList.secondBinding.getToken());
                     }
+                    if (varDeclList.declarationWithInitializerToken != 0 && (isStrictMode || type != TokenType.IN || varType != VAR || varDeclList.init != null)) {
+                        // ES5 legacy: for (var i = AssignmentExpressionNoIn in Expression)
+                        // Invalid in ES6, but allow it in non-strict mode if no ES6 features used,
+                        // i.e., error if strict, for-of, let/const, or destructuring
+                        throw error(AbstractParser.message("for.in.loop.initializer", isForOf ? "of" : "in"), varDeclList.declarationWithInitializerToken);
+                    }
+                    init = varDeclList.firstBinding;
+                    assert init instanceof IdentNode || isDestructuringLhs(init);
                 } else {
                     // for (expr in obj)
                     assert init != null : "for..in/of init expression can not be null here";
 
                     // check if initial expression is a valid L-value
-                    if (!(init instanceof AccessNode ||
-                          init instanceof IndexNode ||
-                          init instanceof IdentNode)) {
+                    if (!checkValidLValue(init, isForOf ? "for-of iterator" : "for-in iterator")) {
                         throw error(AbstractParser.message("not.lvalue.for.in.loop", isForOf ? "of" : "in"), init.getToken());
                     }
-
-                    if (init instanceof IdentNode) {
-                        if (!checkIdentLValue((IdentNode)init)) {
-                            throw error(AbstractParser.message("not.lvalue.for.in.loop", isForOf ? "of" : "in"), init.getToken());
-                        }
-                        verifyStrictIdent((IdentNode)init, isForOf ? "for-of iterator" : "for-in iterator");
-                    }
                 }
 
                 next();
@@ -2075,7 +2071,7 @@
     private boolean lookaheadIsLetDeclaration(final boolean ofContextualKeyword) {
         assert type == LET;
         for (int i = 1;; i++) {
-            TokenType t = T(k + i);
+            final TokenType t = T(k + i);
             switch (t) {
             case EOL:
             case COMMENT:
@@ -2856,6 +2852,7 @@
         final List<Expression> elements = new ArrayList<>();
         // Track elisions.
         boolean elision = true;
+        boolean hasSpread = false;
         loop:
         while (true) {
             long spreadToken = 0;
@@ -2879,6 +2876,7 @@
 
             case ELLIPSIS:
                 if (isES6()) {
+                    hasSpread = true;
                     spreadToken = token;
                     next();
                 }
@@ -2905,7 +2903,7 @@
             }
         }
 
-        return LiteralNode.newInstance(arrayToken, finish, elements);
+        return LiteralNode.newInstance(arrayToken, finish, elements, hasSpread, elision);
     }
 
     /**
@@ -3076,7 +3074,7 @@
      */
     private Expression computedPropertyName() {
         expect(LBRACKET);
-        Expression expression = assignmentExpression(false);
+        final Expression expression = assignmentExpression(false);
         expect(RBRACKET);
         return expression;
     }
@@ -3285,11 +3283,11 @@
         return new PropertyFunction(propertyName, function, computed);
     }
 
-    private PropertyFunction propertyMethodFunction(Expression key, final long methodToken, final int methodLine, final boolean generator, final int flags, boolean computed) {
+    private PropertyFunction propertyMethodFunction(final Expression key, final long methodToken, final int methodLine, final boolean generator, final int flags, final boolean computed) {
         final String methodName = key instanceof PropertyKey ? ((PropertyKey) key).getPropertyName() : getDefaultValidFunctionName(methodLine, false);
         final IdentNode methodNameNode = createIdentNode(((Node)key).getToken(), finish, methodName);
 
-        FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL;
+        final FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL;
         final ParserContextFunctionNode functionNode = createParserContextFunctionNode(methodNameNode, methodToken, functionKind, methodLine, null);
         functionNode.setFlag(flags);
         if (computed) {
@@ -3548,7 +3546,7 @@
             if (isES6()) {
                 final ParserContextFunctionNode currentFunction = getCurrentNonArrowFunction();
                 if (currentFunction.isMethod()) {
-                    long identToken = Token.recast(token, IDENT);
+                    final long identToken = Token.recast(token, IDENT);
                     next();
                     lhs = createIdentNode(identToken, finish, SUPER.getName());
 
@@ -3766,7 +3764,7 @@
             isAnonymous = true;
         }
 
-        FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL;
+        final FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL;
         List<IdentNode> parameters = Collections.emptyList();
         final ParserContextFunctionNode functionNode = createParserContextFunctionNode(name, functionToken, functionKind, functionLine, parameters);
         lc.push(functionNode);
@@ -3870,7 +3868,7 @@
         }
     }
 
-    private static Block maybeWrapBodyInParameterBlock(Block functionBody, ParserContextBlockNode parameterBlock) {
+    private static Block maybeWrapBodyInParameterBlock(final Block functionBody, final ParserContextBlockNode parameterBlock) {
         assert functionBody.isFunctionBody();
         if (!parameterBlock.getStatements().isEmpty()) {
             parameterBlock.appendStatement(new BlockStatement(functionBody));
@@ -4006,26 +4004,26 @@
                     }
 
                     // default parameter
-                    Expression initializer = assignmentExpression(false);
-
-                    ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+                    final Expression initializer = assignmentExpression(false);
+
+                    final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
                     if (currentFunction != null) {
                         if (env._parse_only) {
                             // keep what is seen in source "as is" and save it as parameter expression
-                            BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, initializer);
+                            final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, initializer);
                             currentFunction.addParameterExpression(ident, assignment);
                         } else {
                             // desugar to: param = (param === undefined) ? initializer : param;
                             // possible alternative: if (param === undefined) param = initializer;
-                            BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
-                            TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
-                            BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value);
+                            final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
+                            final TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
+                            final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value);
                             lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
                         }
                     }
                 }
 
-                ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+                final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
                 if (currentFunction != null) {
                     currentFunction.addParameterBinding(ident);
                     if (ident.isRestParameter() || ident.isDefaultParameter()) {
@@ -4044,22 +4042,22 @@
                     ident = ident.setIsDefaultParameter();
 
                     // binding pattern with initializer. desugar to: (param === undefined) ? initializer : param
-                    Expression initializer = assignmentExpression(false);
+                    final Expression initializer = assignmentExpression(false);
 
                     if (env._parse_only) {
                         // we don't want the synthetic identifier in parse only mode
                         value = initializer;
                     } else {
                         // TODO initializer must not contain yield expression if yield=true (i.e. this is generator function's parameter list)
-                        BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
+                        final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
                         value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
                     }
                 }
 
-                ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+                final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
                 if (currentFunction != null) {
                     // destructuring assignment
-                    BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), pattern, value);
+                    final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), pattern, value);
                     if (env._parse_only) {
                         // in parse-only mode, represent source tree "as is"
                         if (ident.isDefaultParameter()) {
@@ -4081,10 +4079,10 @@
 
     private void verifyDestructuringParameterBindingPattern(final Expression pattern, final long paramToken, final int paramLine, final String contextString) {
         verifyDestructuringBindingPattern(pattern, new Consumer<IdentNode>() {
-            public void accept(IdentNode identNode) {
+            public void accept(final IdentNode identNode) {
                 verifyIdent(identNode, contextString);
 
-                ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+                final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
                 if (currentFunction != null) {
                     // declare function-scope variables for destructuring bindings
                     if (!env._parse_only) {
@@ -4398,7 +4396,7 @@
             break;
         }
 
-        Expression expression = leftHandSideExpression();
+        final Expression expression = leftHandSideExpression();
 
         if (last != EOL) {
             switch (type) {
@@ -4549,7 +4547,7 @@
     private Expression expression(final boolean noIn) {
         Expression assignmentExpression = assignmentExpression(noIn);
         while (type == COMMARIGHT) {
-            long commaToken = token;
+            final long commaToken = token;
             next();
 
             boolean rhsRestParameter = false;
@@ -4707,7 +4705,7 @@
     /**
      * Is type one of {@code = *= /= %= += -= <<= >>= >>>= &= ^= |=}?
      */
-    private static boolean isAssignmentOperator(TokenType type) {
+    private static boolean isAssignmentOperator(final TokenType type) {
         switch (type) {
         case ASSIGN:
         case ASSIGN_ADD:
@@ -4729,7 +4727,7 @@
     /**
      * ConditionalExpression.
      */
-    private Expression conditionalExpression(boolean noIn) {
+    private Expression conditionalExpression(final boolean noIn) {
         return expression(TERNARY.getPrecedence(), noIn);
     }
 
@@ -4752,7 +4750,7 @@
 
         lc.push(functionNode);
         try {
-            ParserContextBlockNode parameterBlock = newBlock();
+            final ParserContextBlockNode parameterBlock = newBlock();
             final List<IdentNode> parameters;
             try {
                 parameters = convertArrowFunctionParameterList(paramListExpr, functionLine);
@@ -4829,12 +4827,12 @@
         return parameters;
     }
 
-    private IdentNode verifyArrowParameter(Expression param, int index, int paramLine) {
+    private IdentNode verifyArrowParameter(final Expression param, final int index, final int paramLine) {
         final String contextString = "function parameter";
         if (param instanceof IdentNode) {
-            IdentNode ident = (IdentNode)param;
+            final IdentNode ident = (IdentNode)param;
             verifyStrictIdent(ident, contextString);
-            ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+            final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
             if (currentFunction != null) {
                 currentFunction.addParameterBinding(ident);
             }
@@ -4842,21 +4840,21 @@
         }
 
         if (param.isTokenType(ASSIGN)) {
-            Expression lhs = ((BinaryNode) param).lhs();
-            long paramToken = lhs.getToken();
-            Expression initializer = ((BinaryNode) param).rhs();
+            final Expression lhs = ((BinaryNode) param).lhs();
+            final long paramToken = lhs.getToken();
+            final Expression initializer = ((BinaryNode) param).rhs();
             if (lhs instanceof IdentNode) {
                 // default parameter
-                IdentNode ident = (IdentNode) lhs;
-
-                ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+                final IdentNode ident = (IdentNode) lhs;
+
+                final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
                 if (currentFunction != null) {
                     if (env._parse_only) {
                         currentFunction.addParameterExpression(ident, param);
                     } else {
-                        BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
-                        TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
-                        BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value);
+                        final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
+                        final TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
+                        final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value);
                         lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
                     }
 
@@ -4867,17 +4865,17 @@
             } else if (isDestructuringLhs(lhs)) {
                 // binding pattern with initializer
                 // Introduce synthetic temporary parameter to capture the object to be destructured.
-                IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter().setIsDefaultParameter();
+                final IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter().setIsDefaultParameter();
                 verifyDestructuringParameterBindingPattern(param, paramToken, paramLine, contextString);
 
-                ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+                final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
                 if (currentFunction != null) {
                     if (env._parse_only) {
                         currentFunction.addParameterExpression(ident, param);
                     } else {
-                        BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
-                        TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
-                        BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, value);
+                        final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
+                        final TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
+                        final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, value);
                         lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
                     }
                 }
@@ -4885,18 +4883,18 @@
             }
         } else if (isDestructuringLhs(param)) {
             // binding pattern
-            long paramToken = param.getToken();
+            final long paramToken = param.getToken();
 
             // Introduce synthetic temporary parameter to capture the object to be destructured.
-            IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter();
+            final IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter();
             verifyDestructuringParameterBindingPattern(param, paramToken, paramLine, contextString);
 
-            ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
+            final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
             if (currentFunction != null) {
                 if (env._parse_only) {
                     currentFunction.addParameterExpression(ident, param);
                 } else {
-                    BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, ident);
+                    final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, ident);
                     lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
                 }
             }
@@ -4913,7 +4911,7 @@
             return true;
         }
         for (int i = k - 1; i >= 0; i--) {
-            TokenType t = T(i);
+            final TokenType t = T(i);
             switch (t) {
             case RPAREN:
             case IDENT:
@@ -4941,7 +4939,7 @@
         // find IDENT, RPAREN, ARROW, in that order, skipping over EOL (where allowed) and COMMENT
         int i = 1;
         for (;;) {
-            TokenType t = T(k + i++);
+            final TokenType t = T(k + i++);
             if (t == IDENT) {
                 break;
             } else if (t == EOL || t == COMMENT) {
@@ -4951,7 +4949,7 @@
             }
         }
         for (;;) {
-            TokenType t = T(k + i++);
+            final TokenType t = T(k + i++);
             if (t == RPAREN) {
                 break;
             } else if (t == EOL || t == COMMENT) {
@@ -4961,7 +4959,7 @@
             }
         }
         for (;;) {
-            TokenType t = T(k + i++);
+            final TokenType t = T(k + i++);
             if (t == ARROW) {
                 break;
             } else if (t == COMMENT) {
@@ -5008,7 +5006,7 @@
         }
 
         if (env._parse_only) {
-            List<Expression> exprs = new ArrayList<>();
+            final List<Expression> exprs = new ArrayList<>();
             exprs.add(literal);
             TokenType lastLiteralType;
             do {
@@ -5096,12 +5094,12 @@
      *      ModuleItemList
      */
     private FunctionNode module(final String moduleName) {
-        boolean oldStrictMode = isStrictMode;
+        final boolean oldStrictMode = isStrictMode;
         try {
             isStrictMode = true; // Module code is always strict mode code. (ES6 10.2.1)
 
             // Make a pseudo-token for the script holding its start and length.
-            int functionStart = Math.min(Token.descPosition(Token.withDelimiter(token)), finish);
+            final int functionStart = Math.min(Token.descPosition(Token.withDelimiter(token)), finish);
             final long functionToken = Token.toDesc(FUNCTION, functionStart, source.getLength() - functionStart);
             final int  functionLine  = line;
 
@@ -5214,7 +5212,7 @@
             } else if (isBindingIdentifier()) {
                 // ImportedDefaultBinding
                 final IdentNode importedDefaultBinding = bindingIdentifier("ImportedBinding");
-                Module.ImportEntry defaultImport = Module.ImportEntry.importSpecifier(importedDefaultBinding, startPosition, finish);
+                final Module.ImportEntry defaultImport = Module.ImportEntry.importSpecifier(importedDefaultBinding, startPosition, finish);
 
                 if (type == COMMARIGHT) {
                     next();
@@ -5279,7 +5277,7 @@
     private List<Module.ImportEntry> namedImports(final int startPosition) {
         assert type == LBRACE;
         next();
-        List<Module.ImportEntry> importEntries = new ArrayList<>();
+        final List<Module.ImportEntry> importEntries = new ArrayList<>();
         while (type != RBRACE) {
             final boolean bindingIdentifier = isBindingIdentifier();
             final long nameToken = token;
@@ -5354,11 +5352,11 @@
                 if (type == IDENT && "from".equals(getValue())) {
                     final IdentNode moduleRequest = fromClause();
                     module.addModuleRequest(moduleRequest);
-                    for (Module.ExportEntry exportEntry : exportEntries) {
+                    for (final Module.ExportEntry exportEntry : exportEntries) {
                         module.addIndirectExportEntry(exportEntry.withFrom(moduleRequest, finish));
                     }
                 } else {
-                    for (Module.ExportEntry exportEntry : exportEntries) {
+                    for (final Module.ExportEntry exportEntry : exportEntries) {
                         module.addLocalExportEntry(exportEntry);
                     }
                 }
@@ -5445,7 +5443,7 @@
     private List<Module.ExportEntry> exportClause(final int startPosition) {
         assert type == LBRACE;
         next();
-        List<Module.ExportEntry> exports = new ArrayList<>();
+        final List<Module.ExportEntry> exports = new ArrayList<>();
         while (type != RBRACE) {
             final IdentNode localName = getIdentifierName();
             if (type == IDENT && "as".equals(getValue())) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextFunctionNode.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextFunctionNode.java	Tue Oct 18 17:14:09 2016 +0000
@@ -169,7 +169,7 @@
         return parameters;
     }
 
-    void setParameters(List<IdentNode> parameters) {
+    void setParameters(final List<IdentNode> parameters) {
         this.parameters = parameters;
     }
 
@@ -182,7 +182,7 @@
         return parameterExpressions;
     }
 
-    void addParameterExpression(IdentNode ident, Expression node) {
+    void addParameterExpression(final IdentNode ident, final Expression node) {
         if (parameterExpressions == null) {
             parameterExpressions = new HashMap<>();
         }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextModuleNode.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/ParserContextModuleNode.java	Tue Oct 18 17:14:09 2016 +0000
@@ -41,11 +41,11 @@
     /** Module name. */
     private final String name;
 
-    private List<String> requestedModules = new ArrayList<>();
-    private List<ImportEntry> importEntries = new ArrayList<>();
-    private List<ExportEntry> localExportEntries = new ArrayList<>();
-    private List<ExportEntry> indirectExportEntries = new ArrayList<>();
-    private List<ExportEntry> starExportEntries = new ArrayList<>();
+    private final List<String> requestedModules = new ArrayList<>();
+    private final List<ImportEntry> importEntries = new ArrayList<>();
+    private final List<ExportEntry> localExportEntries = new ArrayList<>();
+    private final List<ExportEntry> indirectExportEntries = new ArrayList<>();
+    private final List<ExportEntry> starExportEntries = new ArrayList<>();
 
     /**
      * Constructor.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AllocationStrategy.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AllocationStrategy.java	Tue Oct 18 17:14:09 2016 +0000
@@ -141,7 +141,7 @@
         final private WeakReference<ScriptObject> prototype;
         final private WeakReference<PropertyMap> prototypeMap;
 
-        private PropertyMap allocatorMap;
+        private final PropertyMap allocatorMap;
 
         AllocatorMap(final ScriptObject prototype, final PropertyMap protoMap, final PropertyMap allocMap) {
             this.prototype = new WeakReference<>(prototype);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CommandExecutor.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CommandExecutor.java	Tue Oct 18 17:14:09 2016 +0000
@@ -148,14 +148,14 @@
         boolean check(String token, final Iterator<String> iterator, final String cwd) {
             // Iterate through redirect prefixes to file a match.
             for (int i = 0; i < redirectPrefixes.length; i++) {
-               String prefix = redirectPrefixes[i];
+               final String prefix = redirectPrefixes[i];
 
                // If a match is found.
                 if (token.startsWith(prefix)) {
                     // Indicate we have at least one redirect (efficiency.)
                     hasRedirects = true;
                     // Map prefix to RedirectType.
-                    RedirectType redirect = redirects[i];
+                    final RedirectType redirect = redirects[i];
                     // Strip prefix from token
                     token = token.substring(prefix.length());
 
@@ -223,8 +223,8 @@
             // Only if there was redirects (saves new structure in ProcessBuilder.)
             if (hasRedirects) {
                 // If output and error are the same file then merge.
-                File outputFile = outputRedirect.file();
-                File errorFile = errorRedirect.file();
+                final File outputFile = outputRedirect.file();
+                final File errorFile = errorRedirect.file();
 
                 if (outputFile != null && outputFile.equals(errorFile)) {
                     mergeError = true;
@@ -274,26 +274,26 @@
         public void run() {
             try {
                 // Buffer for copying.
-                byte[] b = new byte[BUFFER_SIZE];
+                final byte[] b = new byte[BUFFER_SIZE];
                 // Read from the InputStream until EOF.
                 int read;
                 while (-1 < (read = input.read(b, 0, b.length))) {
                     // Write available date to OutputStream.
                     output.write(b, 0, read);
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 // Assume the worst.
                 throw new RuntimeException("Broken pipe", e);
             } finally {
                 // Make sure the streams are closed.
                 try {
                     input.close();
-                } catch (IOException e) {
+                } catch (final IOException e) {
                     // Don't care.
                 }
                 try {
                     output.close();
-                } catch (IOException e) {
+                } catch (final IOException e) {
                     // Don't care.
                 }
             }
@@ -363,7 +363,7 @@
     private long envVarLongValue(final String key) {
         try {
             return Long.parseLong(envVarValue(key, "0"));
-        } catch (NumberFormatException ex) {
+        } catch (final NumberFormatException ex) {
             return 0L;
         }
     }
@@ -478,7 +478,7 @@
         // iterate through all tokens.
         final Iterator<String> iterator = tokens.iterator();
         while (iterator.hasNext()) {
-            String token = iterator.next();
+            final String token = iterator.next();
 
             // Check if is a redirect.
             if (redirectInfo.check(token, iterator, cwd)) {
@@ -551,7 +551,7 @@
      * @param tokens  tokens of the command
      * @param isPiped true if the output of this command should be piped to the next
      */
-    private void command(final List<String> tokens, boolean isPiped) {
+    private void command(final List<String> tokens, final boolean isPiped) {
         // Test to see if we should echo the command to output.
         if (envVarBooleanValue("JJS_ECHO")) {
             System.out.println(String.join(" ", tokens));
@@ -584,7 +584,7 @@
         boolean inputIsPipe = firstProcessBuilder.redirectInput() == Redirect.PIPE;
         boolean outputIsPipe = lastProcessBuilder.redirectOutput() == Redirect.PIPE;
         boolean errorIsPipe = lastProcessBuilder.redirectError() == Redirect.PIPE;
-        boolean inheritIO = envVarBooleanValue("JJS_INHERIT_IO");
+        final boolean inheritIO = envVarBooleanValue("JJS_INHERIT_IO");
 
         // If not redirected and inputStream is current processes' input.
         if (inputIsPipe && (inheritIO || inputStream == System.in)) {
@@ -609,10 +609,10 @@
 
         // Start the processes.
         final List<Process> processes = new ArrayList<>();
-        for (ProcessBuilder pb : processBuilders) {
+        for (final ProcessBuilder pb : processBuilders) {
             try {
                 processes.add(pb.start());
-            } catch (IOException ex) {
+            } catch (final IOException ex) {
                 reportError("unknown.command", String.join(" ", pb.command()));
                 return;
             }
@@ -701,7 +701,7 @@
             // Accumulate the output and error streams.
             outputString += byteOutputStream != null ? byteOutputStream.toString() : "";
             errorString += byteErrorStream != null ? byteErrorStream.toString() : "";
-        } catch (InterruptedException ex) {
+        } catch (final InterruptedException ex) {
             // Kill any living processes.
             processes.stream().forEach(p -> {
                 if (p.isAlive()) {
@@ -829,7 +829,7 @@
         final Iterator<String> iterator = tokens.iterator();
         while (iterator.hasNext() && exitCode == EXIT_SUCCESS) {
             // Next word token.
-            String token = iterator.next();
+            final String token = iterator.next();
 
             if (token == null) {
                 continue;
@@ -876,23 +876,23 @@
         return exitCode;
     }
 
-    void setEnvironment(Map<String, String> environment) {
+    void setEnvironment(final Map<String, String> environment) {
         this.environment = environment;
     }
 
-    void setInputStream(InputStream inputStream) {
+    void setInputStream(final InputStream inputStream) {
         this.inputStream = inputStream;
     }
 
-    void setInputString(String inputString) {
+    void setInputString(final String inputString) {
         this.inputString = inputString;
     }
 
-    void setOutputStream(OutputStream outputStream) {
+    void setOutputStream(final OutputStream outputStream) {
         this.outputStream = outputStream;
     }
 
-    void setErrorStream(OutputStream errorStream) {
+    void setErrorStream(final OutputStream errorStream) {
         this.errorStream = errorStream;
     }
 }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java	Tue Oct 18 17:14:09 2016 +0000
@@ -56,6 +56,8 @@
 import java.lang.reflect.Module;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.CodeSigner;
@@ -81,6 +83,8 @@
 import java.util.function.Consumer;
 import java.util.function.Supplier;
 import java.util.logging.Level;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 import javax.script.ScriptEngine;
 import jdk.dynalink.DynamicLinker;
 import jdk.internal.org.objectweb.asm.ClassReader;
@@ -614,18 +618,37 @@
         }
         this.errors    = errors;
 
+        // if user passed --module-path, we create a module class loader with
+        // passed appLoader as the parent.
+        final String modulePath = env._module_path;
+        ClassLoader appCl = null;
+        if (!env._compile_only && modulePath != null && !modulePath.isEmpty()) {
+            // make sure that caller can create a class loader.
+            if (sm != null) {
+                sm.checkCreateClassLoader();
+            }
+            appCl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+                @Override
+                public ClassLoader run() {
+                    return createModuleLoader(appLoader, modulePath, env._add_modules);
+                }
+            });
+        } else {
+            appCl = appLoader;
+        }
+
         // if user passed -classpath option, make a URLClassLoader with that and
-        // the app loader as the parent.
-        final String classPath = options.getString("classpath");
+        // the app loader or module app loader as the parent.
+        final String classPath = env._classpath;
         if (!env._compile_only && classPath != null && !classPath.isEmpty()) {
             // make sure that caller can create a class loader.
             if (sm != null) {
                 sm.checkCreateClassLoader();
             }
-            this.appLoader = NashornLoader.createClassLoader(classPath, appLoader);
-        } else {
-            this.appLoader = appLoader;
+            appCl = NashornLoader.createClassLoader(classPath, appCl);
         }
+
+        this.appLoader = appCl;
         this.dynamicLinker = Bootstrap.createDynamicLinker(this.appLoader, env._unstable_relink_threshold);
 
         final int cacheSize = env._class_cache_size;
@@ -1339,7 +1362,7 @@
 
         final ModuleFinder finder = new ModuleFinder() {
             @Override
-            public Optional<ModuleReference> find(String name) {
+            public Optional<ModuleReference> find(final String name) {
                 if (name.equals(mn)) {
                     return Optional.of(mref);
                 } else {
@@ -1387,7 +1410,7 @@
         ClassLoader loader = null;
         try {
             loader = clazz.getClassLoader();
-        } catch (SecurityException ignored) {
+        } catch (final SecurityException ignored) {
             // This could fail because of anonymous classes being used.
             // Accessing loader of anonymous class fails (for extension
             // loader class too?). In any case, for us fetching Context
@@ -1750,4 +1773,37 @@
     public SwitchPoint getBuiltinSwitchPoint(final String name) {
         return builtinSwitchPoints.get(name);
     }
+
+    private static ClassLoader createModuleLoader(final ClassLoader cl,
+            final String modulePath, final String addModules) {
+        if (addModules == null) {
+            throw new IllegalArgumentException("--module-path specified with no --add-modules");
+        }
+
+        final Path[] paths = Stream.of(modulePath.split(File.pathSeparator)).
+            map(s -> Paths.get(s)).
+            toArray(sz -> new Path[sz]);
+        final ModuleFinder mf = ModuleFinder.of(paths);
+        final Set<ModuleReference> mrefs = mf.findAll();
+        if (mrefs.isEmpty()) {
+            throw new RuntimeException("No modules in script --module-path: " + modulePath);
+        }
+
+        final Set<String> rootMods;
+        if (addModules.equals("ALL-MODULE-PATH")) {
+            rootMods = mrefs.stream().
+                map(mr->mr.descriptor().name()).
+                collect(Collectors.toSet());
+        } else {
+            rootMods = Stream.of(addModules.split(",")).
+                map(String::trim).
+                collect(Collectors.toSet());
+        }
+
+        final Layer boot = Layer.boot();
+        final Configuration conf = boot.configuration().
+            resolveRequires(mf, ModuleFinder.of(), rootMods);
+        final String firstMod = rootMods.iterator().next();
+        return boot.defineModulesWithOneLoader(conf, cl).findLoader(firstMod);
+    }
 }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java	Tue Oct 18 17:14:09 2016 +0000
@@ -87,7 +87,7 @@
 
     @Override
     String getDocumentation() {
-        String doc = docKey != null?
+        final String doc = docKey != null?
             FunctionDocumentation.getDoc(docKey) : null;
         return doc != null? doc : super.getDocumentation();
     }
@@ -109,7 +109,7 @@
     }
 
     @Override
-    CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, boolean linkLogicOkay) {
+    CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, final boolean linkLogicOkay) {
         assert isValidCallSite(callSiteType) : callSiteType;
 
         CompiledFunction best = null;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONListAdapter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONListAdapter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -155,7 +155,7 @@
     }
 
     @Override
-    public Object getDefaultValue(Class<?> hint) throws UnsupportedOperationException {
+    public Object getDefaultValue(final Class<?> hint) throws UnsupportedOperationException {
         return obj.getDefaultValue(hint);
     }
 }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -221,7 +221,7 @@
             final String res = "/"+ MODULE_MANIPULATOR_NAME.replace('.', '/') + ".class";
             try (InputStream in = NashornLoader.class.getResourceAsStream(res)) {
                 return in.readAllBytes();
-            } catch (IOException exp) {
+            } catch (final IOException exp) {
                 throw new UncheckedIOException(exp);
             }
         };
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptEnvironment.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptEnvironment.java	Tue Oct 18 17:14:09 2016 +0000
@@ -153,6 +153,12 @@
     /** Create a new class loaded for each compilation */
     public final boolean _loader_per_compile;
 
+    /** --module-path, if any */
+    public final String _module_path;
+
+    /** --add-modules, if any */
+    public final String _add_modules;
+
     /** Do not support Java support extensions. */
     public final boolean _no_java;
 
@@ -285,6 +291,8 @@
             _lazy_compilation = lazy_compilation;
         }
         _loader_per_compile   = options.getBoolean("loader.per.compile");
+        _module_path          = options.getString("module.path");
+        _add_modules          = options.getString("add.modules");
         _no_java              = options.getBoolean("no.java");
         _no_syntax_extensions = options.getBoolean("no.syntax.extensions");
         _no_typed_arrays      = options.getBoolean("no.typed.arrays");
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java	Tue Oct 18 17:14:09 2016 +0000
@@ -95,7 +95,7 @@
     }
 
     @Override
-    protected Class<?> findClass(String name) throws ClassNotFoundException {
+    protected Class<?> findClass(final String name) throws ClassNotFoundException {
         final ClassLoader appLoader = context.getAppLoader();
 
         /*
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java	Tue Oct 18 17:14:09 2016 +0000
@@ -80,7 +80,6 @@
 import jdk.nashorn.internal.objects.NativeArray;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
-import jdk.nashorn.internal.runtime.linker.Bootstrap;
 import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
 import jdk.nashorn.internal.runtime.linker.NashornGuards;
@@ -1883,8 +1882,6 @@
             return findCallMethod(desc, request);
         case NEW:
             return findNewMethod(desc, request);
-        case CALL_METHOD:
-            return findCallMethodMethod(desc, request);
         default:
         }
         return null;
@@ -1920,32 +1917,6 @@
     }
 
     /**
-     * Find an implementation for a CALL_METHOD operation. Note that Nashorn internally never uses
-     * CALL_METHOD, but instead always emits two call sites in bytecode, one for GET_METHOD, and then another
-     * one for CALL. Explicit support for CALL_METHOD is provided for the benefit of potential external
-     * callers. The implementation itself actually folds a GET_METHOD method handle into a CALL method handle.
-     *
-     * @param desc    the call site descriptor.
-     * @param request the link request
-     *
-     * @return GuardedInvocation to be invoked at call site.
-     */
-    protected GuardedInvocation findCallMethodMethod(final CallSiteDescriptor desc, final LinkRequest request) {
-        // R(P0, P1, ...)
-        final MethodType callType = desc.getMethodType();
-        // use type Object(P0) for the getter
-        final CallSiteDescriptor getterType = desc.changeMethodType(MethodType.methodType(Object.class, callType.parameterType(0)));
-        final GuardedInvocation getter = findGetMethod(getterType, request, StandardOperation.GET_METHOD);
-
-        // Object(P0) => Object(P0, P1, ...)
-        final MethodHandle argDroppingGetter = MH.dropArguments(getter.getInvocation(), 1, callType.parameterList().subList(1, callType.parameterCount()));
-        // R(Object, P0, P1, ...)
-        final MethodHandle invoker = Bootstrap.createDynamicInvoker("", NashornCallSiteDescriptor.CALL, callType.insertParameterTypes(0, argDroppingGetter.type().returnType()));
-        // Fold Object(P0, P1, ...) into R(Object, P0, P1, ...) => R(P0, P1, ...)
-        return getter.replaceMethods(MH.foldArguments(invoker, argDroppingGetter), getter.getGuard());
-    }
-
-    /**
      * Test whether this object contains in its prototype chain or is itself a with-object.
      * @return true if a with-object was found
      */
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptingFunctions.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptingFunctions.java	Tue Oct 18 17:14:09 2016 +0000
@@ -149,7 +149,7 @@
         String inputString = null;
 
         if (arg0 instanceof NativeArray) {
-            String[] array = (String[])JSType.toJavaArray(arg0, String.class);
+            final String[] array = (String[])JSType.toJavaArray(arg0, String.class);
             tokens = new ArrayList<>();
             tokens.addAll(Arrays.asList(array));
         } else {
@@ -206,7 +206,7 @@
 
         final String outString = executor.getOutputString();
         final String errString = executor.getErrorString();
-        int exitCode = executor.getExitCode();
+        final int exitCode = executor.getExitCode();
 
         // Set globals for secondary results.
         global.set(OUT_NAME, outString, 0);
@@ -222,7 +222,7 @@
 
     private static Function<String, String> readLineHelper;
 
-    public static void setReadLineHelper(Function<String, String> func) {
+    public static void setReadLineHelper(final Function<String, String> func) {
         readLineHelper = Objects.requireNonNull(func);
     }
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Undefined.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Undefined.java	Tue Oct 18 17:14:09 2016 +0000
@@ -103,8 +103,6 @@
             final String name = NashornCallSiteDescriptor.getOperand(desc);
             final String msg = name != null? "not.a.function" : "cant.call.undefined";
             throw typeError(msg, name);
-        case CALL_METHOD:
-            throw lookupTypeError("cant.read.property.of.undefined", desc);
         case GET_PROPERTY:
         case GET_ELEMENT:
         case GET_METHOD:
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java	Tue Oct 18 17:14:09 2016 +0000
@@ -183,7 +183,7 @@
      * @return FindPropertyData or null if not found.
      */
     @Override
-    protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) {
+    protected FindProperty findProperty(final Object key, final boolean deep, final boolean isScope, final ScriptObject start) {
         // We call findProperty on 'expression' with 'expression' itself as start parameter.
         // This way in ScriptObject.setObject we can tell the property is from a 'with' expression
         // (as opposed from another non-scope object in the proto chain such as Object.prototype).
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/Bignum.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/Bignum.java	Tue Oct 18 17:14:09 2016 +0000
@@ -76,7 +76,7 @@
     // grow. There are no checks if the stack-allocated space is sufficient.
     static final int kBigitCapacity = kMaxSignificantBits / kBigitSize;
 
-    private int[] bigits_ = new int[kBigitCapacity];
+    private final int[] bigits_ = new int[kBigitCapacity];
     // A vector backed by bigits_buffer_. This way accesses to the array are
     // checked for out-of-bounds errors.
     // Vector<int> bigits_;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java	Tue Oct 18 17:14:09 2016 +0000
@@ -214,7 +214,7 @@
                 // new target uses a more precise 'self' type than Object.class. We need to
                 // convert the filter type. Note that the profileEntry method returns "self"
                 // argument "as is" and so the cast introduced will succeed for any type.
-                MethodType selfFilterType = MethodType.methodType(newSelfType, newSelfType);
+                final MethodType selfFilterType = MethodType.methodType(newSelfType, newSelfType);
                 selfFilter = selfFilter.asType(selfFilterType);
             }
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NameCodec.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NameCodec.java	Tue Oct 18 17:14:09 2016 +0000
@@ -283,7 +283,7 @@
      * @return the mangled form of the symbolic name.
      */
     public static String encode(final String name) {
-        String bn = mangle(name);
+        final String bn = mangle(name);
         assert((Object)bn == name || looksMangled(bn)) : bn;
         assert(name.equals(decode(bn))) : name;
         return bn;
@@ -303,11 +303,11 @@
         return sn;
     }
 
-    private static boolean looksMangled(String s) {
+    private static boolean looksMangled(final String s) {
         return s.charAt(0) == ESCAPE_C;
     }
 
-    private static String mangle(String s) {
+    private static String mangle(final String s) {
         if (s.length() == 0)
             return NULL_ESCAPE;
 
@@ -315,12 +315,12 @@
         StringBuilder sb = null;
 
         for (int i = 0, slen = s.length(); i < slen; i++) {
-            char c = s.charAt(i);
+            final char c = s.charAt(i);
 
             boolean needEscape = false;
             if (c == ESCAPE_C) {
                 if (i+1 < slen) {
-                    char c1 = s.charAt(i+1);
+                    final char c1 = s.charAt(i+1);
                     if ((i == 0 && c1 == NULL_ESCAPE_C)
                         || c1 != originalOfReplacement(c1)) {
                         // an accidental escape
@@ -356,7 +356,7 @@
         return s;
     }
 
-    private static String demangle(String s) {
+    private static String demangle(final String s) {
         // build this lazily, when we first meet an escape:
         StringBuilder sb = null;
 
@@ -369,8 +369,8 @@
 
             if (c == ESCAPE_C && i+1 < slen) {
                 // might be an escape sequence
-                char rc = s.charAt(i+1);
-                char oc = originalOfReplacement(rc);
+                final char rc = s.charAt(i+1);
+                final char oc = originalOfReplacement(rc);
                 if (oc != rc) {
                     // build sb if this is the first escape
                     if (sb == null) {
@@ -398,34 +398,34 @@
 
     private static final long[] SPECIAL_BITMAP = new long[2];  // 128 bits
     static {
-        String SPECIAL = DANGEROUS_CHARS + REPLACEMENT_CHARS;
-        for (char c : SPECIAL.toCharArray()) {
+        final String SPECIAL = DANGEROUS_CHARS + REPLACEMENT_CHARS;
+        for (final char c : SPECIAL.toCharArray()) {
             SPECIAL_BITMAP[c >>> 6] |= 1L << c;
         }
     }
 
-    private static boolean isSpecial(char c) {
+    private static boolean isSpecial(final char c) {
         if ((c >>> 6) < SPECIAL_BITMAP.length)
             return ((SPECIAL_BITMAP[c >>> 6] >> c) & 1) != 0;
         else
             return false;
     }
 
-    private static char replacementOf(char c) {
+    private static char replacementOf(final char c) {
         if (!isSpecial(c))  return c;
-        int i = DANGEROUS_CHARS.indexOf(c);
+        final int i = DANGEROUS_CHARS.indexOf(c);
         if (i < 0)  return c;
         return REPLACEMENT_CHARS.charAt(i);
     }
 
-    private static char originalOfReplacement(char c) {
+    private static char originalOfReplacement(final char c) {
         if (!isSpecial(c))  return c;
-        int i = REPLACEMENT_CHARS.indexOf(c);
+        final int i = REPLACEMENT_CHARS.indexOf(c);
         if (i < 0)  return c;
         return DANGEROUS_CHARS.charAt(i);
     }
 
-    private static boolean isDangerous(char c) {
+    private static boolean isDangerous(final char c) {
         if (!isSpecial(c))  return false;
         return (DANGEROUS_CHARS.indexOf(c) >= DANGEROUS_CHAR_FIRST_INDEX);
     }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java	Tue Oct 18 17:14:09 2016 +0000
@@ -86,13 +86,11 @@
     private static final MethodHandle EMPTY_ELEM_SETTER =
             MH.dropArguments(EMPTY_PROP_SETTER, 0, Object.class);
 
-    private static final MethodHandle THROW_NO_SUCH_FUNCTION;
     private static final MethodHandle THROW_STRICT_PROPERTY_SETTER;
     private static final MethodHandle THROW_OPTIMISTIC_UNDEFINED;
 
     static {
         final Lookup lookup = new Lookup(MethodHandles.lookup());
-        THROW_NO_SUCH_FUNCTION = lookup.findOwnStatic("throwNoSuchFunction", Object.class, Object.class, Object.class);
         THROW_STRICT_PROPERTY_SETTER = lookup.findOwnStatic("throwStrictPropertySetter", void.class, Object.class, Object.class);
         THROW_OPTIMISTIC_UNDEFINED = lookup.findOwnStatic("throwOptimisticUndefined", Object.class, int.class);
     }
@@ -130,8 +128,6 @@
         if (op != null) {
             final String operand = NashornCallSiteDescriptor.getOperand(desc);
             switch (op) {
-            case CALL_METHOD:
-                return adaptThrower(bindOperand(THROW_NO_SUCH_FUNCTION, operand), desc);
             case GET_METHOD:
             case GET_PROPERTY:
             case GET_ELEMENT: {
@@ -172,11 +168,6 @@
     }
 
     @SuppressWarnings("unused")
-    private static Object throwNoSuchFunction(final Object self, final Object name) {
-        throw createTypeError(self, name, "no.such.function");
-    }
-
-    @SuppressWarnings("unused")
     private static void throwStrictPropertySetter(final Object self, final Object name) {
         throw createTypeError(self, name, "cant.set.property");
     }
@@ -230,7 +221,6 @@
         case NEW:
         case CALL:
             throw typeError("not.a.function", "null");
-        case CALL_METHOD:
         case GET_METHOD:
             throw typeError("no.such.function", getArgument(linkRequest), "null");
         case GET_PROPERTY:
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/OptionTemplate.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/OptionTemplate.java	Tue Oct 18 17:14:09 2016 +0000
@@ -77,6 +77,14 @@
     /** is the option value specified as next argument? */
     private boolean valueNextArg;
 
+    /**
+     * Can this option be repeated in command line?
+     *
+     * For a repeatable option, multiple values will be merged as comma
+     * separated values rather than the last value overriding previous ones.
+     */
+    private boolean repeated;
+
     OptionTemplate(final String resource, final String key, final String value, final boolean isHelp, final boolean isXHelp) {
         this.resource = resource;
         this.key = key;
@@ -223,6 +231,14 @@
         return valueNextArg;
     }
 
+    /**
+     * Can this option be repeated?
+     * @return boolean
+     */
+    public boolean isRepeated() {
+        return repeated;
+    }
+
     private static String strip(final String value, final char start, final char end) {
         final int len = value.length();
         if (len > 1 && value.charAt(0) == start && value.charAt(len - 1) == end) {
@@ -281,6 +297,9 @@
                 case "value_next_arg":
                     this.valueNextArg = Boolean.parseBoolean(arg);
                     break;
+                case "repeated":
+                    this.repeated = true;
+                    break;
                 default:
                     throw new IllegalArgumentException(keyToken);
                 }
@@ -302,6 +321,10 @@
         if (name == null && shortName == null) {
             throw new IllegalArgumentException(origValue);
         }
+
+        if (this.repeated && !"string".equals(this.type)) {
+            throw new IllegalArgumentException("repeated option should be of type string: " + this.name);
+        }
     }
 
     boolean nameMatches(final String aName) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/Options.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/Options.java	Tue Oct 18 17:14:09 2016 +0000
@@ -500,7 +500,16 @@
                 throw new IllegalOptionException(parg.template);
             }
 
-            set(parg.template.getKey(), createOption(parg.template, parg.value));
+            if (parg.template.isRepeated()) {
+                assert parg.template.getType().equals("string");
+
+                final String key = key(parg.template.getKey());
+                final String value = options.containsKey(key)?
+                    (options.get(key).getValue() + "," + parg.value) : Objects.toString(parg.value);
+                options.put(key, new Option<>(value));
+            } else {
+                set(parg.template.getKey(), createOption(parg.template, parg.value));
+            }
 
             // Arg may have a dependency to set other args, e.g.
             // scripting->anon.functions
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Options.properties	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Options.properties	Tue Oct 18 17:14:09 2016 +0000
@@ -237,6 +237,21 @@
     default=true                                   \
 }
 
+nashorn.option.module.path ={                                 \
+    name="--module-path",                                     \
+    desc="--module-path path. Specify where to find user java modules.", \
+    value_next_arg=true,                                      \
+    type=String                                               \
+}
+
+nashorn.option.add.modules ={                                 \
+    name="--add-modules",                                     \
+    desc="--add-modules modules. Specify the root user java modules.", \
+    repeated=true,                                            \
+    value_next_arg=true,                                      \
+    type=String                                               \
+}
+
 nashorn.option.no.java = {                         \
     name="--no-java",                              \
     short_name="-nj",                              \
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/Shell.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/Shell.java	Tue Oct 18 17:14:09 2016 +0000
@@ -292,7 +292,7 @@
                 String l = "";
                 try (final BufferedReader r = Files.newBufferedReader(p)) {
                     l = r.readLine();
-                } catch (IOException ioe) {
+                } catch (final IOException ioe) {
                     // ignore
                 }
                 if (l.startsWith("#!")) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8166902.js	Tue Oct 18 17:14:09 2016 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8166902: Nested object literal property maps not reset in optimistic recompilation
+ *
+ * @test
+ * @run
+ */
+
+var o = {
+    a: "A",
+    b: "B"
+};
+
+var m = {
+    x: { z: o.a },
+    y: o.b
+};
+
+Assert.assertEquals(m.x.z, "A");
+Assert.assertEquals(m.y, "B");
+
--- a/nashorn/test/src/jdk/dynalink/linker/support/test/LookupTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/dynalink/linker/support/test/LookupTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -59,7 +59,7 @@
     private static void privateStaticFunc() {}
 
     @SuppressWarnings("unused")
-    private int myIntField = 0;
+    private final int myIntField = 0;
 
     @SuppressWarnings("unused")
     @DataProvider
@@ -72,26 +72,26 @@
 
     @Test(dataProvider = "flags")
     public void unreflectTest(final boolean publicLookup) throws NoSuchMethodException {
-        MethodHandle mh = Lookup.unreflect(getLookup(publicLookup), LookupTest.class.getMethod("unreflectTest", Boolean.TYPE));
+        final MethodHandle mh = Lookup.unreflect(getLookup(publicLookup), LookupTest.class.getMethod("unreflectTest", Boolean.TYPE));
         Assert.assertNotNull(mh);
     }
 
     @Test
     public void unreflectTest2() throws NoSuchMethodException {
-        MethodHandle mh = Lookup.PUBLIC.unreflect(LookupTest.class.getMethod("unreflectTest", Boolean.TYPE));
+        final MethodHandle mh = Lookup.PUBLIC.unreflect(LookupTest.class.getMethod("unreflectTest", Boolean.TYPE));
         Assert.assertNotNull(mh);
     }
 
     @Test(dataProvider = "flags")
     public void unreflectNegativeTest(final boolean publicLookup) throws NoSuchMethodException {
         try {
-            MethodHandle mh = Lookup.unreflect(getLookup(publicLookup),
+            final MethodHandle mh = Lookup.unreflect(getLookup(publicLookup),
                 LookupTest.class.getDeclaredMethod("privateFunc"));
             if (publicLookup) {
                 throw new RuntimeException("should have thrown Error");
             }
             Assert.assertNotNull(mh);
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(publicLookup);
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
@@ -102,33 +102,33 @@
         try {
             Lookup.PUBLIC.unreflect(LookupTest.class.getDeclaredMethod("privateFunc"));
             throw new RuntimeException("should have thrown Error");
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
     }
 
     @Test(dataProvider = "flags")
     public void unreflectConstructorTest(final boolean publicLookup) throws NoSuchMethodException {
-        MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup), LookupTest.class.getConstructor());
+        final MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup), LookupTest.class.getConstructor());
         Assert.assertNotNull(mh);
     }
 
     @Test
     public void unreflectConstructorTest2() throws NoSuchMethodException {
-        MethodHandle mh = Lookup.PUBLIC.unreflectConstructor(LookupTest.class.getConstructor());
+        final MethodHandle mh = Lookup.PUBLIC.unreflectConstructor(LookupTest.class.getConstructor());
         Assert.assertNotNull(mh);
     }
 
     @Test(dataProvider = "flags")
     public void unreflectConstructorNegativeTest(final boolean publicLookup) throws NoSuchMethodException {
         try {
-            MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup),
+            final MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup),
                 LookupTest.class.getDeclaredConstructor(Integer.TYPE));
             if (publicLookup) {
                 throw new RuntimeException("should have thrown Error");
             }
             Assert.assertNotNull(mh);
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(publicLookup);
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
@@ -140,7 +140,7 @@
             Lookup.PUBLIC.unreflectConstructor(
                 LookupTest.class.getDeclaredConstructor(Integer.TYPE));
             throw new RuntimeException("should have thrown Error");
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
     }
@@ -148,13 +148,13 @@
     @Test(dataProvider = "flags")
     public void findOwnStaticTest(final boolean publicLookup) {
         try {
-            MethodHandle mh = Lookup.findOwnStatic(getLookup(publicLookup), "getLookup",
+            final MethodHandle mh = Lookup.findOwnStatic(getLookup(publicLookup), "getLookup",
                     MethodHandles.Lookup.class, Boolean.TYPE);
             if (publicLookup) {
                 throw new RuntimeException("should have thrown Error");
             }
             Assert.assertNotNull(mh);
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(publicLookup);
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
@@ -166,7 +166,7 @@
             Lookup.PUBLIC.findStatic(LookupTest.class, "getLookup",
                     MethodType.methodType(MethodHandles.Lookup.class, Boolean.TYPE));
             throw new RuntimeException("should have thrown Error");
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
     }
@@ -174,12 +174,12 @@
     @Test(dataProvider = "flags")
     public void findOwnSepcialTest(final boolean publicLookup) {
         try {
-            MethodHandle mh = Lookup.findOwnSpecial(getLookup(publicLookup), "privateFunc", Void.TYPE);
+            final MethodHandle mh = Lookup.findOwnSpecial(getLookup(publicLookup), "privateFunc", Void.TYPE);
             if (publicLookup) {
                 throw new RuntimeException("should have thrown Error");
             }
             Assert.assertNotNull(mh);
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(publicLookup);
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
@@ -190,7 +190,7 @@
         try {
             Lookup.PUBLIC.findOwnSpecial("privateFunc", Void.TYPE);
             throw new RuntimeException("should have thrown Error");
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
     }
@@ -198,12 +198,12 @@
     @Test(dataProvider = "flags")
     public void findGetterTest(final boolean publicLookup) {
         try {
-            MethodHandle mh = new Lookup(getLookup(publicLookup)).findGetter(LookupTest.class, "myIntField", Integer.TYPE);
+            final MethodHandle mh = new Lookup(getLookup(publicLookup)).findGetter(LookupTest.class, "myIntField", Integer.TYPE);
             if (publicLookup) {
                 throw new RuntimeException("should have thrown Error");
             }
             Assert.assertNotNull(mh);
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(publicLookup);
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
@@ -214,7 +214,7 @@
         try {
             Lookup.PUBLIC.findGetter(LookupTest.class, "myIntField", Integer.TYPE);
             throw new RuntimeException("should have thrown Error");
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
     }
@@ -222,13 +222,13 @@
     @Test(dataProvider = "flags")
     public void findVirtualTest(final boolean publicLookup) {
         try {
-            MethodHandle mh = new Lookup(getLookup(publicLookup)).findVirtual(LookupTest.class, "protectedFunc",
+            final MethodHandle mh = new Lookup(getLookup(publicLookup)).findVirtual(LookupTest.class, "protectedFunc",
                     MethodType.methodType(Void.TYPE));
             if (publicLookup) {
                 throw new RuntimeException("should have thrown Error");
             }
             Assert.assertNotNull(mh);
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(publicLookup);
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
@@ -240,7 +240,7 @@
             Lookup.PUBLIC.findVirtual(LookupTest.class, "protectedFunc",
                     MethodType.methodType(Void.TYPE));
             throw new RuntimeException("should have thrown Error");
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
     }
@@ -248,13 +248,13 @@
     @Test(dataProvider = "flags")
     public void findStaticTest(final boolean publicLookup) {
         try {
-            MethodHandle mh = new Lookup(getLookup(publicLookup)).findStatic(LookupTest.class, "privateStaticFunc",
+            final MethodHandle mh = new Lookup(getLookup(publicLookup)).findStatic(LookupTest.class, "privateStaticFunc",
                     MethodType.methodType(Void.TYPE));
             if (publicLookup) {
                 throw new RuntimeException("should have thrown Error");
             }
             Assert.assertNotNull(mh);
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(publicLookup);
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
@@ -266,7 +266,7 @@
             Lookup.PUBLIC.findStatic(LookupTest.class, "privateStaticFunc",
                     MethodType.methodType(Void.TYPE));
             throw new RuntimeException("should have thrown Error");
-        } catch (Error err) {
+        } catch (final Error err) {
             Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
         }
     }
--- a/nashorn/test/src/jdk/dynalink/test/DynamicLinkerFactoryTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/dynalink/test/DynamicLinkerFactoryTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -35,15 +35,15 @@
 import jdk.dynalink.CallSiteDescriptor;
 import jdk.dynalink.DynamicLinker;
 import jdk.dynalink.DynamicLinkerFactory;
+import jdk.dynalink.NamedOperation;
 import jdk.dynalink.NoSuchDynamicMethodException;
-import jdk.dynalink.NamedOperation;
 import jdk.dynalink.Operation;
 import jdk.dynalink.StandardOperation;
+import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.GuardingDynamicLinker;
 import jdk.dynalink.linker.LinkRequest;
 import jdk.dynalink.linker.LinkerServices;
 import jdk.dynalink.support.SimpleRelinkableCallSite;
-import jdk.dynalink.linker.GuardedInvocation;
 import jdk.nashorn.api.scripting.AbstractJSObject;
 import org.testng.Assert;
 import org.testng.annotations.Test;
@@ -80,7 +80,7 @@
         final Operation myOperation = new Operation() {
         };
         final boolean[] reachedFallback = { false };
-        factory.setFallbackLinkers((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> {
+        factory.setFallbackLinkers((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
             Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
             reachedFallback[0] = true;
             return null;
@@ -95,10 +95,10 @@
         Assert.assertFalse(reachedFallback[0]);
         try {
             cs.getTarget().invoke();
-        } catch (NoSuchDynamicMethodException nsdm) {
+        } catch (final NoSuchDynamicMethodException nsdm) {
             // we do expect NoSuchDynamicMethod!
             // because our dummy fallback linker returns null!
-        } catch (Throwable th) {
+        } catch (final Throwable th) {
             throw new RuntimeException("should not reach here with: " + th);
         }
 
@@ -112,7 +112,7 @@
         final Operation myOperation = new Operation() {
         };
         final boolean[] reachedProrityLinker = { false };
-        factory.setPrioritizedLinker((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> {
+        factory.setPrioritizedLinker((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
             Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
             reachedProrityLinker[0] = true;
             return null;
@@ -127,10 +127,10 @@
         Assert.assertFalse(reachedProrityLinker[0]);
         try {
             cs.getTarget().invoke();
-        } catch (NoSuchDynamicMethodException nsdm) {
+        } catch (final NoSuchDynamicMethodException nsdm) {
             // we do expect NoSuchDynamicMethod!
             // because our dummy priority linker returns null!
-        } catch (Throwable th) {
+        } catch (final Throwable th) {
             throw new RuntimeException("should not reach here with: " + th);
         }
 
@@ -144,12 +144,12 @@
         final Operation myOperation = new Operation() {
         };
         final int[] linkerReachCounter = { 0 };
-        factory.setPrioritizedLinker((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> {
+        factory.setPrioritizedLinker((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
             Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
             linkerReachCounter[0]++;
             return null;
         });
-        factory.setFallbackLinkers((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> {
+        factory.setFallbackLinkers((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
             Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
             Assert.assertEquals(linkerReachCounter[0], 1);
             linkerReachCounter[0]++;
@@ -166,9 +166,9 @@
 
         try {
             cs.getTarget().invoke();
-        } catch (NoSuchDynamicMethodException nsdm) {
+        } catch (final NoSuchDynamicMethodException nsdm) {
             // we do expect NoSuchDynamicMethod!
-        } catch (Throwable th) {
+        } catch (final Throwable th) {
             throw new RuntimeException("should not reach here with: " + th);
         }
 
@@ -180,7 +180,7 @@
         final DynamicLinkerFactory factory = newDynamicLinkerFactory(true);
         final boolean[] reachedPrelinkTransformer = { false };
 
-        factory.setPrelinkTransformer((GuardedInvocation inv, LinkRequest linkRequest, LinkerServices linkerServices) -> {
+        factory.setPrelinkTransformer((final GuardedInvocation inv, final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
             reachedPrelinkTransformer[0] = true;
             // just identity transformer!
             return inv;
@@ -200,7 +200,7 @@
         final DynamicLinkerFactory factory = newDynamicLinkerFactory(true);
         final boolean[] reachedInternalObjectsFilter = { false };
 
-        factory.setInternalObjectsFilter((MethodHandle mh) -> {
+        factory.setInternalObjectsFilter((final MethodHandle mh) -> {
             reachedInternalObjectsFilter[0] = true;
             return mh;
         });
@@ -249,10 +249,10 @@
 
         try {
             cs.getTarget().invoke(new Object());
-        } catch (ReachedAutoLoadedDynamicLinkerException e) {
+        } catch (final ReachedAutoLoadedDynamicLinkerException e) {
             // TrustedGuardingDynamicLinkerExporter threw exception on TestLinkerOperation as expected!
             reachedAutoLinker = true;
-        } catch (Throwable th) {
+        } catch (final Throwable th) {
             throw new RuntimeException(th);
         }
 
@@ -270,9 +270,9 @@
                 MethodHandles.publicLookup(), op, mt)));
         final boolean[] reachedGetMember = new boolean[1];
         // check that the nashorn exported linker can be used for user defined JSObject
-        Object obj = new AbstractJSObject() {
+        final Object obj = new AbstractJSObject() {
                 @Override
-                public Object getMember(String name) {
+                public Object getMember(final String name) {
                     reachedGetMember[0] = true;
                     return name.equals("foo")? "bar" : "<unknown>";
                 }
@@ -281,7 +281,7 @@
         Object value = null;
         try {
             value = cs.getTarget().invoke(obj);
-        } catch (Throwable th) {
+        } catch (final Throwable th) {
             throw new RuntimeException(th);
         }
 
@@ -304,7 +304,7 @@
         try {
             final Object obj = engine.eval("({ foo: 'hello' })");
             value = cs.getTarget().invoke(obj);
-        } catch (Throwable th) {
+        } catch (final Throwable th) {
             throw new RuntimeException(th);
         }
         Assert.assertEquals(value, "hello");
--- a/nashorn/test/src/jdk/dynalink/test/TrustedGuardingDynamicLinkerExporter.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/dynalink/test/TrustedGuardingDynamicLinkerExporter.java	Tue Oct 18 17:14:09 2016 +0000
@@ -40,7 +40,7 @@
     @Override
     public List<GuardingDynamicLinker> get() {
         final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>();
-        linkers.add((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> {
+        linkers.add((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
             // handle only the TestLinkerOperation instances
             if (linkRequest.getCallSiteDescriptor().getOperation() instanceof TestLinkerOperation) {
                 System.out.println("inside " + this.getClass().getName());
--- a/nashorn/test/src/jdk/nashorn/api/scripting/test/JDK_8148140_Test.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/JDK_8148140_Test.java	Tue Oct 18 17:14:09 2016 +0000
@@ -54,7 +54,7 @@
                 return true;
             }
             @Override
-            public Object call(Object thiz, Object... args) {
+            public Object call(final Object thiz, final Object... args) {
                 return Arrays.deepToString(args);
             }
         });
--- a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScopeTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScopeTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -737,52 +737,52 @@
         try {
             c.getAttribute("");
             throw new AssertionError("should have thrown IAE");
-        } catch (IllegalArgumentException iae1) {}
+        } catch (final IllegalArgumentException iae1) {}
 
         try {
             c.getAttribute(null);
             throw new AssertionError("should have thrown NPE");
-        } catch (NullPointerException npe1) {}
+        } catch (final NullPointerException npe1) {}
 
         try {
             c.getAttribute("", ScriptContext.ENGINE_SCOPE);
             throw new AssertionError("should have thrown IAE");
-        } catch (IllegalArgumentException iae2) {}
+        } catch (final IllegalArgumentException iae2) {}
 
         try {
             c.getAttribute(null, ScriptContext.ENGINE_SCOPE);
             throw new AssertionError("should have thrown NPE");
-        } catch (NullPointerException npe2) {}
+        } catch (final NullPointerException npe2) {}
 
         try {
             c.removeAttribute("", ScriptContext.ENGINE_SCOPE);
             throw new AssertionError("should have thrown IAE");
-        } catch (IllegalArgumentException iae3) {}
+        } catch (final IllegalArgumentException iae3) {}
 
         try {
             c.removeAttribute(null, ScriptContext.ENGINE_SCOPE);
             throw new AssertionError("should have thrown NPE");
-        } catch (NullPointerException npe3) {}
+        } catch (final NullPointerException npe3) {}
 
         try {
             c.setAttribute("", "value", ScriptContext.ENGINE_SCOPE);
             throw new AssertionError("should have thrown IAE");
-        } catch (IllegalArgumentException iae4) {}
+        } catch (final IllegalArgumentException iae4) {}
 
         try {
             c.setAttribute(null, "value", ScriptContext.ENGINE_SCOPE);
             throw new AssertionError("should have thrown NPE");
-        } catch (NullPointerException npe4) {}
+        } catch (final NullPointerException npe4) {}
 
         try {
             c.getAttributesScope("");
             throw new AssertionError("should have thrown IAE");
-        } catch (IllegalArgumentException iae5) {}
+        } catch (final IllegalArgumentException iae5) {}
 
         try {
             c.getAttributesScope(null);
             throw new AssertionError("should have thrown NPE");
-        } catch (NullPointerException npe5) {}
+        } catch (final NullPointerException npe5) {}
     }
 
     public static class RecursiveEval {
@@ -791,8 +791,8 @@
         private final Bindings engineBindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
 
         public void program() throws ScriptException {
-            ScriptContext sc = new SimpleScriptContext();
-            Bindings global = new SimpleBindings();
+            final ScriptContext sc = new SimpleScriptContext();
+            final Bindings global = new SimpleBindings();
             sc.setBindings(global, ScriptContext.GLOBAL_SCOPE);
             sc.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
             global.put("text", "programText");
@@ -812,7 +812,7 @@
             sc.setBindings(global, ScriptContext.GLOBAL_SCOPE);
             sc.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
             global.put("text", "methodText");
-            String value = engine.eval("text", sc).toString();
+            final String value = engine.eval("text", sc).toString();
             Assert.assertEquals(value, "methodText");
         }
     }
@@ -878,7 +878,7 @@
          engine.eval("newfunc = function() { return func() }");
 
          // call "newfunc" and check the return value
-         Object value = ((Invocable)engine).invokeFunction("newfunc");
+         final Object value = ((Invocable)engine).invokeFunction("newfunc");
          assertTrue(((Number)value).intValue() == 42);
     }
 
@@ -910,7 +910,7 @@
          engine.eval("newfunc = function() { return func() }");
 
          // call "newfunc" and check the return value
-         Object value = ((Invocable)engine).invokeFunction("newfunc");
+         final Object value = ((Invocable)engine).invokeFunction("newfunc");
          assertTrue(((Number)value).intValue() == 42);
     }
 
@@ -922,18 +922,18 @@
         final ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
 
         // create an engine and a ScriptContext, but don't set it as default
-        ScriptContext scriptContext = new SimpleScriptContext();
+        final ScriptContext scriptContext = new SimpleScriptContext();
 
         // Set some value in the context
         scriptContext.setAttribute("myString", "foo", ScriptContext.ENGINE_SCOPE);
 
         // Evaluate script with custom context and get back a function
         final String script = "function (c) { return myString.indexOf(c); }";
-        CompiledScript compiledScript = ((Compilable)engine).compile(script);
-        Object func = compiledScript.eval(scriptContext);
+        final CompiledScript compiledScript = ((Compilable)engine).compile(script);
+        final Object func = compiledScript.eval(scriptContext);
 
         // Invoked function should be able to see context it was evaluated with
-        Object result = ((Invocable) engine).invokeMethod(func, "call", func, "o", null);
+        final Object result = ((Invocable) engine).invokeMethod(func, "call", func, "o", null);
         assertTrue(((Number)result).intValue() == 1);
     }
 }
--- a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -683,7 +683,7 @@
         final ScriptEngineManager manager = new ScriptEngineManager();
         final ScriptEngine e = manager.getEngineByName("nashorn");
         // no exception expected here!
-        Object value = e.getFactory().getParameter("no value assigned to this key");
+        final Object value = e.getFactory().getParameter("no value assigned to this key");
         assertNull(value);
     }
 
@@ -695,7 +695,7 @@
         final AtomicBoolean invoked = new AtomicBoolean(false);
         e.put("f", new Function<String, String>() {
             @Override
-            public String apply(String t) {
+            public String apply(final String t) {
                 invoked.set(true);
                 return t;
             }
@@ -712,7 +712,7 @@
         final AtomicBoolean invoked = new AtomicBoolean(false);
         e.put("c", new Consumer<Object>() {
             @Override
-            public void accept(Object t) {
+            public void accept(final Object t) {
                 assertTrue(t instanceof ScriptObjectMirror);
                 assertEquals(((ScriptObjectMirror)t).get("a"), "xyz");
                 invoked.set(true);
@@ -740,14 +740,14 @@
         try {
             e.put(null, "null-value");
             fail();
-        } catch (NullPointerException x) {
+        } catch (final NullPointerException x) {
             // expected
         }
 
         try {
             e.put("", "empty-value");
             fail();
-        } catch (IllegalArgumentException x) {
+        } catch (final IllegalArgumentException x) {
             // expected
         }
 
@@ -757,98 +757,98 @@
         try {
             b.put(null, "null-value");
             fail();
-        } catch (NullPointerException x) {
+        } catch (final NullPointerException x) {
             // expected
         }
 
         try {
             b.put("", "empty-value");
             fail();
-        } catch (IllegalArgumentException x) {
+        } catch (final IllegalArgumentException x) {
             // expected
         }
 
         try {
             b.get(null);
             fail();
-        } catch (NullPointerException x) {
+        } catch (final NullPointerException x) {
             // expected
         }
 
         try {
             b.get("");
             fail();
-        } catch (IllegalArgumentException x) {
+        } catch (final IllegalArgumentException x) {
             // expected
         }
 
         try {
             b.get(1);
             fail();
-        } catch (ClassCastException x) {
+        } catch (final ClassCastException x) {
             // expected
         }
 
         try {
             b.remove(null);
             fail();
-        } catch (NullPointerException x) {
+        } catch (final NullPointerException x) {
             // expected
         }
 
         try {
             b.remove("");
             fail();
-        } catch (IllegalArgumentException x) {
+        } catch (final IllegalArgumentException x) {
             // expected
         }
 
         try {
             b.remove(1);
             fail();
-        } catch (ClassCastException x) {
+        } catch (final ClassCastException x) {
             // expected
         }
 
         try {
             b.containsKey(null);
             fail();
-        } catch (NullPointerException x) {
+        } catch (final NullPointerException x) {
             // expected
         }
 
         try {
             b.containsKey("");
             fail();
-        } catch (IllegalArgumentException x) {
+        } catch (final IllegalArgumentException x) {
             // expected
         }
 
         try {
             b.containsKey(1);
             fail();
-        } catch (ClassCastException x) {
+        } catch (final ClassCastException x) {
             // expected
         }
 
         try {
             b.putAll(null);
             fail();
-        } catch (NullPointerException x) {
+        } catch (final NullPointerException x) {
             // expected
         }
 
         try {
             b.putAll(Collections.singletonMap((String)null, "null-value"));
             fail();
-        } catch (NullPointerException x) {
+        } catch (final NullPointerException x) {
             // expected
         }
 
         try {
             b.putAll(Collections.singletonMap("", "empty-value"));
             fail();
-        } catch (IllegalArgumentException x) {
+        } catch (final IllegalArgumentException x) {
             // expected
         }
     }
--- a/nashorn/test/src/jdk/nashorn/api/tree/test/ParseAPITest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/tree/test/ParseAPITest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -53,9 +53,9 @@
     private static final String TEST262_SUITE_DIR;
 
     static {
-        String testSrc = System.getProperty("test.src");
+        final String testSrc = System.getProperty("test.src");
         if (testSrc != null) {
-            String testScriptDir = testSrc + "/../../../../../../script/";
+            final String testScriptDir = testSrc + "/../../../../../../script/";
             TEST_BASIC_DIR    = testScriptDir + "basic";
             TEST_MAPTESTS_DIR = testScriptDir + "maptests";
             TEST_SANDBOX_DIR  = testScriptDir + "sandbox";
@@ -74,7 +74,7 @@
         public boolean exclude(File file, String content);
     }
 
-    private void log(String msg) {
+    private void log(final String msg) {
         org.testng.Reporter.log(msg, true);
     }
 
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/doubleconv/test/BignumTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/doubleconv/test/BignumTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -97,8 +97,8 @@
     @Test
     public void testAssign() throws Exception {
 
-        Object bignum = ctor.newInstance();
-        Object bignum2 = ctor.newInstance();
+        final Object bignum = ctor.newInstance();
+        final Object bignum2 = ctor.newInstance();
 
         final Method assignUInt16 = method("assignUInt16", char.class);
         final Method assignUInt64 = method("assignUInt64", long.class);
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -228,8 +228,8 @@
 
     @Test
     public void testNormalizedBoundaries() throws Exception {
-        Object boundary_plus = DiyFpCtor.newInstance();
-        Object boundary_minus = DiyFpCtor.newInstance();
+        final Object boundary_plus = DiyFpCtor.newInstance();
+        final Object boundary_minus = DiyFpCtor.newInstance();
         Object diy_fp = asNormalizedDiyFp.invoke(null, doubleToLong.invoke(null, 1.5));
         normalizedBoundaries.invoke(null, doubleToLong.invoke(null, 1.5), boundary_minus, boundary_plus);
         assertEquals(e.invoke(diy_fp), e.invoke(boundary_minus));
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/linker/test/NameCodecTest.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/linker/test/NameCodecTest.java	Tue Oct 18 17:14:09 2016 +0000
@@ -60,11 +60,11 @@
     static final String REPLACEMENT_CHARS = "-|,?!%{}^_";
 
     static String[][] canonicalSamples() {
-        int ndc = DANGEROUS_CHARS.length();
-        String[][] res = new String[2 * ndc][];
+        final int ndc = DANGEROUS_CHARS.length();
+        final String[][] res = new String[2 * ndc][];
         for (int i = 0; i < ndc; i++) {
-            char dc = DANGEROUS_CHARS.charAt(i);
-            char rc = REPLACEMENT_CHARS.charAt(i);
+            final char dc = DANGEROUS_CHARS.charAt(i);
+            final char rc = REPLACEMENT_CHARS.charAt(i);
             if (dc == '\\') {
                 res[2 * i + 0] = new String[]{"\\-%", "\\%"};
             } else {
@@ -82,11 +82,11 @@
         testEncode(canonicalSamples());
     }
 
-    private void testEncode(String[][] samples) {
-        for (String[] sample : samples) {
-            String s = sample[1];
-            String expResult = sample[0];
-            String result = NameCodec.encode(s);
+    private void testEncode(final String[][] samples) {
+        for (final String[] sample : samples) {
+            final String s = sample[1];
+            final String expResult = sample[0];
+            final String result = NameCodec.encode(s);
             if (!result.equals(expResult)) {
                 System.out.println(s + " => " + result + " != " + expResult);
             }
@@ -101,11 +101,11 @@
         testDecode(canonicalSamples());
     }
 
-    private void testDecode(String[][] samples) {
-        for (String[] sample : samples) {
-            String s = sample[0];
-            String expResult = sample[1];
-            String result = NameCodec.decode(s);
+    private void testDecode(final String[][] samples) {
+        for (final String[] sample : samples) {
+            final String s = sample[0];
+            final String expResult = sample[1];
+            final String result = NameCodec.decode(s);
             assertEquals(expResult, result);
         }
     }
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java	Tue Oct 18 17:14:09 2016 +0000
@@ -224,8 +224,8 @@
 
         boolean explicitOptimistic = false;
 
-        String allContent = new String(Files.readAllBytes(testFile));
-        Iterator<String> scanner = Shell.tokenizeString(allContent).iterator();
+        final String allContent = new String(Files.readAllBytes(testFile));
+        final Iterator<String> scanner = Shell.tokenizeString(allContent).iterator();
         while (scanner.hasNext()) {
             // TODO: Scan for /ref=file qualifiers, etc, to determine run
             // behavior
--- a/nashorn/test/src/jdk/nashorn/test/models/BigAbstract.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/BigAbstract.java	Tue Oct 18 17:14:09 2016 +0000
@@ -26,7 +26,7 @@
 package jdk.nashorn.test.models;
 
 public abstract class BigAbstract {
-    public static void accept(BigAbstract ba) {
+    public static void accept(final BigAbstract ba) {
     }
 
     public abstract void f0();
--- a/nashorn/test/src/jdk/nashorn/test/models/Jdk8072596TestSubject.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/Jdk8072596TestSubject.java	Tue Oct 18 17:14:09 2016 +0000
@@ -49,7 +49,7 @@
     }
 
     // Test having to wrap some arguments but not others, and a vararg array
-    public void test2(String x, final Object y, final ScriptObject w, final Object... z) {
+    public void test2(final String x, final Object y, final ScriptObject w, final Object... z) {
         test1(x, y, w);
 
         Assert.assertEquals(z.length, 2);
--- a/nashorn/test/src/jdk/nashorn/test/models/Reflector.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/Reflector.java	Tue Oct 18 17:14:09 2016 +0000
@@ -42,7 +42,7 @@
     private Reflector() {}
     private static final Module NASHORN_MOD = Context.class.getModule();
 
-    public static Object invoke(Method m, Object self, Object...args) {
+    public static Object invoke(final Method m, final Object self, final Object...args) {
         if (m.getDeclaringClass().getModule() != NASHORN_MOD) {
             throw new RuntimeException(m + " is not from Nashorn module");
         }
@@ -58,7 +58,7 @@
         }
     }
 
-    public static Object newInstance(Constructor c, Object...args) {
+    public static Object newInstance(final Constructor c, final Object...args) {
         if (c.getDeclaringClass().getModule() != NASHORN_MOD) {
             throw new RuntimeException(c + " is not from Nashorn module");
         }
@@ -74,7 +74,7 @@
         }
     }
 
-    public static Object get(Field f, Object self) {
+    public static Object get(final Field f, final Object self) {
         if (f.getDeclaringClass().getModule() != NASHORN_MOD) {
             throw new RuntimeException(f + " is not from Nashorn module");
         }
--- a/test/fmw/gtest/include/gtest/internal/gtest-port.h	Wed Oct 12 12:24:41 2016 +0000
+++ b/test/fmw/gtest/include/gtest/internal/gtest-port.h	Tue Oct 18 17:14:09 2016 +0000
@@ -1586,12 +1586,13 @@
 GTEST_API_ size_t GetThreadCount();
 
 // Passing non-POD classes through ellipsis (...) crashes the ARM
-// compiler and generates a warning in Sun Studio.  The Nokia Symbian
+// compiler and generates a warning in Sun Studio before 12u4. The Nokia Symbian
 // and the IBM XL C/C++ compiler try to instantiate a copy constructor
 // for objects passed through ellipsis (...), failing for uncopyable
 // objects.  We define this to ensure that only POD is passed through
 // ellipsis on these systems.
-#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)
+#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || \
+     (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5130)
 // We lose support for NULL detection where the compiler doesn't like
 // passing non-POD classes through ellipsis (...).
 # define GTEST_ELLIPSIS_NEEDS_POD_ 1
--- a/test/lib/jdk/test/lib/Platform.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/test/lib/jdk/test/lib/Platform.java	Tue Oct 18 17:14:09 2016 +0000
@@ -28,6 +28,9 @@
 public class Platform {
     public  static final String vmName      = System.getProperty("java.vm.name");
     public  static final String vmInfo      = System.getProperty("java.vm.info");
+    private static final String osVersion   = System.getProperty("os.version");
+    private static       int osVersionMajor = -1;
+    private static       int osVersionMinor = -1;
     private static final String osName      = System.getProperty("os.name");
     private static final String dataModel   = System.getProperty("sun.arch.data.model");
     private static final String vmVersion   = System.getProperty("java.vm.version");
@@ -112,6 +115,35 @@
         return osName;
     }
 
+    // Os version support.
+    private static void init_version() {
+        try {
+            final String[] tokens = osVersion.split("\\.");
+            if (tokens.length > 0) {
+                osVersionMajor = Integer.parseInt(tokens[0]);
+                if (tokens.length > 1) {
+                    osVersionMinor = Integer.parseInt(tokens[1]);
+                }
+            }
+        } catch (NumberFormatException e) {
+            osVersionMajor = osVersionMinor = 0;
+        }
+    }
+
+    // Returns major version number from os.version system property.
+    // E.g. 5 on Solaris 10 and 3 on SLES 11.3 (for the linux kernel version).
+    public static int getOsVersionMajor() {
+        if (osVersionMajor == -1) init_version();
+        return osVersionMajor;
+    }
+
+    // Returns minor version number from os.version system property.
+    // E.g. 10 on Solaris 10 and 0 on SLES 11.3 (for the linux kernel version).
+    public static int getOsVersionMinor() {
+        if (osVersionMinor == -1) init_version();
+        return osVersionMinor;
+    }
+
     public static boolean isDebugBuild() {
         return (jdkDebug.toLowerCase().contains("debug"));
     }
--- a/test/lib/jdk/test/lib/cli/predicate/AndPredicate.java	Wed Oct 12 12:24:41 2016 +0000
+++ b/test/lib/jdk/test/lib/cli/predicate/AndPredicate.java	Tue Oct 18 17:14:09 2016 +0000
@@ -28,14 +28,22 @@
 public class AndPredicate implements BooleanSupplier {
     private final BooleanSupplier a;
     private final BooleanSupplier b;
+    private final BooleanSupplier c;
 
     public AndPredicate(BooleanSupplier a, BooleanSupplier b) {
         this.a = a;
         this.b = b;
+        this.c = () -> true; // Boolean.TRUE::booleanValue
+    }
+
+    public AndPredicate(BooleanSupplier a, BooleanSupplier b, BooleanSupplier c) {
+        this.a = a;
+        this.b = b;
+        this.c = c;
     }
 
     @Override
     public boolean getAsBoolean() {
-        return a.getAsBoolean() && b.getAsBoolean();
+        return a.getAsBoolean() && b.getAsBoolean() && c.getAsBoolean();
     }
 }
--- a/test/make/TestMakeBase.gmk	Wed Oct 12 12:24:41 2016 +0000
+++ b/test/make/TestMakeBase.gmk	Tue Oct 18 17:14:09 2016 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -264,4 +264,81 @@
     $(call PathList, $(PATHLIST_INPUT)), \
     PathList call not safe for calling twice))
 
+################################################################################
+# Test FindCommonPathPrefix
+
+$(eval $(call assert-equals, \
+    $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/banan), \
+    /foo/bar, \
+    FindCommonPathPrefix, \
+))
+
+$(eval $(call assert-equals, \
+    $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar), \
+    /foo/bar, \
+    FindCommonPathPrefix, \
+))
+
+$(eval $(call assert-equals, \
+    $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/), \
+    /foo/bar, \
+    FindCommonPathPrefix, \
+))
+
+$(eval $(call assert-equals, \
+    $(call FindCommonPathPrefix, foo/bar/baz, foo/bar/banan), \
+    foo/bar, \
+    FindCommonPathPrefix, \
+))
+
+$(eval $(call assert-equals, \
+    $(call FindCommonPathPrefix, foo/bar/baz, /foo/bar/banan), \
+    , \
+    FindCommonPathPrefix, \
+))
+
+################################################################################
+# DirToDotDot
+
+$(eval $(call assert-equals, \
+    $(call DirToDotDot, foo/bar/baz/), \
+    ../../.., \
+    DirToDotDot, \
+))
+
+$(eval $(call assert-equals, \
+    $(call DirToDotDot, foo/bar), \
+    ../.., \
+    DirToDotDot, \
+))
+
+$(eval $(call assert-equals, \
+    $(call DirToDotDot, /foo), \
+    .., \
+    DirToDotDot, \
+))
+
+################################################################################
+# RelativePath
+
+$(eval $(call assert-equals, \
+    $(call RelativePath, foo/bar/baz, foo/bar/banan), \
+    ../baz, \
+    RelativePath, \
+))
+
+$(eval $(call assert-equals, \
+    $(call RelativePath, foo/bar/baz/banan/kung, foo/bar/banan/kung), \
+    ../../baz/banan/kung, \
+    RelativePath, \
+))
+
+$(eval $(call assert-equals, \
+    $(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/banan/kung/), \
+    ../../baz/banan/kung, \
+    RelativePath, \
+))
+
+################################################################################
+
 all: $(TEST_TARGETS)