changeset 47400:12f96b323f85 lvti

Automatic merge with default
author mcimadamore
date Thu, 05 Oct 2017 22:04:49 +0200
parents eb44934310e4 1129253d3bc7
children 60922e959a98
files src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java src/java.xml/share/classes/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/SecuritySupport.java src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/SecuritySupport.java src/java.xml/share/classes/javax/xml/datatype/SecuritySupport.java src/java.xml/share/classes/javax/xml/parsers/SecuritySupport.java src/java.xml/share/classes/javax/xml/stream/SecuritySupport.java src/java.xml/share/classes/javax/xml/transform/SecuritySupport.java src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java src/java.xml/share/classes/javax/xml/xpath/SecuritySupport.java src/java.xml/share/classes/org/xml/sax/helpers/SecuritySupport.java test/langtools/jdk/javadoc/doclet/testInterface/pkg/ClassWithStaticMethod.java test/langtools/jdk/javadoc/doclet/testInterface/pkg/InterfaceWithStaticMethod.java
diffstat 242 files changed, 3301 insertions(+), 3910 deletions(-) [+]
line wrap: on
line diff
--- a/make/Bundles.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/Bundles.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -40,7 +40,7 @@
 endif
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , Bundles-pre.gmk))
+$(eval $(call IncludeCustomExtension, Bundles-pre.gmk))
 ################################################################################
 # BUNDLE : Name of bundle to create
 # FILES : Files in BASE_DIRS to add to bundle
@@ -322,7 +322,7 @@
 ################################################################################
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , Bundles.gmk))
+$(eval $(call IncludeCustomExtension, Bundles.gmk))
 
 ################################################################################
 
--- a/make/CompileDemos.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/CompileDemos.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -303,7 +303,7 @@
 
 ################################################################################
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , CompileDemos.gmk))
+$(eval $(call IncludeCustomExtension, CompileDemos.gmk))
 
 all: $(TARGETS)
 images: $(IMAGES_TARGETS)
--- a/make/CompileJavaModules.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/CompileJavaModules.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -33,7 +33,7 @@
 include SetupJavaCompilers.gmk
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , CompileJavaModules.gmk))
+$(eval $(call IncludeCustomExtension, CompileJavaModules.gmk))
 
 ################################################################################
 # Module specific build settings
@@ -689,7 +689,7 @@
 
 ################################################################################
 
-$(eval $(call IncludeCustomExtension, , CompileJavaModules-post.gmk))
+$(eval $(call IncludeCustomExtension, CompileJavaModules-post.gmk))
 
 ################################################################################
 
--- a/make/CompileToolsHotspot.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/CompileToolsHotspot.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -35,7 +35,7 @@
 TARGETS :=
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , hotspot/CompileTools.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/CompileTools.gmk))
 
 ifeq ($(INCLUDE_GRAAL), true)
   VM_CI_SRC_DIR := $(TOPDIR)/src/jdk.internal.vm.ci/share/classes
--- a/make/CompileToolsJdk.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/CompileToolsJdk.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -32,7 +32,7 @@
 
 ################################################################################
 
-$(eval $(call IncludeCustomExtension, , CompileTools.gmk))
+$(eval $(call IncludeCustomExtension, CompileTools.gmk))
 
 ################################################################################
 
--- a/make/Docs.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/Docs.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -37,7 +37,7 @@
 
 ################################################################################
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , Docs.gmk))
+$(eval $(call IncludeCustomExtension, Docs.gmk))
 
 ################################################################################
 # This file generates all documentation for OpenJDK.
--- a/make/Images.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/Images.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -34,7 +34,7 @@
 JRE_TARGETS :=
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , Images-pre.gmk))
+$(eval $(call IncludeCustomExtension, Images-pre.gmk))
 
 ############################################################################
 
@@ -426,7 +426,7 @@
 
 # Include custom post hook here to make it possible to augment the target lists
 # before actual target prerequisites are declared.
-$(eval $(call IncludeCustomExtension, , Images-post.gmk))
+$(eval $(call IncludeCustomExtension, Images-post.gmk))
 
 ################################################################################
 
--- a/make/Init.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/Init.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -137,15 +137,16 @@
 
     # The spec files depend on the autoconf source code. This check makes sure
     # the configuration is up to date after changes to configure.
-    CUSTOM_CONFIG_DIR ?= $(topdir)/closed/autoconf
-
-    $(SPECS): $(wildcard $(topdir)/common/autoconf/*) $(wildcard $(CUSTOM_CONFIG_DIR)/*)
+    $(SPECS): $(wildcard $(topdir)/make/autoconf/*) \
+            $(if $(CUSTOM_CONFIG_DIR), $(wildcard $(CUSTOM_CONFIG_DIR)/*))
         ifeq ($(CONF_CHECK), fail)
-	  @echo "Error: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'."
+	  @echo Error: The configuration is not up to date for \
+	      "'$(lastword $(subst /, , $(dir $@)))'."
 	  $(call PrintConfCheckFailed)
 	  @exit 2
         else ifeq ($(CONF_CHECK), auto)
-	  @echo "Note: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'."
+	  @echo Note: The configuration is not up to date for \
+	      "'$(lastword $(subst /, , $(dir $@)))'."
 	  @( cd $(topdir) && \
 	      $(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -f $(topdir)/make/Init.gmk \
 	      SPEC=$@ HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \
@@ -266,6 +267,7 @@
 	  $(ECHO) "Re-running configure using default settings"
         endif
 	( cd $(OUTPUTDIR) && PATH="$(ORIGINAL_PATH)" \
+	    CUSTOM_CONFIG_DIR="$(CUSTOM_CONFIG_DIR)" \
 	    $(BASH) $(CONFIGURE_CMD) $(CONFIGURE_COMMAND_LINE) )
 
   ##############################################################################
--- a/make/InitSupport.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/InitSupport.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -35,8 +35,9 @@
 ifeq ($(HAS_SPEC),)
 
   # Include the corresponding closed file, if present.
-  # Normal hook mechanism cannot be used since we have no SPEC.
-  -include $(topdir)/../closed/make/InitSupport.gmk
+  ifneq ($(CUSTOM_MAKE_DIR), )
+    -include $(CUSTOM_MAKE_DIR)/InitSupport.gmk
+  endif
 
   ##############################################################################
   # Helper functions for the initial part of Init.gmk, before the spec file is
--- a/make/Jprt.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/Jprt.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -104,4 +104,4 @@
 
 ################################################################################
 
-$(eval $(call IncludeCustomExtension, , Jprt.gmk))
+$(eval $(call IncludeCustomExtension, Jprt.gmk))
--- a/make/Main.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/Main.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -51,7 +51,7 @@
 ALL_TARGETS :=
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , Main.gmk))
+$(eval $(call IncludeCustomExtension, Main.gmk))
 
 # All modules for the current target platform.
 ALL_MODULES := $(call FindAllModules)
--- a/make/ReleaseFile.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/ReleaseFile.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -80,7 +80,7 @@
 
 ################################################################################
 
-$(eval $(call IncludeCustomExtension, , ReleaseFile.gmk))
+$(eval $(call IncludeCustomExtension, ReleaseFile.gmk))
 
 ################################################################################
 
--- a/make/RunTests.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/RunTests.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -36,7 +36,7 @@
 JTREG_TEST_TOPDIRS := $(TOPDIR) $(JTREG_TESTROOTS)
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , RunTests.gmk))
+$(eval $(call IncludeCustomExtension, RunTests.gmk))
 
 TEST_RESULTS_DIR := $(OUTPUTDIR)/test-results
 TEST_SUPPORT_DIR := $(OUTPUTDIR)/test-support
--- a/make/SourceRevision.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/SourceRevision.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -28,7 +28,7 @@
 include $(SPEC)
 include MakeBase.gmk
 
-$(eval $(call IncludeCustomExtension, , SourceRevision.gmk))
+$(eval $(call IncludeCustomExtension, SourceRevision.gmk))
 
 ################################################################################
 # Keep track of what source revision is used to create the build, by creating
--- a/make/ToolsJdk.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/ToolsJdk.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -29,7 +29,7 @@
 include JavaCompilation.gmk
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , Tools.gmk))
+$(eval $(call IncludeCustomExtension, Tools.gmk))
 
 ################################################################################
 # To avoid reevaluating the compilation setup for the tools each time this file
--- a/make/UpdateBuildDocs.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/UpdateBuildDocs.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -63,7 +63,7 @@
 
 ################################################################################
 
-$(eval $(call IncludeCustomExtension, , UpdateBuildDocs.gmk))
+$(eval $(call IncludeCustomExtension, UpdateBuildDocs.gmk))
 
 ################################################################################
 
--- a/make/ZipSource.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/ZipSource.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -33,7 +33,7 @@
 SRC_ZIP_WORK_DIR := $(SUPPORT_OUTPUTDIR)/src
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , ZipSource.gmk))
+$(eval $(call IncludeCustomExtension, ZipSource.gmk))
 
 ################################################################################
 # Create the directory structure for src.zip using symlinks.
--- a/make/autoconf/autogen.sh	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/autoconf/autogen.sh	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -52,15 +52,6 @@
   TIMESTAMP=`date +%s`
 fi
 
-if test "x$CUSTOM_CONFIG_DIR" = "x"; then
-  topdir=`cd $script_dir/../..  >/dev/null && pwd`
-  custom_script_dir="$topdir/closed/autoconf"
-else
-  custom_script_dir=$CUSTOM_CONFIG_DIR
-fi
-
-custom_hook=$custom_script_dir/custom-hook.m4
-
 AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`"
 
 if test "x${AUTOCONF}" = x; then
@@ -75,11 +66,16 @@
 echo "Generating generated-configure.sh"
 generate_configure_script "$script_dir/generated-configure.sh" 'cat'
 
-if test -e $custom_hook; then
+if test "x$CUSTOM_CONFIG_DIR" != "x"; then
+  custom_hook=$CUSTOM_CONFIG_DIR/custom-hook.m4
+  if test ! -e $custom_hook; then
+    echo "CUSTOM_CONFIG_DIR set but $CUSTOM_CONFIG_DIR/custom-hook.m4 not present"
+    echo "Error: Cannot continue" 1>&2
+    exit 1
+  fi
+
   # We have custom sources available; also generate configure script
   # with custom hooks compiled in.
   echo "Generating custom generated-configure.sh"
-  generate_configure_script "$custom_script_dir/generated-configure.sh" 'sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"'
-else
-  echo "(No custom hook found at $custom_hook)"
+  generate_configure_script "$CUSTOM_CONFIG_DIR/generated-configure.sh" 'sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"'
 fi
--- a/make/autoconf/configure	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/autoconf/configure	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -46,10 +46,12 @@
 
 conf_script_dir="$TOPDIR/make/autoconf"
 
-if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
-  conf_custom_script_dir="$TOPDIR/closed/autoconf"
-else
-  conf_custom_script_dir="$CUSTOM_CONFIG_DIR"
+if test "x$CUSTOM_CONFIG_DIR" != x; then
+  if test ! -e $CUSTOM_CONFIG_DIR/generated-configure.sh; then
+    echo "CUSTOM_CONFIG_DIR not pointing to a proper custom config dir."
+    echo "Error: Cannot continue" 1>&2
+    exit 1
+  fi
 fi
 
 ###
@@ -76,10 +78,10 @@
     fi
   done
 
-  if test -e $conf_custom_script_dir/generated-configure.sh; then
+  if test "x$CUSTOM_CONFIG_DIR" != x; then
     # If custom source configure is available, make sure it is up-to-date as well.
-    for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $conf_custom_script_dir/*.m4; do
-      if test $file -nt $conf_custom_script_dir/generated-configure.sh; then
+    for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $CUSTOM_CONFIG_DIR/*.m4; do
+      if test $file -nt $CUSTOM_CONFIG_DIR/generated-configure.sh; then
         echo "Warning: The configure source files is newer than the custom generated files."
         run_autogen_or_fail
       fi
@@ -93,11 +95,9 @@
     if test "x$conf_updated_autoconf_files" != x; then
       echo "Configure source code has been updated, checking time stamps"
       check_autoconf_timestamps
-    fi
-
-    if test -e $conf_custom_script_dir; then
+    elif test "x$CUSTOM_CONFIG_DIR" != x; then
       # If custom source configure is available, make sure it is up-to-date as well.
-      conf_custom_updated_autoconf_files=`cd $conf_custom_script_dir && hg status -mard 2> /dev/null | grep autoconf`
+      conf_custom_updated_autoconf_files=`cd $CUSTOM_CONFIG_DIR && hg status -mard 2> /dev/null | grep autoconf`
       if test "x$conf_custom_updated_autoconf_files" != x; then
         echo "Configure custom source code has been updated, checking time stamps"
         check_autoconf_timestamps
@@ -109,11 +109,11 @@
 # Check for local changes
 check_hg_updates
 
-if test -e $conf_custom_script_dir/generated-configure.sh; then
+if test "x$CUSTOM_CONFIG_DIR" != x; then
   # Test if open configure is newer than custom configure, if so, custom needs to
   # be regenerated. This test is required to ensure consistency with custom source.
   conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_script_dir/generated-configure.sh  | cut -d"=" -f 2`
-  conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_custom_script_dir/generated-configure.sh  | cut -d"=" -f 2`
+  conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $CUSTOM_CONFIG_DIR/generated-configure.sh  | cut -d"=" -f 2`
   if test $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then
     echo "Warning: The generated configure file contains changes not present in the custom generated file."
     run_autogen_or_fail
@@ -241,10 +241,10 @@
 ###
 ### Call the configure script
 ###
-if test -e $conf_custom_script_dir/generated-configure.sh; then
+if test "x$CUSTOM_CONFIG_DIR" != x; then
   # Custom source configure available; run that instead
   echo "Running custom generated-configure.sh"
-  conf_script_to_run=$conf_custom_script_dir/generated-configure.sh
+  conf_script_to_run=$CUSTOM_CONFIG_DIR/generated-configure.sh
 else
   echo "Running generated-configure.sh"
   conf_script_to_run=$conf_script_dir/generated-configure.sh
--- a/make/autoconf/spec.gmk.in	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/autoconf/spec.gmk.in	Thu Oct 05 22:04:49 2017 +0200
@@ -847,9 +847,8 @@
 # This macro is called to allow inclusion of closed source counterparts.
 # Unless overridden in closed sources, it expands to nothing.
 # Usage: This function is called in an open makefile, with the following
-# arguments:
-# $1 the name of the repo, or empty if the top-level repo.
-# $2 the name of the makefile
+# argument:
+# $1 the name of the makefile
 define IncludeCustomExtension
 endef
 
--- a/make/common/FindTests.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/common/FindTests.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -27,7 +27,7 @@
 _FIND_TESTS_GMK := 1
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , common/FindTests.gmk))
+$(eval $(call IncludeCustomExtension, common/FindTests.gmk))
 
 # JTREG_TESTROOTS might have been set by a custom extension
 JTREG_TESTROOTS += $(addprefix $(TOPDIR)/test/, hotspot/jtreg jdk langtools nashorn jaxp)
--- a/make/common/MakeBase.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/common/MakeBase.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -991,6 +991,6 @@
 ################################################################################
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , common/MakeBase.gmk))
+$(eval $(call IncludeCustomExtension, common/MakeBase.gmk))
 
 endif # _MAKEBASE_GMK
--- a/make/common/Modules.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/common/Modules.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -43,7 +43,7 @@
 DOCS_MODULES :=
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , common/Modules.gmk))
+$(eval $(call IncludeCustomExtension, common/Modules.gmk))
 
 BOOT_MODULES += \
     java.base \
--- a/make/copy/Copy-java.base.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/copy/Copy-java.base.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -25,7 +25,7 @@
 
 include CopyCommon.gmk
 
-$(eval $(call IncludeCustomExtension, , copy/Copy-java.base.gmk))
+$(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk))
 
 ################################################################################
 #
--- a/make/copy/Copy-java.desktop.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/copy/Copy-java.desktop.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -25,7 +25,7 @@
 
 include CopyCommon.gmk
 
-$(eval $(call IncludeCustomExtension, , copy/Copy-java.desktop.gmk))
+$(eval $(call IncludeCustomExtension, copy/Copy-java.desktop.gmk))
 
 ################################################################################
 
--- a/make/gendata/Gendata-java.base.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/gendata/Gendata-java.base.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -26,7 +26,7 @@
 include GendataCommon.gmk
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , gendata/Gendata-java.base.gmk))
+$(eval $(call IncludeCustomExtension, gendata/Gendata-java.base.gmk))
 
 include GendataBreakIterator.gmk
 
--- a/make/gendata/GendataBlacklistedCerts.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/gendata/GendataBlacklistedCerts.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -23,7 +23,7 @@
 # questions.
 #
 
-$(eval $(call IncludeCustomExtension, , gendata/GendataBlacklistedCerts.gmk))
+$(eval $(call IncludeCustomExtension, gendata/GendataBlacklistedCerts.gmk))
 
 GENDATA_BLACKLISTED_CERTS_SRC += $(TOPDIR)/make/data/blacklistedcertsconverter/blacklisted.certs.pem
 GENDATA_BLACKLISTED_CERTS := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/security/blacklisted.certs
--- a/make/gendata/GendataFontConfig.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/gendata/GendataFontConfig.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -23,7 +23,7 @@
 # questions.
 #
 
-$(eval $(call IncludeCustomExtension, , gendata/GendataFontConfig.gmk))
+$(eval $(call IncludeCustomExtension, gendata/GendataFontConfig.gmk))
 
 GENDATA_FONT_CONFIG_DST := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)
 
--- a/make/gensrc/Gensrc-java.desktop.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/gensrc/Gensrc-java.desktop.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -26,7 +26,7 @@
 include GensrcCommonJdk.gmk
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , gensrc/Gensrc-java.desktop.gmk))
+$(eval $(call IncludeCustomExtension, gensrc/Gensrc-java.desktop.gmk))
 
 ifneq ($(OPENJDK_TARGET_OS), windows)
   include GensrcIcons.gmk
--- a/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -28,7 +28,7 @@
 include $(SPEC)
 include MakeBase.gmk
 
-$(eval $(call IncludeCustomExtension, , gensrc/Gensrc-jdk.internal.vm.compiler.gmk))
+$(eval $(call IncludeCustomExtension, gensrc/Gensrc-jdk.internal.vm.compiler.gmk))
 
 GENSRC_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)
 SRC_DIR := $(TOPDIR)/src/$(MODULE)/share/classes
--- a/make/gensrc/Gensrc-jdk.localedata.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/gensrc/Gensrc-jdk.localedata.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -26,7 +26,7 @@
 include GensrcCommonJdk.gmk
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , gensrc/Gensrc-jdk.localedata.gmk))
+$(eval $(call IncludeCustomExtension, gensrc/Gensrc-jdk.localedata.gmk))
 
 include GensrcLocaleData.gmk
 include GensrcCLDR.gmk
--- a/make/gensrc/GensrcIcons.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/gensrc/GensrcIcons.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -23,7 +23,7 @@
 # questions.
 #
 
-$(eval $(call IncludeCustomExtension, , gensrc/GensrcIcons.gmk))
+$(eval $(call IncludeCustomExtension, gensrc/GensrcIcons.gmk))
 
 GENSRC_AWT_ICONS :=
 GENSRC_AWT_ICONS_SRC :=
--- a/make/hotspot/gensrc/GenerateSources.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/hotspot/gensrc/GenerateSources.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -39,7 +39,7 @@
 include gensrc/GensrcDtrace.gmk
 include gensrc/GensrcJvmti.gmk
 
-$(eval $(call IncludeCustomExtension, , hotspot/gensrc/GenerateSources.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/gensrc/GenerateSources.gmk))
 
 # While technically the rules below are "gendata" which can be done in parallel
 # with native compilation, let's keep it here for simplicity.
--- a/make/hotspot/gensrc/GensrcAdlc.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/hotspot/gensrc/GensrcAdlc.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -23,7 +23,7 @@
 # questions.
 #
 
-$(eval $(call IncludeCustomExtension, , hotspot/gensrc/GensrcAdlc.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/gensrc/GensrcAdlc.gmk))
 
 ifeq ($(call check-jvm-feature, compiler2), true)
 
--- a/make/hotspot/gensrc/GensrcJvmti.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/hotspot/gensrc/GensrcJvmti.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -23,7 +23,7 @@
 # questions.
 #
 
-$(eval $(call IncludeCustomExtension, , hotspot/gensrc/GensrcJvmti.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/gensrc/GensrcJvmti.gmk))
 
 ################################################################################
 # Build tools needed for the JVMTI source code generation
--- a/make/hotspot/lib/CompileGtest.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/hotspot/lib/CompileGtest.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -23,7 +23,7 @@
 # questions.
 #
 
-$(eval $(call IncludeCustomExtension, , hotspot/lib/CompileGtest.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/lib/CompileGtest.gmk))
 
 GTEST_TEST_SRC += $(TOPDIR)/test/hotspot/gtest
 GTEST_LAUNCHER_SRC := $(TOPDIR)/test/hotspot/gtest/gtestLauncher.cpp
--- a/make/hotspot/lib/CompileJvm.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/hotspot/lib/CompileJvm.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -28,7 +28,7 @@
 include lib/JvmFeatures.gmk
 include lib/JvmOverrideFiles.gmk
 
-$(eval $(call IncludeCustomExtension, , hotspot/lib/CompileJvm.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/lib/CompileJvm.gmk))
 
 ################################################################################
 # Setup compilation of the main Hotspot native library (libjvm).
--- a/make/hotspot/lib/JvmFeatures.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/hotspot/lib/JvmFeatures.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -23,7 +23,7 @@
 # questions.
 #
 
-$(eval $(call IncludeCustomExtension, , hotspot/lib/JvmFeatures.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/lib/JvmFeatures.gmk))
 
 ################################################################################
 # Setup CFLAGS and EXCLUDES for the libjvm compilation, depending on which
--- a/make/hotspot/lib/JvmMapfile.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/hotspot/lib/JvmMapfile.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -23,7 +23,7 @@
 # questions.
 #
 
-$(eval $(call IncludeCustomExtension, , hotspot/lib/JvmMapfile.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/lib/JvmMapfile.gmk))
 
 ################################################################################
 # Combine a list of static symbols
--- a/make/hotspot/lib/JvmOverrideFiles.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/hotspot/lib/JvmOverrideFiles.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -23,7 +23,7 @@
 # questions.
 #
 
-$(eval $(call IncludeCustomExtension, , hotspot/lib/JvmOverrideFiles.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/lib/JvmOverrideFiles.gmk))
 
 ################################################################################
 # This file contains explicit overrides of CFLAGS and/or precompiled header
--- a/make/launcher/Launcher-java.base.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/launcher/Launcher-java.base.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -25,7 +25,7 @@
 
 include LauncherCommon.gmk
 
-$(eval $(call IncludeCustomExtension, , launcher/Launcher-java.base.gmk))
+$(eval $(call IncludeCustomExtension, launcher/Launcher-java.base.gmk))
 
 JAVA_RC_FLAGS += -I $(TOPDIR)/src/java.base/windows/native/common
 JAVA_RC_FLAGS += -I $(TOPDIR)/src/java.base/windows/native/launcher/icons
--- a/make/launcher/Launcher-java.desktop.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/launcher/Launcher-java.desktop.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -26,7 +26,7 @@
 include LauncherCommon.gmk
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , launcher/Launcher-java.desktop.gmk))
+$(eval $(call IncludeCustomExtension, launcher/Launcher-java.desktop.gmk))
 
 ifeq ($(ENABLE_HEADLESS_ONLY), false)
   $(eval $(call SetupBuildLauncher, appletviewer, \
--- a/make/lib/Awt2dLibraries.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/lib/Awt2dLibraries.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -23,7 +23,7 @@
 # questions.
 #
 
-$(eval $(call IncludeCustomExtension, , lib/Awt2dLibraries-pre.gmk))
+$(eval $(call IncludeCustomExtension, lib/Awt2dLibraries-pre.gmk))
 
 WIN_AWT_LIB := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt/awt.lib
 
@@ -1070,4 +1070,4 @@
 ################################################################################
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , lib/Awt2dLibraries.gmk))
+$(eval $(call IncludeCustomExtension, lib/Awt2dLibraries.gmk))
--- a/make/lib/CoreLibraries.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/lib/CoreLibraries.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -26,7 +26,7 @@
 WIN_VERIFY_LIB := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libverify/verify.lib
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , lib/CoreLibraries.gmk))
+$(eval $(call IncludeCustomExtension, lib/CoreLibraries.gmk))
 
 
 ##########################################################################################
--- a/make/lib/Lib-java.instrument.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/lib/Lib-java.instrument.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -26,7 +26,7 @@
 include LibCommon.gmk
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , lib/Lib-java.instrument.gmk))
+$(eval $(call IncludeCustomExtension, lib/Lib-java.instrument.gmk))
 
 ################################################################################
 
--- a/make/lib/Lib-java.management.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/lib/Lib-java.management.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -26,7 +26,7 @@
 include LibCommon.gmk
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , lib/Lib-java.management.gmk))
+$(eval $(call IncludeCustomExtension, lib/Lib-java.management.gmk))
 
 ################################################################################
 
--- a/make/lib/Lib-jdk.hotspot.agent.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/lib/Lib-jdk.hotspot.agent.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -25,7 +25,7 @@
 
 include NativeCompilation.gmk
 
-$(eval $(call IncludeCustomExtension, , hotspot/lib/Lib-jdk.hotspot.agent.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/lib/Lib-jdk.hotspot.agent.gmk))
 
 ################################################################################
 
--- a/make/lib/Lib-jdk.management.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/lib/Lib-jdk.management.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -26,7 +26,7 @@
 include LibCommon.gmk
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , lib/Lib-jdk.management.gmk))
+$(eval $(call IncludeCustomExtension, lib/Lib-jdk.management.gmk))
 
 ################################################################################
 
--- a/make/lib/LibCommon.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/lib/LibCommon.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -26,7 +26,7 @@
 include NativeCompilation.gmk
 
 # Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, , lib/LibCommon.gmk))
+$(eval $(call IncludeCustomExtension, lib/LibCommon.gmk))
 
 ################################################################################
 
--- a/make/test/JtregNativeHotspot.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/test/JtregNativeHotspot.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -35,7 +35,7 @@
 include MakeBase.gmk
 include TestFilesCompilation.gmk
 
-$(eval $(call IncludeCustomExtension, , hotspot/test/JtregNative.gmk))
+$(eval $(call IncludeCustomExtension, hotspot/test/JtregNative.gmk))
 
 ################################################################################
 # Targets for building the native tests themselves.
--- a/make/test/JtregNativeJdk.gmk	Tue Oct 03 13:19:47 2017 +0200
+++ b/make/test/JtregNativeJdk.gmk	Thu Oct 05 22:04:49 2017 +0200
@@ -35,7 +35,7 @@
 include MakeBase.gmk
 include TestFilesCompilation.gmk
 
-$(eval $(call IncludeCustomExtension, , test/JtregNative.gmk))
+$(eval $(call IncludeCustomExtension, test/JtregNative.gmk))
 
 ################################################################################
 # Targets for building the native tests themselves.
--- a/src/java.base/share/classes/java/util/ArrayDeque.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/ArrayDeque.java	Thu Oct 05 22:04:49 2017 +0200
@@ -211,7 +211,7 @@
     }
 
     /**
-     * Increments i, mod modulus.
+     * Circularly increments i, mod modulus.
      * Precondition and postcondition: 0 <= i < modulus.
      */
     static final int inc(int i, int modulus) {
@@ -220,7 +220,7 @@
     }
 
     /**
-     * Decrements i, mod modulus.
+     * Circularly decrements i, mod modulus.
      * Precondition and postcondition: 0 <= i < modulus.
      */
     static final int dec(int i, int modulus) {
@@ -233,7 +233,7 @@
      * Precondition: 0 <= i < modulus, 0 <= distance <= modulus.
      * @return index 0 <= i < modulus
      */
-    static final int add(int i, int distance, int modulus) {
+    static final int inc(int i, int distance, int modulus) {
         if ((i += distance) - modulus >= 0) i -= modulus;
         return i;
     }
@@ -825,7 +825,7 @@
             final int i, n;
             return ((n = sub(getFence(), i = cursor, es.length) >> 1) <= 0)
                 ? null
-                : new DeqSpliterator(i, cursor = add(i, n, es.length));
+                : new DeqSpliterator(i, cursor = inc(i, n, es.length));
         }
 
         public void forEachRemaining(Consumer<? super E> action) {
--- a/src/java.base/share/classes/java/util/HashMap.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/HashMap.java	Thu Oct 05 22:04:49 2017 +0200
@@ -490,7 +490,7 @@
     }
 
     /**
-     * Implements Map.putAll and Map constructor
+     * Implements Map.putAll and Map constructor.
      *
      * @param m the map
      * @param evict false when initially constructing this map, else
@@ -557,7 +557,7 @@
     }
 
     /**
-     * Implements Map.get and related methods
+     * Implements Map.get and related methods.
      *
      * @param hash hash for key
      * @param key the key
@@ -612,7 +612,7 @@
     }
 
     /**
-     * Implements Map.put and related methods
+     * Implements Map.put and related methods.
      *
      * @param hash hash for key
      * @param key the key
@@ -700,7 +700,7 @@
         }
         threshold = newThr;
         @SuppressWarnings({"rawtypes","unchecked"})
-            Node<K,V>[] newTab = (Node<K,V>[])new Node[newCap];
+        Node<K,V>[] newTab = (Node<K,V>[])new Node[newCap];
         table = newTab;
         if (oldTab != null) {
             for (int j = 0; j < oldCap; ++j) {
@@ -800,7 +800,7 @@
     }
 
     /**
-     * Implements Map.remove and related methods
+     * Implements Map.remove and related methods.
      *
      * @param hash hash for key
      * @param key the key
@@ -875,7 +875,7 @@
     public boolean containsValue(Object value) {
         Node<K,V>[] tab; V v;
         if ((tab = table) != null && size > 0) {
-            for (Node<K, V> e : tab) {
+            for (Node<K,V> e : tab) {
                 for (; e != null; e = e.next) {
                     if ((v = e.value) == value ||
                         (value != null && value.equals(v)))
@@ -927,7 +927,7 @@
                 throw new NullPointerException();
             if (size > 0 && (tab = table) != null) {
                 int mc = modCount;
-                for (Node<K, V> e : tab) {
+                for (Node<K,V> e : tab) {
                     for (; e != null; e = e.next)
                         action.accept(e.key);
                 }
@@ -975,7 +975,7 @@
                 throw new NullPointerException();
             if (size > 0 && (tab = table) != null) {
                 int mc = modCount;
-                for (Node<K, V> e : tab) {
+                for (Node<K,V> e : tab) {
                     for (; e != null; e = e.next)
                         action.accept(e.value);
                 }
@@ -1038,7 +1038,7 @@
                 throw new NullPointerException();
             if (size > 0 && (tab = table) != null) {
                 int mc = modCount;
-                for (Node<K, V> e : tab) {
+                for (Node<K,V> e : tab) {
                     for (; e != null; e = e.next)
                         action.accept(e);
                 }
@@ -1335,7 +1335,7 @@
             throw new NullPointerException();
         if (size > 0 && (tab = table) != null) {
             int mc = modCount;
-            for (Node<K, V> e : tab) {
+            for (Node<K,V> e : tab) {
                 for (; e != null; e = e.next)
                     action.accept(e.key, e.value);
             }
@@ -1351,7 +1351,7 @@
             throw new NullPointerException();
         if (size > 0 && (tab = table) != null) {
             int mc = modCount;
-            for (Node<K, V> e : tab) {
+            for (Node<K,V> e : tab) {
                 for (; e != null; e = e.next) {
                     e.value = function.apply(e.key, e.value);
                 }
@@ -1394,9 +1394,10 @@
     }
 
     /**
-     * Save the state of the {@code HashMap} instance to a stream (i.e.,
-     * serialize it).
+     * Saves this map to a stream (that is, serializes it).
      *
+     * @param s the stream
+     * @throws IOException if an I/O error occurs
      * @serialData The <i>capacity</i> of the HashMap (the length of the
      *             bucket array) is emitted (int), followed by the
      *             <i>size</i> (an int, the number of key-value
@@ -1415,8 +1416,11 @@
     }
 
     /**
-     * Reconstitute the {@code HashMap} instance from a stream (i.e.,
-     * deserialize it).
+     * Reconstitutes this map from a stream (that is, deserializes it).
+     * @param s the stream
+     * @throws ClassNotFoundException if the class of a serialized object
+     *         could not be found
+     * @throws IOException if an I/O error occurs
      */
     private void readObject(java.io.ObjectInputStream s)
         throws IOException, ClassNotFoundException {
@@ -1445,7 +1449,7 @@
             threshold = ((cap < MAXIMUM_CAPACITY && ft < MAXIMUM_CAPACITY) ?
                          (int)ft : Integer.MAX_VALUE);
             @SuppressWarnings({"rawtypes","unchecked"})
-                Node<K,V>[] tab = (Node<K,V>[])new Node[cap];
+            Node<K,V>[] tab = (Node<K,V>[])new Node[cap];
             table = tab;
 
             // Read the keys and values, and put the mappings in the HashMap
@@ -1830,7 +1834,7 @@
     void internalWriteEntries(java.io.ObjectOutputStream s) throws IOException {
         Node<K,V>[] tab;
         if (size > 0 && (tab = table) != null) {
-            for (Node<K, V> e : tab) {
+            for (Node<K,V> e : tab) {
                 for (; e != null; e = e.next) {
                     s.writeObject(e.key);
                     s.writeObject(e.value);
@@ -1951,7 +1955,6 @@
 
         /**
          * Forms tree of the nodes linked from this node.
-         * @return root of tree
          */
         final void treeify(Node<K,V>[] tab) {
             TreeNode<K,V> root = null;
@@ -2089,8 +2092,11 @@
                 return;
             if (root.parent != null)
                 root = root.root();
-            if (root == null || root.right == null ||
-                (rl = root.left) == null || rl.left == null) {
+            if (root == null
+                || (movable
+                    && (root.right == null
+                        || (rl = root.left) == null
+                        || rl.left == null))) {
                 tab[index] = first.untreeify(map);  // too small
                 return;
             }
@@ -2319,7 +2325,7 @@
 
         static <K,V> TreeNode<K,V> balanceDeletion(TreeNode<K,V> root,
                                                    TreeNode<K,V> x) {
-            for (TreeNode<K,V> xp, xpl, xpr;;)  {
+            for (TreeNode<K,V> xp, xpl, xpr;;) {
                 if (x == null || x == root)
                     return root;
                 else if ((xp = x.parent) == null) {
--- a/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java	Thu Oct 05 22:04:49 2017 +0200
@@ -2490,13 +2490,13 @@
         for (Completion p = stack; p != null; p = p.next)
             ++count;
         return super.toString() +
-            ((r == null) ?
-             ((count == 0) ?
-              "[Not completed]" :
-              "[Not completed, " + count + " dependents]") :
-             (((r instanceof AltResult) && ((AltResult)r).ex != null) ?
-              "[Completed exceptionally]" :
-              "[Completed normally]"));
+            ((r == null)
+             ? ((count == 0)
+                ? "[Not completed]"
+                : "[Not completed, " + count + " dependents]")
+             : (((r instanceof AltResult) && ((AltResult)r).ex != null)
+                ? "[Completed exceptionally: " + ((AltResult)r).ex + "]"
+                : "[Completed normally]"));
     }
 
     // jdk9 additions
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1394,8 +1394,8 @@
     }
 
     /**
-     * Saves the state of the {@code ConcurrentHashMap} instance to a
-     * stream (i.e., serializes it).
+     * Saves this map to a stream (that is, serializes it).
+     *
      * @param s the stream
      * @throws java.io.IOException if an I/O error occurs
      * @serialData
@@ -1439,7 +1439,7 @@
     }
 
     /**
-     * Reconstitutes the instance from a stream (that is, deserializes it).
+     * Reconstitutes this map from a stream (that is, deserializes it).
      * @param s the stream
      * @throws ClassNotFoundException if the class of a serialized object
      *         could not be found
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Thu Oct 05 22:04:49 2017 +0200
@@ -58,6 +58,7 @@
 import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Predicate;
+import java.util.concurrent.atomic.LongAdder;
 
 /**
  * A scalable concurrent {@link ConcurrentNavigableMap} implementation.
@@ -86,12 +87,7 @@
  * associated map using {@code put}, {@code putIfAbsent}, or
  * {@code replace}, depending on exactly which effect you need.)
  *
- * <p>Beware that, unlike in most collections, the {@code size}
- * method is <em>not</em> a constant-time operation. Because of the
- * asynchronous nature of these maps, determining the current number
- * of elements requires a traversal of the elements, and so may report
- * inaccurate results if this collection is modified during traversal.
- * Additionally, the bulk operations {@code putAll}, {@code equals},
+ * <p>Beware that bulk operations {@code putAll}, {@code equals},
  * {@code toArray}, {@code containsValue}, and {@code clear} are
  * <em>not</em> guaranteed to be performed atomically. For example, an
  * iterator operating concurrently with a {@code putAll} operation
@@ -158,42 +154,35 @@
      * be slow and space-intensive using AtomicMarkedReference), nodes
      * use direct CAS'able next pointers.  On deletion, instead of
      * marking a pointer, they splice in another node that can be
-     * thought of as standing for a marked pointer (indicating this by
-     * using otherwise impossible field values).  Using plain nodes
-     * acts roughly like "boxed" implementations of marked pointers,
-     * but uses new nodes only when nodes are deleted, not for every
-     * link.  This requires less space and supports faster
-     * traversal. Even if marked references were better supported by
-     * JVMs, traversal using this technique might still be faster
-     * because any search need only read ahead one more node than
-     * otherwise required (to check for trailing marker) rather than
-     * unmasking mark bits or whatever on each read.
+     * thought of as standing for a marked pointer (see method
+     * unlinkNode).  Using plain nodes acts roughly like "boxed"
+     * implementations of marked pointers, but uses new nodes only
+     * when nodes are deleted, not for every link.  This requires less
+     * space and supports faster traversal. Even if marked references
+     * were better supported by JVMs, traversal using this technique
+     * might still be faster because any search need only read ahead
+     * one more node than otherwise required (to check for trailing
+     * marker) rather than unmasking mark bits or whatever on each
+     * read.
      *
      * This approach maintains the essential property needed in the HM
      * algorithm of changing the next-pointer of a deleted node so
      * that any other CAS of it will fail, but implements the idea by
-     * changing the pointer to point to a different node, not by
-     * marking it.  While it would be possible to further squeeze
-     * space by defining marker nodes not to have key/value fields, it
-     * isn't worth the extra type-testing overhead.  The deletion
-     * markers are rarely encountered during traversal and are
-     * normally quickly garbage collected. (Note that this technique
-     * would not work well in systems without garbage collection.)
+     * changing the pointer to point to a different node (with
+     * otherwise illegal null fields), not by marking it.  While it
+     * would be possible to further squeeze space by defining marker
+     * nodes not to have key/value fields, it isn't worth the extra
+     * type-testing overhead.  The deletion markers are rarely
+     * encountered during traversal, are easily detected via null
+     * checks that are needed anyway, and are normally quickly garbage
+     * collected. (Note that this technique would not work well in
+     * systems without garbage collection.)
      *
      * In addition to using deletion markers, the lists also use
      * nullness of value fields to indicate deletion, in a style
      * similar to typical lazy-deletion schemes.  If a node's value is
      * null, then it is considered logically deleted and ignored even
-     * though it is still reachable. This maintains proper control of
-     * concurrent replace vs delete operations -- an attempted replace
-     * must fail if a delete beat it by nulling field, and a delete
-     * must return the last non-null value held in the field. (Note:
-     * Null, rather than some special marker, is used for value fields
-     * here because it just so happens to mesh with the Map API
-     * requirement that method get returns null if there is no
-     * mapping, which allows nodes to remain concurrently readable
-     * even when deleted. Using any other marker value here would be
-     * messy at best.)
+     * though it is still reachable.
      *
      * Here's the sequence of events for a deletion of node n with
      * predecessor b and successor f, initially:
@@ -203,9 +192,8 @@
      *        +------+       +------+      +------+
      *
      * 1. CAS n's value field from non-null to null.
-     *    From this point on, no public operations encountering
-     *    the node consider this mapping to exist. However, other
-     *    ongoing insertions and deletions might still modify
+     *    Traversals encountering a node with null value ignore it.
+     *    However, ongoing insertions and deletions might still modify
      *    n's next pointer.
      *
      * 2. CAS n's next pointer to point to a new marker node.
@@ -228,12 +216,7 @@
      * thread noticed during a traversal a node with null value and
      * helped out by marking and/or unlinking.  This helping-out
      * ensures that no thread can become stuck waiting for progress of
-     * the deleting thread.  The use of marker nodes slightly
-     * complicates helping-out code because traversals must track
-     * consistent reads of up to four nodes (b, n, marker, f), not
-     * just (b, n, f), although the next field of a marker is
-     * immutable, and once a next field is CAS'ed to point to a
-     * marker, it never again changes, so this requires less care.
+     * the deleting thread.
      *
      * Skip lists add indexing to this scheme, so that the base-level
      * traversals start close to the locations being found, inserted
@@ -243,113 +226,101 @@
      * b) that are not (structurally) deleted, otherwise retrying
      * after processing the deletion.
      *
-     * Index levels are maintained as lists with volatile next fields,
-     * using CAS to link and unlink.  Races are allowed in index-list
-     * operations that can (rarely) fail to link in a new index node
-     * or delete one. (We can't do this of course for data nodes.)
-     * However, even when this happens, the index lists remain sorted,
-     * so correctly serve as indices.  This can impact performance,
-     * but since skip lists are probabilistic anyway, the net result
-     * is that under contention, the effective "p" value may be lower
-     * than its nominal value. And race windows are kept small enough
-     * that in practice these failures are rare, even under a lot of
-     * contention.
+     * Index levels are maintained using CAS to link and unlink
+     * successors ("right" fields).  Races are allowed in index-list
+     * operations that can (rarely) fail to link in a new index node.
+     * (We can't do this of course for data nodes.)  However, even
+     * when this happens, the index lists correctly guide search.
+     * This can impact performance, but since skip lists are
+     * probabilistic anyway, the net result is that under contention,
+     * the effective "p" value may be lower than its nominal value.
      *
-     * The fact that retries (for both base and index lists) are
-     * relatively cheap due to indexing allows some minor
-     * simplifications of retry logic. Traversal restarts are
-     * performed after most "helping-out" CASes. This isn't always
-     * strictly necessary, but the implicit backoffs tend to help
-     * reduce other downstream failed CAS's enough to outweigh restart
-     * cost.  This worsens the worst case, but seems to improve even
-     * highly contended cases.
-     *
-     * Unlike most skip-list implementations, index insertion and
-     * deletion here require a separate traversal pass occurring after
-     * the base-level action, to add or remove index nodes.  This adds
-     * to single-threaded overhead, but improves contended
-     * multithreaded performance by narrowing interference windows,
-     * and allows deletion to ensure that all index nodes will be made
-     * unreachable upon return from a public remove operation, thus
-     * avoiding unwanted garbage retention. This is more important
-     * here than in some other data structures because we cannot null
-     * out node fields referencing user keys since they might still be
-     * read by other ongoing traversals.
+     * Index insertion and deletion sometimes require a separate
+     * traversal pass occurring after the base-level action, to add or
+     * remove index nodes.  This adds to single-threaded overhead, but
+     * improves contended multithreaded performance by narrowing
+     * interference windows, and allows deletion to ensure that all
+     * index nodes will be made unreachable upon return from a public
+     * remove operation, thus avoiding unwanted garbage retention.
      *
      * Indexing uses skip list parameters that maintain good search
      * performance while using sparser-than-usual indices: The
-     * hardwired parameters k=1, p=0.5 (see method doPut) mean
-     * that about one-quarter of the nodes have indices. Of those that
-     * do, half have one level, a quarter have two, and so on (see
-     * Pugh's Skip List Cookbook, sec 3.4).  The expected total space
-     * requirement for a map is slightly less than for the current
-     * implementation of java.util.TreeMap.
+     * hardwired parameters k=1, p=0.5 (see method doPut) mean that
+     * about one-quarter of the nodes have indices. Of those that do,
+     * half have one level, a quarter have two, and so on (see Pugh's
+     * Skip List Cookbook, sec 3.4), up to a maximum of 62 levels
+     * (appropriate for up to 2^63 elements).  The expected total
+     * space requirement for a map is slightly less than for the
+     * current implementation of java.util.TreeMap.
      *
      * Changing the level of the index (i.e, the height of the
-     * tree-like structure) also uses CAS. The head index has initial
-     * level/height of one. Creation of an index with height greater
-     * than the current level adds a level to the head index by
-     * CAS'ing on a new top-most head. To maintain good performance
-     * after a lot of removals, deletion methods heuristically try to
-     * reduce the height if the topmost levels appear to be empty.
-     * This may encounter races in which it possible (but rare) to
-     * reduce and "lose" a level just as it is about to contain an
-     * index (that will then never be encountered). This does no
-     * structural harm, and in practice appears to be a better option
-     * than allowing unrestrained growth of levels.
+     * tree-like structure) also uses CAS.  Creation of an index with
+     * height greater than the current level adds a level to the head
+     * index by CAS'ing on a new top-most head. To maintain good
+     * performance after a lot of removals, deletion methods
+     * heuristically try to reduce the height if the topmost levels
+     * appear to be empty.  This may encounter races in which it is
+     * possible (but rare) to reduce and "lose" a level just as it is
+     * about to contain an index (that will then never be
+     * encountered). This does no structural harm, and in practice
+     * appears to be a better option than allowing unrestrained growth
+     * of levels.
      *
-     * The code for all this is more verbose than you'd like. Most
-     * operations entail locating an element (or position to insert an
-     * element). The code to do this can't be nicely factored out
-     * because subsequent uses require a snapshot of predecessor
-     * and/or successor and/or value fields which can't be returned
-     * all at once, at least not without creating yet another object
-     * to hold them -- creating such little objects is an especially
-     * bad idea for basic internal search operations because it adds
-     * to GC overhead.  (This is one of the few times I've wished Java
-     * had macros.) Instead, some traversal code is interleaved within
-     * insertion and removal operations.  The control logic to handle
-     * all the retry conditions is sometimes twisty. Most search is
-     * broken into 2 parts. findPredecessor() searches index nodes
-     * only, returning a base-level predecessor of the key. findNode()
-     * finishes out the base-level search. Even with this factoring,
-     * there is a fair amount of near-duplication of code to handle
-     * variants.
+     * This class provides concurrent-reader-style memory consistency,
+     * ensuring that read-only methods report status and/or values no
+     * staler than those holding at method entry. This is done by
+     * performing all publication and structural updates using
+     * (volatile) CAS, placing an acquireFence in a few access
+     * methods, and ensuring that linked objects are transitively
+     * acquired via dependent reads (normally once) unless performing
+     * a volatile-mode CAS operation (that also acts as an acquire and
+     * release).  This form of fence-hoisting is similar to RCU and
+     * related techniques (see McKenney's online book
+     * https://www.kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.html)
+     * It minimizes overhead that may otherwise occur when using so
+     * many volatile-mode reads. Using explicit acquireFences is
+     * logistically easier than targeting particular fields to be read
+     * in acquire mode: fences are just hoisted up as far as possible,
+     * to the entry points or loop headers of a few methods. A
+     * potential disadvantage is that these few remaining fences are
+     * not easily optimized away by compilers under exclusively
+     * single-thread use.  It requires some care to avoid volatile
+     * mode reads of other fields. (Note that the memory semantics of
+     * a reference dependently read in plain mode exactly once are
+     * equivalent to those for atomic opaque mode.)  Iterators and
+     * other traversals encounter each node and value exactly once.
+     * Other operations locate an element (or position to insert an
+     * element) via a sequence of dereferences. This search is broken
+     * into two parts. Method findPredecessor (and its specialized
+     * embeddings) searches index nodes only, returning a base-level
+     * predecessor of the key. Callers carry out the base-level
+     * search, restarting if encountering a marker preventing link
+     * modification.  In some cases, it is possible to encounter a
+     * node multiple times while descending levels. For mutative
+     * operations, the reported value is validated using CAS (else
+     * retrying), preserving linearizability with respect to each
+     * other. Others may return any (non-null) value holding in the
+     * course of the method call.  (Search-based methods also include
+     * some useless-looking explicit null checks designed to allow
+     * more fields to be nulled out upon removal, to reduce floating
+     * garbage, but which is not currently done, pending discovery of
+     * a way to do this with less impact on other operations.)
      *
      * To produce random values without interference across threads,
      * we use within-JDK thread local random support (via the
      * "secondary seed", to avoid interference with user-level
      * ThreadLocalRandom.)
      *
-     * A previous version of this class wrapped non-comparable keys
-     * with their comparators to emulate Comparables when using
-     * comparators vs Comparables.  However, JVMs now appear to better
-     * handle infusing comparator-vs-comparable choice into search
-     * loops. Static method cpr(comparator, x, y) is used for all
-     * comparisons, which works well as long as the comparator
-     * argument is set up outside of loops (thus sometimes passed as
-     * an argument to internal methods) to avoid field re-reads.
-     *
      * For explanation of algorithms sharing at least a couple of
      * features with this one, see Mikhail Fomitchev's thesis
      * (http://www.cs.yorku.ca/~mikhail/), Keir Fraser's thesis
      * (http://www.cl.cam.ac.uk/users/kaf24/), and Hakan Sundell's
      * thesis (http://www.cs.chalmers.se/~phs/).
      *
-     * Given the use of tree-like index nodes, you might wonder why
-     * this doesn't use some kind of search tree instead, which would
-     * support somewhat faster search operations. The reason is that
-     * there are no known efficient lock-free insertion and deletion
-     * algorithms for search trees. The immutability of the "down"
-     * links of index nodes (as opposed to mutable "left" fields in
-     * true trees) makes this tractable using only CAS operations.
-     *
      * Notation guide for local variables
-     * Node:         b, n, f    for  predecessor, node, successor
+     * Node:         b, n, f, p for  predecessor, node, successor, aux
      * Index:        q, r, d    for index node, right, down.
-     *               t          for another index node
      * Head:         h
-     * Levels:       j
      * Keys:         k, key
      * Values:       v, value
      * Comparisons:  c
@@ -358,16 +329,6 @@
     private static final long serialVersionUID = -8627078645895051609L;
 
     /**
-     * Special value used to identify base-level header.
-     */
-    static final Object BASE_HEADER = new Object();
-
-    /**
-     * The topmost head index of the skiplist.
-     */
-    private transient volatile HeadIndex<K,V> head;
-
-    /**
      * The comparator used to maintain order in this map, or null if
      * using natural ordering.  (Non-private to simplify access in
      * nested classes.)
@@ -375,311 +336,152 @@
      */
     final Comparator<? super K> comparator;
 
+    /** Lazily initialized topmost index of the skiplist. */
+    private transient Index<K,V> head;
+    /** Lazily initialized element count */
+    private transient LongAdder adder;
     /** Lazily initialized key set */
     private transient KeySet<K,V> keySet;
     /** Lazily initialized values collection */
     private transient Values<K,V> values;
     /** Lazily initialized entry set */
     private transient EntrySet<K,V> entrySet;
-    /** Lazily initialized descending key set */
+    /** Lazily initialized descending map */
     private transient SubMap<K,V> descendingMap;
 
     /**
-     * Initializes or resets state. Needed by constructors, clone,
-     * clear, readObject. and ConcurrentSkipListSet.clone.
-     * (Note that comparator must be separately initialized.)
-     */
-    private void initialize() {
-        keySet = null;
-        entrySet = null;
-        values = null;
-        descendingMap = null;
-        head = new HeadIndex<K,V>(new Node<K,V>(null, BASE_HEADER, null),
-                                  null, null, 1);
-    }
-
-    /**
-     * compareAndSet head node.
-     */
-    private boolean casHead(HeadIndex<K,V> cmp, HeadIndex<K,V> val) {
-        return HEAD.compareAndSet(this, cmp, val);
-    }
-
-    /* ---------------- Nodes -------------- */
-
-    /**
      * Nodes hold keys and values, and are singly linked in sorted
      * order, possibly with some intervening marker nodes. The list is
-     * headed by a dummy node accessible as head.node. The value field
-     * is declared only as Object because it takes special non-V
-     * values for marker and header nodes.
+     * headed by a header node accessible as head.node. Headers and
+     * marker nodes have null keys. The val field (but currently not
+     * the key field) is nulled out upon deletion.
      */
     static final class Node<K,V> {
-        final K key;
-        volatile Object value;
-        volatile Node<K,V> next;
-
-        /**
-         * Creates a new regular node.
-         */
-        Node(K key, Object value, Node<K,V> next) {
+        final K key; // currently, never detached
+        V val;
+        Node<K,V> next;
+        Node(K key, V value, Node<K,V> next) {
             this.key = key;
-            this.value = value;
+            this.val = value;
             this.next = next;
         }
-
-        /**
-         * Creates a new marker node. A marker is distinguished by
-         * having its value field point to itself.  Marker nodes also
-         * have null keys, a fact that is exploited in a few places,
-         * but this doesn't distinguish markers from the base-level
-         * header node (head.node), which also has a null key.
-         */
-        Node(Node<K,V> next) {
-            this.key = null;
-            this.value = this;
-            this.next = next;
-        }
-
-        /**
-         * compareAndSet value field.
-         */
-        boolean casValue(Object cmp, Object val) {
-            return VALUE.compareAndSet(this, cmp, val);
-        }
-
-        /**
-         * compareAndSet next field.
-         */
-        boolean casNext(Node<K,V> cmp, Node<K,V> val) {
-            return NEXT.compareAndSet(this, cmp, val);
-        }
-
-        /**
-         * Returns true if this node is a marker. This method isn't
-         * actually called in any current code checking for markers
-         * because callers will have already read value field and need
-         * to use that read (not another done here) and so directly
-         * test if value points to node.
-         *
-         * @return true if this node is a marker node
-         */
-        boolean isMarker() {
-            return value == this;
-        }
-
-        /**
-         * Returns true if this node is the header of base-level list.
-         * @return true if this node is header node
-         */
-        boolean isBaseHeader() {
-            return value == BASE_HEADER;
-        }
-
-        /**
-         * Tries to append a deletion marker to this node.
-         * @param f the assumed current successor of this node
-         * @return true if successful
-         */
-        boolean appendMarker(Node<K,V> f) {
-            return casNext(f, new Node<K,V>(f));
-        }
-
-        /**
-         * Helps out a deletion by appending marker or unlinking from
-         * predecessor. This is called during traversals when value
-         * field seen to be null.
-         * @param b predecessor
-         * @param f successor
-         */
-        void helpDelete(Node<K,V> b, Node<K,V> f) {
-            /*
-             * Rechecking links and then doing only one of the
-             * help-out stages per call tends to minimize CAS
-             * interference among helping threads.
-             */
-            if (f == next && this == b.next) {
-                if (f == null || f.value != f) // not already marked
-                    casNext(f, new Node<K,V>(f));
-                else
-                    b.casNext(this, f.next);
-            }
-        }
-
-        /**
-         * Returns value if this node contains a valid key-value pair,
-         * else null.
-         * @return this node's value if it isn't a marker or header or
-         * is deleted, else null
-         */
-        V getValidValue() {
-            Object v = value;
-            if (v == this || v == BASE_HEADER)
-                return null;
-            @SuppressWarnings("unchecked") V vv = (V)v;
-            return vv;
-        }
-
-        /**
-         * Creates and returns a new SimpleImmutableEntry holding current
-         * mapping if this node holds a valid value, else null.
-         * @return new entry or null
-         */
-        AbstractMap.SimpleImmutableEntry<K,V> createSnapshot() {
-            Object v = value;
-            if (v == null || v == this || v == BASE_HEADER)
-                return null;
-            @SuppressWarnings("unchecked") V vv = (V)v;
-            return new AbstractMap.SimpleImmutableEntry<K,V>(key, vv);
-        }
-
-        // VarHandle mechanics
-        private static final VarHandle VALUE;
-        private static final VarHandle NEXT;
-        static {
-            try {
-                MethodHandles.Lookup l = MethodHandles.lookup();
-                VALUE = l.findVarHandle(Node.class, "value", Object.class);
-                NEXT = l.findVarHandle(Node.class, "next", Node.class);
-            } catch (ReflectiveOperationException e) {
-                    throw new Error(e);
-            }
-        }
     }
 
-    /* ---------------- Indexing -------------- */
-
     /**
-     * Index nodes represent the levels of the skip list.  Note that
-     * even though both Nodes and Indexes have forward-pointing
-     * fields, they have different types and are handled in different
-     * ways, that can't nicely be captured by placing field in a
-     * shared abstract class.
+     * Index nodes represent the levels of the skip list.
      */
-    static class Index<K,V> {
-        final Node<K,V> node;
+    static final class Index<K,V> {
+        final Node<K,V> node;  // currently, never detached
         final Index<K,V> down;
-        volatile Index<K,V> right;
-
-        /**
-         * Creates index node with given values.
-         */
+        Index<K,V> right;
         Index(Node<K,V> node, Index<K,V> down, Index<K,V> right) {
             this.node = node;
             this.down = down;
             this.right = right;
         }
-
-        /**
-         * compareAndSet right field.
-         */
-        final boolean casRight(Index<K,V> cmp, Index<K,V> val) {
-            return RIGHT.compareAndSet(this, cmp, val);
-        }
-
-        /**
-         * Returns true if the node this indexes has been deleted.
-         * @return true if indexed node is known to be deleted
-         */
-        final boolean indexesDeletedNode() {
-            return node.value == null;
-        }
-
-        /**
-         * Tries to CAS newSucc as successor.  To minimize races with
-         * unlink that may lose this index node, if the node being
-         * indexed is known to be deleted, it doesn't try to link in.
-         * @param succ the expected current successor
-         * @param newSucc the new successor
-         * @return true if successful
-         */
-        final boolean link(Index<K,V> succ, Index<K,V> newSucc) {
-            Node<K,V> n = node;
-            newSucc.right = succ;
-            return n.value != null && casRight(succ, newSucc);
-        }
-
-        /**
-         * Tries to CAS right field to skip over apparent successor
-         * succ.  Fails (forcing a retraversal by caller) if this node
-         * is known to be deleted.
-         * @param succ the expected current successor
-         * @return true if successful
-         */
-        final boolean unlink(Index<K,V> succ) {
-            return node.value != null && casRight(succ, succ.right);
-        }
-
-        // VarHandle mechanics
-        private static final VarHandle RIGHT;
-        static {
-            try {
-                MethodHandles.Lookup l = MethodHandles.lookup();
-                RIGHT = l.findVarHandle(Index.class, "right", Index.class);
-            } catch (ReflectiveOperationException e) {
-                throw new Error(e);
-            }
-        }
     }
 
-    /* ---------------- Head nodes -------------- */
-
-    /**
-     * Nodes heading each level keep track of their level.
-     */
-    static final class HeadIndex<K,V> extends Index<K,V> {
-        final int level;
-        HeadIndex(Node<K,V> node, Index<K,V> down, Index<K,V> right, int level) {
-            super(node, down, right);
-            this.level = level;
-        }
-    }
-
-    /* ---------------- Comparison utilities -------------- */
+    /* ----------------  Utilities -------------- */
 
     /**
      * Compares using comparator or natural ordering if null.
      * Called only by methods that have performed required type checks.
      */
     @SuppressWarnings({"unchecked", "rawtypes"})
-    static final int cpr(Comparator c, Object x, Object y) {
+    static int cpr(Comparator c, Object x, Object y) {
         return (c != null) ? c.compare(x, y) : ((Comparable)x).compareTo(y);
     }
 
+    /**
+     * Returns the header for base node list, or null if uninitialized
+     */
+    final Node<K,V> baseHead() {
+        Index<K,V> h;
+        VarHandle.acquireFence();
+        return ((h = head) == null) ? null : h.node;
+    }
+
+    /**
+     * Tries to unlink deleted node n from predecessor b (if both
+     * exist), by first splicing in a marker if not already present.
+     * Upon return, node n is sure to be unlinked from b, possibly
+     * via the actions of some other thread.
+     *
+     * @param b if nonnull, predecessor
+     * @param n if nonnull, node known to be deleted
+     */
+    static <K,V> void unlinkNode(Node<K,V> b, Node<K,V> n) {
+        if (b != null && n != null) {
+            Node<K,V> f, p;
+            for (;;) {
+                if ((f = n.next) != null && f.key == null) {
+                    p = f.next;               // already marked
+                    break;
+                }
+                else if (NEXT.compareAndSet(n, f,
+                                            new Node<K,V>(null, null, f))) {
+                    p = f;                    // add marker
+                    break;
+                }
+            }
+            NEXT.compareAndSet(b, n, p);
+        }
+    }
+
+    /**
+     * Adds to element count, initializing adder if necessary
+     *
+     * @param c count to add
+     */
+    private void addCount(long c) {
+        LongAdder a;
+        do {} while ((a = adder) == null &&
+                     !ADDER.compareAndSet(this, null, a = new LongAdder()));
+        a.add(c);
+    }
+
+    /**
+     * Returns element count, initializing adder if necessary.
+     */
+    final long getAdderCount() {
+        LongAdder a; long c;
+        do {} while ((a = adder) == null &&
+                     !ADDER.compareAndSet(this, null, a = new LongAdder()));
+        return ((c = a.sum()) <= 0L) ? 0L : c; // ignore transient negatives
+    }
+
     /* ---------------- Traversal -------------- */
 
     /**
-     * Returns a base-level node with key strictly less than given key,
-     * or the base-level header if there is no such node.  Also
-     * unlinks indexes to deleted nodes found along the way.  Callers
-     * rely on this side-effect of clearing indices to deleted nodes.
-     * @param key the key
-     * @return a predecessor of key
+     * Returns an index node with key strictly less than given key.
+     * Also unlinks indexes to deleted nodes found along the way.
+     * Callers rely on this side-effect of clearing indices to deleted
+     * nodes.
+     *
+     * @param key if nonnull the key
+     * @return a predecessor node of key, or null if uninitialized or null key
      */
     private Node<K,V> findPredecessor(Object key, Comparator<? super K> cmp) {
-        if (key == null)
-            throw new NullPointerException(); // don't postpone errors
-        for (;;) {
-            for (Index<K,V> q = head, r = q.right, d;;) {
-                if (r != null) {
-                    Node<K,V> n = r.node;
-                    K k = n.key;
-                    if (n.value == null) {
-                        if (!q.unlink(r))
-                            break;           // restart
-                        r = q.right;         // reread r
-                        continue;
-                    }
-                    if (cpr(cmp, key, k) > 0) {
+        Index<K,V> q;
+        VarHandle.acquireFence();
+        if ((q = head) == null || key == null)
+            return null;
+        else {
+            for (Index<K,V> r, d;;) {
+                while ((r = q.right) != null) {
+                    Node<K,V> p; K k;
+                    if ((p = r.node) == null || (k = p.key) == null ||
+                        p.val == null)  // unlink index to deleted node
+                        RIGHT.compareAndSet(q, r, r.right);
+                    else if (cpr(cmp, key, k) > 0)
                         q = r;
-                        r = r.right;
-                        continue;
-                    }
+                    else
+                        break;
                 }
-                if ((d = q.down) == null)
+                if ((d = q.down) != null)
+                    q = d;
+                else
                     return q.node;
-                q = d;
-                r = d.right;
             }
         }
     }
@@ -689,41 +491,11 @@
      * deleted nodes seen along the way.  Repeatedly traverses at
      * base-level looking for key starting at predecessor returned
      * from findPredecessor, processing base-level deletions as
-     * encountered. Some callers rely on this side-effect of clearing
-     * deleted nodes.
-     *
-     * Restarts occur, at traversal step centered on node n, if:
-     *
-     *   (1) After reading n's next field, n is no longer assumed
-     *       predecessor b's current successor, which means that
-     *       we don't have a consistent 3-node snapshot and so cannot
-     *       unlink any subsequent deleted nodes encountered.
-     *
-     *   (2) n's value field is null, indicating n is deleted, in
-     *       which case we help out an ongoing structural deletion
-     *       before retrying.  Even though there are cases where such
-     *       unlinking doesn't require restart, they aren't sorted out
-     *       here because doing so would not usually outweigh cost of
-     *       restarting.
-     *
-     *   (3) n is a marker or n's predecessor's value field is null,
-     *       indicating (among other possibilities) that
-     *       findPredecessor returned a deleted node. We can't unlink
-     *       the node because we don't know its predecessor, so rely
-     *       on another call to findPredecessor to notice and return
-     *       some earlier predecessor, which it will do. This check is
-     *       only strictly needed at beginning of loop, (and the
-     *       b.value check isn't strictly needed at all) but is done
-     *       each iteration to help avoid contention with other
-     *       threads by callers that will fail to be able to change
-     *       links, and so will retry anyway.
-     *
-     * The traversal loops in doPut, doRemove, and findNear all
-     * include the same three kinds of checks. And specialized
-     * versions appear in findFirst, and findLast and their variants.
-     * They can't easily share code because each uses the reads of
-     * fields held in locals occurring in the orders they were
-     * performed.
+     * encountered. Restarts occur, at traversal step encountering
+     * node n, if n's key field is null, indicating it is a marker, so
+     * its predecessor is deleted before continuing, which we help do
+     * by re-finding a valid predecessor.  The traversal loops in
+     * doPut, doRemove, and findNear all include the same checks.
      *
      * @param key the key
      * @return node holding key, or null if no such
@@ -732,67 +504,81 @@
         if (key == null)
             throw new NullPointerException(); // don't postpone errors
         Comparator<? super K> cmp = comparator;
-        outer: for (;;) {
-            for (Node<K,V> b = findPredecessor(key, cmp), n = b.next;;) {
-                Object v; int c;
-                if (n == null)
+        Node<K,V> b;
+        outer: while ((b = findPredecessor(key, cmp)) != null) {
+            for (;;) {
+                Node<K,V> n; K k; V v; int c;
+                if ((n = b.next) == null)
+                    break outer;               // empty
+                else if ((k = n.key) == null)
+                    break;                     // b is deleted
+                else if ((v = n.val) == null)
+                    unlinkNode(b, n);          // n is deleted
+                else if ((c = cpr(cmp, key, k)) > 0)
+                    b = n;
+                else if (c == 0)
+                    return n;
+                else
                     break outer;
-                Node<K,V> f = n.next;
-                if (n != b.next)                // inconsistent read
-                    break;
-                if ((v = n.value) == null) {    // n is deleted
-                    n.helpDelete(b, f);
-                    break;
-                }
-                if (b.value == null || v == n)  // b is deleted
-                    break;
-                if ((c = cpr(cmp, key, n.key)) == 0)
-                    return n;
-                if (c < 0)
-                    break outer;
-                b = n;
-                n = f;
             }
         }
         return null;
     }
 
     /**
-     * Gets value for key. Almost the same as findNode, but returns
-     * the found value (to avoid retries during re-reads)
+     * Gets value for key. Same idea as findNode, except skips over
+     * deletions and markers, and returns first encountered value to
+     * avoid possibly inconsistent rereads.
      *
      * @param key the key
      * @return the value, or null if absent
      */
     private V doGet(Object key) {
+        Index<K,V> q;
+        VarHandle.acquireFence();
         if (key == null)
             throw new NullPointerException();
         Comparator<? super K> cmp = comparator;
-        outer: for (;;) {
-            for (Node<K,V> b = findPredecessor(key, cmp), n = b.next;;) {
-                Object v; int c;
-                if (n == null)
-                    break outer;
-                Node<K,V> f = n.next;
-                if (n != b.next)                // inconsistent read
-                    break;
-                if ((v = n.value) == null) {    // n is deleted
-                    n.helpDelete(b, f);
+        V result = null;
+        if ((q = head) != null) {
+            outer: for (Index<K,V> r, d;;) {
+                while ((r = q.right) != null) {
+                    Node<K,V> p; K k; V v; int c;
+                    if ((p = r.node) == null || (k = p.key) == null ||
+                        (v = p.val) == null)
+                        RIGHT.compareAndSet(q, r, r.right);
+                    else if ((c = cpr(cmp, key, k)) > 0)
+                        q = r;
+                    else if (c == 0) {
+                        result = v;
+                        break outer;
+                    }
+                    else
+                        break;
+                }
+                if ((d = q.down) != null)
+                    q = d;
+                else {
+                    Node<K,V> b, n;
+                    if ((b = q.node) != null) {
+                        while ((n = b.next) != null) {
+                            V v; int c;
+                            K k = n.key;
+                            if ((v = n.val) == null || k == null ||
+                                (c = cpr(cmp, key, k)) > 0)
+                                b = n;
+                            else {
+                                if (c == 0)
+                                    result = v;
+                                break;
+                            }
+                        }
+                    }
                     break;
                 }
-                if (b.value == null || v == n)  // b is deleted
-                    break;
-                if ((c = cpr(cmp, key, n.key)) == 0) {
-                    @SuppressWarnings("unchecked") V vv = (V)v;
-                    return vv;
-                }
-                if (c < 0)
-                    break outer;
-                b = n;
-                n = f;
             }
         }
-        return null;
+        return result;
     }
 
     /* ---------------- Insertion -------------- */
@@ -800,129 +586,160 @@
     /**
      * Main insertion method.  Adds element if not present, or
      * replaces value if present and onlyIfAbsent is false.
+     *
      * @param key the key
      * @param value the value that must be associated with key
      * @param onlyIfAbsent if should not insert if already present
      * @return the old value, or null if newly inserted
      */
     private V doPut(K key, V value, boolean onlyIfAbsent) {
-        Node<K,V> z;             // added node
         if (key == null)
             throw new NullPointerException();
         Comparator<? super K> cmp = comparator;
-        outer: for (;;) {
-            for (Node<K,V> b = findPredecessor(key, cmp), n = b.next;;) {
-                if (n != null) {
-                    Object v; int c;
-                    Node<K,V> f = n.next;
-                    if (n != b.next)               // inconsistent read
-                        break;
-                    if ((v = n.value) == null) {   // n is deleted
-                        n.helpDelete(b, f);
-                        break;
+        for (;;) {
+            Index<K,V> h; Node<K,V> b;
+            VarHandle.acquireFence();
+            int levels = 0;                    // number of levels descended
+            if ((h = head) == null) {          // try to initialize
+                Node<K,V> base = new Node<K,V>(null, null, null);
+                h = new Index<K,V>(base, null, null);
+                b = (HEAD.compareAndSet(this, null, h)) ? base : null;
+            }
+            else {
+                for (Index<K,V> q = h, r, d;;) { // count while descending
+                    while ((r = q.right) != null) {
+                        Node<K,V> p; K k;
+                        if ((p = r.node) == null || (k = p.key) == null ||
+                            p.val == null)
+                            RIGHT.compareAndSet(q, r, r.right);
+                        else if (cpr(cmp, key, k) > 0)
+                            q = r;
+                        else
+                            break;
                     }
-                    if (b.value == null || v == n) // b is deleted
-                        break;
-                    if ((c = cpr(cmp, key, n.key)) > 0) {
-                        b = n;
-                        n = f;
-                        continue;
+                    if ((d = q.down) != null) {
+                        ++levels;
+                        q = d;
                     }
-                    if (c == 0) {
-                        if (onlyIfAbsent || n.casValue(v, value)) {
-                            @SuppressWarnings("unchecked") V vv = (V)v;
-                            return vv;
-                        }
-                        break; // restart if lost race to replace value
-                    }
-                    // else c < 0; fall through
-                } else if (b == head.node) {
-                    // map is empty, so type check key now
-                    cpr(cmp, key, key);
-                }
-
-                z = new Node<K,V>(key, value, n);
-                if (!b.casNext(n, z))
-                    break;         // restart if lost race to append to b
-                break outer;
-            }
-        }
-
-        int rnd = ThreadLocalRandom.nextSecondarySeed();
-        if ((rnd & 0x80000001) == 0) { // test highest and lowest bits
-            int level = 1, max;
-            while (((rnd >>>= 1) & 1) != 0)
-                ++level;
-            Index<K,V> idx = null;
-            HeadIndex<K,V> h = head;
-            if (level <= (max = h.level)) {
-                for (int i = 1; i <= level; ++i)
-                    idx = new Index<K,V>(z, idx, null);
-            }
-            else { // try to grow by one level
-                level = max + 1; // hold in array and later pick the one to use
-                @SuppressWarnings("unchecked")Index<K,V>[] idxs =
-                    (Index<K,V>[])new Index<?,?>[level+1];
-                for (int i = 1; i <= level; ++i)
-                    idxs[i] = idx = new Index<K,V>(z, idx, null);
-                for (;;) {
-                    h = head;
-                    int oldLevel = h.level;
-                    if (level <= oldLevel) // lost race to add level
-                        break;
-                    HeadIndex<K,V> newh = h;
-                    Node<K,V> oldbase = h.node;
-                    for (int j = oldLevel+1; j <= level; ++j)
-                        newh = new HeadIndex<K,V>(oldbase, newh, idxs[j], j);
-                    if (casHead(h, newh)) {
-                        h = newh;
-                        idx = idxs[level = oldLevel];
+                    else {
+                        b = q.node;
                         break;
                     }
                 }
             }
-            // find insertion points and splice in
-            splice: for (int insertionLevel = level;;) {
-                int j = h.level;
-                for (Index<K,V> q = h, r = q.right, t = idx;;) {
-                    if (q == null || t == null)
-                        break splice;
-                    if (r != null) {
-                        Node<K,V> n = r.node;
-                        // compare before deletion check avoids needing recheck
-                        int c = cpr(cmp, key, n.key);
-                        if (n.value == null) {
-                            if (!q.unlink(r))
+            if (b != null) {
+                Node<K,V> z = null;              // new node, if inserted
+                for (;;) {                       // find insertion point
+                    Node<K,V> n, p; K k; V v; int c;
+                    if ((n = b.next) == null) {
+                        if (b.key == null)       // if empty, type check key now
+                            cpr(cmp, key, key);
+                        c = -1;
+                    }
+                    else if ((k = n.key) == null)
+                        break;                   // can't append; restart
+                    else if ((v = n.val) == null) {
+                        unlinkNode(b, n);
+                        c = 1;
+                    }
+                    else if ((c = cpr(cmp, key, k)) > 0)
+                        b = n;
+                    else if (c == 0 &&
+                             (onlyIfAbsent || VAL.compareAndSet(n, v, value)))
+                        return v;
+
+                    if (c < 0 &&
+                        NEXT.compareAndSet(b, n,
+                                           p = new Node<K,V>(key, value, n))) {
+                        z = p;
+                        break;
+                    }
+                }
+
+                if (z != null) {
+                    int lr = ThreadLocalRandom.nextSecondarySeed();
+                    if ((lr & 0x3) == 0) {       // add indices with 1/4 prob
+                        int hr = ThreadLocalRandom.nextSecondarySeed();
+                        long rnd = ((long)hr << 32) | ((long)lr & 0xffffffffL);
+                        int skips = levels;      // levels to descend before add
+                        Index<K,V> x = null;
+                        for (;;) {               // create at most 62 indices
+                            x = new Index<K,V>(z, x, null);
+                            if (rnd >= 0L || --skips < 0)
                                 break;
-                            r = q.right;
-                            continue;
+                            else
+                                rnd <<= 1;
                         }
-                        if (c > 0) {
-                            q = r;
-                            r = r.right;
-                            continue;
+                        if (addIndices(h, skips, x, cmp) && skips < 0 &&
+                            head == h) {         // try to add new level
+                            Index<K,V> hx = new Index<K,V>(z, x, null);
+                            Index<K,V> nh = new Index<K,V>(h.node, h, hx);
+                            HEAD.compareAndSet(this, h, nh);
                         }
+                        if (z.val == null)       // deleted while adding indices
+                            findPredecessor(key, cmp); // clean
                     }
-
-                    if (j == insertionLevel) {
-                        if (!q.link(r, t))
-                            break; // restart
-                        if (t.node.value == null) {
-                            findNode(key);
-                            break splice;
-                        }
-                        if (--insertionLevel == 0)
-                            break splice;
-                    }
-
-                    if (--j >= insertionLevel && j < level)
-                        t = t.down;
-                    q = q.down;
-                    r = q.right;
+                    addCount(1L);
+                    return null;
                 }
             }
         }
-        return null;
+    }
+
+    /**
+     * Add indices after an insertion. Descends iteratively to the
+     * highest level of insertion, then recursively, to chain index
+     * nodes to lower ones. Returns null on (staleness) failure,
+     * disabling higher-level insertions. Recursion depths are
+     * exponentially less probable.
+     *
+     * @param q starting index for current level
+     * @param skips levels to skip before inserting
+     * @param x index for this insertion
+     * @param cmp comparator
+     */
+    static <K,V> boolean addIndices(Index<K,V> q, int skips, Index<K,V> x,
+                                    Comparator<? super K> cmp) {
+        Node<K,V> z; K key;
+        if (x != null && (z = x.node) != null && (key = z.key) != null &&
+            q != null) {                            // hoist checks
+            boolean retrying = false;
+            for (;;) {                              // find splice point
+                Index<K,V> r, d; int c;
+                if ((r = q.right) != null) {
+                    Node<K,V> p; K k;
+                    if ((p = r.node) == null || (k = p.key) == null ||
+                        p.val == null) {
+                        RIGHT.compareAndSet(q, r, r.right);
+                        c = 0;
+                    }
+                    else if ((c = cpr(cmp, key, k)) > 0)
+                        q = r;
+                    else if (c == 0)
+                        break;                      // stale
+                }
+                else
+                    c = -1;
+
+                if (c < 0) {
+                    if ((d = q.down) != null && skips > 0) {
+                        --skips;
+                        q = d;
+                    }
+                    else if (d != null && !retrying &&
+                             !addIndices(d, 0, x.down, cmp))
+                        break;
+                    else {
+                        x.right = r;
+                        if (RIGHT.compareAndSet(q, r, x))
+                            return true;
+                        else
+                            retrying = true;         // re-find splice point
+                    }
+                }
+            }
+        }
+        return false;
     }
 
     /* ---------------- Deletion -------------- */
@@ -932,15 +749,6 @@
      * deletion marker, unlinks predecessor, removes associated index
      * nodes, and possibly reduces head index level.
      *
-     * Index nodes are cleared out simply by calling findPredecessor.
-     * which unlinks indexes to deleted nodes found along path to key,
-     * which will include the indexes to this node.  This is done
-     * unconditionally. We can't check beforehand whether there are
-     * index nodes because it might be the case that some or all
-     * indexes hadn't been inserted yet for this node during initial
-     * search for it, and we'd like to ensure lack of garbage
-     * retention, so must call to be sure.
-     *
      * @param key the key
      * @param value if non-null, the value that must be
      * associated with key
@@ -950,43 +758,36 @@
         if (key == null)
             throw new NullPointerException();
         Comparator<? super K> cmp = comparator;
-        outer: for (;;) {
-            for (Node<K,V> b = findPredecessor(key, cmp), n = b.next;;) {
-                Object v; int c;
-                if (n == null)
+        V result = null;
+        Node<K,V> b;
+        outer: while ((b = findPredecessor(key, cmp)) != null &&
+                      result == null) {
+            for (;;) {
+                Node<K,V> n; K k; V v; int c;
+                if ((n = b.next) == null)
                     break outer;
-                Node<K,V> f = n.next;
-                if (n != b.next)                    // inconsistent read
+                else if ((k = n.key) == null)
                     break;
-                if ((v = n.value) == null) {        // n is deleted
-                    n.helpDelete(b, f);
-                    break;
+                else if ((v = n.val) == null)
+                    unlinkNode(b, n);
+                else if ((c = cpr(cmp, key, k)) > 0)
+                    b = n;
+                else if (c < 0)
+                    break outer;
+                else if (value != null && !value.equals(v))
+                    break outer;
+                else if (VAL.compareAndSet(n, v, null)) {
+                    result = v;
+                    unlinkNode(b, n);
+                    break; // loop to clean up
                 }
-                if (b.value == null || v == n)      // b is deleted
-                    break;
-                if ((c = cpr(cmp, key, n.key)) < 0)
-                    break outer;
-                if (c > 0) {
-                    b = n;
-                    n = f;
-                    continue;
-                }
-                if (value != null && !value.equals(v))
-                    break outer;
-                if (!n.casValue(v, null))
-                    break;
-                if (!n.appendMarker(f) || !b.casNext(n, f))
-                    findNode(key);                  // retry via findNode
-                else {
-                    findPredecessor(key, cmp);      // clean index
-                    if (head.right == null)
-                        tryReduceLevel();
-                }
-                @SuppressWarnings("unchecked") V vv = (V)v;
-                return vv;
             }
         }
-        return null;
+        if (result != null) {
+            tryReduceLevel();
+            addCount(-1L);
+        }
+        return result;
     }
 
     /**
@@ -1010,77 +811,132 @@
      * reduction.
      */
     private void tryReduceLevel() {
-        HeadIndex<K,V> h = head;
-        HeadIndex<K,V> d;
-        HeadIndex<K,V> e;
-        if (h.level > 3 &&
-            (d = (HeadIndex<K,V>)h.down) != null &&
-            (e = (HeadIndex<K,V>)d.down) != null &&
-            e.right == null &&
-            d.right == null &&
-            h.right == null &&
-            casHead(h, d) && // try to set
-            h.right != null) // recheck
-            casHead(d, h);   // try to backout
+        Index<K,V> h, d, e;
+        if ((h = head) != null && h.right == null &&
+            (d = h.down) != null && d.right == null &&
+            (e = d.down) != null && e.right == null &&
+            HEAD.compareAndSet(this, h, d) &&
+            h.right != null)   // recheck
+            HEAD.compareAndSet(this, d, h);  // try to backout
     }
 
     /* ---------------- Finding and removing first element -------------- */
 
     /**
-     * Specialized variant of findNode to get first valid node.
+     * Gets first valid node, unlinking deleted nodes if encountered.
      * @return first node or null if empty
      */
     final Node<K,V> findFirst() {
-        for (Node<K,V> b, n;;) {
-            if ((n = (b = head.node).next) == null)
-                return null;
-            if (n.value != null)
-                return n;
-            n.helpDelete(b, n.next);
+        Node<K,V> b, n;
+        if ((b = baseHead()) != null) {
+            while ((n = b.next) != null) {
+                if (n.val == null)
+                    unlinkNode(b, n);
+                else
+                    return n;
+            }
         }
+        return null;
+    }
+
+    /**
+     * Entry snapshot version of findFirst
+     */
+    final AbstractMap.SimpleImmutableEntry<K,V> findFirstEntry() {
+        Node<K,V> b, n; V v;
+        if ((b = baseHead()) != null) {
+            while ((n = b.next) != null) {
+                if ((v = n.val) == null)
+                    unlinkNode(b, n);
+                else
+                    return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, v);
+            }
+        }
+        return null;
     }
 
     /**
      * Removes first entry; returns its snapshot.
      * @return null if empty, else snapshot of first entry
      */
-    private Map.Entry<K,V> doRemoveFirstEntry() {
-        for (Node<K,V> b, n;;) {
-            if ((n = (b = head.node).next) == null)
-                return null;
-            Node<K,V> f = n.next;
-            if (n != b.next)
-                continue;
-            Object v = n.value;
-            if (v == null) {
-                n.helpDelete(b, f);
-                continue;
+    private AbstractMap.SimpleImmutableEntry<K,V> doRemoveFirstEntry() {
+        Node<K,V> b, n; V v;
+        if ((b = baseHead()) != null) {
+            while ((n = b.next) != null) {
+                if ((v = n.val) == null || VAL.compareAndSet(n, v, null)) {
+                    K k = n.key;
+                    unlinkNode(b, n);
+                    if (v != null) {
+                        tryReduceLevel();
+                        findPredecessor(k, comparator); // clean index
+                        addCount(-1L);
+                        return new AbstractMap.SimpleImmutableEntry<K,V>(k, v);
+                    }
+                }
             }
-            if (!n.casValue(v, null))
-                continue;
-            if (!n.appendMarker(f) || !b.casNext(n, f))
-                findFirst(); // retry
-            clearIndexToFirst();
-            @SuppressWarnings("unchecked") V vv = (V)v;
-            return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, vv);
         }
+        return null;
+    }
+
+    /* ---------------- Finding and removing last element -------------- */
+
+    /**
+     * Specialized version of find to get last valid node.
+     * @return last node or null if empty
+     */
+    final Node<K,V> findLast() {
+        outer: for (;;) {
+            Index<K,V> q; Node<K,V> b;
+            VarHandle.acquireFence();
+            if ((q = head) == null)
+                break;
+            for (Index<K,V> r, d;;) {
+                while ((r = q.right) != null) {
+                    Node<K,V> p;
+                    if ((p = r.node) == null || p.val == null)
+                        RIGHT.compareAndSet(q, r, r.right);
+                    else
+                        q = r;
+                }
+                if ((d = q.down) != null)
+                    q = d;
+                else {
+                    b = q.node;
+                    break;
+                }
+            }
+            if (b != null) {
+                for (;;) {
+                    Node<K,V> n;
+                    if ((n = b.next) == null) {
+                        if (b.key == null) // empty
+                            break outer;
+                        else
+                            return b;
+                    }
+                    else if (n.key == null)
+                        break;
+                    else if (n.val == null)
+                        unlinkNode(b, n);
+                    else
+                        b = n;
+                }
+            }
+        }
+        return null;
     }
 
     /**
-     * Clears out index nodes associated with deleted first entry.
+     * Entry version of findLast
+     * @return Entry for last node or null if empty
      */
-    private void clearIndexToFirst() {
+    final AbstractMap.SimpleImmutableEntry<K,V> findLastEntry() {
         for (;;) {
-            for (Index<K,V> q = head;;) {
-                Index<K,V> r = q.right;
-                if (r != null && r.indexesDeletedNode() && !q.unlink(r))
-                    break;
-                if ((q = q.down) == null) {
-                    if (head.right == null)
-                        tryReduceLevel();
-                    return;
-                }
-            }
+            Node<K,V> n; V v;
+            if ((n = findLast()) == null)
+                return null;
+            if ((v = n.val) != null)
+                return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, v);
         }
     }
 
@@ -1090,121 +946,54 @@
      * @return null if empty, else snapshot of last entry
      */
     private Map.Entry<K,V> doRemoveLastEntry() {
-        for (;;) {
-            Node<K,V> b = findPredecessorOfLast();
-            Node<K,V> n = b.next;
-            if (n == null) {
-                if (b.isBaseHeader())               // empty
-                    return null;
-                else
-                    continue; // all b's successors are deleted; retry
-            }
+        outer: for (;;) {
+            Index<K,V> q; Node<K,V> b;
+            VarHandle.acquireFence();
+            if ((q = head) == null)
+                break;
             for (;;) {
-                Node<K,V> f = n.next;
-                if (n != b.next)                    // inconsistent read
-                    break;
-                Object v = n.value;
-                if (v == null) {                    // n is deleted
-                    n.helpDelete(b, f);
-                    break;
-                }
-                if (b.value == null || v == n)      // b is deleted
-                    break;
-                if (f != null) {
-                    b = n;
-                    n = f;
-                    continue;
-                }
-                if (!n.casValue(v, null))
-                    break;
-                K key = n.key;
-                if (!n.appendMarker(f) || !b.casNext(n, f))
-                    findNode(key);                  // retry via findNode
-                else {                              // clean index
-                    findPredecessor(key, comparator);
-                    if (head.right == null)
-                        tryReduceLevel();
-                }
-                @SuppressWarnings("unchecked") V vv = (V)v;
-                return new AbstractMap.SimpleImmutableEntry<K,V>(key, vv);
-            }
-        }
-    }
-
-    /* ---------------- Finding and removing last element -------------- */
-
-    /**
-     * Specialized version of find to get last valid node.
-     * @return last node or null if empty
-     */
-    final Node<K,V> findLast() {
-        /*
-         * findPredecessor can't be used to traverse index level
-         * because this doesn't use comparisons.  So traversals of
-         * both levels are folded together.
-         */
-        Index<K,V> q = head;
-        for (;;) {
-            Index<K,V> d, r;
-            if ((r = q.right) != null) {
-                if (r.indexesDeletedNode()) {
-                    q.unlink(r);
-                    q = head; // restart
-                }
-                else
-                    q = r;
-            } else if ((d = q.down) != null) {
-                q = d;
-            } else {
-                for (Node<K,V> b = q.node, n = b.next;;) {
-                    if (n == null)
-                        return b.isBaseHeader() ? null : b;
-                    Node<K,V> f = n.next;            // inconsistent read
-                    if (n != b.next)
+                Index<K,V> d, r; Node<K,V> p;
+                while ((r = q.right) != null) {
+                    if ((p = r.node) == null || p.val == null)
+                        RIGHT.compareAndSet(q, r, r.right);
+                    else if (p.next != null)
+                        q = r;  // continue only if a successor
+                    else
                         break;
-                    Object v = n.value;
-                    if (v == null) {                 // n is deleted
-                        n.helpDelete(b, f);
-                        break;
-                    }
-                    if (b.value == null || v == n)      // b is deleted
-                        break;
-                    b = n;
-                    n = f;
-                }
-                q = head; // restart
-            }
-        }
-    }
-
-    /**
-     * Specialized variant of findPredecessor to get predecessor of last
-     * valid node.  Needed when removing the last entry.  It is possible
-     * that all successors of returned node will have been deleted upon
-     * return, in which case this method can be retried.
-     * @return likely predecessor of last node
-     */
-    private Node<K,V> findPredecessorOfLast() {
-        for (;;) {
-            for (Index<K,V> q = head;;) {
-                Index<K,V> d, r;
-                if ((r = q.right) != null) {
-                    if (r.indexesDeletedNode()) {
-                        q.unlink(r);
-                        break;    // must restart
-                    }
-                    // proceed as far across as possible without overshooting
-                    if (r.node.next != null) {
-                        q = r;
-                        continue;
-                    }
                 }
                 if ((d = q.down) != null)
                     q = d;
-                else
-                    return q.node;
+                else {
+                    b = q.node;
+                    break;
+                }
+            }
+            if (b != null) {
+                for (;;) {
+                    Node<K,V> n; K k; V v;
+                    if ((n = b.next) == null) {
+                        if (b.key == null) // empty
+                            break outer;
+                        else
+                            break; // retry
+                    }
+                    else if ((k = n.key) == null)
+                        break;
+                    else if ((v = n.val) == null)
+                        unlinkNode(b, n);
+                    else if (n.next != null)
+                        b = n;
+                    else if (VAL.compareAndSet(n, v, null)) {
+                        unlinkNode(b, n);
+                        tryReduceLevel();
+                        findPredecessor(k, comparator); // clean index
+                        addCount(-1L);
+                        return new AbstractMap.SimpleImmutableEntry<K,V>(k, v);
+                    }
+                }
             }
         }
+        return null;
     }
 
     /* ---------------- Relational operations -------------- */
@@ -1224,47 +1013,52 @@
     final Node<K,V> findNear(K key, int rel, Comparator<? super K> cmp) {
         if (key == null)
             throw new NullPointerException();
-        for (;;) {
-            for (Node<K,V> b = findPredecessor(key, cmp), n = b.next;;) {
-                Object v;
-                if (n == null)
-                    return ((rel & LT) == 0 || b.isBaseHeader()) ? null : b;
-                Node<K,V> f = n.next;
-                if (n != b.next)                  // inconsistent read
+        Node<K,V> result;
+        outer: for (Node<K,V> b;;) {
+            if ((b = findPredecessor(key, cmp)) == null) {
+                result = null;
+                break;                   // empty
+            }
+            for (;;) {
+                Node<K,V> n; K k; int c;
+                if ((n = b.next) == null) {
+                    result = ((rel & LT) != 0 && b.key != null) ? b : null;
+                    break outer;
+                }
+                else if ((k = n.key) == null)
                     break;
-                if ((v = n.value) == null) {      // n is deleted
-                    n.helpDelete(b, f);
-                    break;
+                else if (n.val == null)
+                    unlinkNode(b, n);
+                else if (((c = cpr(cmp, key, k)) == 0 && (rel & EQ) != 0) ||
+                         (c < 0 && (rel & LT) == 0)) {
+                    result = n;
+                    break outer;
                 }
-                if (b.value == null || v == n)      // b is deleted
-                    break;
-                int c = cpr(cmp, key, n.key);
-                if ((c == 0 && (rel & EQ) != 0) ||
-                    (c <  0 && (rel & LT) == 0))
-                    return n;
-                if ( c <= 0 && (rel & LT) != 0)
-                    return b.isBaseHeader() ? null : b;
-                b = n;
-                n = f;
+                else if (c <= 0 && (rel & LT) != 0) {
+                    result = (b.key != null) ? b : null;
+                    break outer;
+                }
+                else
+                    b = n;
             }
         }
+        return result;
     }
 
     /**
-     * Returns SimpleImmutableEntry for results of findNear.
+     * Variant of findNear returning SimpleImmutableEntry
      * @param key the key
      * @param rel the relation -- OR'ed combination of EQ, LT, GT
      * @return Entry fitting relation, or null if no such
      */
-    final AbstractMap.SimpleImmutableEntry<K,V> getNear(K key, int rel) {
-        Comparator<? super K> cmp = comparator;
+    final AbstractMap.SimpleImmutableEntry<K,V> findNearEntry(K key, int rel,
+                                                              Comparator<? super K> cmp) {
         for (;;) {
-            Node<K,V> n = findNear(key, rel, cmp);
-            if (n == null)
+            Node<K,V> n; V v;
+            if ((n = findNear(key, rel, cmp)) == null)
                 return null;
-            AbstractMap.SimpleImmutableEntry<K,V> e = n.createSnapshot();
-            if (e != null)
-                return e;
+            if ((v = n.val) != null)
+                return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, v);
         }
     }
 
@@ -1276,7 +1070,6 @@
      */
     public ConcurrentSkipListMap() {
         this.comparator = null;
-        initialize();
     }
 
     /**
@@ -1289,7 +1082,6 @@
      */
     public ConcurrentSkipListMap(Comparator<? super K> comparator) {
         this.comparator = comparator;
-        initialize();
     }
 
     /**
@@ -1305,7 +1097,6 @@
      */
     public ConcurrentSkipListMap(Map<? extends K, ? extends V> m) {
         this.comparator = null;
-        initialize();
         putAll(m);
     }
 
@@ -1320,8 +1111,7 @@
      */
     public ConcurrentSkipListMap(SortedMap<K, ? extends V> m) {
         this.comparator = m.comparator();
-        initialize();
-        buildFromSorted(m);
+        buildFromSorted(m); // initializes transients
     }
 
     /**
@@ -1335,7 +1125,10 @@
             @SuppressWarnings("unchecked")
             ConcurrentSkipListMap<K,V> clone =
                 (ConcurrentSkipListMap<K,V>) super.clone();
-            clone.initialize();
+            clone.keySet = null;
+            clone.entrySet = null;
+            clone.values = null;
+            clone.descendingMap = null;
             clone.buildFromSorted(this);
             return clone;
         } catch (CloneNotSupportedException e) {
@@ -1351,58 +1144,49 @@
     private void buildFromSorted(SortedMap<K, ? extends V> map) {
         if (map == null)
             throw new NullPointerException();
-
-        HeadIndex<K,V> h = head;
-        Node<K,V> basepred = h.node;
-
-        // Track the current rightmost node at each level. Uses an
-        // ArrayList to avoid committing to initial or maximum level.
-        ArrayList<Index<K,V>> preds = new ArrayList<>();
-
-        // initialize
-        for (int i = 0; i <= h.level; ++i)
-            preds.add(null);
-        Index<K,V> q = h;
-        for (int i = h.level; i > 0; --i) {
-            preds.set(i, q);
-            q = q.down;
-        }
-
         Iterator<? extends Map.Entry<? extends K, ? extends V>> it =
             map.entrySet().iterator();
+
+        /*
+         * Add equally spaced indices at log intervals, using the bits
+         * of count during insertion. The maximum possible resulting
+         * level is less than the number of bits in a long (64). The
+         * preds array tracks the current rightmost node at each
+         * level.
+         */
+        @SuppressWarnings("unchecked")
+        Index<K,V>[] preds = (Index<K,V>[])new Index<?,?>[64];
+        Node<K,V> bp = new Node<K,V>(null, null, null);
+        Index<K,V> h = preds[0] = new Index<K,V>(bp, null, null);
+        long count = 0;
+
         while (it.hasNext()) {
             Map.Entry<? extends K, ? extends V> e = it.next();
-            int rnd = ThreadLocalRandom.current().nextInt();
-            int j = 0;
-            if ((rnd & 0x80000001) == 0) {
-                do {
-                    ++j;
-                } while (((rnd >>>= 1) & 1) != 0);
-                if (j > h.level) j = h.level + 1;
-            }
             K k = e.getKey();
             V v = e.getValue();
             if (k == null || v == null)
                 throw new NullPointerException();
             Node<K,V> z = new Node<K,V>(k, v, null);
-            basepred.next = z;
-            basepred = z;
-            if (j > 0) {
-                Index<K,V> idx = null;
-                for (int i = 1; i <= j; ++i) {
+            bp = bp.next = z;
+            if ((++count & 3L) == 0L) {
+                long m = count >>> 2;
+                int i = 0;
+                Index<K,V> idx = null, q;
+                do {
                     idx = new Index<K,V>(z, idx, null);
-                    if (i > h.level)
-                        h = new HeadIndex<K,V>(h.node, h, idx, i);
-
-                    if (i < preds.size()) {
-                        preds.get(i).right = idx;
-                        preds.set(i, idx);
-                    } else
-                        preds.add(idx);
-                }
+                    if ((q = preds[i]) == null)
+                        preds[i] = h = new Index<K,V>(h.node, h, idx);
+                    else
+                        preds[i] = q.right = idx;
+                } while (++i < preds.length && ((m >>>= 1) & 1L) != 0L);
             }
         }
-        head = h;
+        if (count != 0L) {
+            VarHandle.releaseFence(); // emulate volatile stores
+            addCount(count);
+            head = h;
+            VarHandle.fullFence();
+        }
     }
 
     /* ---------------- Serialization -------------- */
@@ -1424,11 +1208,14 @@
         s.defaultWriteObject();
 
         // Write out keys and values (alternating)
-        for (Node<K,V> n = findFirst(); n != null; n = n.next) {
-            V v = n.getValidValue();
-            if (v != null) {
-                s.writeObject(n.key);
-                s.writeObject(v);
+        Node<K,V> b, n; V v;
+        if ((b = baseHead()) != null) {
+            while ((n = b.next) != null) {
+                if ((v = n.val) != null) {
+                    s.writeObject(n.key);
+                    s.writeObject(v);
+                }
+                b = n;
             }
         }
         s.writeObject(null);
@@ -1446,64 +1233,47 @@
         throws java.io.IOException, ClassNotFoundException {
         // Read in the Comparator and any hidden stuff
         s.defaultReadObject();
-        // Reset transients
-        initialize();
 
-        /*
-         * This is nearly identical to buildFromSorted, but is
-         * distinct because readObject calls can't be nicely adapted
-         * as the kind of iterator needed by buildFromSorted. (They
-         * can be, but doing so requires type cheats and/or creation
-         * of adapter classes.) It is simpler to just adapt the code.
-         */
-
-        HeadIndex<K,V> h = head;
-        Node<K,V> basepred = h.node;
-        ArrayList<Index<K,V>> preds = new ArrayList<>();
-        for (int i = 0; i <= h.level; ++i)
-            preds.add(null);
-        Index<K,V> q = h;
-        for (int i = h.level; i > 0; --i) {
-            preds.set(i, q);
-            q = q.down;
-        }
+        // Same idea as buildFromSorted
+        @SuppressWarnings("unchecked")
+        Index<K,V>[] preds = (Index<K,V>[])new Index<?,?>[64];
+        Node<K,V> bp = new Node<K,V>(null, null, null);
+        Index<K,V> h = preds[0] = new Index<K,V>(bp, null, null);
+        Comparator<? super K> cmp = comparator;
+        K prevKey = null;
+        long count = 0;
 
         for (;;) {
-            Object k = s.readObject();
+            K k = (K)s.readObject();
             if (k == null)
                 break;
-            Object v = s.readObject();
+            V v = (V)s.readObject();
             if (v == null)
                 throw new NullPointerException();
-            K key = (K) k;
-            V val = (V) v;
-            int rnd = ThreadLocalRandom.current().nextInt();
-            int j = 0;
-            if ((rnd & 0x80000001) == 0) {
+            if (prevKey != null && cpr(cmp, prevKey, k) > 0)
+                throw new IllegalStateException("out of order");
+            prevKey = k;
+            Node<K,V> z = new Node<K,V>(k, v, null);
+            bp = bp.next = z;
+            if ((++count & 3L) == 0L) {
+                long m = count >>> 2;
+                int i = 0;
+                Index<K,V> idx = null, q;
                 do {
-                    ++j;
-                } while (((rnd >>>= 1) & 1) != 0);
-                if (j > h.level) j = h.level + 1;
-            }
-            Node<K,V> z = new Node<K,V>(key, val, null);
-            basepred.next = z;
-            basepred = z;
-            if (j > 0) {
-                Index<K,V> idx = null;
-                for (int i = 1; i <= j; ++i) {
                     idx = new Index<K,V>(z, idx, null);
-                    if (i > h.level)
-                        h = new HeadIndex<K,V>(h.node, h, idx, i);
-
-                    if (i < preds.size()) {
-                        preds.get(i).right = idx;
-                        preds.set(i, idx);
-                    } else
-                        preds.add(idx);
-                }
+                    if ((q = preds[i]) == null)
+                        preds[i] = h = new Index<K,V>(h.node, h, idx);
+                    else
+                        preds[i] = q.right = idx;
+                } while (++i < preds.length && ((m >>>= 1) & 1L) != 0L);
             }
         }
-        head = h;
+        if (count != 0L) {
+            VarHandle.releaseFence();
+            addCount(count);
+            head = h;
+            VarHandle.fullFence();
+        }
     }
 
     /* ------ Map API methods ------ */
@@ -1604,42 +1374,30 @@
     public boolean containsValue(Object value) {
         if (value == null)
             throw new NullPointerException();
-        for (Node<K,V> n = findFirst(); n != null; n = n.next) {
-            V v = n.getValidValue();
-            if (v != null && value.equals(v))
-                return true;
+        Node<K,V> b, n; V v;
+        if ((b = baseHead()) != null) {
+            while ((n = b.next) != null) {
+                if ((v = n.val) != null && value.equals(v))
+                    return true;
+                else
+                    b = n;
+            }
         }
         return false;
     }
 
     /**
-     * Returns the number of key-value mappings in this map.  If this map
-     * contains more than {@code Integer.MAX_VALUE} elements, it
-     * returns {@code Integer.MAX_VALUE}.
-     *
-     * <p>Beware that, unlike in most collections, this method is
-     * <em>NOT</em> a constant-time operation. Because of the
-     * asynchronous nature of these maps, determining the current
-     * number of elements requires traversing them all to count them.
-     * Additionally, it is possible for the size to change during
-     * execution of this method, in which case the returned result
-     * will be inaccurate. Thus, this method is typically not very
-     * useful in concurrent applications.
-     *
-     * @return the number of elements in this map
+     * {@inheritDoc}
      */
     public int size() {
-        long count = 0;
-        for (Node<K,V> n = findFirst(); n != null; n = n.next) {
-            if (n.getValidValue() != null)
-                ++count;
-        }
-        return (count >= Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) count;
+        long c;
+        return ((baseHead() == null) ? 0 :
+                ((c = getAdderCount()) >= Integer.MAX_VALUE) ?
+                Integer.MAX_VALUE : (int) c);
     }
 
     /**
-     * Returns {@code true} if this map contains no key-value mappings.
-     * @return {@code true} if this map contains no key-value mappings
+     * {@inheritDoc}
      */
     public boolean isEmpty() {
         return findFirst() == null;
@@ -1649,23 +1407,32 @@
      * Removes all of the mappings from this map.
      */
     public void clear() {
-        for (;;) {
-            Node<K,V> b, n;
-            HeadIndex<K,V> h = head, d = (HeadIndex<K,V>)h.down;
-            if (d != null)
-                casHead(h, d);            // remove levels
-            else if ((b = h.node) != null && (n = b.next) != null) {
-                Node<K,V> f = n.next;     // remove values
-                if (n == b.next) {
-                    Object v = n.value;
-                    if (v == null)
-                        n.helpDelete(b, f);
-                    else if (n.casValue(v, null) && n.appendMarker(f))
-                        b.casNext(n, f);
+        Index<K,V> h, r, d; Node<K,V> b;
+        VarHandle.acquireFence();
+        while ((h = head) != null) {
+            if ((r = h.right) != null)        // remove indices
+                RIGHT.compareAndSet(h, r, null);
+            else if ((d = h.down) != null)    // remove levels
+                HEAD.compareAndSet(this, h, d);
+            else {
+                long count = 0L;
+                if ((b = h.node) != null) {    // remove nodes
+                    Node<K,V> n; V v;
+                    while ((n = b.next) != null) {
+                        if ((v = n.val) != null &&
+                            VAL.compareAndSet(n, v, null)) {
+                            --count;
+                            v = null;
+                        }
+                        if (v == null)
+                            unlinkNode(b, n);
+                    }
                 }
+                if (count != 0L)
+                    addCount(count);
+                else
+                    break;
             }
-            else
-                break;
         }
     }
 
@@ -1712,16 +1479,15 @@
                               BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
         if (key == null || remappingFunction == null)
             throw new NullPointerException();
-        Node<K,V> n; Object v;
+        Node<K,V> n; V v;
         while ((n = findNode(key)) != null) {
-            if ((v = n.value) != null) {
-                @SuppressWarnings("unchecked") V vv = (V) v;
-                V r = remappingFunction.apply(key, vv);
+            if ((v = n.val) != null) {
+                V r = remappingFunction.apply(key, v);
                 if (r != null) {
-                    if (n.casValue(vv, r))
+                    if (VAL.compareAndSet(n, v, r))
                         return r;
                 }
-                else if (doRemove(key, vv) != null)
+                else if (doRemove(key, v) != null)
                     break;
             }
         }
@@ -1746,20 +1512,19 @@
         if (key == null || remappingFunction == null)
             throw new NullPointerException();
         for (;;) {
-            Node<K,V> n; Object v; V r;
+            Node<K,V> n; V v; V r;
             if ((n = findNode(key)) == null) {
                 if ((r = remappingFunction.apply(key, null)) == null)
                     break;
                 if (doPut(key, r, true) == null)
                     return r;
             }
-            else if ((v = n.value) != null) {
-                @SuppressWarnings("unchecked") V vv = (V) v;
-                if ((r = remappingFunction.apply(key, vv)) != null) {
-                    if (n.casValue(vv, r))
+            else if ((v = n.val) != null) {
+                if ((r = remappingFunction.apply(key, v)) != null) {
+                    if (VAL.compareAndSet(n, v, r))
                         return r;
                 }
-                else if (doRemove(key, vv) != null)
+                else if (doRemove(key, v) != null)
                     break;
             }
         }
@@ -1786,18 +1551,17 @@
         if (key == null || value == null || remappingFunction == null)
             throw new NullPointerException();
         for (;;) {
-            Node<K,V> n; Object v; V r;
+            Node<K,V> n; V v; V r;
             if ((n = findNode(key)) == null) {
                 if (doPut(key, value, true) == null)
                     return value;
             }
-            else if ((v = n.value) != null) {
-                @SuppressWarnings("unchecked") V vv = (V) v;
-                if ((r = remappingFunction.apply(vv, value)) != null) {
-                    if (n.casValue(vv, r))
+            else if ((v = n.val) != null) {
+                if ((r = remappingFunction.apply(v, value)) != null) {
+                    if (VAL.compareAndSet(n, v, r))
                         return r;
                 }
-                else if (doRemove(key, vv) != null)
+                else if (doRemove(key, v) != null)
                     return null;
             }
         }
@@ -1946,16 +1710,60 @@
             return false;
         Map<?,?> m = (Map<?,?>) o;
         try {
-            for (Map.Entry<K,V> e : this.entrySet())
-                if (! e.getValue().equals(m.get(e.getKey())))
-                    return false;
-            for (Map.Entry<?,?> e : m.entrySet()) {
-                Object k = e.getKey();
-                Object v = e.getValue();
-                if (k == null || v == null || !v.equals(get(k)))
-                    return false;
+            Comparator<? super K> cmp = comparator;
+            @SuppressWarnings("unchecked")
+            Iterator<Map.Entry<?,?>> it =
+                (Iterator<Map.Entry<?,?>>)m.entrySet().iterator();
+            if (m instanceof SortedMap &&
+                ((SortedMap<?,?>)m).comparator() == cmp) {
+                Node<K,V> b, n;
+                if ((b = baseHead()) != null) {
+                    while ((n = b.next) != null) {
+                        K k; V v;
+                        if ((v = n.val) != null && (k = n.key) != null) {
+                            if (!it.hasNext())
+                                return false;
+                            Map.Entry<?,?> e = it.next();
+                            Object mk = e.getKey();
+                            Object mv = e.getValue();
+                            if (mk == null || mv == null)
+                                return false;
+                            try {
+                                if (cpr(cmp, k, mk) != 0)
+                                    return false;
+                            } catch (ClassCastException cce) {
+                                return false;
+                            }
+                            if (!mv.equals(v))
+                                return false;
+                        }
+                        b = n;
+                    }
+                }
+                return !it.hasNext();
             }
-            return true;
+            else {
+                while (it.hasNext()) {
+                    V v;
+                    Map.Entry<?,?> e = it.next();
+                    Object mk = e.getKey();
+                    Object mv = e.getValue();
+                    if (mk == null || mv == null ||
+                        (v = get(mk)) == null || !v.equals(mv))
+                        return false;
+                }
+                Node<K,V> b, n;
+                if ((b = baseHead()) != null) {
+                    K k; V v; Object mv;
+                    while ((n = b.next) != null) {
+                        if ((v = n.val) != null && (k = n.key) != null &&
+                            ((mv = m.get(k)) == null || !mv.equals(v)))
+                            return false;
+                        b = n;
+                    }
+                }
+                return true;
+            }
         } catch (ClassCastException unused) {
             return false;
         } catch (NullPointerException unused) {
@@ -2004,13 +1812,13 @@
         if (key == null || oldValue == null || newValue == null)
             throw new NullPointerException();
         for (;;) {
-            Node<K,V> n; Object v;
+            Node<K,V> n; V v;
             if ((n = findNode(key)) == null)
                 return false;
-            if ((v = n.value) != null) {
+            if ((v = n.val) != null) {
                 if (!oldValue.equals(v))
                     return false;
-                if (n.casValue(v, newValue))
+                if (VAL.compareAndSet(n, v, newValue))
                     return true;
             }
         }
@@ -2029,13 +1837,11 @@
         if (key == null || value == null)
             throw new NullPointerException();
         for (;;) {
-            Node<K,V> n; Object v;
+            Node<K,V> n; V v;
             if ((n = findNode(key)) == null)
                 return null;
-            if ((v = n.value) != null && n.casValue(v, value)) {
-                @SuppressWarnings("unchecked") V vv = (V)v;
-                return vv;
-            }
+            if ((v = n.val) != null && VAL.compareAndSet(n, v, value))
+                return v;
         }
     }
 
@@ -2145,7 +1951,7 @@
      * @throws NullPointerException if the specified key is null
      */
     public Map.Entry<K,V> lowerEntry(K key) {
-        return getNear(key, LT);
+        return findNearEntry(key, LT, comparator);
     }
 
     /**
@@ -2168,7 +1974,7 @@
      * @throws NullPointerException if the specified key is null
      */
     public Map.Entry<K,V> floorEntry(K key) {
-        return getNear(key, LT|EQ);
+        return findNearEntry(key, LT|EQ, comparator);
     }
 
     /**
@@ -2191,7 +1997,7 @@
      * @throws NullPointerException if the specified key is null
      */
     public Map.Entry<K,V> ceilingEntry(K key) {
-        return getNear(key, GT|EQ);
+        return findNearEntry(key, GT|EQ, comparator);
     }
 
     /**
@@ -2214,7 +2020,7 @@
      * @throws NullPointerException if the specified key is null
      */
     public Map.Entry<K,V> higherEntry(K key) {
-        return getNear(key, GT);
+        return findNearEntry(key, GT, comparator);
     }
 
     /**
@@ -2234,14 +2040,7 @@
      * the {@code Entry.setValue} method.
      */
     public Map.Entry<K,V> firstEntry() {
-        for (;;) {
-            Node<K,V> n = findFirst();
-            if (n == null)
-                return null;
-            AbstractMap.SimpleImmutableEntry<K,V> e = n.createSnapshot();
-            if (e != null)
-                return e;
-        }
+        return findFirstEntry();
     }
 
     /**
@@ -2251,14 +2050,7 @@
      * the {@code Entry.setValue} method.
      */
     public Map.Entry<K,V> lastEntry() {
-        for (;;) {
-            Node<K,V> n = findLast();
-            if (n == null)
-                return null;
-            AbstractMap.SimpleImmutableEntry<K,V> e = n.createSnapshot();
-            if (e != null)
-                return e;
-        }
+        return findLastEntry();
     }
 
     /**
@@ -2281,11 +2073,10 @@
         return doRemoveLastEntry();
     }
 
-
     /* ---------------- Iterators -------------- */
 
     /**
-     * Base of iterator classes:
+     * Base of iterator classes
      */
     abstract class Iter<T> implements Iterator<T> {
         /** the last node returned by next() */
@@ -2297,14 +2088,7 @@
 
         /** Initializes ascending iterator for entire range. */
         Iter() {
-            while ((next = findFirst()) != null) {
-                Object x = next.value;
-                if (x != null && x != next) {
-                    @SuppressWarnings("unchecked") V vv = (V)x;
-                    nextValue = vv;
-                    break;
-                }
-            }
+            advance(baseHead());
         }
 
         public final boolean hasNext() {
@@ -2312,54 +2096,58 @@
         }
 
         /** Advances next to higher entry. */
-        final void advance() {
-            if (next == null)
-                throw new NoSuchElementException();
-            lastReturned = next;
-            while ((next = next.next) != null) {
-                Object x = next.value;
-                if (x != null && x != next) {
-                    @SuppressWarnings("unchecked") V vv = (V)x;
-                    nextValue = vv;
-                    break;
-                }
+        final void advance(Node<K,V> b) {
+            Node<K,V> n = null;
+            V v = null;
+            if ((lastReturned = b) != null) {
+                while ((n = b.next) != null && (v = n.val) == null)
+                    b = n;
             }
+            nextValue = v;
+            next = n;
         }
 
-        public void remove() {
-            Node<K,V> l = lastReturned;
-            if (l == null)
+        public final void remove() {
+            Node<K,V> n; K k;
+            if ((n = lastReturned) == null || (k = n.key) == null)
                 throw new IllegalStateException();
             // It would not be worth all of the overhead to directly
             // unlink from here. Using remove is fast enough.
-            ConcurrentSkipListMap.this.remove(l.key);
+            ConcurrentSkipListMap.this.remove(k);
             lastReturned = null;
         }
-
     }
 
     final class ValueIterator extends Iter<V> {
         public V next() {
-            V v = nextValue;
-            advance();
+            V v;
+            if ((v = nextValue) == null)
+                throw new NoSuchElementException();
+            advance(next);
             return v;
         }
     }
 
     final class KeyIterator extends Iter<K> {
         public K next() {
-            Node<K,V> n = next;
-            advance();
-            return n.key;
+            Node<K,V> n;
+            if ((n = next) == null)
+                throw new NoSuchElementException();
+            K k = n.key;
+            advance(n);
+            return k;
         }
     }
 
     final class EntryIterator extends Iter<Map.Entry<K,V>> {
         public Map.Entry<K,V> next() {
-            Node<K,V> n = next;
+            Node<K,V> n;
+            if ((n = next) == null)
+                throw new NoSuchElementException();
+            K k = n.key;
             V v = nextValue;
-            advance();
-            return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, v);
+            advance(n);
+            return new AbstractMap.SimpleImmutableEntry<K,V>(k, v);
         }
     }
 
@@ -2725,38 +2513,34 @@
         Map.Entry<K,V> lowestEntry() {
             Comparator<? super K> cmp = m.comparator;
             for (;;) {
-                ConcurrentSkipListMap.Node<K,V> n = loNode(cmp);
-                if (!isBeforeEnd(n, cmp))
+                ConcurrentSkipListMap.Node<K,V> n; V v;
+                if ((n = loNode(cmp)) == null || !isBeforeEnd(n, cmp))
                     return null;
-                Map.Entry<K,V> e = n.createSnapshot();
-                if (e != null)
-                    return e;
+                else if ((v = n.val) != null)
+                    return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, v);
             }
         }
 
         Map.Entry<K,V> highestEntry() {
             Comparator<? super K> cmp = m.comparator;
             for (;;) {
-                ConcurrentSkipListMap.Node<K,V> n = hiNode(cmp);
-                if (n == null || !inBounds(n.key, cmp))
+                ConcurrentSkipListMap.Node<K,V> n; V v;
+                if ((n = hiNode(cmp)) == null || !inBounds(n.key, cmp))
                     return null;
-                Map.Entry<K,V> e = n.createSnapshot();
-                if (e != null)
-                    return e;
+                else if ((v = n.val) != null)
+                    return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, v);
             }
         }
 
         Map.Entry<K,V> removeLowest() {
             Comparator<? super K> cmp = m.comparator;
             for (;;) {
-                Node<K,V> n = loNode(cmp);
-                if (n == null)
+                ConcurrentSkipListMap.Node<K,V> n; K k; V v;
+                if ((n = loNode(cmp)) == null)
                     return null;
-                K k = n.key;
-                if (!inBounds(k, cmp))
+                else if (!inBounds((k = n.key), cmp))
                     return null;
-                V v = m.doRemove(k, null);
-                if (v != null)
+                else if ((v = m.doRemove(k, null)) != null)
                     return new AbstractMap.SimpleImmutableEntry<K,V>(k, v);
             }
         }
@@ -2764,20 +2548,18 @@
         Map.Entry<K,V> removeHighest() {
             Comparator<? super K> cmp = m.comparator;
             for (;;) {
-                Node<K,V> n = hiNode(cmp);
-                if (n == null)
+                ConcurrentSkipListMap.Node<K,V> n; K k; V v;
+                if ((n = hiNode(cmp)) == null)
                     return null;
-                K k = n.key;
-                if (!inBounds(k, cmp))
+                else if (!inBounds((k = n.key), cmp))
                     return null;
-                V v = m.doRemove(k, null);
-                if (v != null)
+                else if ((v = m.doRemove(k, null)) != null)
                     return new AbstractMap.SimpleImmutableEntry<K,V>(k, v);
             }
         }
 
         /**
-         * Submap version of ConcurrentSkipListMap.getNearEntry.
+         * Submap version of ConcurrentSkipListMap.findNearEntry.
          */
         Map.Entry<K,V> getNearEntry(K key, int rel) {
             Comparator<? super K> cmp = m.comparator;
@@ -2791,15 +2573,12 @@
                 return ((rel & LT) != 0) ? null : lowestEntry();
             if (tooHigh(key, cmp))
                 return ((rel & LT) != 0) ? highestEntry() : null;
-            for (;;) {
-                Node<K,V> n = m.findNear(key, rel, cmp);
-                if (n == null || !inBounds(n.key, cmp))
-                    return null;
-                K k = n.key;
-                V v = n.getValidValue();
-                if (v != null)
-                    return new AbstractMap.SimpleImmutableEntry<K,V>(k, v);
-            }
+            AbstractMap.SimpleImmutableEntry<K,V> e =
+                m.findNearEntry(key, rel, cmp);
+            if (e == null || !inBounds(e.getKey(), cmp))
+                return null;
+            else
+                return e;
         }
 
         // Almost the same as getNearEntry, except for keys
@@ -2834,10 +2613,8 @@
                 Node<K,V> n = m.findNear(key, rel, cmp);
                 if (n == null || !inBounds(n.key, cmp))
                     return null;
-                K k = n.key;
-                V v = n.getValidValue();
-                if (v != null)
-                    return k;
+                if (n.val != null)
+                    return n.key;
             }
         }
 
@@ -2868,7 +2645,7 @@
             for (ConcurrentSkipListMap.Node<K,V> n = loNode(cmp);
                  isBeforeEnd(n, cmp);
                  n = n.next) {
-                if (n.getValidValue() != null)
+                if (n.val != null)
                     ++count;
             }
             return count >= Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)count;
@@ -2886,7 +2663,7 @@
             for (ConcurrentSkipListMap.Node<K,V> n = loNode(cmp);
                  isBeforeEnd(n, cmp);
                  n = n.next) {
-                V v = n.getValidValue();
+                V v = n.val;
                 if (v != null && value.equals(v))
                     return true;
             }
@@ -2898,7 +2675,7 @@
             for (ConcurrentSkipListMap.Node<K,V> n = loNode(cmp);
                  isBeforeEnd(n, cmp);
                  n = n.next) {
-                if (n.getValidValue() != null)
+                if (n.val != null)
                     m.remove(n.key);
             }
         }
@@ -3112,19 +2889,18 @@
             V nextValue;
 
             SubMapIter() {
+                VarHandle.acquireFence();
                 Comparator<? super K> cmp = m.comparator;
                 for (;;) {
                     next = isDescending ? hiNode(cmp) : loNode(cmp);
                     if (next == null)
                         break;
-                    Object x = next.value;
-                    if (x != null && x != next) {
+                    V x = next.val;
+                    if (x != null) {
                         if (! inBounds(next.key, cmp))
                             next = null;
-                        else {
-                            @SuppressWarnings("unchecked") V vv = (V)x;
-                            nextValue = vv;
-                        }
+                        else
+                            nextValue = x;
                         break;
                     }
                 }
@@ -3150,14 +2926,12 @@
                     next = next.next;
                     if (next == null)
                         break;
-                    Object x = next.value;
-                    if (x != null && x != next) {
+                    V x = next.val;
+                    if (x != null) {
                         if (tooHigh(next.key, cmp))
                             next = null;
-                        else {
-                            @SuppressWarnings("unchecked") V vv = (V)x;
-                            nextValue = vv;
-                        }
+                        else
+                            nextValue = x;
                         break;
                     }
                 }
@@ -3169,14 +2943,12 @@
                     next = m.findNear(lastReturned.key, LT, cmp);
                     if (next == null)
                         break;
-                    Object x = next.value;
-                    if (x != null && x != next) {
+                    V x = next.val;
+                    if (x != null) {
                         if (tooLow(next.key, cmp))
                             next = null;
-                        else {
-                            @SuppressWarnings("unchecked") V vv = (V)x;
-                            nextValue = vv;
-                        }
+                        else
+                            nextValue = x;
                         break;
                     }
                 }
@@ -3256,22 +3028,28 @@
 
     public void forEach(BiConsumer<? super K, ? super V> action) {
         if (action == null) throw new NullPointerException();
-        V v;
-        for (Node<K,V> n = findFirst(); n != null; n = n.next) {
-            if ((v = n.getValidValue()) != null)
-                action.accept(n.key, v);
+        Node<K,V> b, n; V v;
+        if ((b = baseHead()) != null) {
+            while ((n = b.next) != null) {
+                if ((v = n.val) != null)
+                    action.accept(n.key, v);
+                b = n;
+            }
         }
     }
 
     public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
         if (function == null) throw new NullPointerException();
-        V v;
-        for (Node<K,V> n = findFirst(); n != null; n = n.next) {
-            while ((v = n.getValidValue()) != null) {
-                V r = function.apply(n.key, v);
-                if (r == null) throw new NullPointerException();
-                if (n.casValue(v, r))
-                    break;
+        Node<K,V> b, n; V v;
+        if ((b = baseHead()) != null) {
+            while ((n = b.next) != null) {
+                while ((v = n.val) != null) {
+                    V r = function.apply(n.key, v);
+                    if (r == null) throw new NullPointerException();
+                    if (VAL.compareAndSet(n, v, r))
+                        break;
+                }
+                b = n;
             }
         }
     }
@@ -3282,13 +3060,16 @@
     boolean removeEntryIf(Predicate<? super Entry<K,V>> function) {
         if (function == null) throw new NullPointerException();
         boolean removed = false;
-        for (Node<K,V> n = findFirst(); n != null; n = n.next) {
-            V v;
-            if ((v = n.getValidValue()) != null) {
-                K k = n.key;
-                Map.Entry<K,V> e = new AbstractMap.SimpleImmutableEntry<>(k, v);
-                if (function.test(e) && remove(k, v))
-                    removed = true;
+        Node<K,V> b, n; V v;
+        if ((b = baseHead()) != null) {
+            while ((n = b.next) != null) {
+                if ((v = n.val) != null) {
+                    K k = n.key;
+                    Map.Entry<K,V> e = new AbstractMap.SimpleImmutableEntry<>(k, v);
+                    if (function.test(e) && remove(k, v))
+                        removed = true;
+                }
+                b = n;
             }
         }
         return removed;
@@ -3300,12 +3081,12 @@
     boolean removeValueIf(Predicate<? super V> function) {
         if (function == null) throw new NullPointerException();
         boolean removed = false;
-        for (Node<K,V> n = findFirst(); n != null; n = n.next) {
-            V v;
-            if ((v = n.getValidValue()) != null) {
-                K k = n.key;
-                if (function.test(v) && remove(k, v))
+        Node<K,V> b, n; V v;
+        if ((b = baseHead()) != null) {
+            while ((n = b.next) != null) {
+                if ((v = n.val) != null && function.test(v) && remove(n.key, v))
                     removed = true;
+                b = n;
             }
         }
         return removed;
@@ -3323,30 +3104,27 @@
      * off, or the end of row is encountered. Control of the number of
      * splits relies on some statistical estimation: The expected
      * remaining number of elements of a skip list when advancing
-     * either across or down decreases by about 25%. To make this
-     * observation useful, we need to know initial size, which we
-     * don't. But we can just use Integer.MAX_VALUE so that we
-     * don't prematurely zero out while splitting.
+     * either across or down decreases by about 25%.
      */
     abstract static class CSLMSpliterator<K,V> {
         final Comparator<? super K> comparator;
         final K fence;     // exclusive upper bound for keys, or null if to end
         Index<K,V> row;    // the level to split out
         Node<K,V> current; // current traversal node; initialize at origin
-        int est;           // pseudo-size estimate
+        long est;          // size estimate
         CSLMSpliterator(Comparator<? super K> comparator, Index<K,V> row,
-                        Node<K,V> origin, K fence, int est) {
+                        Node<K,V> origin, K fence, long est) {
             this.comparator = comparator; this.row = row;
             this.current = origin; this.fence = fence; this.est = est;
         }
 
-        public final long estimateSize() { return (long)est; }
+        public final long estimateSize() { return est; }
     }
 
     static final class KeySpliterator<K,V> extends CSLMSpliterator<K,V>
         implements Spliterator<K> {
         KeySpliterator(Comparator<? super K> comparator, Index<K,V> row,
-                       Node<K,V> origin, K fence, int est) {
+                       Node<K,V> origin, K fence, long est) {
             super(comparator, row, origin, fence, est);
         }
 
@@ -3358,7 +3136,7 @@
                 for (Index<K,V> q = row; q != null; q = row = q.down) {
                     Index<K,V> s; Node<K,V> b, n; K sk;
                     if ((s = q.right) != null && (b = s.node) != null &&
-                        (n = b.next) != null && n.value != null &&
+                        (n = b.next) != null && n.val != null &&
                         (sk = n.key) != null && cpr(cmp, sk, ek) > 0 &&
                         (f == null || cpr(cmp, sk, f) < 0)) {
                         current = n;
@@ -3379,10 +3157,10 @@
             Node<K,V> e = current;
             current = null;
             for (; e != null; e = e.next) {
-                K k; Object v;
+                K k;
                 if ((k = e.key) != null && f != null && cpr(cmp, f, k) <= 0)
                     break;
-                if ((v = e.value) != null && v != e)
+                if (e.val != null)
                     action.accept(k);
             }
         }
@@ -3393,12 +3171,12 @@
             K f = fence;
             Node<K,V> e = current;
             for (; e != null; e = e.next) {
-                K k; Object v;
+                K k;
                 if ((k = e.key) != null && f != null && cpr(cmp, f, k) <= 0) {
                     e = null;
                     break;
                 }
-                if ((v = e.value) != null && v != e) {
+                if (e.val != null) {
                     current = e.next;
                     action.accept(k);
                     return true;
@@ -3420,21 +3198,23 @@
     }
     // factory method for KeySpliterator
     final KeySpliterator<K,V> keySpliterator() {
-        Comparator<? super K> cmp = comparator;
-        for (;;) { // ensure h corresponds to origin p
-            HeadIndex<K,V> h; Node<K,V> p;
-            Node<K,V> b = (h = head).node;
-            if ((p = b.next) == null || p.value != null)
-                return new KeySpliterator<K,V>(cmp, h, p, null, (p == null) ?
-                                               0 : Integer.MAX_VALUE);
-            p.helpDelete(b, p.next);
+        Index<K,V> h; Node<K,V> n; long est;
+        VarHandle.acquireFence();
+        if ((h = head) == null) {
+            n = null;
+            est = 0L;
         }
+        else {
+            n = h.node;
+            est = getAdderCount();
+        }
+        return new KeySpliterator<K,V>(comparator, h, n, null, est);
     }
 
     static final class ValueSpliterator<K,V> extends CSLMSpliterator<K,V>
         implements Spliterator<V> {
         ValueSpliterator(Comparator<? super K> comparator, Index<K,V> row,
-                       Node<K,V> origin, K fence, int est) {
+                       Node<K,V> origin, K fence, long est) {
             super(comparator, row, origin, fence, est);
         }
 
@@ -3446,7 +3226,7 @@
                 for (Index<K,V> q = row; q != null; q = row = q.down) {
                     Index<K,V> s; Node<K,V> b, n; K sk;
                     if ((s = q.right) != null && (b = s.node) != null &&
-                        (n = b.next) != null && n.value != null &&
+                        (n = b.next) != null && n.val != null &&
                         (sk = n.key) != null && cpr(cmp, sk, ek) > 0 &&
                         (f == null || cpr(cmp, sk, f) < 0)) {
                         current = n;
@@ -3467,13 +3247,11 @@
             Node<K,V> e = current;
             current = null;
             for (; e != null; e = e.next) {
-                K k; Object v;
+                K k; V v;
                 if ((k = e.key) != null && f != null && cpr(cmp, f, k) <= 0)
                     break;
-                if ((v = e.value) != null && v != e) {
-                    @SuppressWarnings("unchecked") V vv = (V)v;
-                    action.accept(vv);
-                }
+                if ((v = e.val) != null)
+                    action.accept(v);
             }
         }
 
@@ -3483,15 +3261,14 @@
             K f = fence;
             Node<K,V> e = current;
             for (; e != null; e = e.next) {
-                K k; Object v;
+                K k; V v;
                 if ((k = e.key) != null && f != null && cpr(cmp, f, k) <= 0) {
                     e = null;
                     break;
                 }
-                if ((v = e.value) != null && v != e) {
+                if ((v = e.val) != null) {
                     current = e.next;
-                    @SuppressWarnings("unchecked") V vv = (V)v;
-                    action.accept(vv);
+                    action.accept(v);
                     return true;
                 }
             }
@@ -3507,21 +3284,23 @@
 
     // Almost the same as keySpliterator()
     final ValueSpliterator<K,V> valueSpliterator() {
-        Comparator<? super K> cmp = comparator;
-        for (;;) {
-            HeadIndex<K,V> h; Node<K,V> p;
-            Node<K,V> b = (h = head).node;
-            if ((p = b.next) == null || p.value != null)
-                return new ValueSpliterator<K,V>(cmp, h, p, null, (p == null) ?
-                                                 0 : Integer.MAX_VALUE);
-            p.helpDelete(b, p.next);
+        Index<K,V> h; Node<K,V> n; long est;
+        VarHandle.acquireFence();
+        if ((h = head) == null) {
+            n = null;
+            est = 0L;
         }
+        else {
+            n = h.node;
+            est = getAdderCount();
+        }
+        return new ValueSpliterator<K,V>(comparator, h, n, null, est);
     }
 
     static final class EntrySpliterator<K,V> extends CSLMSpliterator<K,V>
         implements Spliterator<Map.Entry<K,V>> {
         EntrySpliterator(Comparator<? super K> comparator, Index<K,V> row,
-                         Node<K,V> origin, K fence, int est) {
+                         Node<K,V> origin, K fence, long est) {
             super(comparator, row, origin, fence, est);
         }
 
@@ -3533,7 +3312,7 @@
                 for (Index<K,V> q = row; q != null; q = row = q.down) {
                     Index<K,V> s; Node<K,V> b, n; K sk;
                     if ((s = q.right) != null && (b = s.node) != null &&
-                        (n = b.next) != null && n.value != null &&
+                        (n = b.next) != null && n.val != null &&
                         (sk = n.key) != null && cpr(cmp, sk, ek) > 0 &&
                         (f == null || cpr(cmp, sk, f) < 0)) {
                         current = n;
@@ -3554,13 +3333,12 @@
             Node<K,V> e = current;
             current = null;
             for (; e != null; e = e.next) {
-                K k; Object v;
+                K k; V v;
                 if ((k = e.key) != null && f != null && cpr(cmp, f, k) <= 0)
                     break;
-                if ((v = e.value) != null && v != e) {
-                    @SuppressWarnings("unchecked") V vv = (V)v;
+                if ((v = e.val) != null) {
                     action.accept
-                        (new AbstractMap.SimpleImmutableEntry<K,V>(k, vv));
+                        (new AbstractMap.SimpleImmutableEntry<K,V>(k, v));
                 }
             }
         }
@@ -3571,16 +3349,15 @@
             K f = fence;
             Node<K,V> e = current;
             for (; e != null; e = e.next) {
-                K k; Object v;
+                K k; V v;
                 if ((k = e.key) != null && f != null && cpr(cmp, f, k) <= 0) {
                     e = null;
                     break;
                 }
-                if ((v = e.value) != null && v != e) {
+                if ((v = e.val) != null) {
                     current = e.next;
-                    @SuppressWarnings("unchecked") V vv = (V)v;
                     action.accept
-                        (new AbstractMap.SimpleImmutableEntry<K,V>(k, vv));
+                        (new AbstractMap.SimpleImmutableEntry<K,V>(k, v));
                     return true;
                 }
             }
@@ -3611,24 +3388,35 @@
 
     // Almost the same as keySpliterator()
     final EntrySpliterator<K,V> entrySpliterator() {
-        Comparator<? super K> cmp = comparator;
-        for (;;) { // almost same as key version
-            HeadIndex<K,V> h; Node<K,V> p;
-            Node<K,V> b = (h = head).node;
-            if ((p = b.next) == null || p.value != null)
-                return new EntrySpliterator<K,V>(cmp, h, p, null, (p == null) ?
-                                                 0 : Integer.MAX_VALUE);
-            p.helpDelete(b, p.next);
+        Index<K,V> h; Node<K,V> n; long est;
+        VarHandle.acquireFence();
+        if ((h = head) == null) {
+            n = null;
+            est = 0L;
         }
+        else {
+            n = h.node;
+            est = getAdderCount();
+        }
+        return new EntrySpliterator<K,V>(comparator, h, n, null, est);
     }
 
     // VarHandle mechanics
     private static final VarHandle HEAD;
+    private static final VarHandle ADDER;
+    private static final VarHandle NEXT;
+    private static final VarHandle VAL;
+    private static final VarHandle RIGHT;
     static {
         try {
             MethodHandles.Lookup l = MethodHandles.lookup();
             HEAD = l.findVarHandle(ConcurrentSkipListMap.class, "head",
-                                   HeadIndex.class);
+                                   Index.class);
+            ADDER = l.findVarHandle(ConcurrentSkipListMap.class, "adder",
+                                    LongAdder.class);
+            NEXT = l.findVarHandle(Node.class, "next", Node.class);
+            VAL = l.findVarHandle(Node.class, "val", Object.class);
+            RIGHT = l.findVarHandle(Index.class, "right", Index.class);
         } catch (ReflectiveOperationException e) {
             throw new Error(e);
         }
--- a/src/java.base/share/classes/java/util/concurrent/ExecutorCompletionService.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ExecutorCompletionService.java	Thu Oct 05 22:04:49 2017 +0200
@@ -174,6 +174,10 @@
         this.completionQueue = completionQueue;
     }
 
+    /**
+     * @throws RejectedExecutionException {@inheritDoc}
+     * @throws NullPointerException       {@inheritDoc}
+     */
     public Future<V> submit(Callable<V> task) {
         if (task == null) throw new NullPointerException();
         RunnableFuture<V> f = newTaskFor(task);
@@ -181,6 +185,10 @@
         return f;
     }
 
+    /**
+     * @throws RejectedExecutionException {@inheritDoc}
+     * @throws NullPointerException       {@inheritDoc}
+     */
     public Future<V> submit(Runnable task, V result) {
         if (task == null) throw new NullPointerException();
         RunnableFuture<V> f = newTaskFor(task, result);
--- a/src/java.base/share/classes/java/util/concurrent/Executors.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/Executors.java	Thu Oct 05 22:04:49 2017 +0200
@@ -514,6 +514,9 @@
             task.run();
             return result;
         }
+        public String toString() {
+            return super.toString() + "[Wrapped task = " + task + "]";
+        }
     }
 
     /**
@@ -540,6 +543,10 @@
                 throw e.getException();
             }
         }
+
+        public String toString() {
+            return super.toString() + "[Wrapped task = " + task + "]";
+        }
     }
 
     /**
@@ -592,6 +599,10 @@
                 throw e.getException();
             }
         }
+
+        public String toString() {
+            return super.toString() + "[Wrapped task = " + task + "]";
+        }
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1375,6 +1375,9 @@
         public final void setRawResult(T v) { result = v; }
         public final boolean exec() { runnable.run(); return true; }
         public final void run() { invoke(); }
+        public String toString() {
+            return super.toString() + "[Wrapped task = " + runnable + "]";
+        }
         private static final long serialVersionUID = 5232453952276885070L;
     }
 
@@ -1392,6 +1395,9 @@
         public final void setRawResult(Void v) { }
         public final boolean exec() { runnable.run(); return true; }
         public final void run() { invoke(); }
+        public String toString() {
+            return super.toString() + "[Wrapped task = " + runnable + "]";
+        }
         private static final long serialVersionUID = 5232453952276885070L;
     }
 
@@ -1437,6 +1443,9 @@
             }
         }
         public final void run() { invoke(); }
+        public String toString() {
+            return super.toString() + "[Wrapped task = " + callable + "]";
+        }
         private static final long serialVersionUID = 2838392045355241008L;
     }
 
--- a/src/java.base/share/classes/java/util/concurrent/FutureTask.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/FutureTask.java	Thu Oct 05 22:04:49 2017 +0200
@@ -480,6 +480,41 @@
         }
     }
 
+    /**
+     * Returns a string representation of this FutureTask.
+     *
+     * @implSpec
+     * The default implementation returns a string identifying this
+     * FutureTask, as well as its completion state.  The state, in
+     * brackets, contains one of the strings {@code "Completed Normally"},
+     * {@code "Completed Exceptionally"}, {@code "Cancelled"}, or {@code
+     * "Not completed"}.
+     *
+     * @return a string representation of this FutureTask
+     */
+    public String toString() {
+        final String status;
+        switch (state) {
+        case NORMAL:
+            status = "[Completed normally]";
+            break;
+        case EXCEPTIONAL:
+            status = "[Completed exceptionally: " + outcome + "]";
+            break;
+        case CANCELLED:
+        case INTERRUPTING:
+        case INTERRUPTED:
+            status = "[Cancelled]";
+            break;
+        default:
+            final Callable<?> callable = this.callable;
+            status = (callable == null)
+                ? "[Not completed]"
+                : "[Not completed, task = " + callable + "]";
+        }
+        return super.toString() + status;
+    }
+
     // VarHandle mechanics
     private static final VarHandle STATE;
     private static final VarHandle RUNNER;
--- a/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Thu Oct 05 22:04:49 2017 +0200
@@ -383,7 +383,7 @@
      */
     private final AtomicInteger ctl = new AtomicInteger(ctlOf(RUNNING, 0));
     private static final int COUNT_BITS = Integer.SIZE - 3;
-    private static final int CAPACITY   = (1 << COUNT_BITS) - 1;
+    private static final int COUNT_MASK = (1 << COUNT_BITS) - 1;
 
     // runState is stored in the high-order bits
     private static final int RUNNING    = -1 << COUNT_BITS;
@@ -393,8 +393,8 @@
     private static final int TERMINATED =  3 << COUNT_BITS;
 
     // Packing and unpacking ctl
-    private static int runStateOf(int c)     { return c & ~CAPACITY; }
-    private static int workerCountOf(int c)  { return c & CAPACITY; }
+    private static int runStateOf(int c)     { return c & ~COUNT_MASK; }
+    private static int workerCountOf(int c)  { return c & COUNT_MASK; }
     private static int ctlOf(int rs, int wc) { return rs | wc; }
 
     /*
@@ -434,7 +434,7 @@
      * decrements are performed within getTask.
      */
     private void decrementWorkerCount() {
-        do {} while (! compareAndDecrementWorkerCount(ctl.get()));
+        ctl.addAndGet(-1);
     }
 
     /**
@@ -538,12 +538,17 @@
      * Core pool size is the minimum number of workers to keep alive
      * (and not allow to time out etc) unless allowCoreThreadTimeOut
      * is set, in which case the minimum is zero.
+     *
+     * Since the worker count is actually stored in COUNT_BITS bits,
+     * the effective limit is {@code corePoolSize & COUNT_MASK}.
      */
     private volatile int corePoolSize;
 
     /**
-     * Maximum pool size. Note that the actual maximum is internally
-     * bounded by CAPACITY.
+     * Maximum pool size.
+     *
+     * Since the worker count is actually stored in COUNT_BITS bits,
+     * the effective limit is {@code maximumPoolSize & COUNT_MASK}.
      */
     private volatile int maximumPoolSize;
 
@@ -705,7 +710,7 @@
             int c = ctl.get();
             if (isRunning(c) ||
                 runStateAtLeast(c, TIDYING) ||
-                (runStateOf(c) == SHUTDOWN && ! workQueue.isEmpty()))
+                (runStateLessThan(c, STOP) && ! workQueue.isEmpty()))
                 return;
             if (workerCountOf(c) != 0) { // Eligible to terminate
                 interruptIdleWorkers(ONLY_ONE);
@@ -744,17 +749,12 @@
      * specially.
      */
     private void checkShutdownAccess() {
+        // assert mainLock.isHeldByCurrentThread();
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             security.checkPermission(shutdownPerm);
-            final ReentrantLock mainLock = this.mainLock;
-            mainLock.lock();
-            try {
-                for (Worker w : workers)
-                    security.checkAccess(w.thread);
-            } finally {
-                mainLock.unlock();
-            }
+            for (Worker w : workers)
+                security.checkAccess(w.thread);
         }
     }
 
@@ -763,14 +763,9 @@
      * (in which case some threads may remain uninterrupted).
      */
     private void interruptWorkers() {
-        final ReentrantLock mainLock = this.mainLock;
-        mainLock.lock();
-        try {
-            for (Worker w : workers)
-                w.interruptIfStarted();
-        } finally {
-            mainLock.unlock();
-        }
+        // assert mainLock.isHeldByCurrentThread();
+        for (Worker w : workers)
+            w.interruptIfStarted();
     }
 
     /**
@@ -896,26 +891,22 @@
      */
     private boolean addWorker(Runnable firstTask, boolean core) {
         retry:
-        for (;;) {
-            int c = ctl.get();
-            int rs = runStateOf(c);
-
+        for (int c = ctl.get();;) {
             // Check if queue empty only if necessary.
-            if (rs >= SHUTDOWN &&
-                ! (rs == SHUTDOWN &&
-                   firstTask == null &&
-                   ! workQueue.isEmpty()))
+            if (runStateAtLeast(c, SHUTDOWN)
+                && (runStateAtLeast(c, STOP)
+                    || firstTask != null
+                    || workQueue.isEmpty()))
                 return false;
 
             for (;;) {
-                int wc = workerCountOf(c);
-                if (wc >= CAPACITY ||
-                    wc >= (core ? corePoolSize : maximumPoolSize))
+                if (workerCountOf(c)
+                    >= ((core ? corePoolSize : maximumPoolSize) & COUNT_MASK))
                     return false;
                 if (compareAndIncrementWorkerCount(c))
                     break retry;
                 c = ctl.get();  // Re-read ctl
-                if (runStateOf(c) != rs)
+                if (runStateAtLeast(c, SHUTDOWN))
                     continue retry;
                 // else CAS failed due to workerCount change; retry inner loop
             }
@@ -934,10 +925,10 @@
                     // Recheck while holding lock.
                     // Back out on ThreadFactory failure or if
                     // shut down before lock acquired.
-                    int rs = runStateOf(ctl.get());
+                    int c = ctl.get();
 
-                    if (rs < SHUTDOWN ||
-                        (rs == SHUTDOWN && firstTask == null)) {
+                    if (isRunning(c) ||
+                        (runStateLessThan(c, STOP) && firstTask == null)) {
                         if (t.isAlive()) // precheck that t is startable
                             throw new IllegalThreadStateException();
                         workers.add(w);
@@ -1044,10 +1035,10 @@
 
         for (;;) {
             int c = ctl.get();
-            int rs = runStateOf(c);
 
             // Check if queue empty only if necessary.
-            if (rs >= SHUTDOWN && (rs >= STOP || workQueue.isEmpty())) {
+            if (runStateAtLeast(c, SHUTDOWN)
+                && (runStateAtLeast(c, STOP) || workQueue.isEmpty())) {
                 decrementWorkerCount();
                 return null;
             }
@@ -1140,17 +1131,12 @@
                     wt.interrupt();
                 try {
                     beforeExecute(wt, task);
-                    Throwable thrown = null;
                     try {
                         task.run();
-                    } catch (RuntimeException x) {
-                        thrown = x; throw x;
-                    } catch (Error x) {
-                        thrown = x; throw x;
-                    } catch (Throwable x) {
-                        thrown = x; throw new Error(x);
-                    } finally {
-                        afterExecute(task, thrown);
+                        afterExecute(task, null);
+                    } catch (Throwable ex) {
+                        afterExecute(task, ex);
+                        throw ex;
                     }
                 } finally {
                     task = null;
@@ -1331,7 +1317,7 @@
      *
      * If the task cannot be submitted for execution, either because this
      * executor has been shutdown or because its capacity has been reached,
-     * the task is handled by the current {@code RejectedExecutionHandler}.
+     * the task is handled by the current {@link RejectedExecutionHandler}.
      *
      * @param command the task to execute
      * @throws RejectedExecutionException at discretion of
@@ -1438,7 +1424,7 @@
     }
 
     public boolean isShutdown() {
-        return ! isRunning(ctl.get());
+        return runStateAtLeast(ctl.get(), SHUTDOWN);
     }
 
     /** Used by ScheduledThreadPoolExecutor. */
@@ -1459,7 +1445,7 @@
      */
     public boolean isTerminating() {
         int c = ctl.get();
-        return ! isRunning(c) && runStateLessThan(c, TERMINATED);
+        return runStateAtLeast(c, SHUTDOWN) && runStateLessThan(c, TERMINATED);
     }
 
     public boolean isTerminated() {
@@ -1472,7 +1458,7 @@
         final ReentrantLock mainLock = this.mainLock;
         mainLock.lock();
         try {
-            while (!runStateAtLeast(ctl.get(), TERMINATED)) {
+            while (runStateLessThan(ctl.get(), TERMINATED)) {
                 if (nanos <= 0L)
                     return false;
                 nanos = termination.awaitNanos(nanos);
@@ -1951,7 +1937,7 @@
         }
         int c = ctl.get();
         String runState =
-            runStateLessThan(c, SHUTDOWN) ? "Running" :
+            isRunning(c) ? "Running" :
             runStateAtLeast(c, TERMINATED) ? "Terminated" :
             "Shutting down";
         return super.toString() +
--- a/src/java.base/share/classes/java/util/concurrent/TimeUnit.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/TimeUnit.java	Thu Oct 05 22:04:49 2017 +0200
@@ -342,11 +342,13 @@
      * using:
      *
      * <pre> {@code
-     * public synchronized Object poll(long timeout, TimeUnit unit)
+     * public E poll(long timeout, TimeUnit unit)
      *     throws InterruptedException {
-     *   while (empty) {
-     *     unit.timedWait(this, timeout);
-     *     ...
+     *   synchronized (lock) {
+     *     while (isEmpty()) {
+     *       unit.timedWait(lock, timeout);
+     *       ...
+     *     }
      *   }
      * }}</pre>
      *
--- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java	Thu Oct 05 22:04:49 2017 +0200
@@ -67,11 +67,11 @@
     private static final long serialVersionUID = 7373984972572414692L;
 
     /*
-      To keep sources in sync, the remainder of this source file is
-      exactly cloned from AbstractQueuedSynchronizer, replacing class
-      name and changing ints related with sync state to longs. Please
-      keep it that way.
-    */
+     * To keep sources in sync, the remainder of this source file is
+     * exactly cloned from AbstractQueuedSynchronizer, replacing class
+     * name and changing ints related with sync state to longs. Please
+     * keep it that way.
+     */
 
     /**
      * Creates a new {@code AbstractQueuedLongSynchronizer} instance
@@ -725,8 +725,7 @@
     /**
      * Returns {@code true} if synchronization is held exclusively with
      * respect to the current (calling) thread.  This method is invoked
-     * upon each call to a non-waiting {@link ConditionObject} method.
-     * (Waiting methods instead invoke {@link #release}.)
+     * upon each call to a {@link ConditionObject} method.
      *
      * <p>The default implementation throws {@link
      * UnsupportedOperationException}. This method is invoked
@@ -1366,9 +1365,8 @@
     }
 
     /**
-     * Condition implementation for a {@link
-     * AbstractQueuedLongSynchronizer} serving as the basis of a {@link
-     * Lock} implementation.
+     * Condition implementation for a {@link AbstractQueuedLongSynchronizer}
+     * serving as the basis of a {@link Lock} implementation.
      *
      * <p>Method documentation for this class describes mechanics,
      * not behavioral specifications from the point of view of Lock
@@ -1401,6 +1399,8 @@
          * @return its new wait node
          */
         private Node addConditionWaiter() {
+            if (!isHeldExclusively())
+                throw new IllegalMonitorStateException();
             Node t = lastWaiter;
             // If lastWaiter is cancelled, clean out.
             if (t != null && t.waitStatus != Node.CONDITION) {
--- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java	Thu Oct 05 22:04:49 2017 +0200
@@ -194,19 +194,13 @@
  * represent the locked state. While a non-reentrant lock
  * does not strictly require recording of the current owner
  * thread, this class does so anyway to make usage easier to monitor.
- * It also supports conditions and exposes
- * one of the instrumentation methods:
+ * It also supports conditions and exposes some instrumentation methods:
  *
  * <pre> {@code
  * class Mutex implements Lock, java.io.Serializable {
  *
  *   // Our internal helper class
  *   private static class Sync extends AbstractQueuedSynchronizer {
- *     // Reports whether in locked state
- *     protected boolean isHeldExclusively() {
- *       return getState() == 1;
- *     }
- *
  *     // Acquires the lock if state is zero
  *     public boolean tryAcquire(int acquires) {
  *       assert acquires == 1; // Otherwise unused
@@ -220,14 +214,27 @@
  *     // Releases the lock by setting state to zero
  *     protected boolean tryRelease(int releases) {
  *       assert releases == 1; // Otherwise unused
- *       if (getState() == 0) throw new IllegalMonitorStateException();
+ *       if (!isHeldExclusively())
+ *         throw new IllegalMonitorStateException();
  *       setExclusiveOwnerThread(null);
  *       setState(0);
  *       return true;
  *     }
  *
+ *     // Reports whether in locked state
+ *     public boolean isLocked() {
+ *       return getState() != 0;
+ *     }
+ *
+ *     public boolean isHeldExclusively() {
+ *       // a data race, but safe due to out-of-thin-air guarantees
+ *       return getExclusiveOwnerThread() == Thread.currentThread();
+ *     }
+ *
  *     // Provides a Condition
- *     Condition newCondition() { return new ConditionObject(); }
+ *     public Condition newCondition() {
+ *       return new ConditionObject();
+ *     }
  *
  *     // Deserializes properly
  *     private void readObject(ObjectInputStream s)
@@ -240,12 +247,17 @@
  *   // The sync object does all the hard work. We just forward to it.
  *   private final Sync sync = new Sync();
  *
- *   public void lock()                { sync.acquire(1); }
- *   public boolean tryLock()          { return sync.tryAcquire(1); }
- *   public void unlock()              { sync.release(1); }
- *   public Condition newCondition()   { return sync.newCondition(); }
- *   public boolean isLocked()         { return sync.isHeldExclusively(); }
- *   public boolean hasQueuedThreads() { return sync.hasQueuedThreads(); }
+ *   public void lock()              { sync.acquire(1); }
+ *   public boolean tryLock()        { return sync.tryAcquire(1); }
+ *   public void unlock()            { sync.release(1); }
+ *   public Condition newCondition() { return sync.newCondition(); }
+ *   public boolean isLocked()       { return sync.isLocked(); }
+ *   public boolean isHeldByCurrentThread() {
+ *     return sync.isHeldExclusively();
+ *   }
+ *   public boolean hasQueuedThreads() {
+ *     return sync.hasQueuedThreads();
+ *   }
  *   public void lockInterruptibly() throws InterruptedException {
  *     sync.acquireInterruptibly(1);
  *   }
@@ -1193,8 +1205,7 @@
     /**
      * Returns {@code true} if synchronization is held exclusively with
      * respect to the current (calling) thread.  This method is invoked
-     * upon each call to a non-waiting {@link ConditionObject} method.
-     * (Waiting methods instead invoke {@link #release}.)
+     * upon each call to a {@link ConditionObject} method.
      *
      * <p>The default implementation throws {@link
      * UnsupportedOperationException}. This method is invoked
@@ -1834,9 +1845,8 @@
     }
 
     /**
-     * Condition implementation for a {@link
-     * AbstractQueuedSynchronizer} serving as the basis of a {@link
-     * Lock} implementation.
+     * Condition implementation for a {@link AbstractQueuedSynchronizer}
+     * serving as the basis of a {@link Lock} implementation.
      *
      * <p>Method documentation for this class describes mechanics,
      * not behavioral specifications from the point of view of Lock
@@ -1867,6 +1877,8 @@
          * @return its new wait node
          */
         private Node addConditionWaiter() {
+            if (!isHeldExclusively())
+                throw new IllegalMonitorStateException();
             Node t = lastWaiter;
             // If lastWaiter is cancelled, clean out.
             if (t != null && t.waitStatus != Node.CONDITION) {
--- a/src/java.base/share/classes/java/util/concurrent/locks/Condition.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/locks/Condition.java	Thu Oct 05 22:04:49 2017 +0200
@@ -73,7 +73,7 @@
  * available in the buffer. This can be achieved using two
  * {@link Condition} instances.
  * <pre>
- * class BoundedBuffer {
+ * class BoundedBuffer&lt;E&gt; {
  *   <b>final Lock lock = new ReentrantLock();</b>
  *   final Condition notFull  = <b>lock.newCondition(); </b>
  *   final Condition notEmpty = <b>lock.newCondition(); </b>
@@ -81,7 +81,7 @@
  *   final Object[] items = new Object[100];
  *   int putptr, takeptr, count;
  *
- *   public void put(Object x) throws InterruptedException {
+ *   public void put(E x) throws InterruptedException {
  *     <b>lock.lock();
  *     try {</b>
  *       while (count == items.length)
@@ -95,12 +95,12 @@
  *     }</b>
  *   }
  *
- *   public Object take() throws InterruptedException {
+ *   public E take() throws InterruptedException {
  *     <b>lock.lock();
  *     try {</b>
  *       while (count == 0)
  *         <b>notEmpty.await();</b>
- *       Object x = items[takeptr];
+ *       E x = (E) items[takeptr];
  *       if (++takeptr == items.length) takeptr = 0;
  *       --count;
  *       <b>notFull.signal();</b>
@@ -310,7 +310,8 @@
      * the following form:
      *
      * <pre> {@code
-     * boolean aMethod(long timeout, TimeUnit unit) {
+     * boolean aMethod(long timeout, TimeUnit unit)
+     *     throws InterruptedException {
      *   long nanos = unit.toNanos(timeout);
      *   lock.lock();
      *   try {
@@ -320,6 +321,7 @@
      *       nanos = theCondition.awaitNanos(nanos);
      *     }
      *     // ...
+     *     return true;
      *   } finally {
      *     lock.unlock();
      *   }
@@ -410,7 +412,8 @@
      * <p>The return value indicates whether the deadline has elapsed,
      * which can be used as follows:
      * <pre> {@code
-     * boolean aMethod(Date deadline) {
+     * boolean aMethod(Date deadline)
+     *     throws InterruptedException {
      *   boolean stillWaiting = true;
      *   lock.lock();
      *   try {
@@ -420,6 +423,7 @@
      *       stillWaiting = theCondition.awaitUntil(deadline);
      *     }
      *     // ...
+     *     return true;
      *   } finally {
      *     lock.unlock();
      *   }
--- a/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java	Thu Oct 05 22:04:49 2017 +0200
@@ -151,18 +151,20 @@
  *   }
  *
  *   double distanceFromOrigin() { // A read-only method
+ *     double currentX, currentY;
  *     long stamp = sl.tryOptimisticRead();
- *     double currentX = x, currentY = y;
- *     if (!sl.validate(stamp)) {
- *       stamp = sl.readLock();
+ *     do {
+ *       if (stamp == 0L)
+ *         stamp = sl.readLock();
  *       try {
+ *         // possibly racy reads
  *         currentX = x;
  *         currentY = y;
  *       } finally {
- *         sl.unlockRead(stamp);
+ *         stamp = sl.tryConvertToOptimisticRead(stamp);
  *       }
- *     }
- *     return Math.sqrt(currentX * currentX + currentY * currentY);
+ *     } while (stamp == 0);
+ *     return Math.hypot(currentX, currentY);
  *   }
  *
  *   void moveIfAtOrigin(double newX, double newY) { // upgrade
--- a/src/java.base/share/classes/sun/security/util/Cache.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/share/classes/sun/security/util/Cache.java	Thu Oct 05 22:04:49 2017 +0200
@@ -164,7 +164,7 @@
     public static class EqualByteArray {
 
         private final byte[] b;
-        private volatile int hash;
+        private int hash;
 
         public EqualByteArray(byte[] b) {
             this.b = b;
@@ -172,12 +172,8 @@
 
         public int hashCode() {
             int h = hash;
-            if (h == 0) {
-                h = b.length + 1;
-                for (int i = 0; i < b.length; i++) {
-                    h += (b[i] & 0xff) * 37;
-                }
-                hash = h;
+            if (h == 0 && b.length > 0) {
+                hash = h = Arrays.hashCode(b);
             }
             return h;
         }
--- a/src/java.base/windows/native/libnet/NetworkInterface_winXP.c	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.base/windows/native/libnet/NetworkInterface_winXP.c	Thu Oct 05 22:04:49 2017 +0200
@@ -62,7 +62,8 @@
 
 #endif
 
-static int bufsize = 4096;
+const ULONG BUFF_SIZE = 15360;
+const int MAX_TRIES = 3;
 
 /*
  * return an array of IP_ADAPTER_ADDRESSES containing one element
@@ -80,23 +81,23 @@
     int _ret = 0;
 
 
-    adapterInfo = (IP_ADAPTER_ADDRESSES *)malloc (bufsize);
+    adapterInfo = (IP_ADAPTER_ADDRESSES *) malloc(BUFF_SIZE);
     if (adapterInfo == NULL) {
         JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
             "Native heap allocation failure");
         return -1;
     }
 
-    len = bufsize;
+    len = BUFF_SIZE;
     flags = GAA_FLAG_SKIP_DNS_SERVER;
     flags |= GAA_FLAG_SKIP_MULTICAST;
     flags |= GAA_FLAG_INCLUDE_PREFIX;
     ret = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
 
-    if (ret == ERROR_BUFFER_OVERFLOW) {
+    for (int try = 0; ret == ERROR_BUFFER_OVERFLOW && try < MAX_TRIES; ++try) {
         IP_ADAPTER_ADDRESSES * newAdapterInfo = NULL;
-        if (len  < (ULONG_MAX - bufsize)) {
-            len = len + bufsize;
+        if (len < (ULONG_MAX - BUFF_SIZE)) {
+            len += BUFF_SIZE;
         }
         newAdapterInfo =
             (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
@@ -159,21 +160,21 @@
     size_t error_msg_buf_size =
         strlen("IP Helper Library GetAdaptersAddresses function failed with error == ") + 10;
     int _ret = 0;
-    adapterInfo = (IP_ADAPTER_ADDRESSES *)malloc (bufsize);
+    adapterInfo = (IP_ADAPTER_ADDRESSES *) malloc(BUFF_SIZE);
     if (adapterInfo == NULL) {
         JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
             "Native heap allocation failure");
         return NULL;
     }
-    len = bufsize;
+    len = BUFF_SIZE;
     flags = GAA_FLAG_SKIP_DNS_SERVER;
     flags |= GAA_FLAG_SKIP_MULTICAST;
     flags |= GAA_FLAG_INCLUDE_PREFIX;
     val = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
-    if (val == ERROR_BUFFER_OVERFLOW) {
+    for (int try = 0; val == ERROR_BUFFER_OVERFLOW && try < MAX_TRIES; ++try) {
         IP_ADAPTER_ADDRESSES * newAdapterInfo = NULL;
-        if (len  < (ULONG_MAX - bufsize)) {
-            len = len + bufsize;
+        if (len < (ULONG_MAX - BUFF_SIZE)) {
+            len += BUFF_SIZE;
         }
         newAdapterInfo =
                 (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/XalanConstants.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/XalanConstants.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +26,7 @@
 
 package com.sun.org.apache.xalan.internal;
 
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Commonly used constants.
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLMessages.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLMessages.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,10 +21,9 @@
 
 package com.sun.org.apache.xalan.internal.res;
 
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
-import java.util.ListResourceBundle;
-
 import com.sun.org.apache.xpath.internal.res.XPATHMessages;
+import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Sets things up for issuing error messages. This class is misnamed, and should
@@ -37,7 +36,7 @@
     /**
      * The language specific resource object for Xalan messages.
      */
-    private static ListResourceBundle XSLTBundle = null;
+    private static ResourceBundle XSLTBundle = null;
     /**
      * The class name of the Xalan error message string table.
      */
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.org.apache.xalan.internal.utils;
 
 import com.sun.org.apache.xalan.internal.XalanConstants;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * This is the base class for features and properties
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,6 +22,7 @@
 package com.sun.org.apache.xalan.internal.utils;
 
 import java.util.function.Supplier;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * This class is duplicated for each JAXP subpackage so keep it in sync.
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,326 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- */
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.org.apache.xalan.internal.utils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Properties;
-
-/**
- * This class is duplicated for each subpackage so keep it in sync. It is
- * package private and therefore is not exposed as part of any API.
- *
- * @xerces.internal
- */
-public final class SecuritySupport {
-
-    private static final SecuritySupport securitySupport = new SecuritySupport();
-
-    /**
-     * Return an instance of this class.
-     */
-    public static SecuritySupport getInstance() {
-        return securitySupport;
-    }
-
-    public static ClassLoader getContextClassLoader() {
-        return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader cl = null;
-                try {
-                    cl = Thread.currentThread().getContextClassLoader();
-                } catch (SecurityException ex) {
-                }
-                return cl;
-            }
-        });
-    }
-
-    static ClassLoader getSystemClassLoader() {
-        return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader cl = null;
-                try {
-                    cl = ClassLoader.getSystemClassLoader();
-                } catch (SecurityException ex) {
-                }
-                return cl;
-            }
-        });
-    }
-
-    static ClassLoader getParentClassLoader(final ClassLoader cl) {
-        return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader parent = null;
-                try {
-                    parent = cl.getParent();
-                } catch (SecurityException ex) {
-                }
-
-                // eliminate loops in case of the boot
-                // ClassLoader returning itself as a parent
-                return (parent == cl) ? null : parent;
-            }
-        });
-    }
-
-    public static String getSystemProperty(final String propName) {
-        return (String) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                return System.getProperty(propName);
-            }
-        });
-    }
-
-    public static String getSystemProperty(final String propName, final String def) {
-        return (String) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                return System.getProperty(propName, def);
-            }
-        });
-    }
-
-    static FileInputStream getFileInputStream(final File file)
-            throws FileNotFoundException {
-        try {
-            return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                public Object run() throws FileNotFoundException {
-                    return new FileInputStream(file);
-                }
-            });
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-    public static InputStream getResourceAsStream(final String name) {
-        return (InputStream) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                return SecuritySupport.class.getResourceAsStream("/"+name);
-            }
-        });
-    }
-
-    /**
-     * Gets a resource bundle using the specified base name, the default locale, and the caller's class loader.
-     * @param bundle the base name of the resource bundle, a fully qualified class name
-     * @return a resource bundle for the given base name and the default locale
-     */
-    public static ListResourceBundle getResourceBundle(String bundle) {
-        return getResourceBundle(bundle, Locale.getDefault());
-    }
-
-    /**
-     * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
-     * @param bundle the base name of the resource bundle, a fully qualified class name
-     * @param locale the locale for which a resource bundle is desired
-     * @return a resource bundle for the given base name and locale
-     */
-    public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
-        return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
-            public ListResourceBundle run() {
-                try {
-                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
-                } catch (MissingResourceException e) {
-                    try {
-                        return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
-                    } catch (MissingResourceException e2) {
-                        throw new MissingResourceException(
-                                "Could not load any resource bundle by " + bundle, bundle, "");
-                    }
-                }
-            }
-        });
-    }
-
-    public static boolean getFileExists(final File f) {
-        return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
-                        return f.exists() ? Boolean.TRUE : Boolean.FALSE;
-                    }
-                })).booleanValue();
-    }
-
-    static long getLastModified(final File f) {
-        return ((Long) AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
-                        return f.lastModified();
-                    }
-                })).longValue();
-    }
-
-    /**
-     * Strip off path from an URI
-     *
-     * @param uri an URI with full path
-     * @return the file name only
-     */
-    public static String sanitizePath(String uri) {
-        if (uri == null) {
-            return "";
-        }
-        int i = uri.lastIndexOf("/");
-        if (i > 0) {
-            return uri.substring(i+1, uri.length());
-        }
-        return "";
-    }
-
-    /**
-     * Check the protocol used in the systemId against allowed protocols
-     *
-     * @param systemId the Id of the URI
-     * @param allowedProtocols a list of allowed protocols separated by comma
-     * @param accessAny keyword to indicate allowing any protocol
-     * @return the name of the protocol if rejected, null otherwise
-     */
-    public static String checkAccess(String systemId, String allowedProtocols, String accessAny) throws IOException {
-        if (systemId == null || (allowedProtocols != null &&
-                allowedProtocols.equalsIgnoreCase(accessAny))) {
-            return null;
-        }
-
-        String protocol;
-        if (systemId.indexOf(":")==-1) {
-            protocol = "file";
-        } else {
-            URL url = new URL(systemId);
-            protocol = url.getProtocol();
-            if (protocol.equalsIgnoreCase("jar")) {
-                String path = url.getPath();
-                protocol = path.substring(0, path.indexOf(":"));
-            } else if (protocol.equalsIgnoreCase("jrt")) {
-                // if the systemId is "jrt" then allow access if "file" allowed
-                protocol = "file";
-            }
-        }
-
-        if (isProtocolAllowed(protocol, allowedProtocols)) {
-            //access allowed
-            return null;
-        } else {
-            return protocol;
-        }
-    }
-
-    /**
-     * Check if the protocol is in the allowed list of protocols. The check
-     * is case-insensitive while ignoring whitespaces.
-     *
-     * @param protocol a protocol
-     * @param allowedProtocols a list of allowed protocols
-     * @return true if the protocol is in the list
-     */
-    private static boolean isProtocolAllowed(String protocol, String allowedProtocols) {
-         if (allowedProtocols == null) {
-             return false;
-         }
-         String temp[] = allowedProtocols.split(",");
-         for (String t : temp) {
-             t = t.trim();
-             if (t.equalsIgnoreCase(protocol)) {
-                 return true;
-             }
-         }
-         return false;
-     }
-
-    /**
-     * Read JAXP system property in this order: system property,
-     * $java.home/conf/jaxp.properties if the system property is not specified
-     *
-     * @param propertyId the Id of the property
-     * @return the value of the property
-     */
-    public static String getJAXPSystemProperty(String sysPropertyId) {
-        String accessExternal = getSystemProperty(sysPropertyId);
-        if (accessExternal == null) {
-            accessExternal = readJAXPProperty(sysPropertyId);
-        }
-        return accessExternal;
-    }
-
-    /**
-     * Read from $java.home/conf/jaxp.properties for the specified property
-     * The program
-     *
-     * @param propertyId the Id of the property
-     * @return the value of the property
-     */
-    static String readJAXPProperty(String propertyId) {
-        String value = null;
-        InputStream is = null;
-        try {
-            if (firstTime) {
-                synchronized (cacheProps) {
-                    if (firstTime) {
-                        String configFile = getSystemProperty("java.home") + File.separator +
-                            "conf" + File.separator + "jaxp.properties";
-                        File f = new File(configFile);
-                        if (getFileExists(f)) {
-                            is = getFileInputStream(f);
-                            cacheProps.load(is);
-                        }
-                        firstTime = false;
-                    }
-                }
-            }
-            value = cacheProps.getProperty(propertyId);
-
-        }
-        catch (Exception ex) {}
-        finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException ex) {}
-            }
-        }
-
-        return value;
-    }
-
-    /**
-     * Cache for properties in java.home/conf/jaxp.properties
-     */
-    static final Properties cacheProps = new Properties();
-
-    /**
-     * Flag indicating if the program has tried reading java.home/conf/jaxp.properties
-     */
-    static volatile boolean firstTime = true;
-
-    private SecuritySupport () {}
-}
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 
 import com.sun.org.apache.xalan.internal.XalanConstants;
 import java.util.concurrent.CopyOnWriteArrayList;
+import jdk.xml.internal.SecuritySupport;
 import org.xml.sax.SAXException;
 
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Import.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,7 +25,6 @@
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
 import com.sun.org.apache.xalan.internal.XalanConstants;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
@@ -33,6 +33,7 @@
 import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
 import java.util.Iterator;
 import javax.xml.XMLConstants;
+import jdk.xml.internal.SecuritySupport;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Include.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,7 +25,6 @@
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
 import com.sun.org.apache.xalan.internal.XalanConstants;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
@@ -33,6 +33,7 @@
 import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
 import java.util.Iterator;
 import javax.xml.XMLConstants;
+import jdk.xml.internal.SecuritySupport;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,7 +25,6 @@
 import com.sun.org.apache.xalan.internal.XalanConstants;
 import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType;
@@ -49,6 +49,7 @@
 import javax.xml.parsers.SAXParserFactory;
 import jdk.xml.internal.JdkXmlFeatures;
 import jdk.xml.internal.JdkXmlUtils;
+import jdk.xml.internal.SecuritySupport;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,12 +23,10 @@
 
 import com.sun.org.apache.bcel.internal.classfile.JavaClass;
 import com.sun.org.apache.xalan.internal.XalanConstants;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
 import com.sun.org.apache.xml.internal.dtm.DTM;
-import java.io.BufferedOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -51,6 +50,7 @@
 import javax.xml.catalog.CatalogFeatures;
 import jdk.xml.internal.JdkXmlFeatures;
 import jdk.xml.internal.JdkXmlUtils;
+import jdk.xml.internal.SecuritySupport;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 
@@ -730,7 +730,7 @@
      */
     public boolean setDestDirectory(String dstDirName) {
         final File dir = new File(dstDirName);
-        if (SecuritySupport.getFileExists(dir) || dir.mkdirs()) {
+        if (SecuritySupport.doesFileExist(dir) || dir.mkdirs()) {
             _destDir = dir;
             return true;
         }
@@ -902,7 +902,7 @@
             String parentDir = outFile.getParent();
             if (parentDir != null) {
                 File parentFile = new File(parentDir);
-                if (!SecuritySupport.getFileExists(parentFile))
+                if (!SecuritySupport.doesFileExist(parentFile))
                     parentFile.mkdirs();
             }
         }
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,13 +21,12 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
 
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode;
 import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.ResourceBundle;
-
-import com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * @author Jacek Ambroziak
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/Util.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/Util.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,12 +21,11 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
 
-import java.util.StringTokenizer;
-
 import com.sun.org.apache.bcel.internal.generic.Type;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
 import com.sun.org.apache.xml.internal.utils.XML11Char;
+import java.util.StringTokenizer;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * @author Jacek Ambroziak
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/LoadDocument.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/LoadDocument.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,10 +22,6 @@
 package com.sun.org.apache.xalan.internal.xsltc.dom;
 
 import com.sun.org.apache.xalan.internal.XalanConstants;
-import java.io.FileNotFoundException;
-
-import javax.xml.transform.stream.StreamSource;
-
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
 import com.sun.org.apache.xalan.internal.xsltc.DOMCache;
 import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
@@ -33,16 +29,14 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
 import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xml.internal.dtm.DTM;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
 import com.sun.org.apache.xml.internal.dtm.DTMManager;
-import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
 import com.sun.org.apache.xml.internal.dtm.ref.EmptyIterator;
 import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
-
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
+import java.io.FileNotFoundException;
+import javax.xml.transform.stream.StreamSource;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * @author Morten Jorgensen
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,17 +21,16 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.dom;
 
-import java.text.CollationKey;
-import java.text.Collator;
-import java.util.Locale;
-
+import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
 import com.sun.org.apache.xalan.internal.xsltc.CollatorFactory;
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
 import com.sun.org.apache.xalan.internal.xsltc.TransletException;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
 import com.sun.org.apache.xml.internal.utils.StringComparable;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import java.text.CollationKey;
+import java.text.Collator;
+import java.util.Locale;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Base class for sort records containing application specific sort keys
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -23,7 +24,23 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.runtime;
 
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import com.sun.org.apache.xalan.internal.xsltc.DOM;
+import com.sun.org.apache.xalan.internal.xsltc.Translet;
+import com.sun.org.apache.xalan.internal.xsltc.dom.AbsoluteIterator;
+import com.sun.org.apache.xalan.internal.xsltc.dom.ArrayNodeListIterator;
+import com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter;
+import com.sun.org.apache.xalan.internal.xsltc.dom.MultiDOM;
+import com.sun.org.apache.xalan.internal.xsltc.dom.SingletonIterator;
+import com.sun.org.apache.xalan.internal.xsltc.dom.StepIterator;
+import com.sun.org.apache.xml.internal.dtm.Axis;
+import com.sun.org.apache.xml.internal.dtm.DTM;
+import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
+import com.sun.org.apache.xml.internal.dtm.DTMManager;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy;
+import com.sun.org.apache.xml.internal.serializer.NamespaceMappings;
+import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
+import com.sun.org.apache.xml.internal.utils.XML11Char;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.text.FieldPosition;
@@ -33,31 +50,13 @@
 import java.util.ResourceBundle;
 import java.util.concurrent.atomic.AtomicInteger;
 import javax.xml.transform.dom.DOMSource;
-
-import com.sun.org.apache.xalan.internal.xsltc.DOM;
-import com.sun.org.apache.xalan.internal.xsltc.Translet;
-import com.sun.org.apache.xalan.internal.xsltc.dom.AbsoluteIterator;
-import com.sun.org.apache.xml.internal.dtm.Axis;
-import com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter;
-import com.sun.org.apache.xalan.internal.xsltc.dom.MultiDOM;
-import com.sun.org.apache.xalan.internal.xsltc.dom.SingletonIterator;
-import com.sun.org.apache.xalan.internal.xsltc.dom.StepIterator;
-import com.sun.org.apache.xalan.internal.xsltc.dom.ArrayNodeListIterator;
-import com.sun.org.apache.xml.internal.dtm.DTM;
-import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
-import com.sun.org.apache.xml.internal.dtm.DTMManager;
-import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
-import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy;
-
+import jdk.xml.internal.SecuritySupport;
+import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
-import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
-import com.sun.org.apache.xml.internal.serializer.NamespaceMappings;
-import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
-import com.sun.org.apache.xml.internal.utils.XML11Char;
 
 /**
  * Standard XSLT functions. All standard functions expect the current node
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/output/WriterOutputBuffer.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/output/WriterOutputBuffer.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,10 +21,10 @@
 
 package com.sun.org.apache.xalan.internal.xsltc.runtime.output;
 
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.Writer;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * @author Santiago Pericas-Geertsen
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,7 +26,6 @@
 
 import com.sun.org.apache.xalan.internal.XalanConstants;
 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
 import com.sun.org.apache.xalan.internal.xsltc.Translet;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
@@ -41,8 +41,8 @@
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReader;
 import java.lang.module.ModuleReference;
-import java.lang.module.ModuleReader;
 import java.lang.reflect.InvocationTargetException;
 import java.security.AccessController;
 import java.security.CodeSigner;
@@ -61,6 +61,7 @@
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.URIResolver;
+import jdk.xml.internal.SecuritySupport;
 
 
 /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,10 +25,9 @@
 import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
 import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase;
 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
+import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager.Property;
 import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager;
-import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager.Property;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
@@ -52,8 +52,8 @@
 import java.util.zip.ZipFile;
 import javax.xml.XMLConstants;
 import javax.xml.catalog.CatalogException;
+import javax.xml.catalog.CatalogFeatures.Feature;
 import javax.xml.catalog.CatalogFeatures;
-import javax.xml.catalog.CatalogFeatures.Feature;
 import javax.xml.catalog.CatalogManager;
 import javax.xml.catalog.CatalogResolver;
 import javax.xml.parsers.SAXParser;
@@ -78,6 +78,7 @@
 import javax.xml.transform.stream.StreamSource;
 import jdk.xml.internal.JdkXmlFeatures;
 import jdk.xml.internal.JdkXmlUtils;
+import jdk.xml.internal.SecuritySupport;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLFilter;
 import org.xml.sax.XMLReader;
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,7 +25,6 @@
 import com.sun.org.apache.xerces.internal.util.XML11Char;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
 import java.io.IOException;
 import java.io.ObjectInputStream;
@@ -34,6 +34,7 @@
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
+import jdk.xml.internal.SecuritySupport;
 import org.w3c.dom.Attr;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.Comment;
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -54,7 +55,6 @@
 import javax.xml.XMLConstants;
 import javax.xml.catalog.CatalogFeatures;
 import jdk.xml.internal.JdkXmlUtils;
-import jdk.xml.internal.SecuritySupport;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMErrorHandler;
 import org.w3c.dom.DOMException;
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,10 +21,10 @@
 
 
 package com.sun.org.apache.xerces.internal.dom;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Used to format DOM error messages, using the system locale.
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,9 +21,9 @@
 
 package com.sun.org.apache.xerces.internal.impl;
 
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Enumeration;
 import java.util.NoSuchElementException;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Commonly used constants.
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/PropertyManager.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/PropertyManager.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLResolver;
 import jdk.xml.internal.JdkXmlUtils;
-import jdk.xml.internal.SecuritySupport;
 
 /**
  *  This class manages different properties related to Stax specification and its implementation.
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 
 /*
@@ -27,6 +28,10 @@
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
+import com.sun.org.apache.xerces.internal.xni.Augmentations;
 import com.sun.org.apache.xerces.internal.xni.QName;
 import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
@@ -38,11 +43,6 @@
 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
-import com.sun.org.apache.xerces.internal.xni.Augmentations;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
 import com.sun.xml.internal.stream.XMLBufferListener;
 import com.sun.xml.internal.stream.XMLEntityStorage;
 import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;
@@ -53,6 +53,7 @@
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.events.XMLEvent;
 import jdk.xml.internal.JdkXmlUtils;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  *
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 
 /*
@@ -27,7 +28,6 @@
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLResourceIdentifierImpl;
 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.org.apache.xerces.internal.xni.Augmentations;
 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
@@ -43,6 +43,7 @@
 import java.io.IOException;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.events.XMLEvent;
+import jdk.xml.internal.SecuritySupport;
 
 
 /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -27,7 +28,6 @@
 import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
 import com.sun.org.apache.xerces.internal.util.*;
 import com.sun.org.apache.xerces.internal.util.URI;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
@@ -52,13 +52,14 @@
 import java.util.StringTokenizer;
 import javax.xml.XMLConstants;
 import javax.xml.catalog.CatalogException;
+import javax.xml.catalog.CatalogFeatures.Feature;
 import javax.xml.catalog.CatalogFeatures;
-import javax.xml.catalog.CatalogFeatures.Feature;
 import javax.xml.catalog.CatalogManager;
 import javax.xml.catalog.CatalogResolver;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.transform.Source;
 import jdk.xml.internal.JdkXmlUtils;
+import jdk.xml.internal.SecuritySupport;
 import org.xml.sax.InputSource;
 
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,10 +21,10 @@
 
 package com.sun.org.apache.xerces.internal.impl.dv;
 
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-import java.util.MissingResourceException;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Base class for datatype exceptions. For DTD types, the exception can be
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,10 +22,10 @@
 package com.sun.org.apache.xerces.internal.impl.msg;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,13 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,13 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,13 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,13 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,13 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,13 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,13 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,13 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,13 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,13 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.impl.msg;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,11 +21,11 @@
 
 package com.sun.org.apache.xerces.internal.impl.xpath.regex;
 
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import java.util.ArrayList;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
-import java.util.ArrayList;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * A Regular Expression Parser.
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -41,7 +42,6 @@
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
 import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
 import com.sun.org.apache.xerces.internal.xni.QName;
@@ -77,6 +77,7 @@
 import java.util.WeakHashMap;
 import javax.xml.XMLConstants;
 import jdk.xml.internal.JdkXmlUtils;
+import jdk.xml.internal.SecuritySupport;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMError;
 import org.w3c.dom.DOMErrorHandler;
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -87,7 +88,6 @@
 import java.util.Vector;
 import javax.xml.XMLConstants;
 import jdk.xml.internal.JdkXmlUtils;
-import jdk.xml.internal.SecuritySupport;
 
 /**
  * The XML Schema validator. The validator implements a document
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,10 +22,10 @@
 package com.sun.org.apache.xerces.internal.impl.xs;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 
 /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,9 +21,6 @@
 
 package com.sun.org.apache.xerces.internal.impl.xs.opti;
 
-import java.io.IOException;
-import java.util.Locale;
-
 import com.sun.org.apache.xerces.internal.impl.Constants;
 import com.sun.org.apache.xerces.internal.impl.XML11DTDScannerImpl;
 import com.sun.org.apache.xerces.internal.impl.XML11NSDocumentScannerImpl;
@@ -50,6 +48,8 @@
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration;
+import java.io.IOException;
+import java.util.Locale;
 import javax.xml.XMLConstants;
 import jdk.xml.internal.JdkXmlUtils;
 import jdk.xml.internal.SecuritySupport;
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -61,7 +62,6 @@
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
 import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
 import com.sun.org.apache.xerces.internal.xni.QName;
@@ -107,6 +107,7 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import jdk.xml.internal.JdkXmlUtils;
+import jdk.xml.internal.SecuritySupport;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -26,7 +26,6 @@
 package com.sun.org.apache.xerces.internal.jaxp.datatype;
 
 import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.Serializable;
@@ -42,6 +41,7 @@
 import javax.xml.datatype.Duration;
 import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.namespace.QName;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * <p>Representation for W3C XML Schema 1.0 date/time datatypes.
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,10 +21,10 @@
 
 package com.sun.org.apache.xerces.internal.jaxp.validation;
 
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * <p>Used to format JAXP Validation API error messages using a specified locale.</p>
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -68,7 +69,6 @@
 import javax.xml.XMLConstants;
 import javax.xml.catalog.CatalogFeatures;
 import jdk.xml.internal.JdkXmlUtils;
-import jdk.xml.internal.SecuritySupport;
 
 /**
  * This class is the configuration used to parse XML 1.0 and XML 1.1 documents.
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,10 +21,10 @@
 
 package com.sun.org.apache.xerces.internal.util;
 
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * <p>Used to format JAXP 1.3 Datatype API error messages using a specified locale.</p>
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,10 +21,10 @@
 
 package com.sun.org.apache.xerces.internal.util;
 
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Used to format SAX error messages using a specified locale.
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,6 +22,7 @@
 package com.sun.org.apache.xerces.internal.utils;
 
 import java.util.function.Supplier;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * This class is duplicated for each JAXP subpackage so keep it in sync.
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,295 +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.
- */
-
-package com.sun.org.apache.xerces.internal.utils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.Properties;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-
-/**
- * This class is duplicated for each subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of any API.
- *
- * @xerces.internal
- */
-public final class SecuritySupport {
-
-    private static final SecuritySupport securitySupport = new SecuritySupport();
-
-    /**
-     * Return an instance of this class.
-     * @return an instance of this class
-     */
-    public static SecuritySupport getInstance() {
-        return securitySupport;
-    }
-
-    static ClassLoader getContextClassLoader() {
-        return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> {
-            ClassLoader cl = null;
-            try {
-                cl = Thread.currentThread().getContextClassLoader();
-            } catch (SecurityException ex) { }
-            return cl;
-        });
-    }
-
-    static ClassLoader getSystemClassLoader() {
-        return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> {
-            ClassLoader cl = null;
-            try {
-                cl = ClassLoader.getSystemClassLoader();
-            } catch (SecurityException ex) {}
-            return cl;
-        });
-    }
-
-    static ClassLoader getParentClassLoader(final ClassLoader cl) {
-        return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> {
-            ClassLoader parent = null;
-            try {
-                parent = cl.getParent();
-            } catch (SecurityException ex) {}
-
-            // eliminate loops in case of the boot
-            // ClassLoader returning itself as a parent
-            return (parent == cl) ? null : parent;
-        });
-    }
-
-    public static String getSystemProperty(final String propName) {
-        return AccessController.doPrivileged((PrivilegedAction<String>) () ->
-                System.getProperty(propName));
-    }
-
-    static FileInputStream getFileInputStream(final File file)
-    throws FileNotFoundException
-    {
-        try {
-            return AccessController.doPrivileged(
-                    (PrivilegedExceptionAction<FileInputStream>)() ->
-                    new FileInputStream(file));
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-    /**
-     * Gets a resource bundle using the specified base name, the default locale, and the caller's class loader.
-     * @param bundle the base name of the resource bundle, a fully qualified class name
-     * @return a resource bundle for the given base name and the default locale
-     */
-    public static ResourceBundle getResourceBundle(String bundle) {
-        return getResourceBundle(bundle, Locale.getDefault());
-    }
-
-    /**
-     * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
-     * @param bundle the base name of the resource bundle, a fully qualified class name
-     * @param locale the locale for which a resource bundle is desired
-     * @return a resource bundle for the given base name and locale
-     */
-    public static ResourceBundle getResourceBundle(final String bundle, final Locale locale) {
-        return AccessController.doPrivileged((PrivilegedAction<ResourceBundle>) () -> {
-            try {
-                return PropertyResourceBundle.getBundle(bundle, locale);
-            } catch (MissingResourceException e) {
-                try {
-                    return PropertyResourceBundle.getBundle(bundle, new Locale("en", "US"));
-                } catch (MissingResourceException e2) {
-                    throw new MissingResourceException(
-                            "Could not load any resource bundle by " + bundle, bundle, "");
-                }
-            }
-        });
-    }
-
-    static boolean getFileExists(final File f) {
-        return (AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
-                f.exists()));
-    }
-
-    static long getLastModified(final File f) {
-        return (AccessController.doPrivileged((PrivilegedAction<Long>) () ->
-                f.lastModified()));
-    }
-
-    /**
-     * Strip off path from an URI
-     *
-     * @param uri an URI with full path
-     * @return the file name only
-     */
-    public static String sanitizePath(String uri) {
-        if (uri == null) {
-            return "";
-        }
-        int i = uri.lastIndexOf("/");
-        if (i > 0) {
-            return uri.substring(i+1, uri.length());
-        }
-        return uri;
-    }
-
-    /**
-     * Check the protocol used in the systemId against allowed protocols
-     *
-     * @param systemId the Id of the URI
-     * @param allowedProtocols a list of allowed protocols separated by comma
-     * @param accessAny keyword to indicate allowing any protocol
-     * @return the name of the protocol if rejected, null otherwise
-     * @throws java.io.IOException
-     */
-    public static String checkAccess(String systemId, String allowedProtocols, String accessAny) throws IOException {
-        if (systemId == null || (allowedProtocols != null &&
-                allowedProtocols.equalsIgnoreCase(accessAny))) {
-            return null;
-        }
-
-        String protocol;
-        if (!systemId.contains(":")) {
-            protocol = "file";
-        } else {
-            URL url = new URL(systemId);
-            protocol = url.getProtocol();
-            if (protocol.equalsIgnoreCase("jar")) {
-                String path = url.getPath();
-                protocol = path.substring(0, path.indexOf(":"));
-            } else if (protocol.equalsIgnoreCase("jrt")) {
-                // if the systemId is "jrt" then allow access if "file" allowed
-                protocol = "file";
-            }
-        }
-
-        if (isProtocolAllowed(protocol, allowedProtocols)) {
-            //access allowed
-            return null;
-        } else {
-            return protocol;
-        }
-    }
-
-    /**
-     * Check if the protocol is in the allowed list of protocols. The check
-     * is case-insensitive while ignoring whitespaces.
-     *
-     * @param protocol a protocol
-     * @param allowedProtocols a list of allowed protocols
-     * @return true if the protocol is in the list
-     */
-    private static boolean isProtocolAllowed(String protocol, String allowedProtocols) {
-         if (allowedProtocols == null) {
-             return false;
-         }
-         String temp[] = allowedProtocols.split(",");
-         for (String t : temp) {
-             t = t.trim();
-             if (t.equalsIgnoreCase(protocol)) {
-                 return true;
-             }
-         }
-         return false;
-     }
-
-    /**
-     * Read JAXP system property in this order: system property,
-     * $java.home/conf/jaxp.properties if the system property is not specified
-     *
-     * @param sysPropertyId the Id of the property
-     * @return the value of the property
-     */
-    public static String getJAXPSystemProperty(String sysPropertyId) {
-        String value = getSystemProperty(sysPropertyId);
-        if (value == null) {
-            value = readJAXPProperty(sysPropertyId);
-        }
-        return value;
-    }
-
-     /**
-     * Read from $java.home/conf/jaxp.properties for the specified property
-     * The program
-     *
-     * @param propertyId the Id of the property
-     * @return the value of the property
-     */
-    static String readJAXPProperty(String propertyId) {
-        String value = null;
-        InputStream is = null;
-        try {
-            if (firstTime) {
-                synchronized (cacheProps) {
-                    if (firstTime) {
-                        String configFile = getSystemProperty("java.home") + File.separator +
-                            "conf" + File.separator + "jaxp.properties";
-                        File f = new File(configFile);
-                        if (getFileExists(f)) {
-                            is = getFileInputStream(f);
-                            cacheProps.load(is);
-                        }
-                        firstTime = false;
-                    }
-                }
-            }
-            value = cacheProps.getProperty(propertyId);
-
-        }
-        catch (IOException ex) {}
-        finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException ex) {}
-            }
-        }
-
-        return value;
-    }
-
-   /**
-     * Cache for properties in java.home/conf/jaxp.properties
-     */
-    static final Properties cacheProps = new Properties();
-
-    /**
-     * Flag indicating if the program has tried reading java.home/conf/jaxp.properties
-     */
-    static volatile boolean firstTime = true;
-
-    private SecuritySupport () {}
-}
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import com.sun.org.apache.xerces.internal.impl.Constants;
 import com.sun.org.apache.xerces.internal.util.SecurityManager;
 import java.util.concurrent.CopyOnWriteArrayList;
+import jdk.xml.internal.SecuritySupport;
 import org.xml.sax.SAXException;
 
 /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/utils/XMLSecurityPropertyManager.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/utils/XMLSecurityPropertyManager.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 
 import com.sun.org.apache.xerces.internal.impl.Constants;
 import javax.xml.XMLConstants;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * This class manages security related properties
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- */
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.org.apache.xerces.internal.xinclude;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * This class is duplicated for each subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of any API.
- *
- * @xerces.internal
- */
-final class SecuritySupport {
-
-    private static final SecuritySupport securitySupport = new SecuritySupport();
-
-    /**
-     * Return an instance of this class.
-     */
-    static SecuritySupport getInstance() {
-        return securitySupport;
-    }
-
-    ClassLoader getContextClassLoader() {
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader cl = null;
-                try {
-                    cl = Thread.currentThread().getContextClassLoader();
-                } catch (SecurityException ex) { }
-                return cl;
-            }
-        });
-    }
-
-    ClassLoader getSystemClassLoader() {
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader cl = null;
-                try {
-                    cl = ClassLoader.getSystemClassLoader();
-                } catch (SecurityException ex) {}
-                return cl;
-            }
-        });
-    }
-
-    ClassLoader getParentClassLoader(final ClassLoader cl) {
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader parent = null;
-                try {
-                    parent = cl.getParent();
-                } catch (SecurityException ex) {}
-
-                // eliminate loops in case of the boot
-                // ClassLoader returning itself as a parent
-                return (parent == cl) ? null : parent;
-            }
-        });
-    }
-
-    String getSystemProperty(final String propName) {
-        return (String)
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                return System.getProperty(propName);
-            }
-        });
-    }
-
-    FileInputStream getFileInputStream(final File file)
-    throws FileNotFoundException
-    {
-        try {
-            return (FileInputStream)
-            AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                public Object run() throws FileNotFoundException {
-                    return new FileInputStream(file);
-                }
-            });
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-    boolean getFileExists(final File f) {
-        return ((Boolean)
-                AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
-                        return f.exists();
-                    }
-                })).booleanValue();
-    }
-
-    long getLastModified(final File f) {
-        return ((Long)
-                AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
-                        return f.lastModified();
-                    }
-                })).longValue();
-    }
-
-    private SecuritySupport () {}
-}
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,10 +22,10 @@
 package com.sun.org.apache.xerces.internal.xinclude;
 
 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 // TODO: fix error messages in XIncludeMessages.properties
 /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,12 +21,12 @@
 
 package com.sun.org.apache.xerces.internal.xpointer;
 
+import com.sun.org.apache.xerces.internal.util.MessageFormatter;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-import com.sun.org.apache.xerces.internal.util.MessageFormatter;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * XPointerMessageFormatter provides error messages for the XPointer Framework
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/res/XMLMessages.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/res/XMLMessages.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,9 +21,9 @@
 
 package com.sun.org.apache.xml.internal.res;
 
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
-import java.util.ListResourceBundle;
 import java.util.Locale;
+import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * A utility class for issuing XML error messages.
@@ -36,7 +36,7 @@
   protected Locale fLocale = Locale.getDefault();
 
   /** The language specific resource object for XML messages.  */
-  private static ListResourceBundle XMLBundle = null;
+  private static ResourceBundle XMLBundle = null;
 
   /** The class name of the XML error message string table.    */
   private static final String XML_ERROR_RESOURCES =
@@ -103,7 +103,7 @@
    *
    * @return The formatted message string.
    */
-  public static final String createMsg(ListResourceBundle fResourceBundle,
+  public static final String createMsg(ResourceBundle fResourceBundle,
         String msgKey, Object args[])  //throws Exception
   {
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- */
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.org.apache.xml.internal.serialize;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * This class is duplicated for each subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of any API.
- *
- * @xerces.internal
- */
-final class SecuritySupport {
-
-    private static final SecuritySupport securitySupport = new SecuritySupport();
-
-    /**
-     * Return an instance of this class.
-     */
-    static SecuritySupport getInstance() {
-        return securitySupport;
-    }
-
-    ClassLoader getContextClassLoader() {
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader cl = null;
-                try {
-                    cl = Thread.currentThread().getContextClassLoader();
-                } catch (SecurityException ex) { }
-                return cl;
-            }
-        });
-    }
-
-    ClassLoader getSystemClassLoader() {
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader cl = null;
-                try {
-                    cl = ClassLoader.getSystemClassLoader();
-                } catch (SecurityException ex) {}
-                return cl;
-            }
-        });
-    }
-
-    ClassLoader getParentClassLoader(final ClassLoader cl) {
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader parent = null;
-                try {
-                    parent = cl.getParent();
-                } catch (SecurityException ex) {}
-
-                // eliminate loops in case of the boot
-                // ClassLoader returning itself as a parent
-                return (parent == cl) ? null : parent;
-            }
-        });
-    }
-
-    String getSystemProperty(final String propName) {
-        return (String)
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                return System.getProperty(propName);
-            }
-        });
-    }
-
-    FileInputStream getFileInputStream(final File file)
-    throws FileNotFoundException
-    {
-        try {
-            return (FileInputStream)
-            AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                public Object run() throws FileNotFoundException {
-                    return new FileInputStream(file);
-                }
-            });
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-    boolean getFileExists(final File f) {
-        return ((Boolean)
-                AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
-                        return f.exists();
-                    }
-                })).booleanValue();
-    }
-
-    long getLastModified(final File f) {
-        return ((Long)
-                AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
-                        return f.lastModified();
-                    }
-                })).longValue();
-    }
-
-    private SecuritySupport () {}
-}
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,7 +23,6 @@
 package com.sun.org.apache.xml.internal.serialize;
 
 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
@@ -30,6 +30,7 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.StringTokenizer;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  *
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/CharInfo.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/CharInfo.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,7 +21,6 @@
 
 package com.sun.org.apache.xml.internal.serializer;
 
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
 import com.sun.org.apache.xml.internal.serializer.utils.SystemIDResolver;
 import com.sun.org.apache.xml.internal.serializer.utils.Utils;
@@ -37,6 +36,7 @@
 import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
 import javax.xml.transform.TransformerException;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * This class provides services that tell if a character should have
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/Encodings.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/Encodings.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,27 +21,26 @@
 
 package com.sun.org.apache.xml.internal.serializer;
 
+import java.io.BufferedWriter;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
-import java.io.BufferedWriter;
+import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.io.IOException;
-import java.net.MalformedURLException;
 import java.nio.charset.Charset;
 import java.nio.charset.IllegalCharsetNameException;
 import java.nio.charset.UnsupportedCharsetException;
 import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map.Entry;
 import java.util.Map;
-import java.util.Map.Entry;
-
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Provides information about encodings. Depends on the Java runtime
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,7 +21,9 @@
 
 package com.sun.org.apache.xml.internal.serializer;
 
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
+import com.sun.org.apache.xml.internal.serializer.utils.Utils;
+import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -28,12 +31,8 @@
 import java.security.PrivilegedAction;
 import java.util.Enumeration;
 import java.util.Properties;
-
 import javax.xml.transform.OutputKeys;
-
-import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
-import com.sun.org.apache.xml.internal.serializer.utils.Utils;
-import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * This class is a factory to generate a set of default properties
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,6 +21,9 @@
 
 package com.sun.org.apache.xml.internal.serializer;
 
+import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
+import com.sun.org.apache.xml.internal.serializer.utils.Utils;
+import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -34,22 +38,16 @@
 import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
-
 import javax.xml.transform.ErrorListener;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
-
+import jdk.xml.internal.SecuritySupport;
 import org.w3c.dom.Node;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
-import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
-import com.sun.org.apache.xml.internal.serializer.utils.Utils;
-import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
-
 /**
  * This abstract class is a base class for other stream
  * serializers (xml, html, text ...) that write output to a stream.
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/utils/Messages.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/utils/Messages.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,11 +21,9 @@
 
 package com.sun.org.apache.xml.internal.serializer.utils;
 
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
-import java.util.ListResourceBundle;
 import java.util.Locale;
-import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * A utility class for issuing error messages.
@@ -99,7 +97,7 @@
     private final Locale m_locale = Locale.getDefault();
 
     /** The language specific resource object for messages.  */
-    private ListResourceBundle m_resourceBundle;
+    private ResourceBundle m_resourceBundle;
 
     /** The class name of the error message string table with no language suffix. */
     private String m_resourceBundleName;
@@ -173,10 +171,8 @@
      * @return The formatted message string.
      * @xsl.usage internal
      */
-    private final String createMsg(
-        ListResourceBundle fResourceBundle,
-        String msgKey,
-        Object args[]) //throws Exception
+    private final String createMsg(ResourceBundle fResourceBundle, String msgKey,
+            Object args[]) //throws Exception
     {
 
         String fmsg = null;
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,7 +23,6 @@
 
 import com.sun.org.apache.xalan.internal.XalanConstants;
 import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
 import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
 import java.util.HashMap;
 import javax.xml.XMLConstants;
@@ -32,6 +32,7 @@
 import javax.xml.parsers.SAXParserFactory;
 import jdk.xml.internal.JdkXmlFeatures;
 import jdk.xml.internal.JdkXmlUtils;
+import jdk.xml.internal.SecuritySupport;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXNotSupportedException;
--- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncSystemProperty.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncSystemProperty.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Sep 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,15 +21,14 @@
 
 package com.sun.org.apache.xpath.internal.functions;
 
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-
 import com.sun.org.apache.xpath.internal.XPathContext;
 import com.sun.org.apache.xpath.internal.objects.XObject;
 import com.sun.org.apache.xpath.internal.objects.XString;
 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Execute the SystemProperty() function.
--- a/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEntityStorage.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEntityStorage.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,11 +32,11 @@
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.URI;
 import com.sun.org.apache.xerces.internal.util.XMLResourceIdentifierImpl;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
 import java.util.HashMap;
 import java.util.Map;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  *
--- a/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/WriterUtility.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/WriterUtility.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,8 +31,7 @@
 import java.io.Writer;
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetEncoder;
-import com.sun.org.apache.xerces.internal.util.XMLChar;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Implements common xml writer functions.
--- a/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,12 @@
 
 package com.sun.xml.internal.stream.writers;
 
+import com.sun.org.apache.xerces.internal.impl.Constants;
+import com.sun.org.apache.xerces.internal.impl.PropertyManager;
+import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
+import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.xni.QName;
+import com.sun.xml.internal.stream.util.ReadOnlyIterator;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -35,26 +41,17 @@
 import java.util.AbstractMap;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Random;
+import java.util.Set;
 import java.util.Vector;
-import java.util.Set;
-import java.util.Iterator;
-
 import javax.xml.XMLConstants;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.stream.StreamResult;
-
-import com.sun.org.apache.xerces.internal.impl.Constants;
-import com.sun.org.apache.xerces.internal.impl.PropertyManager;
-import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
-import com.sun.org.apache.xerces.internal.util.SymbolTable;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
-import com.sun.org.apache.xerces.internal.xni.QName;
-
-import com.sun.xml.internal.stream.util.ReadOnlyIterator;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * This class implements a StAX XMLStreamWriter. It extends
--- a/src/java.xml/share/classes/javax/xml/datatype/FactoryFinder.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/javax/xml/datatype/FactoryFinder.java	Thu Oct 05 22:04:49 2017 +0200
@@ -33,6 +33,7 @@
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
 import java.util.function.Supplier;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * <p>Implements pluggable Datatypes.</p>
@@ -61,18 +62,12 @@
      */
     private static volatile boolean firstTime = true;
 
-    /**
-     * Security support class use to check access control before
-     * getting certain system resources.
-     */
-    private final static SecuritySupport ss = new SecuritySupport();
-
     // Define system property "jaxp.debug" to get output
     static {
         // Use try/catch block to support applets, which throws
         // SecurityException out of this code.
         try {
-            String val = ss.getSystemProperty("jaxp.debug");
+            String val = SecuritySupport.getSystemProperty("jaxp.debug");
             // Allow simply setting the prop to turn on debug
             debug = val != null && !"false".equals(val);
         }
@@ -106,7 +101,7 @@
                 if (useBSClsLoader) {
                     return Class.forName(className, false, FactoryFinder.class.getClassLoader());
                 } else {
-                    cl = ss.getContextClassLoader();
+                    cl = SecuritySupport.getContextClassLoader();
                     if (cl == null) {
                         throw new ClassNotFoundException();
                     }
@@ -227,7 +222,7 @@
 
         // Use the system property first
         try {
-            String systemProp = ss.getSystemProperty(factoryId);
+            String systemProp = SecuritySupport.getSystemProperty(factoryId);
             if (systemProp != null) {
                 dPrint(()->"found system property, value=" + systemProp);
                 return newInstance(type, systemProp, null, true);
@@ -242,13 +237,13 @@
             if (firstTime) {
                 synchronized (cacheProps) {
                     if (firstTime) {
-                        String configFile = ss.getSystemProperty("java.home") + File.separator +
+                        String configFile = SecuritySupport.getSystemProperty("java.home") + File.separator +
                             "conf" + File.separator + "jaxp.properties";
                         File f = new File(configFile);
                         firstTime = false;
-                        if (ss.doesFileExist(f)) {
+                        if (SecuritySupport.doesFileExist(f)) {
                             dPrint(()->"Read properties file "+f);
-                            cacheProps.load(ss.getFileInputStream(f));
+                            cacheProps.load(SecuritySupport.getFileInputStream(f));
                         }
                     }
                 }
--- a/src/java.xml/share/classes/javax/xml/datatype/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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 javax.xml.datatype;
-
-import java.security.*;
-import java.io.*;
-
-/**
- * This class is duplicated for each JAXP subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of the JAXP
- * API.
- *
- * Security related methods that only work on J2SE 1.2 and newer.
- */
-class SecuritySupport  {
-
-
-    ClassLoader getContextClassLoader() {
-        return (ClassLoader)
-                AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader cl = null;
-                try {
-                    cl = Thread.currentThread().getContextClassLoader();
-                } catch (SecurityException ex) { }
-                return cl;
-            }
-        });
-    }
-
-    String getSystemProperty(final String propName) {
-        return (String)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
-                    return System.getProperty(propName);
-                }
-            });
-    }
-
-    FileInputStream getFileInputStream(final File file)
-        throws FileNotFoundException
-    {
-        try {
-            return (FileInputStream)
-                AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws FileNotFoundException {
-                        return new FileInputStream(file);
-                    }
-                });
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-    boolean doesFileExist(final File f) {
-    return ((Boolean)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
-                    return f.exists();
-                }
-            })).booleanValue();
-    }
-
-}
--- a/src/java.xml/share/classes/javax/xml/parsers/FactoryFinder.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/javax/xml/parsers/FactoryFinder.java	Thu Oct 05 22:04:49 2017 +0200
@@ -33,6 +33,7 @@
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
 import java.util.function.Supplier;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * <p>Implements pluggable Parsers.</p>
@@ -61,18 +62,12 @@
      */
     static volatile boolean firstTime = true;
 
-    /**
-     * Security support class use to check access control before
-     * getting certain system resources.
-     */
-    private static final SecuritySupport ss = new SecuritySupport();
-
     // Define system property "jaxp.debug" to get output
     static {
         // Use try/catch block to support applets, which throws
         // SecurityException out of this code.
         try {
-            String val = ss.getSystemProperty("jaxp.debug");
+            String val = SecuritySupport.getSystemProperty("jaxp.debug");
             // Allow simply setting the prop to turn on debug
             debug = val != null && !"false".equals(val);
         }
@@ -106,7 +101,7 @@
                 if (useBSClsLoader) {
                     return Class.forName(className, false, FactoryFinder.class.getClassLoader());
                 } else {
-                    cl = ss.getContextClassLoader();
+                    cl = SecuritySupport.getContextClassLoader();
                     if (cl == null) {
                         throw new ClassNotFoundException();
                     }
@@ -226,7 +221,7 @@
 
         // Use the system property first
         try {
-            String systemProp = ss.getSystemProperty(factoryId);
+            String systemProp = SecuritySupport.getSystemProperty(factoryId);
             if (systemProp != null) {
                 dPrint(()->"found system property, value=" + systemProp);
                 return newInstance(type, systemProp, null, true);
@@ -241,13 +236,13 @@
             if (firstTime) {
                 synchronized (cacheProps) {
                     if (firstTime) {
-                        String configFile = ss.getSystemProperty("java.home") + File.separator +
+                        String configFile = SecuritySupport.getSystemProperty("java.home") + File.separator +
                             "conf" + File.separator + "jaxp.properties";
                         File f = new File(configFile);
                         firstTime = false;
-                        if (ss.doesFileExist(f)) {
+                        if (SecuritySupport.doesFileExist(f)) {
                             dPrint(()->"Read properties file "+f);
-                            cacheProps.load(ss.getFileInputStream(f));
+                            cacheProps.load(SecuritySupport.getFileInputStream(f));
                         }
                     }
                 }
--- a/src/java.xml/share/classes/javax/xml/parsers/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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 javax.xml.parsers;
-
-import java.security.*;
-import java.io.*;
-
-/**
- * This class is duplicated for each JAXP subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of the JAXP
- * API.
- *
- * Security related methods that only work on J2SE 1.2 and newer.
- */
-class SecuritySupport  {
-
-
-    ClassLoader getContextClassLoader() throws SecurityException{
-        return (ClassLoader)
-                AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader cl = null;
-                //try {
-                cl = Thread.currentThread().getContextClassLoader();
-                //} catch (SecurityException ex) { }
-
-                if (cl == null)
-                    cl = ClassLoader.getSystemClassLoader();
-
-                return cl;
-            }
-        });
-    }
-
-    String getSystemProperty(final String propName) {
-        return (String)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
-                    return System.getProperty(propName);
-                }
-            });
-    }
-
-    FileInputStream getFileInputStream(final File file)
-        throws FileNotFoundException
-    {
-        try {
-            return (FileInputStream)
-                AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws FileNotFoundException {
-                        return new FileInputStream(file);
-                    }
-                });
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-    boolean doesFileExist(final File f) {
-    return ((Boolean)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
-                    return f.exists();
-                }
-            })).booleanValue();
-    }
-
-}
--- a/src/java.xml/share/classes/javax/xml/stream/FactoryFinder.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/javax/xml/stream/FactoryFinder.java	Thu Oct 05 22:04:49 2017 +0200
@@ -33,6 +33,7 @@
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
 import java.util.function.Supplier;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * <p>Implements pluggable streams.</p>
@@ -62,18 +63,12 @@
      */
     private static volatile boolean firstTime = true;
 
-    /**
-     * Security support class use to check access control before
-     * getting certain system resources.
-     */
-    final private static SecuritySupport ss = new SecuritySupport();
-
     // Define system property "jaxp.debug" to get output
     static {
         // Use try/catch block to support applets, which throws
         // SecurityException out of this code.
         try {
-            String val = ss.getSystemProperty("jaxp.debug");
+            String val = SecuritySupport.getSystemProperty("jaxp.debug");
             // Allow simply setting the prop to turn on debug
             debug = val != null && !"false".equals(val);
         }
@@ -107,7 +102,7 @@
                 if (useBSClsLoader) {
                     return Class.forName(className, false, FactoryFinder.class.getClassLoader());
                 } else {
-                    cl = ss.getContextClassLoader();
+                    cl = SecuritySupport.getContextClassLoader();
                     if (cl == null) {
                         throw new ClassNotFoundException();
                     }
@@ -256,7 +251,7 @@
 
             final String systemProp;
             if (type.getName().equals(factoryId)) {
-                systemProp = ss.getSystemProperty(factoryId);
+                systemProp = SecuritySupport.getSystemProperty(factoryId);
             } else {
                 systemProp = System.getProperty(factoryId);
             }
@@ -277,21 +272,21 @@
             if (firstTime) {
                 synchronized (cacheProps) {
                     if (firstTime) {
-                        configFile = ss.getSystemProperty("java.home") + File.separator +
+                        configFile = SecuritySupport.getSystemProperty("java.home") + File.separator +
                             "conf" + File.separator + "stax.properties";
                         final File fStax = new File(configFile);
                         firstTime = false;
-                        if (ss.doesFileExist(fStax)) {
+                        if (SecuritySupport.doesFileExist(fStax)) {
                             dPrint(()->"Read properties file "+fStax);
-                            cacheProps.load(ss.getFileInputStream(fStax));
+                            cacheProps.load(SecuritySupport.getFileInputStream(fStax));
                         }
                         else {
-                            configFile = ss.getSystemProperty("java.home") + File.separator +
+                            configFile = SecuritySupport.getSystemProperty("java.home") + File.separator +
                                 "conf" + File.separator + "jaxp.properties";
                             final File fJaxp = new File(configFile);
-                            if (ss.doesFileExist(fJaxp)) {
+                            if (SecuritySupport.doesFileExist(fJaxp)) {
                                 dPrint(()->"Read properties file "+fJaxp);
-                                cacheProps.load(ss.getFileInputStream(fJaxp));
+                                cacheProps.load(SecuritySupport.getFileInputStream(fJaxp));
                             }
                         }
                     }
--- a/src/java.xml/share/classes/javax/xml/stream/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  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 javax.xml.stream;
-
-import java.security.*;
-import java.io.*;
-
-/**
- * This class is duplicated for each JAXP subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of the JAXP
- * API.
- *
- * Security related methods that only work on J2SE 1.2 and newer.
- */
-class SecuritySupport  {
-
-
-    ClassLoader getContextClassLoader() throws SecurityException{
-        return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> {
-            ClassLoader cl = Thread.currentThread().getContextClassLoader();
-
-            if (cl == null)
-                cl = ClassLoader.getSystemClassLoader();
-
-            return cl;
-        });
-    }
-
-    String getSystemProperty(final String propName) {
-        return AccessController.doPrivileged((PrivilegedAction<String>) () ->
-                System.getProperty(propName));
-    }
-
-    FileInputStream getFileInputStream(final File file)
-        throws FileNotFoundException
-    {
-        try {
-            return AccessController.doPrivileged((PrivilegedExceptionAction<FileInputStream>) ()
-                    -> new FileInputStream(file));
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-    boolean doesFileExist(final File f) {
-        return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> f.exists());
-    }
-
-}
--- a/src/java.xml/share/classes/javax/xml/transform/FactoryFinder.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/javax/xml/transform/FactoryFinder.java	Thu Oct 05 22:04:49 2017 +0200
@@ -35,6 +35,7 @@
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
 import java.util.function.Supplier;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * <p>Implements pluggable Datatypes.</p>
@@ -64,18 +65,12 @@
      */
     static volatile boolean firstTime = true;
 
-    /**
-     * Security support class use to check access control before
-     * getting certain system resources.
-     */
-    private final static SecuritySupport ss = new SecuritySupport();
-
     // Define system property "jaxp.debug" to get output
     static {
         // Use try/catch block to support applets, which throws
         // SecurityException out of this code.
         try {
-            String val = ss.getSystemProperty("jaxp.debug");
+            String val = SecuritySupport.getSystemProperty("jaxp.debug");
             // Allow simply setting the prop to turn on debug
             debug = val != null && !"false".equals(val);
         }
@@ -109,7 +104,7 @@
                 if (useBSClsLoader) {
                     return Class.forName(className, false, FactoryFinder.class.getClassLoader());
                 } else {
-                    cl = ss.getContextClassLoader();
+                    cl = SecuritySupport.getContextClassLoader();
                     if (cl == null) {
                         throw new ClassNotFoundException();
                     }
@@ -258,7 +253,7 @@
         dPrint(()->"find factoryId =" + factoryId);
         // Use the system property first
         try {
-            String systemProp = ss.getSystemProperty(factoryId);
+            String systemProp = SecuritySupport.getSystemProperty(factoryId);
             if (systemProp != null) {
                 dPrint(()->"found system property, value=" + systemProp);
                 return newInstance(type, systemProp, null, true, true);
@@ -273,13 +268,13 @@
             if (firstTime) {
                 synchronized (cacheProps) {
                     if (firstTime) {
-                        String configFile = ss.getSystemProperty("java.home") + File.separator +
+                        String configFile = SecuritySupport.getSystemProperty("java.home") + File.separator +
                             "conf" + File.separator + "jaxp.properties";
                         File f = new File(configFile);
                         firstTime = false;
-                        if (ss.doesFileExist(f)) {
+                        if (SecuritySupport.doesFileExist(f)) {
                             dPrint(()->"Read properties file "+f);
-                            cacheProps.load(ss.getFileInputStream(f));
+                            cacheProps.load(SecuritySupport.getFileInputStream(f));
                         }
                     }
                 }
--- a/src/java.xml/share/classes/javax/xml/transform/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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 javax.xml.transform;
-
-import java.security.*;
-import java.io.*;
-
-/**
- * This class is duplicated for each JAXP subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of the JAXP
- * API.
- *
- * Security related methods that only work on J2SE 1.2 and newer.
- */
-class SecuritySupport  {
-
-
-    ClassLoader getContextClassLoader() throws SecurityException{
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                ClassLoader cl = null;
-                //try {
-                cl = Thread.currentThread().getContextClassLoader();
-                //} catch (SecurityException ex) { }
-                if (cl == null)
-                    cl = ClassLoader.getSystemClassLoader();
-                return cl;
-            }
-        });
-    }
-
-    String getSystemProperty(final String propName) {
-        return (String)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
-                    return System.getProperty(propName);
-                }
-            });
-    }
-
-    FileInputStream getFileInputStream(final File file)
-        throws FileNotFoundException
-    {
-        try {
-            return (FileInputStream)
-                AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws FileNotFoundException {
-                        return new FileInputStream(file);
-                    }
-                });
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-    boolean doesFileExist(final File f) {
-    return ((Boolean)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
-                    return f.exists();
-                }
-            })).booleanValue();
-    }
-
-}
--- a/src/java.xml/share/classes/javax/xml/validation/SchemaFactory.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/javax/xml/validation/SchemaFactory.java	Thu Oct 05 22:04:49 2017 +0200
@@ -30,6 +30,7 @@
 import java.net.URL;
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
+import jdk.xml.internal.SecuritySupport;
 import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
@@ -111,8 +112,6 @@
  */
 public abstract class SchemaFactory {
 
-     private static SecuritySupport ss = new SecuritySupport();
-
     /**
      * Constructor for derived classes.
      *
@@ -235,7 +234,7 @@
      */
     public static SchemaFactory newInstance(String schemaLanguage) {
         ClassLoader cl;
-        cl = ss.getContextClassLoader();
+        cl = SecuritySupport.getContextClassLoader();
 
         if (cl == null) {
             //cl = ClassLoader.getSystemClassLoader();
@@ -299,7 +298,7 @@
         ClassLoader cl = classLoader;
 
         if (cl == null) {
-            cl = ss.getContextClassLoader();
+            cl = SecuritySupport.getContextClassLoader();
         }
 
         SchemaFactory f = new SchemaFactoryFinder(cl).createInstance(factoryClassName);
--- a/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java	Thu Oct 05 22:04:49 2017 +0200
@@ -36,6 +36,7 @@
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
 import java.util.function.Supplier;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Implementation of {@link SchemaFactory#newInstance(String)}.
@@ -47,10 +48,7 @@
 
     /** debug support code. */
     private static boolean debug = false;
-    /**
-     *<p> Take care of restrictions imposed by java security model </p>
-     */
-    private static final SecuritySupport ss = new SecuritySupport();
+
     private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal";
     /**
      * <p>Cache properties for performance.</p>
@@ -65,7 +63,7 @@
     static {
         // Use try/catch block to support applets
         try {
-            debug = ss.getSystemProperty("jaxp.debug") != null;
+            debug = SecuritySupport.getSystemProperty("jaxp.debug") != null;
         } catch (Exception unused) {
             debug = false;
         }
@@ -107,7 +105,7 @@
 
     private void debugDisplayClassLoader() {
         try {
-            if( classLoader == ss.getContextClassLoader() ) {
+            if( classLoader == SecuritySupport.getContextClassLoader() ) {
                 debugPrintln(()->"using thread context class loader ("+classLoader+") for search");
                 return;
             }
@@ -166,7 +164,7 @@
         // system property look up
         try {
             debugPrintln(()->"Looking up system property '"+propertyName+"'" );
-            String r = ss.getSystemProperty(propertyName);
+            String r = SecuritySupport.getSystemProperty(propertyName);
             if(r!=null) {
                 debugPrintln(()->"The value is '"+r+"'");
                 sf = createInstance(r, true);
@@ -180,7 +178,7 @@
             }
         }
 
-        String javah = ss.getSystemProperty( "java.home" );
+        String javah = SecuritySupport.getSystemProperty( "java.home" );
         String configFile = javah + File.separator +
         "conf" + File.separator + "jaxp.properties";
 
@@ -192,9 +190,9 @@
                     if(firstTime){
                         File f=new File( configFile );
                         firstTime = false;
-                        if(ss.doesFileExist(f)){
+                        if(SecuritySupport.doesFileExist(f)){
                             debugPrintln(()->"Read properties file " + f);
-                            cacheProps.load(ss.getFileInputStream(f));
+                            cacheProps.load(SecuritySupport.getFileInputStream(f));
                         }
                     }
                 }
@@ -411,6 +409,6 @@
 
     // Used for debugging purposes
     private static String which( Class<?> clazz ) {
-        return ss.getClassSource(clazz);
+        return SecuritySupport.getClassSource(clazz);
     }
 }
--- a/src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package javax.xml.validation;
-
-import java.net.URL;
-import java.security.*;
-import java.io.*;
-
-/**
- * This class is duplicated for each JAXP subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of the JAXP
- * API.
- *
- * Security related methods that only work on J2SE 1.2 and newer.
- */
-class SecuritySupport  {
-
-
-    ClassLoader getContextClassLoader() {
-        return
-        AccessController.doPrivileged(new PrivilegedAction<>() {
-            @Override
-            public ClassLoader run() {
-                ClassLoader cl = Thread.currentThread().getContextClassLoader();
-                if (cl == null)
-                    cl = ClassLoader.getSystemClassLoader();
-                return cl;
-            }
-        });
-    }
-
-    String getSystemProperty(final String propName) {
-        return AccessController.doPrivileged(new PrivilegedAction<>() {
-                @Override
-                public String run() {
-                    return System.getProperty(propName);
-                }
-            });
-    }
-
-    FileInputStream getFileInputStream(final File file)
-        throws FileNotFoundException
-    {
-        try {
-            return AccessController.doPrivileged(
-                new PrivilegedExceptionAction<>() {
-                    @Override
-                    public FileInputStream run() throws FileNotFoundException {
-                        return new FileInputStream(file);
-                    }
-                });
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-    // Used for debugging purposes
-    String getClassSource(Class<?> cls) {
-        return AccessController.doPrivileged(new PrivilegedAction<>() {
-            @Override
-            public String run() {
-                CodeSource cs = cls.getProtectionDomain().getCodeSource();
-                if (cs != null) {
-                   URL loc = cs.getLocation();
-                   return loc != null ? loc.toString() : "(no location)";
-                } else {
-                   return "(no code source)";
-                }
-            }
-        });
-    }
-
-    boolean doesFileExist(final File f) {
-        return AccessController.doPrivileged(new PrivilegedAction<>() {
-            @Override
-            public Boolean run() {
-                return f.exists();
-            }
-        });
-    }
-
-}
--- a/src/java.xml/share/classes/javax/xml/xpath/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package javax.xml.xpath;
-
-import java.net.URL;
-import java.security.*;
-import java.io.*;
-
-/**
- * This class is duplicated for each JAXP subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of the JAXP
- * API.
- *
- * Security related methods that only work on J2SE 1.2 and newer.
- */
-class SecuritySupport  {
-
-
-    ClassLoader getContextClassLoader() {
-        return AccessController.doPrivileged(new PrivilegedAction<>() {
-            @Override
-            public ClassLoader run() {
-                ClassLoader cl = null;
-                try {
-                    cl = Thread.currentThread().getContextClassLoader();
-                } catch (SecurityException ex) { }
-                return cl;
-            }
-        });
-    }
-
-    String getSystemProperty(final String propName) {
-        return AccessController.doPrivileged(new PrivilegedAction<>() {
-            @Override
-            public String run() {
-                return System.getProperty(propName);
-            }
-        });
-    }
-
-    FileInputStream getFileInputStream(final File file)
-        throws FileNotFoundException
-    {
-        try {
-            return AccessController.doPrivileged(
-                new PrivilegedExceptionAction<>() {
-                    @Override
-                    public FileInputStream run() throws FileNotFoundException {
-                        return new FileInputStream(file);
-                    }
-                });
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-    // Used for debugging purposes
-    String getClassSource(Class<?> cls) {
-        return AccessController.doPrivileged(new PrivilegedAction<>() {
-            @Override
-            public String run() {
-                CodeSource cs = cls.getProtectionDomain().getCodeSource();
-                if (cs != null) {
-                   URL loc = cs.getLocation();
-                   return loc != null ? loc.toString() : "(no location)";
-                } else {
-                   return "(no code source)";
-                }
-            }
-        });
-    }
-
-    boolean doesFileExist(final File f) {
-        return AccessController.doPrivileged(new PrivilegedAction<>() {
-            @Override
-            public Boolean run() {
-                return f.exists();
-            }
-        });
-    }
-
-}
--- a/src/java.xml/share/classes/javax/xml/xpath/XPathFactory.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/javax/xml/xpath/XPathFactory.java	Thu Oct 05 22:04:49 2017 +0200
@@ -26,6 +26,7 @@
 package javax.xml.xpath;
 
 import com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * <p>An {@code XPathFactory} instance can be used to create
@@ -63,11 +64,6 @@
     public static final String DEFAULT_OBJECT_MODEL_URI = "http://java.sun.com/jaxp/xpath/dom";
 
     /**
-     *<p> Take care of restrictions imposed by java security model </p>
-     */
-    private static SecuritySupport ss = new SecuritySupport() ;
-
-    /**
      * <p>Protected constructor as {@link #newInstance()} or {@link #newInstance(String uri)}
      * or {@link #newInstance(String uri, String factoryClassName, ClassLoader classLoader)}
      * should be used to create a new instance of an {@code XPathFactory}.</p>
@@ -217,7 +213,7 @@
                     "XPathFactory#newInstance(String uri) cannot be called with uri == \"\"");
         }
 
-        ClassLoader classLoader = ss.getContextClassLoader();
+        ClassLoader classLoader = SecuritySupport.getContextClassLoader();
 
         if (classLoader == null) {
             //use the current class loader
@@ -296,7 +292,7 @@
         }
 
         if (cl == null) {
-            cl = ss.getContextClassLoader();
+            cl = SecuritySupport.getContextClassLoader();
         }
 
         XPathFactory f = new XPathFactoryFinder(cl).createInstance(factoryClassName);
--- a/src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java	Thu Oct 05 22:04:49 2017 +0200
@@ -36,6 +36,7 @@
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
 import java.util.function.Supplier;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Implementation of {@link XPathFactory#newInstance(String)}.
@@ -46,13 +47,12 @@
 class XPathFactoryFinder  {
     private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xpath.internal";
 
-    private static final SecuritySupport ss = new SecuritySupport() ;
     /** debug support code. */
     private static boolean debug = false;
     static {
         // Use try/catch block to support applets
         try {
-            debug = ss.getSystemProperty("jaxp.debug") != null;
+            debug = SecuritySupport.getSystemProperty("jaxp.debug") != null;
         } catch (Exception unused) {
             debug = false;
         }
@@ -103,7 +103,7 @@
 
     private void debugDisplayClassLoader() {
         try {
-            if( classLoader == ss.getContextClassLoader() ) {
+            if( classLoader == SecuritySupport.getContextClassLoader() ) {
                 debugPrintln(() -> "using thread context class loader ("+classLoader+") for search");
                 return;
             }
@@ -159,7 +159,7 @@
         // system property look up
         try {
             debugPrintln(()->"Looking up system property '"+propertyName+"'" );
-            String r = ss.getSystemProperty(propertyName);
+            String r = SecuritySupport.getSystemProperty(propertyName);
             if(r!=null) {
                 debugPrintln(()->"The value is '"+r+"'");
                 xpathFactory = createInstance(r, true);
@@ -175,7 +175,7 @@
             }
         }
 
-        String javah = ss.getSystemProperty( "java.home" );
+        String javah = SecuritySupport.getSystemProperty( "java.home" );
         String configFile = javah + File.separator +
         "conf" + File.separator + "jaxp.properties";
 
@@ -186,9 +186,9 @@
                     if(firstTime){
                         File f=new File( configFile );
                         firstTime = false;
-                        if(ss.doesFileExist(f)){
+                        if(SecuritySupport.doesFileExist(f)){
                             debugPrintln(()->"Read properties file " + f);
-                            cacheProps.load(ss.getFileInputStream(f));
+                            cacheProps.load(SecuritySupport.getFileInputStream(f));
                         }
                     }
                 }
@@ -407,7 +407,7 @@
 
     // Used for debugging purposes
     private static String which( Class<?> clazz ) {
-        return ss.getClassSource(clazz);
+        return SecuritySupport.getClassSource(clazz);
     }
 
 }
--- a/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java	Thu Oct 05 22:04:49 2017 +0200
@@ -29,7 +29,9 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URL;
 import java.security.AccessController;
+import java.security.CodeSource;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -82,7 +84,7 @@
     public static String getSystemProperty(final String propName) {
         return
         AccessController.doPrivileged(
-                (PrivilegedAction<String>) () -> (String)System.getProperty(propName));
+                (PrivilegedAction<String>) () -> System.getProperty(propName));
     }
 
     /**
@@ -220,6 +222,12 @@
                 -> f.exists()));
     }
 
+    /**
+     * Creates and returns a new FileInputStream from a file.
+     * @param file the specified file
+     * @return the FileInputStream
+     * @throws FileNotFoundException if the file is not found
+     */
     public static FileInputStream getFileInputStream(final File file)
             throws FileNotFoundException {
         try {
@@ -231,6 +239,16 @@
     }
 
     /**
+     * Returns the resource as a stream.
+     * @param name the resource name
+     * @return the resource stream
+     */
+    public static InputStream getResourceAsStream(final String name) {
+        return AccessController.doPrivileged((PrivilegedAction<InputStream>) () ->
+                SecuritySupport.class.getResourceAsStream("/"+name));
+    }
+
+    /**
      * Gets a resource bundle using the specified base name, the default locale, and the caller's class loader.
      * @param bundle the base name of the resource bundle, a fully qualified class name
      * @return a resource bundle for the given base name and the default locale
@@ -259,4 +277,179 @@
             }
         });
     }
+
+    /**
+     * Checks whether the file exists.
+     * @param f the specified file
+     * @return true if the file exists, false otherwise
+     */
+    public static boolean doesFileExist(final File f) {
+        return (AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> f.exists()));
+    }
+
+    /**
+     * Checks the LastModified attribute of a file.
+     * @param f the specified file
+     * @return the LastModified attribute
+     */
+    static long getLastModified(final File f) {
+        return (AccessController.doPrivileged((PrivilegedAction<Long>) () -> f.lastModified()));
+    }
+
+    /**
+     * Strip off path from an URI
+     *
+     * @param uri an URI with full path
+     * @return the file name only
+     */
+    public static String sanitizePath(String uri) {
+        if (uri == null) {
+            return "";
+        }
+        int i = uri.lastIndexOf("/");
+        if (i > 0) {
+            return uri.substring(i+1, uri.length());
+        }
+        return "";
+    }
+
+    /**
+     * Check the protocol used in the systemId against allowed protocols
+     *
+     * @param systemId the Id of the URI
+     * @param allowedProtocols a list of allowed protocols separated by comma
+     * @param accessAny keyword to indicate allowing any protocol
+     * @return the name of the protocol if rejected, null otherwise
+     */
+    public static String checkAccess(String systemId, String allowedProtocols,
+            String accessAny) throws IOException {
+        if (systemId == null || (allowedProtocols != null &&
+                allowedProtocols.equalsIgnoreCase(accessAny))) {
+            return null;
+        }
+
+        String protocol;
+        if (!systemId.contains(":")) {
+            protocol = "file";
+        } else {
+            URL url = new URL(systemId);
+            protocol = url.getProtocol();
+            if (protocol.equalsIgnoreCase("jar")) {
+                String path = url.getPath();
+                protocol = path.substring(0, path.indexOf(":"));
+            } else if (protocol.equalsIgnoreCase("jrt")) {
+                // if the systemId is "jrt" then allow access if "file" allowed
+                protocol = "file";
+            }
+        }
+
+        if (isProtocolAllowed(protocol, allowedProtocols)) {
+            //access allowed
+            return null;
+        } else {
+            return protocol;
+        }
+    }
+
+    /**
+     * Check if the protocol is in the allowed list of protocols. The check
+     * is case-insensitive while ignoring whitespaces.
+     *
+     * @param protocol a protocol
+     * @param allowedProtocols a list of allowed protocols
+     * @return true if the protocol is in the list
+     */
+    private static boolean isProtocolAllowed(String protocol, String allowedProtocols) {
+         if (allowedProtocols == null) {
+             return false;
+         }
+         String temp[] = allowedProtocols.split(",");
+         for (String t : temp) {
+             t = t.trim();
+             if (t.equalsIgnoreCase(protocol)) {
+                 return true;
+             }
+         }
+         return false;
+     }
+
+    public static ClassLoader getContextClassLoader() {
+        return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> {
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            if (cl == null)
+                cl = ClassLoader.getSystemClassLoader();
+            return cl;
+        });
+    }
+
+
+    public static ClassLoader getSystemClassLoader() {
+        return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> {
+            ClassLoader cl = null;
+            try {
+                cl = ClassLoader.getSystemClassLoader();
+            } catch (SecurityException ex) {
+            }
+            return cl;
+        });
+    }
+
+    public static ClassLoader getParentClassLoader(final ClassLoader cl) {
+        return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> {
+            ClassLoader parent = null;
+            try {
+                parent = cl.getParent();
+            } catch (SecurityException ex) {
+            }
+
+            // eliminate loops in case of the boot
+            // ClassLoader returning itself as a parent
+            return (parent == cl) ? null : parent;
+        });
+    }
+
+
+    // Used for debugging purposes
+    public static String getClassSource(Class<?> cls) {
+        return AccessController.doPrivileged((PrivilegedAction<String>) () -> {
+            CodeSource cs = cls.getProtectionDomain().getCodeSource();
+            if (cs != null) {
+                URL loc = cs.getLocation();
+                return loc != null ? loc.toString() : "(no location)";
+            } else {
+                return "(no code source)";
+            }
+        });
+    }
+
+    // ----------------  For SAX ----------------------
+    /**
+     * Returns the current thread's context class loader, or the system class loader
+     * if the context class loader is null.
+     * @return the current thread's context class loader, or the system class loader
+     * @throws SecurityException
+     */
+    public static ClassLoader getClassLoader() throws SecurityException{
+        return AccessController.doPrivileged((PrivilegedAction<ClassLoader>)() -> {
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            if (cl == null) {
+                cl = ClassLoader.getSystemClassLoader();
+            }
+
+            return cl;
+        });
+    }
+
+    public static InputStream getResourceAsStream(final ClassLoader cl, final String name)
+    {
+        return AccessController.doPrivileged((PrivilegedAction<InputStream>) () -> {
+            InputStream ris;
+            if (cl == null) {
+                ris = SecuritySupport.class.getResourceAsStream(name);
+            } else {
+                ris = cl.getResourceAsStream(name);
+            }
+            return ris;
+        });
+    }
 }
--- a/src/java.xml/share/classes/org/xml/sax/helpers/ParserAdapter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/org/xml/sax/helpers/ParserAdapter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -34,23 +34,22 @@
 import java.io.IOException;
 import java.util.Enumeration;
 import java.util.Vector;
-
-import org.xml.sax.Parser;      // deprecated
+import jdk.xml.internal.SecuritySupport;
+import org.xml.sax.AttributeList; // deprecated
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.DocumentHandler; // deprecated
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
 import org.xml.sax.InputSource;
 import org.xml.sax.Locator;
-import org.xml.sax.AttributeList; // deprecated
-import org.xml.sax.EntityResolver;
-import org.xml.sax.DTDHandler;
-import org.xml.sax.DocumentHandler; // deprecated
-import org.xml.sax.ErrorHandler;
+import org.xml.sax.Parser;      // deprecated
 import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import org.xml.sax.XMLReader;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
 
 
 /**
@@ -82,7 +81,6 @@
 @SuppressWarnings("deprecation")
 public class ParserAdapter implements XMLReader, DocumentHandler
 {
-    private static SecuritySupport ss = new SecuritySupport();
 
     ////////////////////////////////////////////////////////////////////
     // Constructors.
@@ -104,7 +102,7 @@
     {
         super();
 
-        String driver = ss.getSystemProperty("org.xml.sax.parser");
+        String driver = SecuritySupport.getSystemProperty("org.xml.sax.parser");
 
         try {
             setup(ParserFactory.makeParser());
--- a/src/java.xml/share/classes/org/xml/sax/helpers/ParserFactory.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/org/xml/sax/helpers/ParserFactory.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 
 package org.xml.sax.helpers;
 
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Java-specific class for dynamically loading SAX parsers.
@@ -66,7 +67,6 @@
 @SuppressWarnings( "deprecation" )
 @Deprecated(since="1.5")
 public class ParserFactory {
-    private static SecuritySupport ss = new SecuritySupport();
 
     /**
      * Private null constructor.
@@ -104,7 +104,7 @@
         NullPointerException,
         ClassCastException
     {
-        String className = ss.getSystemProperty("org.xml.sax.parser");
+        String className = SecuritySupport.getSystemProperty("org.xml.sax.parser");
         if (className == null) {
             throw new NullPointerException("No value for sax.parser property");
         } else {
@@ -140,7 +140,8 @@
         InstantiationException,
         ClassCastException
     {
-        return NewInstance.newInstance (org.xml.sax.Parser.class, ss.getClassLoader(), className);
+        return NewInstance.newInstance (org.xml.sax.Parser.class,
+                SecuritySupport.getClassLoader(), className);
     }
 
 }
--- a/src/java.xml/share/classes/org/xml/sax/helpers/SecuritySupport.java	Tue Oct 03 13:19:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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 org.xml.sax.helpers;
-
-import java.io.*;
-import java.security.*;
-
-/**
- * This class is duplicated for each JAXP subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of the JAXP
- * API.
- *
- * Security related methods that only work on J2SE 1.2 and newer.
- */
-class SecuritySupport  {
-
-    /**
-     * Returns the current thread's context class loader, or the system class loader
-     * if the context class loader is null.
-     * @return the current thread's context class loader, or the system class loader
-     * @throws SecurityException
-     */
-    ClassLoader getClassLoader() throws SecurityException{
-        return AccessController.doPrivileged((PrivilegedAction<ClassLoader>)() -> {
-            ClassLoader cl = Thread.currentThread().getContextClassLoader();
-            if (cl == null) {
-                cl = ClassLoader.getSystemClassLoader();
-            }
-
-            return cl;
-        });
-    }
-
-    String getSystemProperty(final String propName) {
-        return AccessController.doPrivileged((PrivilegedAction<String>)()
-                -> System.getProperty(propName));
-    }
-
-    FileInputStream getFileInputStream(final File file)
-        throws FileNotFoundException
-    {
-        try {
-            return AccessController.doPrivileged((PrivilegedExceptionAction<FileInputStream>)() ->
-                    new FileInputStream(file));
-        } catch (PrivilegedActionException e) {
-            throw (FileNotFoundException)e.getException();
-        }
-    }
-
-
-    InputStream getResourceAsStream(final ClassLoader cl, final String name)
-    {
-        return AccessController.doPrivileged((PrivilegedAction<InputStream>) () -> {
-            InputStream ris;
-            if (cl == null) {
-                ris = SecuritySupport.class.getResourceAsStream(name);
-            } else {
-                ris = cl.getResourceAsStream(name);
-            }
-            return ris;
-        });
-    }
-
-    boolean doesFileExist(final File f) {
-        return (AccessController.doPrivileged((PrivilegedAction<Boolean>)() ->
-                f.exists()));
-    }
-
-}
--- a/src/java.xml/share/classes/org/xml/sax/helpers/XMLReaderFactory.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/java.xml/share/classes/org/xml/sax/helpers/XMLReaderFactory.java	Thu Oct 05 22:04:49 2017 +0200
@@ -31,6 +31,7 @@
 // $Id: XMLReaderFactory.java,v 1.2.2.1 2005/07/31 22:48:08 jeffsuttor Exp $
 
 package org.xml.sax.helpers;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -41,6 +42,7 @@
 import java.util.Objects;
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
+import jdk.xml.internal.SecuritySupport;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 
@@ -94,7 +96,6 @@
     }
 
     private static final String property = "org.xml.sax.driver";
-    private static final SecuritySupport ss = new SecuritySupport();
 
     /**
      * Obtains a new instance of a {@link org.xml.sax.XMLReader}.
@@ -138,11 +139,11 @@
         throws SAXException
     {
         String          className = null;
-        ClassLoader     cl = ss.getClassLoader();
+        ClassLoader     cl = SecuritySupport.getClassLoader();
 
         // 1. try the JVM-instance-wide system property
         try {
-            className = ss.getSystemProperty(property);
+            className = SecuritySupport.getSystemProperty(property);
         }
         catch (RuntimeException e) { /* continue searching */ }
 
@@ -187,7 +188,7 @@
     public static XMLReader createXMLReader (String className)
         throws SAXException
     {
-        return loadClass (ss.getClassLoader(), className);
+        return loadClass (SecuritySupport.getClassLoader(), className);
     }
 
     private static XMLReader loadClass (ClassLoader loader, String className)
@@ -224,11 +225,11 @@
         BufferedReader      reader;
 
         try {
-            in = ss.getResourceAsStream(cl, service);
+            in = SecuritySupport.getResourceAsStream(cl, service);
 
             // If no provider found then try the current ClassLoader
             if (in == null) {
-                in = ss.getResourceAsStream(null, service);
+                in = SecuritySupport.getResourceAsStream(null, service);
             }
 
             if (in != null) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Oct 05 22:04:49 2017 +0200
@@ -3077,7 +3077,7 @@
                 if (that.getMode() == ReferenceMode.INVOKE &&
                         TreeInfo.isStaticSelector(that.expr, names) &&
                         that.kind.isUnbound() &&
-                        !desc.getParameterTypes().head.isParameterized()) {
+                        lookupHelper.site.isRaw()) {
                     chk.checkRaw(that.expr, localEnv);
                 }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -34,7 +34,6 @@
 import com.sun.tools.javac.api.Formattable;
 import com.sun.tools.javac.file.PathFileObject;
 import com.sun.tools.javac.tree.JCTree.*;
-import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration;
 
 import static com.sun.tools.javac.api.DiagnosticFormatter.PositionKind.*;
 
@@ -52,6 +51,37 @@
 public final class RawDiagnosticFormatter extends AbstractDiagnosticFormatter {
 
     /**
+     * The raw diagnostic helper.
+     */
+    RawDiagnosticPosHelper rawDiagnosticPosHelper;
+
+    /**
+     * Helper class to generate stable positions for AST nodes occurring in diagnostic arguments.
+     * If the AST node appears in the same line number as the main diagnostic, the line is information is omitted.
+     * Otherwise both line and column information is included, using the format @{code line:col}".
+     *
+     * Note: since subdiagnostics can be created without a diagnostic source, a position helper
+     * should always refer to the toplevel diagnostic source.
+     */
+    static class RawDiagnosticPosHelper {
+        private final JCDiagnostic diag;
+
+        RawDiagnosticPosHelper(JCDiagnostic diag) {
+            this.diag = diag;
+        }
+
+        String getPosition(JCExpression exp) {
+            DiagnosticSource diagSource = diag.getDiagnosticSource();
+            long diagLine = diag.getLineNumber();
+            long expLine = diagSource.getLineNumber(exp.pos);
+            long expCol = diagSource.getColumnNumber(exp.pos, false);
+            return (expLine == diagLine) ?
+                    String.valueOf(expCol) :
+                    expLine + ":" + expCol;
+        }
+    }
+
+    /**
      * Create a formatter based on the supplied options.
      * @param options
      */
@@ -65,6 +95,7 @@
     //provide common default formats
     public String formatDiagnostic(JCDiagnostic d, Locale l) {
         try {
+            rawDiagnosticPosHelper = new RawDiagnosticPosHelper(d);
             StringBuilder buf = new StringBuilder();
             if (d.getPosition() != Position.NOPOS) {
                 buf.append(formatSource(d, false, null));
@@ -89,8 +120,9 @@
             return buf.toString();
         }
         catch (Exception e) {
-            //e.printStackTrace();
             return null;
+        } finally {
+            rawDiagnosticPosHelper = null;
         }
     }
 
@@ -122,8 +154,8 @@
         if (arg instanceof Formattable) {
             s = arg.toString();
         } else if (arg instanceof JCExpression) {
-            JCExpression tree = (JCExpression)arg;
-            s = "@" + tree.getStartPosition();
+            Assert.checkNonNull(rawDiagnosticPosHelper);
+            s = "@" + rawDiagnosticPosHelper.getPosition((JCExpression)arg);
         } else if (arg instanceof PathFileObject) {
             s = ((PathFileObject) arg).getShortName();
         } else {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -334,7 +334,6 @@
 
                 List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
                 if (!commentTags.isEmpty()) {
-                    div.addContent(Contents.SPACE);
                     addInlineDeprecatedComment(annotationType, deprs.get(0), div);
                 }
             }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -616,7 +616,6 @@
                 DocTree dt = deprs.get(0);
                 List<? extends DocTree> commentTags = ch.getBody(configuration, dt);
                 if (!commentTags.isEmpty()) {
-                    div.addContent(Contents.SPACE);
                     addInlineDeprecatedComment(typeElement, deprs.get(0), div);
                 }
             }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -1715,8 +1715,7 @@
         Content div;
         Content result = commentTagsToContent(null, element, tags, first);
         if (depr) {
-            Content italic = HtmlTree.SPAN(HtmlStyle.deprecationComment, result);
-            div = HtmlTree.DIV(HtmlStyle.block, italic);
+            div = HtmlTree.DIV(HtmlStyle.deprecationComment, result);
             htmltree.addContent(div);
         }
         else {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java	Thu Oct 05 22:04:49 2017 +0200
@@ -189,9 +189,8 @@
         if (utils.isDeprecated(member)) {
             Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(member));
             div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
-            div.addContent(Contents.SPACE);
             if (!deprs.isEmpty()) {
-                addInlineDeprecatedComment(member, deprs.get(0), div);
+                addSummaryDeprecatedComment(member, deprs.get(0), div);
             }
             tdSummary.addContent(div);
             return;
@@ -200,7 +199,6 @@
             if (te != null &&  utils.isTypeElement(te) && utils.isDeprecated(te)) {
                 Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(te));
                 div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
-                div.addContent(Contents.SPACE);
                 tdSummary.addContent(div);
             }
         }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Thu Oct 05 22:04:49 2017 +0200
@@ -179,7 +179,6 @@
             if (utils.isDeprecated(element)) {
                 result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
                         htmlWriter.getDeprecatedPhrase(element)));
-                result.addContent(RawHtml.nbsp);
                 if (!deprs.isEmpty()) {
                     List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
                     if (!commentTags.isEmpty()) {
@@ -191,19 +190,17 @@
             if (utils.isDeprecated(element)) {
                 result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
                         htmlWriter.getDeprecatedPhrase(element)));
-                result.addContent(RawHtml.nbsp);
                 if (!deprs.isEmpty()) {
                     List<? extends DocTree> bodyTags = ch.getBody(configuration, deprs.get(0));
                     Content body = commentTagsToOutput(null, element, bodyTags, false);
                     if (!body.isEmpty())
-                        result.addContent(HtmlTree.SPAN(HtmlStyle.deprecationComment, body));
+                        result.addContent(HtmlTree.DIV(HtmlStyle.deprecationComment, body));
                 }
             } else {
                 Element ee = utils.getEnclosingTypeElement(element);
                 if (utils.isDeprecated(ee)) {
                     result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
                         htmlWriter.getDeprecatedPhrase(ee)));
-                    result.addContent(RawHtml.nbsp);
                 }
             }
         }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Thu Oct 05 22:04:49 2017 +0200
@@ -660,7 +660,7 @@
     display:inline-block;
 }
 
-div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase,
+div.block div.deprecationComment, div.block div.block span.emphasizedPhrase,
 div.block div.block span.interfaceName {
     font-style:normal;
 }
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Tue Oct 03 13:19:47 2017 +0200
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Thu Oct 05 22:04:49 2017 +0200
@@ -234,49 +234,6 @@
             }
         },
 
-        new Option(true, CommandOption.CHECK_MODULES) {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                if (task.command != null) {
-                    throw new BadArgs("err.command.set", task.command, opt);
-                }
-                Set<String> mods =  Set.of(arg.split(","));
-                task.options.addmods.addAll(mods);
-                task.command = task.checkModuleDeps(mods);
-            }
-        },
-        new Option(true, CommandOption.GENERATE_MODULE_INFO) {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                if (task.command != null) {
-                    throw new BadArgs("err.command.set", task.command, opt);
-                }
-                task.command = task.genModuleInfo(Paths.get(arg), false);
-            }
-        },
-        new Option(true, CommandOption.GENERATE_OPEN_MODULE) {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                if (task.command != null) {
-                    throw new BadArgs("err.command.set", task.command, opt);
-                }
-                task.command = task.genModuleInfo(Paths.get(arg), true);
-            }
-        },
-        new Option(false, CommandOption.LIST_DEPS) {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                if (task.command != null) {
-                    throw new BadArgs("err.command.set", task.command, opt);
-                }
-                task.command = task.listModuleDeps(false);
-            }
-        },
-        new Option(false, CommandOption.LIST_REDUCED_DEPS) {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                if (task.command != null) {
-                    throw new BadArgs("err.command.set", task.command, opt);
-                }
-                task.command = task.listModuleDeps(true);
-            }
-        },
-
         // ---- paths option ----
         new Option(true, "-cp", "-classpath", "--class-path") {
             void process(JdepsTask task, String opt, String arg) {
@@ -312,15 +269,6 @@
                 task.options.addmods.addAll(mods);
             }
         },
-        new Option(true, "-m", "--module") {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                if (!task.options.rootModules.isEmpty()) {
-                    throw new BadArgs("err.option.already.specified", opt);
-                }
-                task.options.rootModules.add(arg);
-                task.options.addmods.add(arg);
-            }
-        },
         new Option(true, "--multi-release") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 if (arg.equalsIgnoreCase("base")) {
@@ -338,6 +286,70 @@
                 }
             }
         },
+        new Option(false, "-q", "-quiet") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.nowarning = true;
+            }
+        },
+        new Option(false, "-version", "--version") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.version = true;
+            }
+        },
+
+        // ---- module-specific options ----
+
+        new Option(true, "-m", "--module") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                if (!task.options.rootModules.isEmpty()) {
+                    throw new BadArgs("err.option.already.specified", opt);
+                }
+                task.options.rootModules.add(arg);
+                task.options.addmods.add(arg);
+            }
+        },
+        new Option(true, CommandOption.GENERATE_MODULE_INFO) {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                if (task.command != null) {
+                    throw new BadArgs("err.command.set", task.command, opt);
+                }
+                task.command = task.genModuleInfo(Paths.get(arg), false);
+            }
+        },
+        new Option(true, CommandOption.GENERATE_OPEN_MODULE) {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                if (task.command != null) {
+                    throw new BadArgs("err.command.set", task.command, opt);
+                }
+                task.command = task.genModuleInfo(Paths.get(arg), true);
+            }
+        },
+        new Option(true, CommandOption.CHECK_MODULES) {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                if (task.command != null) {
+                    throw new BadArgs("err.command.set", task.command, opt);
+                }
+                Set<String> mods =  Set.of(arg.split(","));
+                task.options.addmods.addAll(mods);
+                task.command = task.checkModuleDeps(mods);
+            }
+        },
+        new Option(false, CommandOption.LIST_DEPS) {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                if (task.command != null) {
+                    throw new BadArgs("err.command.set", task.command, opt);
+                }
+                task.command = task.listModuleDeps(false);
+            }
+        },
+        new Option(false, CommandOption.LIST_REDUCED_DEPS) {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                if (task.command != null) {
+                    throw new BadArgs("err.command.set", task.command, opt);
+                }
+                task.command = task.listModuleDeps(true);
+            }
+        },
 
         // ---- Target filtering options ----
         new Option(true, "-p", "-package", "--package") {
@@ -424,17 +436,6 @@
             }
         },
 
-        new Option(false, "-q", "-quiet") {
-            void process(JdepsTask task, String opt, String arg) {
-                task.options.nowarning = true;
-            }
-        },
-