changeset 50071:abdd4c02cf8d patterns

manual merge with default
author vromero
date Fri, 13 Apr 2018 14:55:11 -0400
parents c63f4ebb8d35 3852547060c8
children 9f2f2702ec31
files make/mapfiles/libjsig/mapfile-vers-solaris src/java.base/linux/native/libjsig/jsig.c src/java.base/macosx/native/libjsig/jsig.c src/java.base/share/classes/java/time/format/ZoneName.java src/java.base/solaris/native/libjsig/jsig.c src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
diffstat 132 files changed, 5356 insertions(+), 4066 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Apr 10 18:56:07 2018 +0100
+++ b/.hgtags	Fri Apr 13 14:55:11 2018 -0400
@@ -479,3 +479,4 @@
 3acb379b86725c47e7f33358cb22efa8752ae532 jdk-11+6
 f7363de371c9a1f668bd0a01b7df3d1ddb9cc58b jdk-11+7
 755e1b55a4dff510f9639cdb5c5e82549a7e09b3 jdk-11+8
+0c3e252cea44f06aef570ef464950ab97c669970 jdk-11+9
--- a/make/CreateJmods.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/CreateJmods.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -117,6 +117,17 @@
           --hash-modules '^(?!$(EXCLUDE_PATTERN)$$)'
     endif
   endif
+else # not java.base
+  ifeq ($(OPENJDK_TARGET_OS), windows)
+    # Only java.base needs to include the MSVC*_DLLs. Make sure no other module
+    # tries to include them (typically imported ones).
+    ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCR_DLL))), )
+      JMOD_FLAGS += --exclude '$(notdir $(MSVCR_DLL))'
+    endif
+    ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCP_DLL))), )
+      JMOD_FLAGS += --exclude '$(notdir $(MSVCP_DLL))'
+    endif
+  endif
 endif
 
 # Changes to the jmod tool itself should also trigger a rebuild of all jmods.
@@ -133,18 +144,21 @@
   DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS))
 endif
 
+JMOD_FLAGS += --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}'
+
 # Create jmods in a temp dir and then move them into place to keep the
 # module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
 $(JMODS_DIR)/$(MODULE).jmod: $(DEPS)
 	$(call LogWarn, Creating $(patsubst $(OUTPUTDIR)/%, %, $@))
 	$(call MakeDir, $(JMODS_DIR) $(JMODS_TEMPDIR))
 	$(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@)
-	$(JMOD) create \
-            --module-version $(VERSION_SHORT) \
-            --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
-            --module-path $(JMODS_DIR) \
-	    --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
-	    $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@)
+	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/jmods/$(MODULE).jmod, \
+	    $(JMOD) create \
+	        --module-version $(VERSION_SHORT) \
+	        --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
+	        --module-path $(JMODS_DIR) \
+	        $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@) \
+	)
 	$(MV) $(JMODS_TEMPDIR)/$(notdir $@) $@
 
 TARGETS += $(JMODS_DIR)/$(MODULE).jmod
--- a/make/Init.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/Init.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -226,6 +226,15 @@
   # Parse COMPARE_BUILD (for makefile development)
   $(eval $(call ParseCompareBuild))
 
+  # If no LOG= was given on command line, but we have a non-standard default
+  # value, use that instead and re-parse log level.
+  ifeq ($(LOG), )
+    ifneq ($(DEFAULT_LOG), )
+      override LOG := $(DEFAULT_LOG)
+      $(eval $(call ParseLogLevel))
+    endif
+  endif
+
   ifeq ($(LOG_NOFILE), true)
     # Disable build log if LOG=[level,]nofile was given
     override BUILD_LOG_PIPE :=
--- a/make/InitSupport.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/InitSupport.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -131,73 +131,6 @@
     endif
   endef
 
-  # Look for a given option in the LOG variable, and if found, set a variable
-  # and remove the option from the LOG variable
-  # $1: The option to look for
-  # $2: The option to set to "true" if the option is found
-  define ParseLogOption
-    ifneq ($$(findstring $1, $$(LOG)),)
-      $2 := true
-      # COMMA is defined in spec.gmk, but that is not included yet
-      COMMA := ,
-      # First try to remove ",<option>" if it exists, otherwise just remove "<option>"
-      LOG_STRIPPED := $$(subst $1,, $$(subst $$(COMMA)$(strip $1),, $$(LOG)))
-      # We might have ended up with a leading comma. Remove it. Need override
-      # since LOG is set from the command line.
-      override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
-    endif
-  endef
-
-  define ParseLogLevel
-    # Catch old-style VERBOSE= command lines.
-    ifneq ($$(origin VERBOSE), undefined)
-      $$(info Error: VERBOSE is deprecated. Use LOG=<warn|info|debug|trace> instead.)
-      $$(error Cannot continue)
-    endif
-
-    # Setup logging according to LOG
-
-    # If the "nofile" argument is given, act on it and strip it away
-    $$(eval $$(call ParseLogOption, nofile, LOG_NOFILE))
-
-    # If the "cmdline" argument is given, act on it and strip it away
-    $$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
-
-    # If the "profile-to-log" argument is given, write shell times in build log
-    $$(eval $$(call ParseLogOption, profile-to-log, LOG_PROFILE_TIMES_LOG))
-
-    # If the "profile" argument is given, write shell times in separate log file
-    # IMPORTANT: $(ParseLogOption profile-to-log) should go first. Otherwise
-    # parsing of 'LOG=debug,profile-to-log,nofile' ends up in the following error:
-    # Error: LOG contains unknown option or log level: debug-to-log.
-    $$(eval $$(call ParseLogOption, profile, LOG_PROFILE_TIMES_FILE))
-
-    # Treat LOG=profile-to-log as if it were LOG=profile,profile-to-log
-    LOG_PROFILE_TIMES_FILE := $$(firstword $$(LOG_PROFILE_TIMES_FILE) $$(LOG_PROFILE_TIMES_LOG))
-
-    LOG_LEVEL := $$(LOG)
-
-    ifeq ($$(LOG_LEVEL),)
-      # Set LOG to "warn" as default if not set
-      LOG_LEVEL := warn
-    endif
-
-    ifeq ($$(LOG_LEVEL), warn)
-      MAKE_LOG_FLAGS := -s
-    else ifeq ($$(LOG_LEVEL), info)
-      MAKE_LOG_FLAGS := -s
-    else ifeq ($$(LOG_LEVEL), debug)
-      MAKE_LOG_FLAGS :=
-    else ifeq ($$(LOG_LEVEL), trace)
-      MAKE_LOG_FLAGS :=
-    else
-      $$(info Error: LOG contains unknown option or log level: $$(LOG).)
-      $$(info LOG can be <level>[,<opt>[...]] where <opt> is nofile | cmdlines | profile | profile-to-log)
-      $$(info and <level> is warn | info | debug | trace)
-      $$(error Cannot continue)
-    endif
-  endef
-
   define ParseConfAndSpec
     ifneq ($$(origin SPEC), undefined)
       # We have been given a SPEC, check that it works out properly
@@ -477,30 +410,38 @@
   endef
 
   define PrintFailureReports
-	$(if $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log), \
-	  $(PRINTF) "\n=== Output from failing command(s) repeated here ===\n" $(NEWLINE) \
-	  $(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log)), \
-	      $(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" $(NEWLINE) \
-	      ($(GREP) -v -e "^Note: including file:" <  $(logfile) || true) | $(HEAD) -n 12 $(NEWLINE) \
-	      if test `$(WC) -l < $(logfile)` -gt 12; then \
-	        $(ECHO) "   ... (rest of output omitted)" ; \
-	      fi $(NEWLINE) \
+	$(if $(filter none, $(LOG_REPORT)), , \
+	  $(if $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log), \
+	    $(PRINTF) "\n=== Output from failing command(s) repeated here ===\n" $(NEWLINE) \
+	    $(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log)), \
+	        $(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" $(NEWLINE) \
+	        $(if $(filter all, $(LOG_REPORT)), \
+	          $(GREP) -v -e "^Note: including file:" <  $(logfile) || true $(NEWLINE) \
+	        , \
+	          ($(GREP) -v -e "^Note: including file:" <  $(logfile) || true) | $(HEAD) -n 12 $(NEWLINE) \
+	          if test `$(WC) -l < $(logfile)` -gt 12; then \
+	            $(ECHO) "   ... (rest of output omitted)" ; \
+	          fi $(NEWLINE) \
+	        ) \
+	    ) \
+	    $(PRINTF) "\n* All command lines available in $(MAKESUPPORT_OUTPUTDIR)/failure-logs.\n" $(NEWLINE) \
+	    $(PRINTF) "=== End of repeated output ===\n" \
 	  ) \
-	  $(PRINTF) "\n* All command lines available in $(MAKESUPPORT_OUTPUTDIR)/failure-logs.\n" $(NEWLINE) \
-	  $(PRINTF) "=== End of repeated output ===\n" \
 	)
   endef
 
   define PrintBuildLogFailures
-	if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then  \
-	  $(PRINTF) "\n=== Make failed targets repeated here ===\n" ; \
-	  $(GREP) "recipe for target .* failed" $(BUILD_LOG) ; \
-	  $(PRINTF) "=== End of repeated output ===\n" ; \
-	  $(PRINTF) "\nHint: Try searching the build log for the name of the first failed target.\n" ; \
-	else \
-	  $(PRINTF) "\nNo indication of failed target found.\n" ; \
-	  $(PRINTF) "Hint: Try searching the build log for '] Error'.\n" ; \
-	fi
+	$(if $(filter none, $(LOG_REPORT)), , \
+	  if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then  \
+	    $(PRINTF) "\n=== Make failed targets repeated here ===\n" ; \
+	    $(GREP) "recipe for target .* failed" $(BUILD_LOG) ; \
+	    $(PRINTF) "=== End of repeated output ===\n" ; \
+	    $(PRINTF) "\nHint: Try searching the build log for the name of the first failed target.\n" ; \
+	  else \
+	    $(PRINTF) "\nNo indication of failed target found.\n" ; \
+	    $(PRINTF) "Hint: Try searching the build log for '] Error'.\n" ; \
+	  fi \
+	)
   endef
 
   define RotateLogFiles
@@ -583,8 +524,107 @@
 
 endif # HAS_SPEC
 
+# Look for a given option in the LOG variable, and if found, set a variable
+# and remove the option from the LOG variable
+# $1: The option to look for
+# $2: The variable to set to "true" if the option is found
+define ParseLogOption
+  ifneq ($$(findstring $1, $$(LOG)),)
+    override $2 := true
+    # COMMA is defined in spec.gmk, but that is not included yet
+    COMMA := ,
+    # First try to remove ",<option>" if it exists, otherwise just remove "<option>"
+    LOG_STRIPPED := $$(subst $1,, $$(subst $$(COMMA)$$(strip $1),, $$(LOG)))
+    # We might have ended up with a leading comma. Remove it. Need override
+    # since LOG is set from the command line.
+    override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
+  endif
+endef
+
+# Look for a given option with an assignment in the LOG variable, and if found,
+# set a variable to that value and remove the option from the LOG variable
+# $1: The option to look for
+# $2: The variable to set to the value of the option, if found
+define ParseLogValue
+  ifneq ($$(findstring $1=, $$(LOG)),)
+    # Make words of out comma-separated list and find the one with opt=val
+    value := $$(strip $$(subst $$(strip $1)=,, $$(filter $$(strip $1)=%, $$(subst $$(COMMA), , $$(LOG)))))
+    override $2 := $$(value)
+    # COMMA is defined in spec.gmk, but that is not included yet
+    COMMA := ,
+    # First try to remove ",<option>" if it exists, otherwise just remove "<option>"
+    LOG_STRIPPED := $$(subst $$(strip $1)=$$(value),, \
+        $$(subst $$(COMMA)$$(strip $1)=$$(value),, $$(LOG)))
+    # We might have ended up with a leading comma. Remove it. Need override
+    # since LOG is set from the command line.
+    override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
+  endif
+endef
+
+
+define ParseLogLevel
+  # Catch old-style VERBOSE= command lines.
+  ifneq ($$(origin VERBOSE), undefined)
+    $$(info Error: VERBOSE is deprecated. Use LOG=<warn|info|debug|trace> instead.)
+    $$(error Cannot continue)
+  endif
+
+  # Setup logging according to LOG
+
+  # If "nofile" is present, do not log to a file
+  $$(eval $$(call ParseLogOption, nofile, LOG_NOFILE))
+
+  # If "cmdline" is present, print all executes "important" command lines.
+  $$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
+
+  # If "report" is present, use non-standard reporting options at build failure.
+  $$(eval $$(call ParseLogValue, report, LOG_REPORT))
+  ifneq ($$(LOG_REPORT), )
+    ifeq ($$(filter $$(LOG_REPORT), none all default), )
+      $$(info Error: LOG=report has invalid value: $$(LOG_REPORT).)
+      $$(info Valid values: LOG=report=<none>|<all>|<default>)
+      $$(error Cannot continue)
+    endif
+  endif
+
+  # If "profile-to-log" is present, write shell times in build log
+  $$(eval $$(call ParseLogOption, profile-to-log, LOG_PROFILE_TIMES_LOG))
+
+  # If "profile" is present, write shell times in separate log file
+  # IMPORTANT: $(ParseLogOption profile-to-log) should go first. Otherwise
+  # parsing of 'LOG=debug,profile-to-log,nofile' ends up in the following error:
+  # Error: LOG contains unknown option or log level: debug-to-log.
+  $$(eval $$(call ParseLogOption, profile, LOG_PROFILE_TIMES_FILE))
+
+  # Treat LOG=profile-to-log as if it were LOG=profile,profile-to-log
+  LOG_PROFILE_TIMES_FILE := $$(firstword $$(LOG_PROFILE_TIMES_FILE) $$(LOG_PROFILE_TIMES_LOG))
+
+  override LOG_LEVEL := $$(LOG)
+
+  ifeq ($$(LOG_LEVEL),)
+    # Set LOG to "warn" as default if not set
+    override LOG_LEVEL := warn
+  endif
+
+  ifeq ($$(LOG_LEVEL), warn)
+    override MAKE_LOG_FLAGS := -s
+  else ifeq ($$(LOG_LEVEL), info)
+    override MAKE_LOG_FLAGS := -s
+  else ifeq ($$(LOG_LEVEL), debug)
+    override MAKE_LOG_FLAGS :=
+  else ifeq ($$(LOG_LEVEL), trace)
+    override MAKE_LOG_FLAGS :=
+  else
+    $$(info Error: LOG contains unknown option or log level: $$(LOG).)
+    $$(info LOG can be <level>[,<opt>[...]] where <opt> is nofile | cmdlines | profile | profile-to-log)
+    $$(info and <level> is warn | info | debug | trace)
+    $$(error Cannot continue)
+  endif
+endef
+
 MAKE_LOG_VARS = $(foreach v, \
-    LOG_LEVEL LOG_NOFILE LOG_CMDLINES LOG_PROFILE_TIMES_LOG LOG_PROFILE_TIMES_FILE, \
+    LOG_LEVEL LOG_NOFILE LOG_CMDLINES LOG_REPORT LOG_PROFILE_TIMES_LOG \
+    LOG_PROFILE_TIMES_FILE, \
     $v=$($v) \
 )
 
--- a/make/autoconf/basics.m4	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/autoconf/basics.m4	Fri Apr 13 14:55:11 2018 -0400
@@ -23,6 +23,7 @@
 # questions.
 #
 
+###############################################################################
 # Create a function/macro that takes a series of named arguments. The call is
 # similar to AC_DEFUN, but the setup of the function looks like this:
 # BASIC_DEFUN_NAMED([MYFUNC], [FOO *BAR], [$@], [
@@ -91,6 +92,42 @@
   ])
 ])
 
+###############################################################################
+# Check if a list of space-separated words are selected only from a list of
+# space-separated legal words. Typical use is to see if a user-specified
+# set of words is selected from a set of legal words.
+#
+# Sets the specified variable to list of non-matching (offending) words, or to
+# the empty string if all words are matching the legal set.
+#
+# $1: result variable name
+# $2: list of values to check
+# $3: list of legal values
+AC_DEFUN([BASIC_GET_NON_MATCHING_VALUES],
+[
+  # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326
+  # Notice that the original variant fails on SLES 10 and 11
+  values_to_check=`$ECHO $2 | $TR ' ' '\n'`
+  legal_values=`$ECHO $3 | $TR ' ' '\n'`
+  result=`$GREP -Fvx "$legal_values" <<< "$values_to_check" | $GREP -v '^$'`
+  $1=${result//$'\n'/ }
+])
+
+###############################################################################
+# Sort a space-separated list, and remove duplicates.
+#
+# Sets the specified variable to the resulting list.
+#
+# $1: result variable name
+# $2: list of values to sort
+AC_DEFUN([BASIC_SORT_LIST],
+[
+  values_to_sort=`$ECHO $2 | $TR ' ' '\n'`
+  result=`$SORT -u <<< "$values_to_sort" | $GREP -v '^$'`
+  $1=${result//$'\n'/ }
+])
+
+###############################################################################
 # Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
 # If so, then append $1 to $2 \
 # Also set JVM_ARG_OK to true/false depending on outcome.
@@ -135,6 +172,7 @@
   fi
 ])
 
+###############################################################################
 # This will make sure the given variable points to a full and proper
 # path. This means:
 # 1) There will be no spaces in the path. On unix platforms,
@@ -178,6 +216,7 @@
   fi
 ])
 
+###############################################################################
 # This will make sure the given variable points to a executable
 # with a full and proper path. This means:
 # 1) There will be no spaces in the path. On unix platforms,
@@ -249,6 +288,7 @@
   fi
 ])
 
+###############################################################################
 AC_DEFUN([BASIC_REMOVE_SYMBOLIC_LINKS],
 [
   if test "x$OPENJDK_BUILD_OS" != xwindows; then
@@ -295,6 +335,7 @@
   fi
 ])
 
+###############################################################################
 # Register a --with argument but mark it as deprecated
 # $1: The name of the with argument to deprecate, not including --with-
 AC_DEFUN([BASIC_DEPRECATED_ARG_WITH],
@@ -304,6 +345,7 @@
       [AC_MSG_WARN([Option --with-$1 is deprecated and will be ignored.])])
 ])
 
+###############################################################################
 # Register a --enable argument but mark it as deprecated
 # $1: The name of the with argument to deprecate, not including --enable-
 # $2: The name of the argument to deprecate, in shell variable style (i.e. with _ instead of -)
@@ -322,6 +364,7 @@
   fi
 ])
 
+###############################################################################
 AC_DEFUN_ONCE([BASIC_INIT],
 [
   # Save the original command line. This is passed to us by the wrapper configure script.
@@ -334,6 +377,7 @@
   AC_MSG_NOTICE([Configuration created at $DATE_WHEN_CONFIGURED.])
 ])
 
+###############################################################################
 # Test that variable $1 denoting a program is not empty. If empty, exit with an error.
 # $1: variable to check
 AC_DEFUN([BASIC_CHECK_NONEMPTY],
@@ -343,6 +387,7 @@
   fi
 ])
 
+###############################################################################
 # Check that there are no unprocessed overridden variables left.
 # If so, they are an incorrect argument and we will exit with an error.
 AC_DEFUN([BASIC_CHECK_LEFTOVER_OVERRIDDEN],
@@ -354,6 +399,7 @@
   fi
 ])
 
+###############################################################################
 # Setup a tool for the given variable. If correctly specified by the user,
 # use that value, otherwise search for the tool using the supplied code snippet.
 # $1: variable to set
@@ -420,6 +466,7 @@
   fi
 ])
 
+###############################################################################
 # Call BASIC_SETUP_TOOL with AC_PATH_PROGS to locate the tool
 # $1: variable to set
 # $2: executable name (or list of names) to look for
@@ -429,6 +476,7 @@
   BASIC_SETUP_TOOL($1, [AC_PATH_PROGS($1, $2, , $3)])
 ])
 
+###############################################################################
 # Call BASIC_SETUP_TOOL with AC_CHECK_TOOLS to locate the tool
 # $1: variable to set
 # $2: executable name (or list of names) to look for
@@ -437,6 +485,7 @@
   BASIC_SETUP_TOOL($1, [AC_CHECK_TOOLS($1, $2)])
 ])
 
+###############################################################################
 # Like BASIC_PATH_PROGS but fails if no tool was found.
 # $1: variable to set
 # $2: executable name (or list of names) to look for
@@ -447,6 +496,7 @@
   BASIC_CHECK_NONEMPTY($1)
 ])
 
+###############################################################################
 # Like BASIC_SETUP_TOOL but fails if no tool was found.
 # $1: variable to set
 # $2: autoconf macro to call to look for the special tool
@@ -456,6 +506,7 @@
   BASIC_CHECK_NONEMPTY($1)
 ])
 
+###############################################################################
 # Setup the most fundamental tools that relies on not much else to set up,
 # but is used by much of the early bootstrap code.
 AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
@@ -528,6 +579,7 @@
   BASIC_PATH_PROGS(PANDOC, pandoc)
 ])
 
+###############################################################################
 # Setup basic configuration paths, and platform-specific stuff related to PATHs.
 AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
 [
@@ -569,6 +621,7 @@
   AC_SUBST(USERNAME)
 ])
 
+###############################################################################
 # Evaluates platform specific overrides for devkit variables.
 # $1: Name of variable
 AC_DEFUN([BASIC_EVAL_DEVKIT_VARIABLE],
@@ -578,6 +631,7 @@
   fi
 ])
 
+###############################################################################
 AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
 [
   AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
@@ -756,6 +810,7 @@
   AC_MSG_RESULT([$EXTRA_PATH])
 ])
 
+###############################################################################
 AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
 [
 
@@ -855,6 +910,7 @@
 
 #%%% Simple tools %%%
 
+###############################################################################
 # Check if we have found a usable version of make
 # $1: the path to a potential make binary (or empty)
 # $2: the description on how we found this
@@ -908,6 +964,7 @@
   fi
 ])
 
+###############################################################################
 AC_DEFUN([BASIC_CHECK_MAKE_OUTPUT_SYNC],
 [
   # Check if make supports the output sync option and if so, setup using it.
@@ -934,6 +991,7 @@
   AC_SUBST(OUTPUT_SYNC)
 ])
 
+###############################################################################
 # Goes looking for a usable version of GNU make.
 AC_DEFUN([BASIC_CHECK_GNU_MAKE],
 [
@@ -981,6 +1039,7 @@
   BASIC_CHECK_MAKE_OUTPUT_SYNC
 ])
 
+###############################################################################
 AC_DEFUN([BASIC_CHECK_FIND_DELETE],
 [
   # Test if find supports -delete
@@ -1009,6 +1068,7 @@
   AC_SUBST(FIND_DELETE)
 ])
 
+###############################################################################
 AC_DEFUN([BASIC_CHECK_TAR],
 [
   # Test which kind of tar was found
@@ -1043,6 +1103,7 @@
   AC_SUBST(TAR_SUPPORTS_TRANSFORM)
 ])
 
+###############################################################################
 AC_DEFUN([BASIC_CHECK_GREP],
 [
   # Test that grep supports -Fx with a list of pattern which includes null pattern.
@@ -1066,6 +1127,7 @@
   fi
 ])
 
+###############################################################################
 AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
 [
   BASIC_CHECK_GNU_MAKE
@@ -1132,6 +1194,7 @@
   fi
 ])
 
+###############################################################################
 # Check if build directory is on local disk. If not possible to determine,
 # we prefer to claim it's local.
 # Argument 1: directory to test
@@ -1171,6 +1234,7 @@
   fi
 ])
 
+###############################################################################
 # Check that source files have basic read permissions set. This might
 # not be the case in cygwin in certain conditions.
 AC_DEFUN_ONCE([BASIC_CHECK_SRC_PERMS],
@@ -1183,6 +1247,7 @@
   fi
 ])
 
+###############################################################################
 AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES],
 [
   AC_MSG_CHECKING([if build directory is on local disk])
@@ -1205,6 +1270,7 @@
   fi
 ])
 
+###############################################################################
 # Check for support for specific options in bash
 AC_DEFUN_ONCE([BASIC_CHECK_BASH_OPTIONS],
 [
@@ -1260,6 +1326,26 @@
   AC_SUBST(DEFAULT_MAKE_TARGET)
 ])
 
+###############################################################################
+# Setup the default value for LOG=
+#
+AC_DEFUN_ONCE([BASIC_SETUP_DEFAULT_LOG],
+[
+  AC_ARG_WITH(log, [AS_HELP_STRING([--with-log],
+      [[default vaue for make LOG argument [warn]]])])
+  AC_MSG_CHECKING([for default LOG value])
+  if test "x$with_log" = x; then
+    DEFAULT_LOG=""
+  else
+    # Syntax for valid LOG options is a bit too complex for it to be worth
+    # implementing a test for correctness in configure. Just accept it.
+    DEFAULT_LOG=$with_log
+  fi
+  AC_MSG_RESULT([$DEFAULT_LOG])
+  AC_SUBST(DEFAULT_LOG)
+])
+
+###############################################################################
 # Code to run after AC_OUTPUT
 AC_DEFUN_ONCE([BASIC_POST_CONFIG_OUTPUT],
 [
--- a/make/autoconf/configure.ac	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/autoconf/configure.ac	Fri Apr 13 14:55:11 2018 -0400
@@ -120,6 +120,7 @@
 
 # Misc basic settings
 BASIC_SETUP_DEFAULT_MAKE_TARGET
+BASIC_SETUP_DEFAULT_LOG
 
 ###############################################################################
 #
@@ -272,7 +273,7 @@
 CUSTOM_LATE_HOOK
 
 # This needs to be done after CUSTOM_LATE_HOOK since we can setup custom features.
-HOTSPOT_VALIDATE_JVM_FEATURES
+HOTSPOT_FINALIZE_JVM_FEATURES
 
 # Did user specify any unknown variables?
 BASIC_CHECK_LEFTOVER_OVERRIDDEN
--- a/make/autoconf/help.m4	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/autoconf/help.m4	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -213,8 +213,16 @@
   printf "Configuration summary:\n"
   printf "* Debug level:    $DEBUG_LEVEL\n"
   printf "* HS debug level: $HOTSPOT_DEBUG_LEVEL\n"
-  printf "* JDK variant:    $JDK_VARIANT\n"
   printf "* JVM variants:   $JVM_VARIANTS\n"
+  printf "* JVM features:   "
+
+  for variant in $JVM_VARIANTS; do
+    features_var_name=JVM_FEATURES_$variant
+    JVM_FEATURES_FOR_VARIANT=${!features_var_name}
+    printf "$variant: \'$JVM_FEATURES_FOR_VARIANT\' "
+  done
+  printf "\n"
+
   printf "* OpenJDK target: OS: $OPENJDK_TARGET_OS, CPU architecture: $OPENJDK_TARGET_CPU_ARCH, address length: $OPENJDK_TARGET_CPU_BITS\n"
   printf "* Version string: $VERSION_STRING ($VERSION_SHORT)\n"
 
--- a/make/autoconf/hotspot.m4	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/autoconf/hotspot.m4	Fri Apr 13 14:55:11 2018 -0400
@@ -93,22 +93,16 @@
   AC_MSG_RESULT([$JVM_VARIANTS])
 
   # Check that the selected variants are valid
-
-  # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326
-  # Notice that the original variant failes on SLES 10 and 11
-  NEEDLE=${VALID_JVM_VARIANTS// /$'\n'}
-  STACK=${JVM_VARIANTS// /$'\n'}
-  INVALID_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
+  BASIC_GET_NON_MATCHING_VALUES(INVALID_VARIANTS, $JVM_VARIANTS, $VALID_JVM_VARIANTS)
   if test "x$INVALID_VARIANTS" != x; then
-    AC_MSG_NOTICE([Unknown variant(s) specified: $INVALID_VARIANTS])
-    AC_MSG_ERROR([The available JVM variants are: $VALID_JVM_VARIANTS])
+    AC_MSG_NOTICE([Unknown variant(s) specified: "$INVALID_VARIANTS"])
+    AC_MSG_NOTICE([The available JVM variants are: "$VALID_JVM_VARIANTS"])
+    AC_MSG_ERROR([Cannot continue])
   fi
 
   # All "special" variants share the same output directory ("server")
   VALID_MULTIPLE_JVM_VARIANTS="server client minimal"
-  NEEDLE=${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}
-  STACK=${JVM_VARIANTS// /$'\n'}
-  INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
+  BASIC_GET_NON_MATCHING_VALUES(INVALID_MULTIPLE_VARIANTS, $JVM_VARIANTS, $VALID_MULTIPLE_JVM_VARIANTS)
   if  test "x$INVALID_MULTIPLE_VARIANTS" != x && test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = xtrue; then
     AC_MSG_ERROR([You cannot build multiple variants with anything else than $VALID_MULTIPLE_JVM_VARIANTS.])
   fi
@@ -263,14 +257,30 @@
 #
 AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
 [
+  # Prettify the VALID_JVM_FEATURES string
+  BASIC_SORT_LIST(VALID_JVM_FEATURES, $VALID_JVM_FEATURES)
+
   # The user can in some cases supply additional jvm features. For the custom
   # variant, this defines the entire variant.
   AC_ARG_WITH([jvm-features], [AS_HELP_STRING([--with-jvm-features],
-      [additional JVM features to enable (separated by comma),  use '--help' to show possible values @<:@none@:>@])])
+      [JVM features to enable (foo) or disable (-foo), separated by comma. Use '--help' to show possible values @<:@none@:>@])])
   if test "x$with_jvm_features" != x; then
-    AC_MSG_CHECKING([additional JVM features])
-    JVM_FEATURES=`$ECHO $with_jvm_features | $SED -e 's/,/ /g'`
-    AC_MSG_RESULT([$JVM_FEATURES])
+    AC_MSG_CHECKING([user specified JVM feature list])
+    USER_JVM_FEATURE_LIST=`$ECHO $with_jvm_features | $SED -e 's/,/ /g'`
+    AC_MSG_RESULT([$user_jvm_feature_list])
+    # These features will be added to all variant defaults
+    JVM_FEATURES=`$ECHO $USER_JVM_FEATURE_LIST | $AWK '{ for (i=1; i<=NF; i++) if (!match($i, /-.*/)) print $i }'`
+    # These features will be removed from all variant defaults
+    DISABLED_JVM_FEATURES=`$ECHO $USER_JVM_FEATURE_LIST | $AWK '{ for (i=1; i<=NF; i++) if (match($i, /-.*/)) print substr($i, 2) }'`
+
+    # Verify that the user has provided valid features
+    BASIC_GET_NON_MATCHING_VALUES(INVALID_FEATURES, $JVM_FEATURES $DISABLED_JVM_FEATURES, $VALID_JVM_FEATURES)
+    if test "x$INVALID_FEATURES" != x; then
+      AC_MSG_NOTICE([Unknown JVM features specified: "$INVALID_FEATURES"])
+      AC_MSG_NOTICE([The available JVM features are: "$VALID_JVM_FEATURES"])
+      AC_MSG_ERROR([Cannot continue])
+    fi
+
   fi
 
   # Override hotspot cpu definitions for ARM platforms
@@ -390,7 +400,7 @@
     NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES cds"
   fi
 
-  # Enable features depending on variant.
+  # Enable default features depending on variant.
   JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci $JVM_FEATURES_aot $JVM_FEATURES_graal"
   JVM_FEATURES_client="compiler1 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci"
   JVM_FEATURES_core="$NON_MINIMAL_FEATURES $JVM_FEATURES"
@@ -413,29 +423,29 @@
 ])
 
 ###############################################################################
-# Validate JVM features once all setup is complete, including custom setup.
+# Finalize JVM features once all setup is complete, including custom setup.
 #
-AC_DEFUN_ONCE([HOTSPOT_VALIDATE_JVM_FEATURES],
+AC_DEFUN_ONCE([HOTSPOT_FINALIZE_JVM_FEATURES],
 [
-  # Keep feature lists sorted and free of duplicates
-  JVM_FEATURES_server="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_server | $SORT -u))"
-  JVM_FEATURES_client="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_client | $SORT -u))"
-  JVM_FEATURES_core="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_core | $SORT -u))"
-  JVM_FEATURES_minimal="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_minimal | $SORT -u))"
-  JVM_FEATURES_zero="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_zero | $SORT -u))"
-  JVM_FEATURES_custom="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_custom | $SORT -u))"
-
-  # Validate features
   for variant in $JVM_VARIANTS; do
     AC_MSG_CHECKING([JVM features for JVM variant '$variant'])
     features_var_name=JVM_FEATURES_$variant
-    JVM_FEATURES_TO_TEST=${!features_var_name}
-    AC_MSG_RESULT([$JVM_FEATURES_TO_TEST])
-    NEEDLE=${VALID_JVM_FEATURES// /$'\n'}
-    STACK=${JVM_FEATURES_TO_TEST// /$'\n'}
-    INVALID_FEATURES=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
+    JVM_FEATURES_FOR_VARIANT=${!features_var_name}
+
+    # Filter out user-requested disabled features
+    BASIC_GET_NON_MATCHING_VALUES(JVM_FEATURES_FOR_VARIANT, $JVM_FEATURES_FOR_VARIANT, $DISABLED_JVM_FEATURES)
+
+    # Keep feature lists sorted and free of duplicates
+    BASIC_SORT_LIST(JVM_FEATURES_FOR_VARIANT, $JVM_FEATURES_FOR_VARIANT)
+
+    # Update real feature set variable
+    eval $features_var_name='"'$JVM_FEATURES_FOR_VARIANT'"'
+    AC_MSG_RESULT(["$JVM_FEATURES_FOR_VARIANT"])
+
+    # Validate features (for configure script errors, not user errors)
+    INVALID_FEATURES=`$GREP -Fvx "${VALID_JVM_FEATURES// /$'\n'}" <<< "${JVM_FEATURES_FOR_VARIANT// /$'\n'}"`
     if test "x$INVALID_FEATURES" != x; then
-      AC_MSG_ERROR([Invalid JVM feature(s): $INVALID_FEATURES])
+      AC_MSG_ERROR([Internal configure script error. Invalid JVM feature(s): $INVALID_FEATURES])
     fi
   done
 ])
--- a/make/autoconf/spec.gmk.in	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/autoconf/spec.gmk.in	Fri Apr 13 14:55:11 2018 -0400
@@ -332,6 +332,7 @@
 
 # Default make target
 DEFAULT_MAKE_TARGET:=@DEFAULT_MAKE_TARGET@
+DEFAULT_LOG:=@DEFAULT_LOG@
 
 FREETYPE_TO_USE:=@FREETYPE_TO_USE@
 FREETYPE_LIBS:=@FREETYPE_LIBS@
--- a/make/autoconf/toolchain_windows.m4	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/autoconf/toolchain_windows.m4	Fri Apr 13 14:55:11 2018 -0400
@@ -522,7 +522,6 @@
     if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
       AC_MSG_RESULT([ok])
       MSVC_DLL="$POSSIBLE_MSVC_DLL"
-      BASIC_FIXUP_PATH(MSVC_DLL)
       AC_MSG_CHECKING([for $DLL_NAME])
       AC_MSG_RESULT([$MSVC_DLL])
     else
--- a/make/common/NativeCompilation.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/common/NativeCompilation.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -905,20 +905,22 @@
 
       $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib
       $1_EXTRA_LDFLAGS += "-implib:$$($1_IMPORT_LIBRARY)"
-      # To properly trigger downstream dependants of the import library, just as
-      # for debug files, we must have a recipe in the rule. To avoid rerunning
-      # the recipe every time have it touch the target. If an import library
-      # file is deleted by something external, explicitly delete the target to
-      # trigger a rebuild of both.
-      ifneq ($$(wildcard $$($1_IMPORT_LIBRARY)), $$($1_IMPORT_LIBRARY))
-        $$(call LogDebug, Deleting $$($1_BASENAME) because import library is missing)
-        $$(shell $(RM) $$($1_TARGET))
-      endif
-      $$($1_IMPORT_LIBRARY): $$($1_TARGET)
+      ifeq ($$($1_TYPE), LIBRARY)
+        # To properly trigger downstream dependants of the import library, just as
+        # for debug files, we must have a recipe in the rule. To avoid rerunning
+        # the recipe every time have it touch the target. If an import library
+        # file is deleted by something external, explicitly delete the target to
+        # trigger a rebuild of both.
+        ifneq ($$(wildcard $$($1_IMPORT_LIBRARY)), $$($1_IMPORT_LIBRARY))
+          $$(call LogDebug, Deleting $$($1_BASENAME) because import library is missing)
+          $$(shell $(RM) $$($1_TARGET))
+        endif
+        $$($1_IMPORT_LIBRARY): $$($1_TARGET)
 		$$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
 		  $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
 		)
 		$(TOUCH) $$@
+      endif
     endif
 
     $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
--- a/make/conf/jib-profiles.js	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/conf/jib-profiles.js	Fri Apr 13 14:55:11 2018 -0400
@@ -497,8 +497,10 @@
             configure_args: [
                 "--with-jvm-variants=minimal1,client",
                 "--with-x=" + input.get("devkit", "install_path") + "/arm-linux-gnueabihf/libc/usr/X11R6-PI",
+                "--with-fontconfig=" + input.get("devkit", "install_path") + "/arm-linux-gnueabihf/libc/usr/X11R6-PI",
                 "--openjdk-target=arm-linux-gnueabihf",
-                "--with-abi-profile=arm-vfp-hflt"
+                "--with-abi-profile=arm-vfp-hflt",
+                "--with-freetype=bundled"
             ],
         },
 
--- a/make/gensrc/GensrcCLDR.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/gensrc/GensrcCLDR.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -34,19 +34,28 @@
 
 CLDR_BASE_LOCALES := "en-US"
 
+ZONENAME_TEMPLATE := $(TOPDIR)/src/java.base/share/classes/java/time/format/ZoneName.java.template
+
 $(CLDR_BASEMETAINFO_FILE): $(wildcard $(CLDRSRCDIR)/common/dtd/*.dtd) \
     $(wildcard $(CLDRSRCDIR)/common/main/en*.xml) \
     $(wildcard $(CLDRSRCDIR)/common/supplemental/*.xml) \
+    $(ZONENAME_TEMPLATE) \
     $(BUILD_TOOLS_JDK)
 	$(MKDIR) -p $(GENSRC_BASEDIR)
-	$(TOOL_CLDRCONVERTER) -base $(CLDRSRCDIR) -baselocales $(CLDR_BASE_LOCALES) -basemodule -o $(GENSRC_BASEDIR)
+	$(TOOL_CLDRCONVERTER) -base $(CLDRSRCDIR) \
+	    -baselocales $(CLDR_BASE_LOCALES) \
+	    -o $(GENSRC_BASEDIR) \
+	    -basemodule \
+	    -zntempfile $(ZONENAME_TEMPLATE)
 
 $(CLDR_METAINFO_FILE): $(wildcard $(CLDRSRCDIR)/common/dtd/*.dtd) \
     $(wildcard $(CLDRSRCDIR)/common/main/*.xml) \
     $(wildcard $(CLDRSRCDIR)/common/supplemental/*.xml) \
     $(BUILD_TOOLS_JDK)
 	$(MKDIR) -p $(GENSRC_DIR)
-	$(TOOL_CLDRCONVERTER) -base $(CLDRSRCDIR) -baselocales $(CLDR_BASE_LOCALES) -o $(GENSRC_DIR)
+	$(TOOL_CLDRCONVERTER) -base $(CLDRSRCDIR) \
+	    -baselocales $(CLDR_BASE_LOCALES) \
+	    -o $(GENSRC_DIR)
 
 GENSRC_JAVA_BASE += $(CLDR_BASEMETAINFO_FILE)
 GENSRC_JDK_LOCALEDATA += $(CLDR_METAINFO_FILE)
--- a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,16 +28,15 @@
 import static build.tools.cldrconverter.Bundle.jreTimeZoneNames;
 import build.tools.cldrconverter.BundleGenerator.BundleType;
 import java.io.File;
-import java.nio.file.DirectoryStream;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
+import java.nio.file.*;
+import java.time.*;
 import java.util.*;
 import java.util.ResourceBundle.Control;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
+import java.util.stream.Stream;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import org.xml.sax.SAXNotRecognizedException;
@@ -56,12 +55,13 @@
     static final String BCP47_LDML_DTD_SYSTEM_ID = "http://www.unicode.org/cldr/dtd/2.0/ldmlBCP47.dtd";
 
 
-    private static String CLDR_BASE = "../CLDR/21.0.1/";
+    private static String CLDR_BASE;
     static String LOCAL_LDML_DTD;
     static String LOCAL_SPPL_LDML_DTD;
     static String LOCAL_BCP47_LDML_DTD;
     private static String SOURCE_FILE_DIR;
     private static String SPPL_SOURCE_FILE;
+    private static String SPPL_META_SOURCE_FILE;
     private static String NUMBERING_SOURCE_FILE;
     private static String METAZONES_SOURCE_FILE;
     private static String LIKELYSUBTAGS_SOURCE_FILE;
@@ -85,6 +85,7 @@
     static final String PARENT_LOCALE_PREFIX = "parentLocale.";
 
     private static SupplementDataParseHandler handlerSuppl;
+    private static SupplementalMetadataParseHandler handlerSupplMeta;
     private static LikelySubtagsParseHandler handlerLikelySubtags;
     static NumberingSystemsParseHandler handlerNumbering;
     static MetaZonesParseHandler handlerMetaZones;
@@ -100,6 +101,9 @@
     private static final ResourceBundle.Control defCon =
         ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_DEFAULT);
 
+    private static final String[] AVAILABLE_TZIDS = TimeZone.getAvailableIDs();
+    private static String zoneNameTempFile;
+
     static enum DraftType {
         UNCONFIRMED,
         PROVISIONAL,
@@ -195,6 +199,10 @@
                         verbose = true;
                         break;
 
+                    case "-zntempfile":
+                        zoneNameTempFile = args[++i];
+                        break;
+
                     case "-help":
                         usage();
                         System.exit(0);
@@ -221,6 +229,7 @@
         NUMBERING_SOURCE_FILE = CLDR_BASE + "/supplemental/numberingSystems.xml";
         METAZONES_SOURCE_FILE = CLDR_BASE + "/supplemental/metaZones.xml";
         TIMEZONE_SOURCE_FILE = CLDR_BASE + "/bcp47/timezone.xml";
+        SPPL_META_SOURCE_FILE = CLDR_BASE + "/supplemental/supplementalMetadata.xml";
 
         if (BASE_LOCALES.isEmpty()) {
             setupBaseLocales("en-US");
@@ -234,6 +243,11 @@
 
         List<Bundle> bundles = readBundleList();
         convertBundles(bundles);
+
+        // Generate java.time.format.ZoneName.java
+        if (isBaseModule) {
+            generateZoneName();
+        }
     }
 
     private static void usage() {
@@ -246,7 +260,7 @@
                 + "\t-basemodule    generates bundles that go into java.base module%n"
                 + "\t-baselocales loc(,loc)*      locales that go into the base module%n"
                 + "\t-o dir         output directory (default: ./build/gensrc)%n"
-                + "\t-o dir         output directory (defaut: ./build/gensrc)%n"
+                + "\t-zntempfile    template file for java.time.format.ZoneName.java%n"
                 + "\t-utf8          use UTF-8 rather than \\uxxxx (for debug)%n");
     }
 
@@ -401,6 +415,11 @@
         // Parse likelySubtags
         handlerLikelySubtags = new LikelySubtagsParseHandler();
         parseLDMLFile(new File(LIKELYSUBTAGS_SOURCE_FILE), handlerLikelySubtags);
+
+        // Parse supplementalMetadata
+        // Currently only interested in deprecated time zone ids.
+        handlerSupplMeta = new SupplementalMetadataParseHandler();
+        parseLDMLFile(new File(SPPL_META_SOURCE_FILE), handlerSupplMeta);
     }
 
     // Parsers for data in "bcp47" directory
@@ -656,13 +675,16 @@
             });
         }
 
-        for (String tzid : handlerMetaZones.keySet()) {
-            String tzKey = TIMEZONE_ID_PREFIX + tzid;
-            Object data = map.get(tzKey);
+        Arrays.stream(AVAILABLE_TZIDS).forEach(tzid -> {
+            // If the tzid is deprecated, get the data for the replacement id
+            String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid))
+                                   .orElse(tzid);
+            Object data = map.get(TIMEZONE_ID_PREFIX + tzKey);
+
             if (data instanceof String[]) {
                 names.put(tzid, data);
             } else {
-                String meta = handlerMetaZones.get(tzid);
+                String meta = handlerMetaZones.get(tzKey);
                 if (meta != null) {
                     String metaKey = METAZONE_ID_PREFIX + meta;
                     data = map.get(metaKey);
@@ -673,7 +695,8 @@
                     }
                 }
             }
-        }
+        });
+
         return names;
     }
 
@@ -948,4 +971,44 @@
 
         return candidates;
     }
+
+    private static void generateZoneName() throws Exception {
+        Files.createDirectories(Paths.get(DESTINATION_DIR, "java", "time", "format"));
+        Files.write(Paths.get(DESTINATION_DIR, "java", "time", "format", "ZoneName.java"),
+            Files.lines(Paths.get(zoneNameTempFile))
+                .flatMap(l -> {
+                    if (l.equals("%%%%ZIDMAP%%%%")) {
+                        return zidMapEntry();
+                    } else if (l.equals("%%%%MZONEMAP%%%%")) {
+                        return handlerMetaZones.mzoneMapEntry();
+                    } else if (l.equals("%%%%DEPRECATED%%%%")) {
+                        return handlerSupplMeta.deprecatedMap();
+                    } else {
+                        return Stream.of(l);
+                    }
+                })
+                .collect(Collectors.toList()),
+            StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
+    }
+
+    private static Stream<String> zidMapEntry() {
+        Map<String, String> canonMap = new HashMap<>();
+        handlerTimeZone.getData().entrySet().stream()
+            .forEach(e -> {
+                String[] ids = ((String)e.getValue()).split("\\s");
+                for (int i = 1; i < ids.length; i++) {
+                    canonMap.put(ids[i], ids[0]);
+                }});
+        return ZoneId.getAvailableZoneIds().stream()
+                .map(id -> {
+                    String canonId = canonMap.getOrDefault(id, id);
+                    String meta = handlerMetaZones.get(canonId);
+                    String zone001 = handlerMetaZones.zidMap().get(meta);
+                    return zone001 == null ? "" :
+                            String.format("        \"%s\", \"%s\", \"%s\",",
+                                            id, meta, zone001);
+                })
+                .filter(s -> !s.isEmpty())
+                .sorted();
+    }
 }
--- a/make/jdk/src/classes/build/tools/cldrconverter/MetaZonesParseHandler.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/jdk/src/classes/build/tools/cldrconverter/MetaZonesParseHandler.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * 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,9 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.*;
+import java.util.stream.*;
+
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -34,6 +37,10 @@
 class MetaZonesParseHandler extends AbstractLDMLHandler<String> {
     private String tzid, metazone;
 
+    // for java.time.format.ZoneNames.java
+    private List<String> mzoneMapEntryList = new ArrayList<>();
+    private Map<String, String> zones = new HashMap<>();
+
     MetaZonesParseHandler() {
     }
 
@@ -64,6 +71,19 @@
             pushIgnoredContainer(qName);
             break;
 
+        case "mapZone":
+            String territory = attributes.getValue("territory");
+            if (territory.equals("001")) {
+                zones.put(attributes.getValue("other"), attributes.getValue("type"));
+            } else {
+                mzoneMapEntryList.add(String.format("        \"%s\", \"%s\", \"%s\",",
+                    attributes.getValue("other"),
+                    territory,
+                    attributes.getValue("type")));
+            }
+            pushIgnoredContainer(qName);
+            break;
+
         case "version":
         case "generation":
             pushIgnoredContainer(qName);
@@ -89,4 +109,12 @@
         }
         currentContainer = currentContainer.getParent();
     }
+
+    public Map<String, String> zidMap() {
+        return zones;
+    }
+
+    public Stream<String> mzoneMapEntry() {
+        return mzoneMapEntryList.stream();
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/jdk/src/classes/build/tools/cldrconverter/SupplementalMetadataParseHandler.java	Fri Apr 13 14:55:11 2018 -0400
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package build.tools.cldrconverter;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.stream.Stream;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Handles parsing of files in Locale Data Markup Language for
+ * SupplementalMetadata.xml
+ */
+
+class SupplementalMetadataParseHandler extends AbstractLDMLHandler<Object> {
+    @Override
+    public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException {
+        // avoid HTTP traffic to unicode.org
+        if (systemID.startsWith(CLDRConverter.SPPL_LDML_DTD_SYSTEM_ID)) {
+            return new InputSource((new File(CLDRConverter.LOCAL_SPPL_LDML_DTD)).toURI().toString());
+        }
+        return null;
+    }
+
+    @Override
+    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+        switch (qName) {
+        case "zoneAlias":
+            String reason = attributes.getValue("reason");
+            if ("deprecated".equals(reason)) {
+                put(attributes.getValue("type"), attributes.getValue("replacement"));
+            }
+            pushIgnoredContainer(qName);
+            break;
+        default:
+            // treat anything else as a container
+            pushContainer(qName, attributes);
+            break;
+        }
+    }
+
+    public Stream<String> deprecatedMap() {
+        return keySet().stream()
+                .map(k -> String.format("        \"%s\", \"%s\",", k, get(k)))
+                .sorted();
+    }
+}
--- a/make/launcher/Launcher-jdk.pack.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/launcher/Launcher-jdk.pack.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -88,6 +88,7 @@
     CFLAGS_solaris := -KPIC, \
     CFLAGS_macosx := -fPIC, \
     DISABLED_WARNINGS_gcc := unused-result implicit-fallthrough, \
+    DISABLED_WARNINGS_microsoft := 4005, \
     LDFLAGS := $(UNPACKEXE_ZIPOBJS) \
         $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/make/lib/Awt2dLibraries.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/lib/Awt2dLibraries.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -543,7 +543,7 @@
       DISABLED_WARNINGS_solstudio := \
          E_STATEMENT_NOT_REACHED \
          E_END_OF_LOOP_CODE_NOT_REACHED, \
-      DISABLED_WARNINGS_microsoft := 4267 4244, \
+      DISABLED_WARNINGS_microsoft := 4267 4244 4312, \
       LDFLAGS := $(LDFLAGS_JDKLIB) \
           $(call SET_SHARED_LIBRARY_ORIGIN), \
   ))
--- a/make/lib/Lib-java.base.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/lib/Lib-java.base.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -155,10 +155,10 @@
 ################################################################################
 # Create the jsig library
 
-ifneq ($(OPENJDK_TARGET_OS), windows)
+ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
   ifeq ($(STATIC_BUILD), false)
 
-    LIBJSIG_SRC_DIR := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjsig
+    LIBJSIG_SRC_DIR := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjsig
     LIBJSIG_MAPFILE := $(wildcard $(TOPDIR)/make/mapfiles/libjsig/mapfile-vers-$(OPENJDK_TARGET_OS))
 
     ifeq ($(OPENJDK_TARGET_OS), linux)
--- a/make/lib/Lib-java.desktop.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/lib/Lib-java.desktop.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -50,6 +50,7 @@
 
   LIBJSOUND_CFLAGS := \
       -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop \
+      $(ALSA_CFLAGS) \
       $(LIBJAVA_HEADER_FLAGS) \
       $(foreach dir, $(LIBJSOUND_SRC_DIRS), -I$(dir)) \
       -DX_PLATFORM=X_$(OPENJDK_TARGET_OS_UPPERCASE) \
--- a/make/lib/Lib-jdk.accessibility.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/lib/Lib-jdk.accessibility.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -45,6 +45,7 @@
         NAME := javaaccessbridge$1, \
         SRC := $(JAVA_AB_SRCDIR), \
         OPTIMIZATION := LOW, \
+        DISABLED_WARNINGS_microsoft := 4311 4302 4312, \
         CFLAGS := $(CFLAGS_JDKLIB) $(ACCESSBRIDGE_CFLAGS) \
             $(addprefix -I,$(JAVA_AB_SRCDIR)) \
             -I$(ROOT_SRCDIR)/include/bridge \
@@ -69,6 +70,7 @@
         NAME := windowsaccessbridge$1, \
         SRC := $(WIN_AB_SRCDIR), \
         OPTIMIZATION := LOW, \
+        DISABLED_WARNINGS_microsoft := 4311 4302 4312, \
         CFLAGS := $(filter-out -MD, $(CFLAGS_JDKLIB)) -MT $(ACCESSBRIDGE_CFLAGS) \
             $(addprefix -I,$(WIN_AB_SRCDIR)) \
             -I$(ROOT_SRCDIR)/include/bridge \
--- a/make/lib/Lib-jdk.pack.gmk	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/lib/Lib-jdk.pack.gmk	Fri Apr 13 14:55:11 2018 -0400
@@ -40,6 +40,7 @@
         $(LIBJAVA_HEADER_FLAGS), \
     CFLAGS_release := -DPRODUCT, \
     DISABLED_WARNINGS_gcc := implicit-fallthrough, \
+    DISABLED_WARNINGS_microsoft := 4005, \
     LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LDFLAGS_windows := -map:$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpack.map -debug, \
--- a/make/mapfiles/libjsig/mapfile-vers-solaris	Tue Apr 10 18:56:07 2018 +0100
+++ b/make/mapfiles/libjsig/mapfile-vers-solaris	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
         global:
             JVM_begin_signal_setting;
             JVM_end_signal_setting;
-            JVM_get_libjsig_version;
             JVM_get_signal_action;
             sigaction;
             signal;
--- a/src/hotspot/os/solaris/os_solaris.cpp	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/hotspot/os/solaris/os_solaris.cpp	Fri Apr 13 14:55:11 2018 -0400
@@ -2101,8 +2101,6 @@
 static int *preinstalled_sigs = NULL;
 static struct sigaction *chainedsigactions = NULL;
 static Semaphore* sig_sem = NULL;
-typedef int (*version_getting_t)();
-version_getting_t os::Solaris::get_libjsig_version = NULL;
 
 int os::sigexitnum_pd() {
   assert(Sigexit > 0, "signal memory not yet initialized");
@@ -3968,13 +3966,7 @@
                                         dlsym(RTLD_DEFAULT, "JVM_end_signal_setting"));
     get_signal_action = CAST_TO_FN_PTR(get_signal_t,
                                        dlsym(RTLD_DEFAULT, "JVM_get_signal_action"));
-    get_libjsig_version = CAST_TO_FN_PTR(version_getting_t,
-                                         dlsym(RTLD_DEFAULT, "JVM_get_libjsig_version"));
     libjsig_is_loaded = true;
-    if (os::Solaris::get_libjsig_version != NULL) {
-      int libjsigversion =  (*os::Solaris::get_libjsig_version)();
-      assert(libjsigversion == JSIG_VERSION_1_4_1, "libjsig version mismatch");
-    }
     assert(UseSignalChaining, "should enable signal-chaining");
   }
   if (libjsig_is_loaded) {
--- a/src/java.base/linux/native/libjsig/jsig.c	Tue Apr 10 18:56:07 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-/* CopyrightVersion 1.2 */
-
-/* This is a special library that should be loaded before libc &
- * libthread to interpose the signal handler installation functions:
- * sigaction(), signal(), sigset().
- * Used for signal-chaining. See RFE 4381843.
- */
-
-#include <signal.h>
-#include <dlfcn.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#define bool int
-#define true 1
-#define false 0
-
-#define MASK(sig) ((uint64_t)1 << (sig-1))  // 0 is not a signal.
-// Check whether all signals fit into jvmsigs. -1 as MASK shifts by -1.
-#if (64 < NSIG-1)
-#error "Not all signals can be encoded in jvmsigs. Adapt its type!"
-#endif
-static struct sigaction sact[NSIG]; /* saved signal handlers */
-static uint64_t jvmsigs = 0; /* signals used by jvm */
-
-/* used to synchronize the installation of signal handlers */
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-static pthread_t tid = 0;
-
-typedef void (*sa_handler_t)(int);
-typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
-typedef sa_handler_t (*signal_t)(int, sa_handler_t);
-typedef int (*sigaction_t)(int, const struct sigaction *, struct sigaction *);
-
-static signal_t os_signal = 0; /* os's version of signal()/sigset() */
-static sigaction_t os_sigaction = 0; /* os's version of sigaction() */
-
-static bool jvm_signal_installing = false;
-static bool jvm_signal_installed = false;
-
-static void signal_lock() {
-  pthread_mutex_lock(&mutex);
-  /* When the jvm is installing its set of signal handlers, threads
-   * other than the jvm thread should wait */
-  if (jvm_signal_installing) {
-    if (tid != pthread_self()) {
-      pthread_cond_wait(&cond, &mutex);
-    }
-  }
-}
-
-static void signal_unlock() {
-  pthread_mutex_unlock(&mutex);
-}
-
-static sa_handler_t call_os_signal(int sig, sa_handler_t disp,
-                                   bool is_sigset) {
-  if (os_signal == NULL) {
-    if (!is_sigset) {
-      os_signal = (signal_t)dlsym(RTLD_NEXT, "signal");
-    } else {
-      os_signal = (signal_t)dlsym(RTLD_NEXT, "sigset");
-    }
-    if (os_signal == NULL) {
-      printf("%s\n", dlerror());
-      exit(0);
-    }
-  }
-  return (*os_signal)(sig, disp);
-}
-
-static void save_signal_handler(int sig, sa_handler_t disp) {
-  sigset_t set;
-  sact[sig].sa_handler = disp;
-  sigemptyset(&set);
-  sact[sig].sa_mask = set;
-  sact[sig].sa_flags = 0;
-}
-
-static sa_handler_t set_signal(int sig, sa_handler_t disp, bool is_sigset) {
-  sa_handler_t oldhandler;
-  bool sigused;
-
-  signal_lock();
-
-  sigused = (sig < NSIG) && ((MASK(sig) & jvmsigs) != 0);
-  if (jvm_signal_installed && sigused) {
-    /* jvm has installed its signal handler for this signal. */
-    /* Save the handler. Don't really install it. */
-    oldhandler = sact[sig].sa_handler;
-    save_signal_handler(sig, disp);
-
-    signal_unlock();
-    return oldhandler;
-  } else if (sig < NSIG && jvm_signal_installing) {
-    /* jvm is installing its signal handlers. Install the new
-     * handlers and save the old ones. jvm uses sigaction().
-     * Leave the piece here just in case. */
-    oldhandler = call_os_signal(sig, disp, is_sigset);
-    save_signal_handler(sig, oldhandler);
-
-    /* Record the signals used by jvm */
-    jvmsigs |= MASK(sig);
-
-    signal_unlock();
-    return oldhandler;
-  } else {
-    /* jvm has no relation with this signal (yet). Install the
-     * the handler. */
-    oldhandler = call_os_signal(sig, disp, is_sigset);
-
-    signal_unlock();
-    return oldhandler;
-  }
-}
-
-sa_handler_t signal(int sig, sa_handler_t disp) {
-  return set_signal(sig, disp, false);
-}
-
-sa_handler_t sigset(int sig, sa_handler_t disp) {
-  return set_signal(sig, disp, true);
- }
-
-static int call_os_sigaction(int sig, const struct sigaction  *act,
-                             struct sigaction *oact) {
-  if (os_sigaction == NULL) {
-    os_sigaction = (sigaction_t)dlsym(RTLD_NEXT, "sigaction");
-    if (os_sigaction == NULL) {
-      printf("%s\n", dlerror());
-      exit(0);
-    }
-  }
-  return (*os_sigaction)(sig, act, oact);
-}
-
-int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) {
-  int res;
-  bool sigused;
-  struct sigaction oldAct;
-
-  signal_lock();
-
-  sigused = (sig < NSIG) && ((MASK(sig) & jvmsigs) != 0);
-  if (jvm_signal_installed && sigused) {
-    /* jvm has installed its signal handler for this signal. */
-    /* Save the handler. Don't really install it. */
-    if (oact != NULL) {
-      *oact = sact[sig];
-    }
-    if (act != NULL) {
-      sact[sig] = *act;
-    }
-
-    signal_unlock();
-    return 0;
-  } else if (sig < NSIG && jvm_signal_installing) {
-    /* jvm is installing its signal handlers. Install the new
-     * handlers and save the old ones. */
-    res = call_os_sigaction(sig, act, &oldAct);
-    sact[sig] = oldAct;
-    if (oact != NULL) {
-      *oact = oldAct;
-    }
-
-    /* Record the signals used by jvm */
-    jvmsigs |= MASK(sig);
-
-    signal_unlock();
-    return res;
-  } else {
-    /* jvm has no relation with this signal (yet). Install the
-     * the handler. */
-    res = call_os_sigaction(sig, act, oact);
-
-    signal_unlock();
-    return res;
-  }
-}
-
-/* The three functions for the jvm to call into */
-void JVM_begin_signal_setting() {
-  signal_lock();
-  jvm_signal_installing = true;
-  tid = pthread_self();
-  signal_unlock();
-}
-
-void JVM_end_signal_setting() {
-  signal_lock();
-  jvm_signal_installed = true;
-  jvm_signal_installing = false;
-  pthread_cond_broadcast(&cond);
-  signal_unlock();
-}
-
-struct sigaction *JVM_get_signal_action(int sig) {
-  /* Does race condition make sense here? */
-  if ((MASK(sig) & jvmsigs) != 0) {
-    return &sact[sig];
-  }
-  return NULL;
-}
--- a/src/java.base/macosx/native/libjsig/jsig.c	Tue Apr 10 18:56:07 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,237 +0,0 @@
-/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-/* CopyrightVersion 1.2 */
-
-/* This is a special library that should be loaded before libc &
- * libthread to interpose the signal handler installation functions:
- * sigaction(), signal(), sigset().
- * Used for signal-chaining. See RFE 4381843.
- */
-
-#include <signal.h>
-#include <dlfcn.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-#define MASK(sig) ((uint32_t)1 << (sig-1))  // 0 is not a signal.
-#if (32 < NSIG-1)
-#error "Not all signals can be encoded in jvmsigs. Adapt its type!"
-#endif
-static struct sigaction sact[NSIG]; /* saved signal handlers */
-static uint32_t jvmsigs = 0; /* signals used by jvm */
-static __thread bool reentry = false; /* prevent reentry deadlock (per-thread) */
-
-/* used to synchronize the installation of signal handlers */
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-static pthread_t tid = 0;
-
-typedef void (*sa_handler_t)(int);
-typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
-typedef sa_handler_t (*signal_t)(int, sa_handler_t);
-typedef int (*sigaction_t)(int, const struct sigaction *, struct sigaction *);
-
-static signal_t os_signal = 0; /* os's version of signal()/sigset() */
-static sigaction_t os_sigaction = 0; /* os's version of sigaction() */
-
-static bool jvm_signal_installing = false;
-static bool jvm_signal_installed = false;
-
-static void signal_lock() {
-  pthread_mutex_lock(&mutex);
-  /* When the jvm is installing its set of signal handlers, threads
-   * other than the jvm thread should wait */
-  if (jvm_signal_installing) {
-    if (tid != pthread_self()) {
-      pthread_cond_wait(&cond, &mutex);
-    }
-  }
-}
-
-static void signal_unlock() {
-  pthread_mutex_unlock(&mutex);
-}
-
-static sa_handler_t call_os_signal(int sig, sa_handler_t disp,
-                                   bool is_sigset) {
-  sa_handler_t res;
-
-  if (os_signal == NULL) {
-    if (!is_sigset) {
-      os_signal = (signal_t)dlsym(RTLD_NEXT, "signal");
-    } else {
-      os_signal = (signal_t)dlsym(RTLD_NEXT, "sigset");
-    }
-    if (os_signal == NULL) {
-      printf("%s\n", dlerror());
-      exit(0);
-    }
-  }
-  reentry = true;
-  res = (*os_signal)(sig, disp);
-  reentry = false;
-  return res;
-}
-
-static void save_signal_handler(int sig, sa_handler_t disp) {
-  sigset_t set;
-  sact[sig].sa_handler = disp;
-  sigemptyset(&set);
-  sact[sig].sa_mask = set;
-  sact[sig].sa_flags = 0;
-}
-
-static sa_handler_t set_signal(int sig, sa_handler_t disp, bool is_sigset) {
-  sa_handler_t oldhandler;
-  bool sigused;
-
-  signal_lock();
-
-  sigused = (MASK(sig) & jvmsigs) != 0;
-  if (jvm_signal_installed && sigused) {
-    /* jvm has installed its signal handler for this signal. */
-    /* Save the handler. Don't really install it. */
-    oldhandler = sact[sig].sa_handler;
-    save_signal_handler(sig, disp);
-
-    signal_unlock();
-    return oldhandler;
-  } else if (jvm_signal_installing) {
-    /* jvm is installing its signal handlers. Install the new
-     * handlers and save the old ones. jvm uses sigaction().
-     * Leave the piece here just in case. */
-    oldhandler = call_os_signal(sig, disp, is_sigset);
-    save_signal_handler(sig, oldhandler);
-
-    /* Record the signals used by jvm */
-    jvmsigs |= MASK(sig);
-
-    signal_unlock();
-    return oldhandler;
-  } else {
-    /* jvm has no relation with this signal (yet). Install the
-     * the handler. */
-    oldhandler = call_os_signal(sig, disp, is_sigset);
-
-    signal_unlock();
-    return oldhandler;
-  }
-}
-
-sa_handler_t signal(int sig, sa_handler_t disp) {
-  return set_signal(sig, disp, false);
-}
-
-sa_handler_t sigset(int sig, sa_handler_t disp) {
-  printf("sigset() is not supported by BSD");
-  exit(0);
- }
-
-static int call_os_sigaction(int sig, const struct sigaction  *act,
-                             struct sigaction *oact) {
-  if (os_sigaction == NULL) {
-    os_sigaction = (sigaction_t)dlsym(RTLD_NEXT, "sigaction");
-    if (os_sigaction == NULL) {
-      printf("%s\n", dlerror());
-      exit(0);
-    }
-  }
-  return (*os_sigaction)(sig, act, oact);
-}
-
-int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) {
-  int res;
-  bool sigused;
-  struct sigaction oldAct;
-
-  if (reentry) {
-    return call_os_sigaction(sig, act, oact);
-  }
-
-  signal_lock();
-
-  sigused = (MASK(sig) & jvmsigs) != 0;
-  if (jvm_signal_installed && sigused) {
-    /* jvm has installed its signal handler for this signal. */
-    /* Save the handler. Don't really install it. */
-    if (oact != NULL) {
-      *oact = sact[sig];
-    }
-    if (act != NULL) {
-      sact[sig] = *act;
-    }
-
-    signal_unlock();
-    return 0;
-  } else if (jvm_signal_installing) {
-    /* jvm is installing its signal handlers. Install the new
-     * handlers and save the old ones. */
-    res = call_os_sigaction(sig, act, &oldAct);
-    sact[sig] = oldAct;
-    if (oact != NULL) {
-      *oact = oldAct;
-    }
-
-    /* Record the signals used by jvm */
-    jvmsigs |= MASK(sig);
-
-    signal_unlock();
-    return res;
-  } else {
-    /* jvm has no relation with this signal (yet). Install the
-     * the handler. */
-    res = call_os_sigaction(sig, act, oact);
-
-    signal_unlock();
-    return res;
-  }
-}
-
-/* The three functions for the jvm to call into */
-void JVM_begin_signal_setting() {
-  signal_lock();
-  jvm_signal_installing = true;
-  tid = pthread_self();
-  signal_unlock();
-}
-
-void JVM_end_signal_setting() {
-  signal_lock();
-  jvm_signal_installed = true;
-  jvm_signal_installing = false;
-  pthread_cond_broadcast(&cond);
-  signal_unlock();
-}
-
-struct sigaction *JVM_get_signal_action(int sig) {
-  /* Does race condition make sense here? */
-  if ((MASK(sig) & jvmsigs) != 0) {
-    return &sact[sig];
-  }
-  return NULL;
-}
--- a/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java	Fri Apr 13 14:55:11 2018 -0400
@@ -49,6 +49,18 @@
                                Object info,
                                // Caller information:
                                Class<?> callerClass) {
+        // Restrict bootstrap methods to those whose first parameter is Lookup
+        // The motivation here is, in the future, to possibly support BSMs
+        // that do not accept the meta-data of lookup/name/type, thereby
+        // allowing the co-opting of existing methods to be used as BSMs as
+        // long as the static arguments can be passed as method arguments
+        MethodType mt = bootstrapMethod.type();
+        if (mt.parameterCount() < 2 ||
+            !MethodHandles.Lookup.class.isAssignableFrom(mt.parameterType(0))) {
+            throw new BootstrapMethodError(
+                    "Invalid bootstrap method declared for resolving a dynamic constant: " + bootstrapMethod);
+        }
+
         // BSMI.invoke handles all type checking and exception translation.
         // If type is not a reference type, the JVM is expecting a boxed
         // version, and will manage unboxing on the other side.
--- a/src/java.base/share/classes/java/lang/invoke/package-info.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/lang/invoke/package-info.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -122,8 +122,11 @@
  * On success the call site then becomes permanently linked to the {@code invokedynamic}
  * instruction.
  * <p>
- * For a dynamically-computed constant, the result of the bootstrap method is cached
- * as the resolved constant value.
+ * For a dynamically-computed constant, the first parameter of the bootstrap
+ * method must be assignable to {@code MethodHandles.Lookup}. If this condition
+ * is not met, a {@code BootstrapMethodError} is thrown.
+ * On success the result of the bootstrap method is cached as the resolved
+ * constant value.
  * <p>
  * If an exception, {@code E} say, occurs during execution of the bootstrap method, then
  * resolution fails and terminates abnormally. {@code E} is rethrown if the type of
@@ -171,16 +174,25 @@
  * <h2>Types of bootstrap methods</h2>
  * For a dynamically-computed call site, the bootstrap method is invoked with parameter
  * types {@code MethodHandles.Lookup}, {@code String}, {@code MethodType}, and the types
- * of any static arguments; the return type is {@code CallSite}. For a
- * dynamically-computed constant, the bootstrap method is invoked with parameter types
+ * of any static arguments; the return type is {@code CallSite}.
+ * <p>
+ * For a dynamically-computed constant, the bootstrap method is invoked with parameter types
  * {@code MethodHandles.Lookup}, {@code String}, {@code Class}, and the types of any
  * static arguments; the return type is the type represented by the {@code Class}.
- *
+ * <p>
  * Because {@link java.lang.invoke.MethodHandle#invoke MethodHandle.invoke} allows for
- * adaptations between the invoked method type and the method handle's method type,
+ * adaptations between the invoked method type and the bootstrap method handle's method type,
  * there is flexibility in the declaration of the bootstrap method.
- * For example, the first argument could be {@code Object}
- * instead of {@code MethodHandles.Lookup}, and the return type
+ * For a dynamically-computed constant the first parameter type of the bootstrap method handle
+ * must be assignable to {@code MethodHandles.Lookup}, other than that constraint the same degree
+ * of flexibility applies to bootstrap methods of dynamically-computed call sites and
+ * dynamically-computed constants.
+ * Note: this constraint allows for the future possibility where the bootstrap method is
+ * invoked with just the parameter types of static arguments, thereby supporting a wider
+ * range of methods compatible with the static arguments (such as methods that don't declare
+ * or require the lookup, name, and type meta-data parameters).
+ * <p> For example, for dynamically-computed call site, a the first argument
+ * could be {@code Object} instead of {@code MethodHandles.Lookup}, and the return type
  * could also be {@code Object} instead of {@code CallSite}.
  * (Note that the types and number of the stacked arguments limit
  * the legal kinds of bootstrap methods to appropriately typed
@@ -227,7 +239,10 @@
  * {@code String} and {@code Integer} (or {@code int}), respectively.
  * The second-to-last example assumes that all extra arguments are of type
  * {@code String}.
- * The other examples work with all types of extra arguments.
+ * The other examples work with all types of extra arguments.  Note that all
+ * the examples except the second and third also work with dynamically-computed
+ * constants if the return type is changed to be compatible with the
+ * constant's declared type (such as {@code Object}, which is always compatible).
  * <p>
  * Since dynamically-computed constants can be provided as static arguments to bootstrap
  * methods, there are no limitations on the types of bootstrap arguments.
--- a/src/java.base/share/classes/java/nio/Bits.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/nio/Bits.java	Fri Apr 13 14:55:11 2018 -0400
@@ -65,25 +65,13 @@
 
     private static final Unsafe UNSAFE = Unsafe.getUnsafe();
 
-    static Unsafe unsafe() {
-        return UNSAFE;
-    }
-
-
     // -- Processor and memory-system properties --
 
-    private static final ByteOrder BYTE_ORDER
-        = UNSAFE.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
-
-    static ByteOrder byteOrder() {
-        return BYTE_ORDER;
-    }
-
     private static int PAGE_SIZE = -1;
 
     static int pageSize() {
         if (PAGE_SIZE == -1)
-            PAGE_SIZE = unsafe().pageSize();
+            PAGE_SIZE = UNSAFE.pageSize();
         return PAGE_SIZE;
     }
 
--- a/src/java.base/share/classes/java/nio/Buffer.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/nio/Buffer.java	Fri Apr 13 14:55:11 2018 -0400
@@ -183,7 +183,7 @@
 
 public abstract class Buffer {
     // Cached unsafe-access object
-    static final Unsafe UNSAFE = Bits.unsafe();
+    static final Unsafe UNSAFE = Unsafe.getUnsafe();
 
     /**
      * The characteristics of Spliterators that traverse and split elements
--- a/src/java.base/share/classes/java/nio/ByteOrder.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/nio/ByteOrder.java	Fri Apr 13 14:55:11 2018 -0400
@@ -25,6 +25,7 @@
 
 package java.nio;
 
+import jdk.internal.misc.Unsafe;
 
 /**
  * A typesafe enumeration for byte orders.
@@ -57,6 +58,12 @@
     public static final ByteOrder LITTLE_ENDIAN
         = new ByteOrder("LITTLE_ENDIAN");
 
+    // Retrieve the native byte order. It's used early during bootstrap, and
+    // must be initialized after BIG_ENDIAN and LITTLE_ENDIAN.
+    private static final ByteOrder NATIVE_ORDER
+        = Unsafe.getUnsafe().isBigEndian()
+            ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
+
     /**
      * Retrieves the native byte order of the underlying platform.
      *
@@ -69,7 +76,7 @@
      *          virtual machine is running
      */
     public static ByteOrder nativeOrder() {
-        return Bits.byteOrder();
+        return NATIVE_ORDER;
     }
 
     /**
--- a/src/java.base/share/classes/java/nio/X-Buffer.java.template	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template	Fri Apr 13 14:55:11 2018 -0400
@@ -1579,7 +1579,7 @@
     boolean bigEndian                                   // package-private
         = true;
     boolean nativeByteOrder                             // package-private
-        = (Bits.byteOrder() == ByteOrder.BIG_ENDIAN);
+        = (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN);
 
     /**
      * Retrieves this buffer's byte order.
@@ -1608,7 +1608,7 @@
     public final $Type$Buffer order(ByteOrder bo) {
         bigEndian = (bo == ByteOrder.BIG_ENDIAN);
         nativeByteOrder =
-            (bigEndian == (Bits.byteOrder() == ByteOrder.BIG_ENDIAN));
+            (bigEndian == (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN));
         return this;
     }
 
--- a/src/java.base/share/classes/java/time/format/ZoneName.java	Tue Apr 10 18:56:07 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,798 +0,0 @@
-/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.time.format;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * A helper class to map a zone name to metazone and back to the
- * appropriate zone id for the particular locale.
- * <p>
- * The zid<->metazone mappings are based on CLDR metaZones.xml.
- * The alias mappings are based on Link entries in tzdb data files.
- */
-class ZoneName {
-
-    public static String toZid(String zid, Locale locale) {
-        String mzone = zidToMzone.get(zid);
-        if (mzone == null && aliases.containsKey(zid)) {
-            zid = aliases.get(zid);
-            mzone = zidToMzone.get(zid);
-        }
-        if (mzone != null) {
-            Map<String, String> map = mzoneToZidL.get(mzone);
-            if (map != null && map.containsKey(locale.getCountry())) {
-                zid = map.get(locale.getCountry());
-            } else {
-                zid = mzoneToZid.get(mzone);
-            }
-        }
-        return toZid(zid);
-    }
-
-    public static String toZid(String zid) {
-        if (aliases.containsKey(zid)) {
-            return aliases.get(zid);
-        }
-        return zid;
-    }
-
-    private static final String[] zidMap = new String[] {
-        "Pacific/Rarotonga", "Cook", "Pacific/Rarotonga",
-        "Europe/Tirane", "Europe_Central", "Europe/Paris",
-        "America/Recife", "Brasilia", "America/Sao_Paulo",
-        "America/Argentina/San_Juan", "Argentina", "America/Buenos_Aires",
-        "Asia/Kolkata", "India", "Asia/Calcutta",
-        "America/Guayaquil", "Ecuador", "America/Guayaquil",
-        "Europe/Samara", "Moscow", "Europe/Moscow",
-        "Indian/Antananarivo", "Africa_Eastern", "Africa/Nairobi",
-        "America/Santa_Isabel", "America_Pacific", "America/Los_Angeles",
-        "America/Montserrat", "Atlantic", "America/Halifax",
-        "Pacific/Port_Moresby", "Papua_New_Guinea", "Pacific/Port_Moresby",
-        "Europe/Paris", "Europe_Central", "Europe/Paris",
-        "America/Argentina/Salta", "Argentina", "America/Buenos_Aires",
-        "Asia/Omsk", "Omsk", "Asia/Omsk",
-        "Africa/Ceuta", "Europe_Central", "Europe/Paris",
-        "America/Argentina/San_Luis", "Argentina_Western", "America/Argentina/San_Luis",
-        "America/Atikokan", "America_Eastern", "America/New_York",
-        "Asia/Vladivostok", "Vladivostok", "Asia/Vladivostok",
-        "America/Argentina/Jujuy", "Argentina", "America/Buenos_Aires",
-        "Asia/Almaty", "Kazakhstan_Eastern", "Asia/Almaty",
-        "Atlantic/Canary", "Europe_Western", "Atlantic/Canary",
-        "Asia/Bangkok", "Indochina", "Asia/Saigon",
-        "America/Caracas", "Venezuela", "America/Caracas",
-        "Australia/Hobart", "Australia_Eastern", "Australia/Sydney",
-        "America/Havana", "Cuba", "America/Havana",
-        "Africa/Malabo", "Africa_Western", "Africa/Lagos",
-        "Australia/Lord_Howe", "Lord_Howe", "Australia/Lord_Howe",
-        "Pacific/Fakaofo", "Tokelau", "Pacific/Fakaofo",
-        "America/Matamoros", "America_Central", "America/Chicago",
-        "America/Guadeloupe", "Atlantic", "America/Halifax",
-        "Europe/Helsinki", "Europe_Eastern", "Europe/Bucharest",
-        "Asia/Calcutta", "India", "Asia/Calcutta",
-        "Africa/Kinshasa", "Africa_Western", "Africa/Lagos",
-        "America/Miquelon", "Pierre_Miquelon", "America/Miquelon",
-        "Europe/Athens", "Europe_Eastern", "Europe/Bucharest",
-        "Asia/Novosibirsk", "Novosibirsk", "Asia/Novosibirsk",
-        "Indian/Cocos", "Cocos", "Indian/Cocos",
-        "Africa/Bujumbura", "Africa_Central", "Africa/Maputo",
-        "Europe/Mariehamn", "Europe_Eastern", "Europe/Bucharest",
-        "America/Winnipeg", "America_Central", "America/Chicago",
-        "America/Buenos_Aires", "Argentina", "America/Buenos_Aires",
-        "America/Yellowknife", "America_Mountain", "America/Denver",
-        "Pacific/Midway", "Samoa", "Pacific/Apia",
-        "Africa/Dar_es_Salaam", "Africa_Eastern", "Africa/Nairobi",
-        "Pacific/Tahiti", "Tahiti", "Pacific/Tahiti",
-        "Asia/Gaza", "Europe_Eastern", "Europe/Bucharest",
-        "Australia/Lindeman", "Australia_Eastern", "Australia/Sydney",
-        "Europe/Kaliningrad", "Europe_Eastern", "Europe/Bucharest",
-        "Europe/Bucharest", "Europe_Eastern", "Europe/Bucharest",
-        "America/Lower_Princes", "Atlantic", "America/Halifax",
-        "Pacific/Chuuk", "Truk", "Pacific/Truk",
-        "America/Anchorage", "Alaska", "America/Juneau",
-        "America/Rankin_Inlet", "America_Central", "America/Chicago",
-        "America/Marigot", "Atlantic", "America/Halifax",
-        "Africa/Juba", "Africa_Eastern", "Africa/Nairobi",
-        "Africa/Algiers", "Europe_Central", "Europe/Paris",
-        "Europe/Kiev", "Europe_Eastern", "Europe/Bucharest",
-        "America/Santarem", "Brasilia", "America/Sao_Paulo",
-        "Africa/Brazzaville", "Africa_Western", "Africa/Lagos",
-        "Asia/Choibalsan", "Choibalsan", "Asia/Choibalsan",
-        "Indian/Christmas", "Christmas", "Indian/Christmas",
-        "America/Nassau", "America_Eastern", "America/New_York",
-        "Africa/Tunis", "Europe_Central", "Europe/Paris",
-        "Pacific/Noumea", "New_Caledonia", "Pacific/Noumea",
-        "Africa/El_Aaiun", "Europe_Western", "Atlantic/Canary",
-        "Europe/Sarajevo", "Europe_Central", "Europe/Paris",
-        "America/Campo_Grande", "Amazon", "America/Manaus",
-        "America/Puerto_Rico", "Atlantic", "America/Halifax",
-        "Antarctica/Mawson", "Mawson", "Antarctica/Mawson",
-        "Pacific/Galapagos", "Galapagos", "Pacific/Galapagos",
-        "Asia/Tehran", "Iran", "Asia/Tehran",
-        "America/Port-au-Prince", "America_Eastern", "America/New_York",
-        "America/Scoresbysund", "Greenland_Eastern", "America/Scoresbysund",
-        "Africa/Harare", "Africa_Central", "Africa/Maputo",
-        "America/Dominica", "Atlantic", "America/Halifax",
-        "Europe/Chisinau", "Europe_Eastern", "Europe/Bucharest",
-        "America/Chihuahua", "America_Mountain", "America/Denver",
-        "America/La_Paz", "Bolivia", "America/La_Paz",
-        "Indian/Chagos", "Indian_Ocean", "Indian/Chagos",
-        "Australia/Broken_Hill", "Australia_Central", "Australia/Adelaide",
-        "America/Grenada", "Atlantic", "America/Halifax",
-        "America/North_Dakota/New_Salem", "America_Central", "America/Chicago",
-        "Pacific/Majuro", "Marshall_Islands", "Pacific/Majuro",
-        "Australia/Adelaide", "Australia_Central", "Australia/Adelaide",
-        "Europe/Warsaw", "Europe_Central", "Europe/Paris",
-        "Europe/Vienna", "Europe_Central", "Europe/Paris",
-        "Atlantic/Cape_Verde", "Cape_Verde", "Atlantic/Cape_Verde",
-        "America/Mendoza", "Argentina", "America/Buenos_Aires",
-        "Pacific/Gambier", "Gambier", "Pacific/Gambier",
-        "Europe/Istanbul", "Europe_Eastern", "Europe/Bucharest",
-        "America/Kentucky/Monticello", "America_Eastern", "America/New_York",
-        "America/Chicago", "America_Central", "America/Chicago",
-        "Asia/Ulaanbaatar", "Mongolia", "Asia/Ulaanbaatar",
-        "Indian/Maldives", "Maldives", "Indian/Maldives",
-        "America/Mexico_City", "America_Central", "America/Chicago",
-        "Africa/Asmara", "Africa_Eastern", "Africa/Nairobi",
-        "Asia/Chongqing", "China", "Asia/Shanghai",
-        "America/Argentina/La_Rioja", "Argentina", "America/Buenos_Aires",
-        "America/Tijuana", "America_Pacific", "America/Los_Angeles",
-        "Asia/Harbin", "China", "Asia/Shanghai",
-        "Pacific/Honolulu", "Hawaii_Aleutian", "Pacific/Honolulu",
-        "Atlantic/Azores", "Azores", "Atlantic/Azores",
-        "Indian/Mayotte", "Africa_Eastern", "Africa/Nairobi",
-        "America/Guatemala", "America_Central", "America/Chicago",
-        "America/Indianapolis", "America_Eastern", "America/New_York",
-        "America/Halifax", "Atlantic", "America/Halifax",
-        "America/Resolute", "America_Central", "America/Chicago",
-        "Europe/London", "GMT", "Atlantic/Reykjavik",
-        "America/Hermosillo", "America_Mountain", "America/Denver",
-        "Atlantic/Madeira", "Europe_Western", "Atlantic/Canary",
-        "Europe/Zagreb", "Europe_Central", "Europe/Paris",
-        "America/Boa_Vista", "Amazon", "America/Manaus",
-        "America/Regina", "America_Central", "America/Chicago",
-        "America/Cordoba", "Argentina", "America/Buenos_Aires",
-        "America/Shiprock", "America_Mountain", "America/Denver",
-        "Europe/Luxembourg", "Europe_Central", "Europe/Paris",
-        "America/Cancun", "America_Central", "America/Chicago",
-        "Pacific/Enderbury", "Phoenix_Islands", "Pacific/Enderbury",
-        "Africa/Bissau", "GMT", "Atlantic/Reykjavik",
-        "Antarctica/Vostok", "Vostok", "Antarctica/Vostok",
-        "Pacific/Apia", "Samoa", "Pacific/Apia",
-        "Australia/Perth", "Australia_Western", "Australia/Perth",
-        "America/Juneau", "Alaska", "America/Juneau",
-        "Africa/Mbabane", "Africa_Southern", "Africa/Johannesburg",
-        "Pacific/Niue", "Niue", "Pacific/Niue",
-        "Europe/Zurich", "Europe_Central", "Europe/Paris",
-        "America/Rio_Branco", "Amazon", "America/Manaus",
-        "Africa/Ndjamena", "Africa_Western", "Africa/Lagos",
-        "Asia/Macau", "China", "Asia/Shanghai",
-        "America/Lima", "Peru", "America/Lima",
-        "Africa/Windhoek", "Africa_Central", "Africa/Maputo",
-        "America/Sitka", "Alaska", "America/Juneau",
-        "America/Mazatlan", "America_Mountain", "America/Denver",
-        "Asia/Saigon", "Indochina", "Asia/Saigon",
-        "Asia/Kamchatka", "Magadan", "Asia/Magadan",
-        "America/Menominee", "America_Central", "America/Chicago",
-        "America/Belize", "America_Central", "America/Chicago",
-        "America/Sao_Paulo", "Brasilia", "America/Sao_Paulo",
-        "America/Barbados", "Atlantic", "America/Halifax",
-        "America/Porto_Velho", "Amazon", "America/Manaus",
-        "America/Costa_Rica", "America_Central", "America/Chicago",
-        "Europe/Monaco", "Europe_Central", "Europe/Paris",
-        "Europe/Riga", "Europe_Eastern", "Europe/Bucharest",
-        "Europe/Vatican", "Europe_Central", "Europe/Paris",
-        "Europe/Madrid", "Europe_Central", "Europe/Paris",
-        "Africa/Dakar", "GMT", "Atlantic/Reykjavik",
-        "Asia/Damascus", "Europe_Eastern", "Europe/Bucharest",
-        "Asia/Hong_Kong", "Hong_Kong", "Asia/Hong_Kong",
-        "America/Adak", "Hawaii_Aleutian", "Pacific/Honolulu",
-        "Europe/Vilnius", "Europe_Eastern", "Europe/Bucharest",
-        "America/Indiana/Indianapolis", "America_Eastern", "America/New_York",
-        "Africa/Freetown", "GMT", "Atlantic/Reykjavik",
-        "Atlantic/Reykjavik", "GMT", "Atlantic/Reykjavik",
-        "Asia/Ho_Chi_Minh", "Indochina", "Asia/Saigon",
-        "America/St_Kitts", "Atlantic", "America/Halifax",
-        "America/Martinique", "Atlantic", "America/Halifax",
-        "America/Thule", "Atlantic", "America/Halifax",
-        "America/Asuncion", "Paraguay", "America/Asuncion",
-        "Africa/Luanda", "Africa_Western", "Africa/Lagos",
-        "America/Monterrey", "America_Central", "America/Chicago",
-        "Pacific/Fiji", "Fiji", "Pacific/Fiji",
-        "Africa/Banjul", "GMT", "Atlantic/Reykjavik",
-        "America/Grand_Turk", "America_Eastern", "America/New_York",
-        "Pacific/Pitcairn", "Pitcairn", "Pacific/Pitcairn",
-        "America/Montevideo", "Uruguay", "America/Montevideo",
-        "America/Bahia_Banderas", "America_Central", "America/Chicago",
-        "America/Cayman", "America_Eastern", "America/New_York",
-        "Pacific/Norfolk", "Norfolk", "Pacific/Norfolk",
-        "Africa/Ouagadougou", "GMT", "Atlantic/Reykjavik",
-        "America/Maceio", "Brasilia", "America/Sao_Paulo",
-        "Pacific/Guam", "Chamorro", "Pacific/Saipan",
-        "Africa/Monrovia", "GMT", "Atlantic/Reykjavik",
-        "Africa/Bamako", "GMT", "Atlantic/Reykjavik",
-        "Asia/Colombo", "India", "Asia/Calcutta",
-        "Asia/Urumqi", "China", "Asia/Shanghai",
-        "Asia/Kabul", "Afghanistan", "Asia/Kabul",
-        "America/Yakutat", "Alaska", "America/Juneau",
-        "America/Phoenix", "America_Mountain", "America/Denver",
-        "Asia/Nicosia", "Europe_Eastern", "Europe/Bucharest",
-        "Asia/Phnom_Penh", "Indochina", "Asia/Saigon",
-        "America/Rainy_River", "America_Central", "America/Chicago",
-        "Europe/Uzhgorod", "Europe_Eastern", "Europe/Bucharest",
-        "Pacific/Saipan", "Chamorro", "Pacific/Saipan",
-        "America/St_Vincent", "Atlantic", "America/Halifax",
-        "Europe/Rome", "Europe_Central", "Europe/Paris",
-        "America/Nome", "Alaska", "America/Juneau",
-        "Africa/Mogadishu", "Africa_Eastern", "Africa/Nairobi",
-        "Europe/Zaporozhye", "Europe_Eastern", "Europe/Bucharest",
-        "Pacific/Funafuti", "Tuvalu", "Pacific/Funafuti",
-        "Atlantic/South_Georgia", "South_Georgia", "Atlantic/South_Georgia",
-        "Europe/Skopje", "Europe_Central", "Europe/Paris",
-        "Asia/Yekaterinburg", "Yekaterinburg", "Asia/Yekaterinburg",
-        "Australia/Melbourne", "Australia_Eastern", "Australia/Sydney",
-        "America/Argentina/Cordoba", "Argentina", "America/Buenos_Aires",
-        "Africa/Kigali", "Africa_Central", "Africa/Maputo",
-        "Africa/Blantyre", "Africa_Central", "Africa/Maputo",
-        "Africa/Tripoli", "Europe_Eastern", "Europe/Bucharest",
-        "Africa/Gaborone", "Africa_Central", "Africa/Maputo",
-        "Asia/Kuching", "Malaysia", "Asia/Kuching",
-        "Pacific/Nauru", "Nauru", "Pacific/Nauru",
-        "America/Aruba", "Atlantic", "America/Halifax",
-        "America/Antigua", "Atlantic", "America/Halifax",
-        "Europe/Volgograd", "Volgograd", "Europe/Volgograd",
-        "Africa/Djibouti", "Africa_Eastern", "Africa/Nairobi",
-        "America/Catamarca", "Argentina", "America/Buenos_Aires",
-        "Asia/Manila", "Philippines", "Asia/Manila",
-        "Pacific/Kiritimati", "Line_Islands", "Pacific/Kiritimati",
-        "Asia/Shanghai", "China", "Asia/Shanghai",
-        "Pacific/Truk", "Truk", "Pacific/Truk",
-        "Pacific/Tarawa", "Gilbert_Islands", "Pacific/Tarawa",
-        "Africa/Conakry", "GMT", "Atlantic/Reykjavik",
-        "Asia/Bishkek", "Kyrgystan", "Asia/Bishkek",
-        "Europe/Gibraltar", "Europe_Central", "Europe/Paris",
-        "Asia/Rangoon", "Myanmar", "Asia/Rangoon",
-        "Asia/Baku", "Azerbaijan", "Asia/Baku",
-        "America/Santiago", "Chile", "America/Santiago",
-        "America/El_Salvador", "America_Central", "America/Chicago",
-        "America/Noronha", "Noronha", "America/Noronha",
-        "America/St_Thomas", "Atlantic", "America/Halifax",
-        "Atlantic/St_Helena", "GMT", "Atlantic/Reykjavik",
-        "Asia/Krasnoyarsk", "Krasnoyarsk", "Asia/Krasnoyarsk",
-        "America/Vancouver", "America_Pacific", "America/Los_Angeles",
-        "Europe/Belgrade", "Europe_Central", "Europe/Paris",
-        "America/St_Barthelemy", "Atlantic", "America/Halifax",
-        "Asia/Pontianak", "Indonesia_Western", "Asia/Jakarta",
-        "Africa/Lusaka", "Africa_Central", "Africa/Maputo",
-        "America/Godthab", "Greenland_Western", "America/Godthab",
-        "Asia/Dhaka", "Bangladesh", "Asia/Dhaka",
-        "Asia/Dubai", "Gulf", "Asia/Dubai",
-        "Europe/Moscow", "Moscow", "Europe/Moscow",
-        "America/Louisville", "America_Eastern", "America/New_York",
-        "Australia/Darwin", "Australia_Central", "Australia/Adelaide",
-        "America/Santo_Domingo", "Atlantic", "America/Halifax",
-        "America/Argentina/Ushuaia", "Argentina", "America/Buenos_Aires",
-        "America/Tegucigalpa", "America_Central", "America/Chicago",
-        "Asia/Aden", "Arabian", "Asia/Riyadh",
-        "America/Inuvik", "America_Mountain", "America/Denver",
-        "Asia/Beirut", "Europe_Eastern", "Europe/Bucharest",
-        "Asia/Qatar", "Arabian", "Asia/Riyadh",
-        "Europe/Oslo", "Europe_Central", "Europe/Paris",
-        "Asia/Anadyr", "Magadan", "Asia/Magadan",
-        "Pacific/Palau", "Palau", "Pacific/Palau",
-        "Arctic/Longyearbyen", "Europe_Central", "Europe/Paris",
-        "America/Anguilla", "Atlantic", "America/Halifax",
-        "Asia/Aqtau", "Kazakhstan_Western", "Asia/Aqtobe",
-        "Asia/Yerevan", "Armenia", "Asia/Yerevan",
-        "Africa/Lagos", "Africa_Western", "Africa/Lagos",
-        "America/Denver", "America_Mountain", "America/Denver",
-        "Antarctica/Palmer", "Chile", "America/Santiago",
-        "Europe/Stockholm", "Europe_Central", "Europe/Paris",
-        "America/Bahia", "Brasilia", "America/Sao_Paulo",
-        "America/Danmarkshavn", "GMT", "Atlantic/Reykjavik",
-        "Indian/Mauritius", "Mauritius", "Indian/Mauritius",
-        "Pacific/Chatham", "Chatham", "Pacific/Chatham",
-        "Europe/Prague", "Europe_Central", "Europe/Paris",
-        "America/Blanc-Sablon", "Atlantic", "America/Halifax",
-        "America/Bogota", "Colombia", "America/Bogota",
-        "America/Managua", "America_Central", "America/Chicago",
-        "Pacific/Auckland", "New_Zealand", "Pacific/Auckland",
-        "Atlantic/Faroe", "Europe_Western", "Atlantic/Canary",
-        "America/Cambridge_Bay", "America_Mountain", "America/Denver",
-        "America/Los_Angeles", "America_Pacific", "America/Los_Angeles",
-        "Africa/Khartoum", "Africa_Central", "Africa/Maputo",
-        "Europe/Simferopol", "Europe_Eastern", "Europe/Bucharest",
-        "Australia/Currie", "Australia_Eastern", "Australia/Sydney",
-        "Europe/Guernsey", "GMT", "Atlantic/Reykjavik",
-        "Asia/Thimphu", "Bhutan", "Asia/Thimphu",
-        "America/Eirunepe", "Amazon", "America/Manaus",
-        "Africa/Nairobi", "Africa_Eastern", "Africa/Nairobi",
-        "Asia/Yakutsk", "Yakutsk", "Asia/Yakutsk",
-        "Asia/Yangon", "Myanmar", "Asia/Rangoon",
-        "America/Goose_Bay", "Atlantic", "America/Halifax",
-        "Africa/Maseru", "Africa_Southern", "Africa/Johannesburg",
-        "America/Swift_Current", "America_Central", "America/Chicago",
-        "America/Guyana", "Guyana", "America/Guyana",
-        "Asia/Tokyo", "Japan", "Asia/Tokyo",
-        "Indian/Kerguelen", "French_Southern", "Indian/Kerguelen",
-        "America/Belem", "Brasilia", "America/Sao_Paulo",
-        "Pacific/Wallis", "Wallis", "Pacific/Wallis",
-        "America/Whitehorse", "America_Pacific", "America/Los_Angeles",
-        "America/North_Dakota/Beulah", "America_Central", "America/Chicago",
-        "Asia/Jerusalem", "Israel", "Asia/Jerusalem",
-        "Antarctica/Syowa", "Syowa", "Antarctica/Syowa",
-        "America/Thunder_Bay", "America_Eastern", "America/New_York",
-        "Asia/Brunei", "Brunei", "Asia/Brunei",
-        "America/Metlakatla", "America_Pacific", "America/Los_Angeles",
-        "Asia/Dushanbe", "Tajikistan", "Asia/Dushanbe",
-        "Pacific/Kosrae", "Kosrae", "Pacific/Kosrae",
-        "America/Coral_Harbour", "America_Eastern", "America/New_York",
-        "America/Tortola", "Atlantic", "America/Halifax",
-        "Asia/Karachi", "Pakistan", "Asia/Karachi",
-        "Indian/Reunion", "Reunion", "Indian/Reunion",
-        "America/Detroit", "America_Eastern", "America/New_York",
-        "Australia/Eucla", "Australia_CentralWestern", "Australia/Eucla",
-        "Asia/Seoul", "Korea", "Asia/Seoul",
-        "Asia/Singapore", "Singapore", "Asia/Singapore",
-        "Africa/Casablanca", "Europe_Western", "Atlantic/Canary",
-        "Asia/Dili", "East_Timor", "Asia/Dili",
-        "America/Indiana/Vincennes", "America_Eastern", "America/New_York",
-        "Europe/Dublin", "GMT", "Atlantic/Reykjavik",
-        "America/St_Johns", "Newfoundland", "America/St_Johns",
-        "Antarctica/Macquarie", "Macquarie", "Antarctica/Macquarie",
-        "America/Port_of_Spain", "Atlantic", "America/Halifax",
-        "Europe/Budapest", "Europe_Central", "Europe/Paris",
-        "America/Fortaleza", "Brasilia", "America/Sao_Paulo",
-        "Australia/Brisbane", "Australia_Eastern", "Australia/Sydney",
-        "Atlantic/Bermuda", "Atlantic", "America/Halifax",
-        "Asia/Amman", "Europe_Eastern", "Europe/Bucharest",
-        "Asia/Tashkent", "Uzbekistan", "Asia/Tashkent",
-        "Antarctica/DumontDUrville", "DumontDUrville", "Antarctica/DumontDUrville",
-        "Antarctica/Casey", "Australia_Western", "Australia/Perth",
-        "Asia/Vientiane", "Indochina", "Asia/Saigon",
-        "Pacific/Johnston", "Hawaii_Aleutian", "Pacific/Honolulu",
-        "America/Jamaica", "America_Eastern", "America/New_York",
-        "Africa/Addis_Ababa", "Africa_Eastern", "Africa/Nairobi",
-        "Pacific/Ponape", "Ponape", "Pacific/Ponape",
-        "Europe/Jersey", "GMT", "Atlantic/Reykjavik",
-        "Africa/Lome", "GMT", "Atlantic/Reykjavik",
-        "America/Manaus", "Amazon", "America/Manaus",
-        "Africa/Niamey", "Africa_Western", "Africa/Lagos",
-        "Asia/Kashgar", "China", "Asia/Shanghai",
-        "Pacific/Tongatapu", "Tonga", "Pacific/Tongatapu",
-        "Europe/Minsk", "Europe_Eastern", "Europe/Bucharest",
-        "America/Edmonton", "America_Mountain", "America/Denver",
-        "Asia/Baghdad", "Arabian", "Asia/Riyadh",
-        "Asia/Kathmandu", "Nepal", "Asia/Katmandu",
-        "America/Ojinaga", "America_Mountain", "America/Denver",
-        "Africa/Abidjan", "GMT", "Atlantic/Reykjavik",
-        "America/Indiana/Winamac", "America_Eastern", "America/New_York",
-        "Asia/Qyzylorda", "Kazakhstan_Eastern", "Asia/Almaty",
-        "Australia/Sydney", "Australia_Eastern", "Australia/Sydney",
-        "Asia/Ashgabat", "Turkmenistan", "Asia/Ashgabat",
-        "Europe/Amsterdam", "Europe_Central", "Europe/Paris",
-        "America/Dawson_Creek", "America_Mountain", "America/Denver",
-        "Africa/Cairo", "Europe_Eastern", "Europe/Bucharest",
-        "Asia/Pyongyang", "Korea", "Asia/Seoul",
-        "Africa/Kampala", "Africa_Eastern", "Africa/Nairobi",
-        "America/Araguaina", "Brasilia", "America/Sao_Paulo",
-        "Asia/Novokuznetsk", "Novosibirsk", "Asia/Novosibirsk",
-        "Pacific/Kwajalein", "Marshall_Islands", "Pacific/Majuro",
-        "Africa/Lubumbashi", "Africa_Central", "Africa/Maputo",
-        "Asia/Sakhalin", "Sakhalin", "Asia/Sakhalin",
-        "America/Indiana/Vevay", "America_Eastern", "America/New_York",
-        "Africa/Maputo", "Africa_Central", "Africa/Maputo",
-        "Atlantic/Faeroe", "Europe_Western", "Atlantic/Canary",
-        "America/North_Dakota/Center", "America_Central", "America/Chicago",
-        "Pacific/Wake", "Wake", "Pacific/Wake",
-        "Pacific/Pago_Pago", "Samoa", "Pacific/Apia",
-        "America/Moncton", "Atlantic", "America/Halifax",
-        "Africa/Sao_Tome", "Africa_Western", "Africa/Lagos",
-        "America/Glace_Bay", "Atlantic", "America/Halifax",
-        "Asia/Jakarta", "Indonesia_Western", "Asia/Jakarta",
-        "Africa/Asmera", "Africa_Eastern", "Africa/Nairobi",
-        "Europe/Lisbon", "Europe_Western", "Atlantic/Canary",
-        "America/Dawson", "America_Pacific", "America/Los_Angeles",
-        "America/Cayenne", "French_Guiana", "America/Cayenne",
-        "Asia/Bahrain", "Arabian", "Asia/Riyadh",
-        "Europe/Malta", "Europe_Central", "Europe/Paris",
-        "America/Indiana/Tell_City", "America_Central", "America/Chicago",
-        "America/Indiana/Petersburg", "America_Eastern", "America/New_York",
-        "Antarctica/Rothera", "Rothera", "Antarctica/Rothera",
-        "Asia/Aqtobe", "Kazakhstan_Western", "Asia/Aqtobe",
-        "Europe/Vaduz", "Europe_Central", "Europe/Paris",
-        "America/Indiana/Marengo", "America_Eastern", "America/New_York",
-        "Europe/Brussels", "Europe_Central", "Europe/Paris",
-        "Europe/Andorra", "Europe_Central", "Europe/Paris",
-        "America/Indiana/Knox", "America_Central", "America/Chicago",
-        "Pacific/Easter", "Easter", "Pacific/Easter",
-        "America/Argentina/Rio_Gallegos", "Argentina", "America/Buenos_Aires",
-        "Asia/Oral", "Kazakhstan_Western", "Asia/Aqtobe",
-        "Europe/Copenhagen", "Europe_Central", "Europe/Paris",
-        "Africa/Johannesburg", "Africa_Southern", "Africa/Johannesburg",
-        "Pacific/Pohnpei", "Ponape", "Pacific/Ponape",
-        "America/Argentina/Tucuman", "Argentina", "America/Buenos_Aires",
-        "America/Toronto", "America_Eastern", "America/New_York",
-        "Asia/Makassar", "Indonesia_Central", "Asia/Makassar",
-        "Europe/Berlin", "Europe_Central", "Europe/Paris",
-        "America/Argentina/Mendoza", "Argentina", "America/Buenos_Aires",
-        "America/Cuiaba", "Amazon", "America/Manaus",
-        "America/Creston", "America_Mountain", "America/Denver",
-        "Asia/Samarkand", "Uzbekistan", "Asia/Tashkent",
-        "Asia/Hovd", "Hovd", "Asia/Hovd",
-        "Europe/Bratislava", "Europe_Central", "Europe/Paris",
-        "Africa/Accra", "GMT", "Atlantic/Reykjavik",
-        "Africa/Douala", "Africa_Western", "Africa/Lagos",
-        "Africa/Nouakchott", "GMT", "Atlantic/Reykjavik",
-        "Europe/Sofia", "Europe_Eastern", "Europe/Bucharest",
-        "Antarctica/Davis", "Davis", "Antarctica/Davis",
-        "Antarctica/McMurdo", "New_Zealand", "Pacific/Auckland",
-        "Europe/San_Marino", "Europe_Central", "Europe/Paris",
-        "Africa/Porto-Novo", "Africa_Western", "Africa/Lagos",
-        "Asia/Jayapura", "Indonesia_Eastern", "Asia/Jayapura",
-        "America/St_Lucia", "Atlantic", "America/Halifax",
-        "America/Nipigon", "America_Eastern", "America/New_York",
-        "America/Argentina/Catamarca", "Argentina", "America/Buenos_Aires",
-        "Europe/Isle_of_Man", "GMT", "Atlantic/Reykjavik",
-        "America/Kentucky/Louisville", "America_Eastern", "America/New_York",
-        "America/Merida", "America_Central", "America/Chicago",
-        "Pacific/Marquesas", "Marquesas", "Pacific/Marquesas",
-        "Asia/Magadan", "Magadan", "Asia/Magadan",
-        "Africa/Libreville", "Africa_Western", "Africa/Lagos",
-        "Pacific/Efate", "Vanuatu", "Pacific/Efate",
-        "Asia/Kuala_Lumpur", "Malaysia", "Asia/Kuching",
-        "America/Iqaluit", "America_Eastern", "America/New_York",
-        "Indian/Comoro", "Africa_Eastern", "Africa/Nairobi",
-        "America/Panama", "America_Eastern", "America/New_York",
-        "Asia/Hebron", "Europe_Eastern", "Europe/Bucharest",
-        "America/Jujuy", "Argentina", "America/Buenos_Aires",
-        "America/Pangnirtung", "America_Eastern", "America/New_York",
-        "Asia/Tbilisi", "Georgia", "Asia/Tbilisi",
-        "Europe/Podgorica", "Europe_Central", "Europe/Paris",
-        "America/Boise", "America_Mountain", "America/Denver",
-        "Asia/Muscat", "Gulf", "Asia/Dubai",
-        "Indian/Mahe", "Seychelles", "Indian/Mahe",
-        "America/Montreal", "America_Eastern", "America/New_York",
-        "Africa/Bangui", "Africa_Western", "Africa/Lagos",
-        "America/Curacao", "Atlantic", "America/Halifax",
-        "Asia/Taipei", "Taipei", "Asia/Taipei",
-        "Europe/Ljubljana", "Europe_Central", "Europe/Paris",
-        "Atlantic/Stanley", "Falkland", "Atlantic/Stanley",
-        "Pacific/Guadalcanal", "Solomon", "Pacific/Guadalcanal",
-        "Asia/Kuwait", "Arabian", "Asia/Riyadh",
-        "Asia/Riyadh", "Arabian", "Asia/Riyadh",
-        "Europe/Tallinn", "Europe_Eastern", "Europe/Bucharest",
-        "America/New_York", "America_Eastern", "America/New_York",
-        "America/Paramaribo", "Suriname", "America/Paramaribo",
-        "America/Argentina/Buenos_Aires", "Argentina", "America/Buenos_Aires",
-        "Asia/Irkutsk", "Irkutsk", "Asia/Irkutsk",
-        "Asia/Katmandu", "Nepal", "Asia/Katmandu",
-        "America/Kralendijk", "Atlantic", "America/Halifax",
-    };
-    private static final String[] mzoneMap = new String[] {
-        "GMT", "ML", "Africa/Bamako",
-        "GMT", "IE", "Europe/Dublin",
-        "GMT", "SN", "Africa/Dakar",
-        "GMT", "GH", "Africa/Accra",
-        "GMT", "CI", "Africa/Abidjan",
-        "GMT", "BF", "Africa/Ouagadougou",
-        "GMT", "MR", "Africa/Nouakchott",
-        "GMT", "GM", "Africa/Banjul",
-        "GMT", "SL", "Africa/Freetown",
-        "GMT", "GN", "Africa/Conakry",
-        "GMT", "SH", "Atlantic/St_Helena",
-        "GMT", "GB", "Europe/London",
-        "GMT", "LR", "Africa/Monrovia",
-        "GMT", "TG", "Africa/Lome",
-        "Africa_Western", "ST", "Africa/Sao_Tome",
-        "Africa_Western", "CF", "Africa/Bangui",
-        "Africa_Western", "NE", "Africa/Niamey",
-        "Africa_Western", "CM", "Africa/Douala",
-        "Africa_Western", "CD", "Africa/Kinshasa",
-        "Africa_Western", "CG", "Africa/Brazzaville",
-        "Africa_Western", "GA", "Africa/Libreville",
-        "Africa_Western", "TD", "Africa/Ndjamena",
-        "Africa_Western", "AO", "Africa/Luanda",
-        "Africa_Western", "GQ", "Africa/Malabo",
-        "Africa_Eastern", "YT", "Indian/Mayotte",
-        "Africa_Eastern", "UG", "Africa/Kampala",
-        "Africa_Eastern", "ET", "Africa/Addis_Ababa",
-        "Africa_Eastern", "MG", "Indian/Antananarivo",
-        "Africa_Eastern", "TZ", "Africa/Dar_es_Salaam",
-        "Africa_Eastern", "SO", "Africa/Mogadishu",
-        "Africa_Eastern", "ER", "Africa/Asmera",
-        "Africa_Eastern", "KM", "Indian/Comoro",
-        "Africa_Eastern", "DJ", "Africa/Djibouti",
-        "Europe_Central", "GI", "Europe/Gibraltar",
-        "Europe_Central", "DK", "Europe/Copenhagen",
-        "Europe_Central", "SE", "Europe/Stockholm",
-        "Europe_Central", "CH", "Europe/Zurich",
-        "Europe_Central", "AL", "Europe/Tirane",
-        "Europe_Central", "RS", "Europe/Belgrade",
-        "Europe_Central", "HU", "Europe/Budapest",
-        "Europe_Central", "MT", "Europe/Malta",
-        "Europe_Central", "PL", "Europe/Warsaw",
-        "Europe_Central", "ME", "Europe/Podgorica",
-        "Europe_Central", "ES", "Europe/Madrid",
-        "Europe_Central", "CZ", "Europe/Prague",
-        "Europe_Central", "IT", "Europe/Rome",
-        "Europe_Central", "SI", "Europe/Ljubljana",
-        "Europe_Central", "LI", "Europe/Vaduz",
-        "Europe_Central", "AT", "Europe/Vienna",
-        "Europe_Central", "VA", "Europe/Vatican",
-        "Europe_Central", "DE", "Europe/Berlin",
-        "Europe_Central", "NO", "Europe/Oslo",
-        "Europe_Central", "SK", "Europe/Bratislava",
-        "Europe_Central", "AD", "Europe/Andorra",
-        "Europe_Central", "SM", "Europe/San_Marino",
-        "Europe_Central", "MK", "Europe/Skopje",
-        "Europe_Central", "TN", "Africa/Tunis",
-        "Europe_Central", "HR", "Europe/Zagreb",
-        "Europe_Central", "NL", "Europe/Amsterdam",
-        "Europe_Central", "BE", "Europe/Brussels",
-        "Europe_Central", "MC", "Europe/Monaco",
-        "Europe_Central", "LU", "Europe/Luxembourg",
-        "Europe_Central", "BA", "Europe/Sarajevo",
-        "China", "MO", "Asia/Macau",
-        "America_Pacific", "MX", "America/Tijuana",
-        "America_Pacific", "CA", "America/Vancouver",
-        "Indochina", "LA", "Asia/Vientiane",
-        "Indochina", "KH", "Asia/Phnom_Penh",
-        "Indochina", "TH", "Asia/Bangkok",
-        "Korea", "KP", "Asia/Pyongyang",
-        "America_Mountain", "MX", "America/Hermosillo",
-        "America_Mountain", "CA", "America/Edmonton",
-        "Africa_Southern", "LS", "Africa/Maseru",
-        "Africa_Southern", "SZ", "Africa/Mbabane",
-        "Chile", "AQ", "Antarctica/Palmer",
-        "New_Zealand", "AQ", "Antarctica/McMurdo",
-        "Gulf", "OM", "Asia/Muscat",
-        "Europe_Western", "FO", "Atlantic/Faeroe",
-        "America_Eastern", "TC", "America/Grand_Turk",
-        "America_Eastern", "CA", "America/Toronto",
-        "America_Eastern", "BS", "America/Nassau",
-        "America_Eastern", "PA", "America/Panama",
-        "America_Eastern", "JM", "America/Jamaica",
-        "America_Eastern", "KY", "America/Cayman",
-        "Africa_Central", "BI", "Africa/Bujumbura",
-        "Africa_Central", "ZM", "Africa/Lusaka",
-        "Africa_Central", "ZW", "Africa/Harare",
-        "Africa_Central", "CD", "Africa/Lubumbashi",
-        "Africa_Central", "BW", "Africa/Gaborone",
-        "Africa_Central", "RW", "Africa/Kigali",
-        "Africa_Central", "MW", "Africa/Blantyre",
-        "America_Central", "MX", "America/Mexico_City",
-        "America_Central", "HN", "America/Tegucigalpa",
-        "America_Central", "CA", "America/Winnipeg",
-        "America_Central", "GT", "America/Guatemala",
-        "America_Central", "SV", "America/El_Salvador",
-        "America_Central", "CR", "America/Costa_Rica",
-        "America_Central", "BZ", "America/Belize",
-        "Atlantic", "MS", "America/Montserrat",
-        "Atlantic", "AG", "America/Antigua",
-        "Atlantic", "TT", "America/Port_of_Spain",
-        "Atlantic", "MQ", "America/Martinique",
-        "Atlantic", "DM", "America/Dominica",
-        "Atlantic", "KN", "America/St_Kitts",
-        "Atlantic", "BM", "Atlantic/Bermuda",
-        "Atlantic", "PR", "America/Puerto_Rico",
-        "Atlantic", "AW", "America/Aruba",
-        "Atlantic", "VG", "America/Tortola",
-        "Atlantic", "GD", "America/Grenada",
-        "Atlantic", "GL", "America/Thule",
-        "Atlantic", "BB", "America/Barbados",
-        "Atlantic", "BQ", "America/Kralendijk",
-        "Atlantic", "SX", "America/Lower_Princes",
-        "Atlantic", "VI", "America/St_Thomas",
-        "Atlantic", "MF", "America/Marigot",
-        "Atlantic", "AI", "America/Anguilla",
-        "Atlantic", "AN", "America/Curacao",
-        "Atlantic", "LC", "America/St_Lucia",
-        "Atlantic", "GP", "America/Guadeloupe",
-        "Atlantic", "VC", "America/St_Vincent",
-        "Arabian", "QA", "Asia/Qatar",
-        "Arabian", "YE", "Asia/Aden",
-        "Arabian", "KW", "Asia/Kuwait",
-        "Arabian", "BH", "Asia/Bahrain",
-        "Arabian", "IQ", "Asia/Baghdad",
-        "India", "LK", "Asia/Colombo",
-        "Europe_Eastern", "SY", "Asia/Damascus",
-        "Europe_Eastern", "BG", "Europe/Sofia",
-        "Europe_Eastern", "GR", "Europe/Athens",
-        "Europe_Eastern", "JO", "Asia/Amman",
-        "Europe_Eastern", "CY", "Asia/Nicosia",
-        "Europe_Eastern", "AX", "Europe/Mariehamn",
-        "Europe_Eastern", "LB", "Asia/Beirut",
-        "Europe_Eastern", "FI", "Europe/Helsinki",
-        "Europe_Eastern", "EG", "Africa/Cairo",
-        "Chamorro", "GU", "Pacific/Guam",
-    };
-    private static final String[] aliasMap = new String[] {
-        "Brazil/Acre", "America/Rio_Branco",
-        "US/Indiana-Starke", "America/Indiana/Knox",
-        "America/Atka", "America/Adak",
-        "America/St_Barthelemy", "America/Guadeloupe",
-        "Australia/North", "Australia/Darwin",
-        "Europe/Zagreb", "Europe/Belgrade",
-        "Etc/Universal", "Etc/UTC",
-        "NZ-CHAT", "Pacific/Chatham",
-        "Asia/Macao", "Asia/Macau",
-        "Pacific/Yap", "Pacific/Chuuk",
-        "Egypt", "Africa/Cairo",
-        "US/Central", "America/Chicago",
-        "Canada/Atlantic", "America/Halifax",
-        "Brazil/East", "America/Sao_Paulo",
-        "America/Cordoba", "America/Argentina/Cordoba",
-        "US/Hawaii", "Pacific/Honolulu",
-        "America/Louisville", "America/Kentucky/Louisville",
-        "America/Shiprock", "America/Denver",
-        "Australia/Canberra", "Australia/Sydney",
-        "Asia/Chungking", "Asia/Chongqing",
-        "Universal", "Etc/UTC",
-        "US/Alaska", "America/Anchorage",
-        "Asia/Ujung_Pandang", "Asia/Makassar",
-        "Japan", "Asia/Tokyo",
-        "Atlantic/Faeroe", "Atlantic/Faroe",
-        "Asia/Istanbul", "Europe/Istanbul",
-        "US/Pacific", "America/Los_Angeles",
-        "Mexico/General", "America/Mexico_City",
-        "Poland", "Europe/Warsaw",
-        "Africa/Asmera", "Africa/Asmara",
-        "Asia/Saigon", "Asia/Ho_Chi_Minh",
-        "US/Michigan", "America/Detroit",
-        "America/Argentina/ComodRivadavia", "America/Argentina/Catamarca",
-        "W-SU", "Europe/Moscow",
-        "Australia/ACT", "Australia/Sydney",
-        "Asia/Calcutta", "Asia/Kolkata",
-        "Arctic/Longyearbyen", "Europe/Oslo",
-        "America/Knox_IN", "America/Indiana/Knox",
-        "ROC", "Asia/Taipei",
-        "Zulu", "Etc/UTC",
-        "Australia/Yancowinna", "Australia/Broken_Hill",
-        "Australia/West", "Australia/Perth",
-        "Singapore", "Asia/Singapore",
-        "Europe/Mariehamn", "Europe/Helsinki",
-        "ROK", "Asia/Seoul",
-        "America/Porto_Acre", "America/Rio_Branco",
-        "Etc/Zulu", "Etc/UTC",
-        "Canada/Yukon", "America/Whitehorse",
-        "Europe/Vatican", "Europe/Rome",
-        "Africa/Timbuktu", "Africa/Bamako",
-        "America/Buenos_Aires", "America/Argentina/Buenos_Aires",
-        "Canada/Pacific", "America/Vancouver",
-        "US/Pacific-New", "America/Los_Angeles",
-        "Mexico/BajaNorte", "America/Tijuana",
-        "Europe/Guernsey", "Europe/London",
-        "Asia/Tel_Aviv", "Asia/Jerusalem",
-        "Chile/Continental", "America/Santiago",
-        "Jamaica", "America/Jamaica",
-        "Mexico/BajaSur", "America/Mazatlan",
-        "Canada/Eastern", "America/Toronto",
-        "Australia/Tasmania", "Australia/Hobart",
-        "NZ", "Pacific/Auckland",
-        "America/Lower_Princes", "America/Curacao",
-        "GMT-", "Etc/GMT",
-        "America/Rosario", "America/Argentina/Cordoba",
-        "Libya", "Africa/Tripoli",
-        "Asia/Ashkhabad", "Asia/Ashgabat",
-        "Australia/NSW", "Australia/Sydney",
-        "America/Marigot", "America/Guadeloupe",
-        "Europe/Bratislava", "Europe/Prague",
-        "Portugal", "Europe/Lisbon",
-        "Etc/GMT-", "Etc/GMT",
-        "Europe/San_Marino", "Europe/Rome",
-        "Europe/Sarajevo", "Europe/Belgrade",
-        "Antarctica/South_Pole", "Antarctica/McMurdo",
-        "Canada/Central", "America/Winnipeg",
-        "Etc/GMT", "Etc/GMT",
-        "Europe/Isle_of_Man", "Europe/London",
-        "America/Fort_Wayne", "America/Indiana/Indianapolis",
-        "Eire", "Europe/Dublin",
-        "America/Coral_Harbour", "America/Atikokan",
-        "Europe/Nicosia", "Asia/Nicosia",
-        "US/Samoa", "Pacific/Pago_Pago",
-        "Hongkong", "Asia/Hong_Kong",
-        "Canada/Saskatchewan", "America/Regina",
-        "Asia/Thimbu", "Asia/Thimphu",
-        "Kwajalein", "Pacific/Kwajalein",
-        "GB", "Europe/London",
-        "Chile/EasterIsland", "Pacific/Easter",
-        "US/East-Indiana", "America/Indiana/Indianapolis",
-        "Australia/LHI", "Australia/Lord_Howe",
-        "Cuba", "America/Havana",
-        "America/Jujuy", "America/Argentina/Jujuy",
-        "US/Mountain", "America/Denver",
-        "Atlantic/Jan_Mayen", "Europe/Oslo",
-        "Europe/Tiraspol", "Europe/Chisinau",
-        "Europe/Podgorica", "Europe/Belgrade",
-        "US/Arizona", "America/Phoenix",
-        "Navajo", "America/Denver",
-        "Etc/Greenwich", "Etc/GMT",
-        "Canada/Mountain", "America/Edmonton",
-        "Iceland", "Atlantic/Reykjavik",
-        "Australia/Victoria", "Australia/Melbourne",
-        "Australia/South", "Australia/Adelaide",
-        "Brazil/West", "America/Manaus",
-        "Pacific/Ponape", "Pacific/Pohnpei",
-        "Europe/Ljubljana", "Europe/Belgrade",
-        "Europe/Jersey", "Europe/London",
-        "Australia/Queensland", "Australia/Brisbane",
-        "UTC", "Etc/UTC",
-        "Canada/Newfoundland", "America/St_Johns",
-        "Europe/Skopje", "Europe/Belgrade",
-        "PRC", "Asia/Shanghai",
-        "UCT", "Etc/UCT",
-        "America/Mendoza", "America/Argentina/Mendoza",
-        "Israel", "Asia/Jerusalem",
-        "US/Eastern", "America/New_York",
-        "Asia/Ulan_Bator", "Asia/Ulaanbaatar",
-        "Turkey", "Europe/Istanbul",
-        "GMT", "Etc/GMT",
-        "US/Aleutian", "America/Adak",
-        "Brazil/DeNoronha", "America/Noronha",
-        "GB-Eire", "Europe/London",
-        "Asia/Dacca", "Asia/Dhaka",
-        "America/Ensenada", "America/Tijuana",
-        "America/Catamarca", "America/Argentina/Catamarca",
-        "Iran", "Asia/Tehran",
-        "Greenwich", "Etc/GMT",
-        "Pacific/Truk", "Pacific/Chuuk",
-        "Pacific/Samoa", "Pacific/Pago_Pago",
-        "America/Virgin", "America/St_Thomas",
-        "Asia/Katmandu", "Asia/Kathmandu",
-        "America/Indianapolis", "America/Indiana/Indianapolis",
-        "Europe/Belfast", "Europe/London",
-        "America/Kralendijk", "America/Curacao",
-        "Asia/Rangoon", "Asia/Yangon",
-    };
-
-    private static final Map<String, String> zidToMzone = new HashMap<>();
-    private static final Map<String, String> mzoneToZid = new HashMap<>();
-    private static final Map<String, Map<String, String>> mzoneToZidL = new HashMap<>();
-    private static final Map<String, String> aliases = new HashMap<>();
-
-    static {
-        for (int i = 0; i < zidMap.length; i += 3) {
-            zidToMzone.put(zidMap[i], zidMap[i + 1]);
-            mzoneToZid.put(zidMap[i + 1], zidMap[i + 2]);
-        }
-
-        for (int i = 0; i < mzoneMap.length; i += 3) {
-            String mzone = mzoneMap[i];
-            Map<String, String> map = mzoneToZidL.get(mzone);
-            if (map == null) {
-                map = new HashMap<>();
-                mzoneToZidL.put(mzone, map);
-            }
-            map.put(mzoneMap[i + 1], mzoneMap[i + 2]);
-        }
-
-        for (int i = 0; i < aliasMap.length; i += 2) {
-            aliases.put(aliasMap[i], aliasMap[i + 1]);
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/time/format/ZoneName.java.template	Fri Apr 13 14:55:11 2018 -0400
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.time.format;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * A helper class to map a zone name to metazone and back to the
+ * appropriate zone id for the particular locale.
+ * <p>
+ * The zid<->metazone mappings are based on CLDR metaZones.xml.
+ * The alias mappings are based on Link entries in tzdb data files and
+ * CLDR's supplementalMetadata.xml.
+ */
+class ZoneName {
+
+    public static String toZid(String zid, Locale locale) {
+        String mzone = zidToMzone.get(zid);
+        if (mzone == null && aliases.containsKey(zid)) {
+            zid = aliases.get(zid);
+            mzone = zidToMzone.get(zid);
+        }
+        if (mzone != null) {
+            Map<String, String> map = mzoneToZidL.get(mzone);
+            if (map != null && map.containsKey(locale.getCountry())) {
+                zid = map.get(locale.getCountry());
+            } else {
+                zid = mzoneToZid.get(mzone);
+            }
+        }
+        return toZid(zid);
+    }
+
+    public static String toZid(String zid) {
+        if (aliases.containsKey(zid)) {
+            return aliases.get(zid);
+        }
+        return zid;
+    }
+
+    private static final String[] zidMap = new String[] {
+        // From metaZones.xml
+%%%%ZIDMAP%%%%
+
+        // From tzdb
+        "Africa/Khartoum", "Africa_Central", "Africa/Maputo", // tzdata2017c
+        "Africa/Windhoek", "Africa_Central", "Africa/Maputo", // tzdata2017c
+        "Africa/Sao_Tome", "Africa_Western", "Africa/Lagos",  // tzdata2018c
+    };
+    private static final String[] mzoneMap = new String[] {
+        // From metaZones.xml
+%%%%MZONEMAP%%%%
+
+        // From tzdb
+        "Africa_Western", "ST", "Africa/Sao_Tome", // tzdata2018c
+    };
+    private static final String[] aliasMap = new String[] {
+        // From supplementalMetadata.xml
+%%%%DEPRECATED%%%%
+
+        // From tzdb
+        "Brazil/Acre", "America/Rio_Branco",
+        "US/Indiana-Starke", "America/Indiana/Knox",
+        "America/Atka", "America/Adak",
+        "America/St_Barthelemy", "America/Guadeloupe",
+        "Australia/North", "Australia/Darwin",
+        "Europe/Zagreb", "Europe/Belgrade",
+        "Etc/Universal", "Etc/UTC",
+        "NZ-CHAT", "Pacific/Chatham",
+        "Asia/Macao", "Asia/Macau",
+        "Pacific/Yap", "Pacific/Chuuk",
+        "Egypt", "Africa/Cairo",
+        "US/Central", "America/Chicago",
+        "Canada/Atlantic", "America/Halifax",
+        "Brazil/East", "America/Sao_Paulo",
+        "America/Cordoba", "America/Argentina/Cordoba",
+        "US/Hawaii", "Pacific/Honolulu",
+        "America/Louisville", "America/Kentucky/Louisville",
+        "America/Shiprock", "America/Denver",
+        "Australia/Canberra", "Australia/Sydney",
+        "Asia/Chungking", "Asia/Chongqing",
+        "Universal", "Etc/UTC",
+        "US/Alaska", "America/Anchorage",
+        "Asia/Ujung_Pandang", "Asia/Makassar",
+        "Japan", "Asia/Tokyo",
+        "Atlantic/Faeroe", "Atlantic/Faroe",
+        "Asia/Istanbul", "Europe/Istanbul",
+        "US/Pacific", "America/Los_Angeles",
+        "Mexico/General", "America/Mexico_City",
+        "Poland", "Europe/Warsaw",
+        "Africa/Asmera", "Africa/Asmara",
+        "Asia/Saigon", "Asia/Ho_Chi_Minh",
+        "US/Michigan", "America/Detroit",
+        "America/Argentina/ComodRivadavia", "America/Argentina/Catamarca",
+        "W-SU", "Europe/Moscow",
+        "Australia/ACT", "Australia/Sydney",
+        "Asia/Calcutta", "Asia/Kolkata",
+        "Arctic/Longyearbyen", "Europe/Oslo",
+        "America/Knox_IN", "America/Indiana/Knox",
+        "ROC", "Asia/Taipei",
+        "Zulu", "Etc/UTC",
+        "Australia/Yancowinna", "Australia/Broken_Hill",
+        "Australia/West", "Australia/Perth",
+        "Singapore", "Asia/Singapore",
+        "Europe/Mariehamn", "Europe/Helsinki",
+        "ROK", "Asia/Seoul",
+        "America/Porto_Acre", "America/Rio_Branco",
+        "Etc/Zulu", "Etc/UTC",
+        "Canada/Yukon", "America/Whitehorse",
+        "Europe/Vatican", "Europe/Rome",
+        "Africa/Timbuktu", "Africa/Bamako",
+        "America/Buenos_Aires", "America/Argentina/Buenos_Aires",
+        "Canada/Pacific", "America/Vancouver",
+        "US/Pacific-New", "America/Los_Angeles",
+        "Mexico/BajaNorte", "America/Tijuana",
+        "Europe/Guernsey", "Europe/London",
+        "Asia/Tel_Aviv", "Asia/Jerusalem",
+        "Chile/Continental", "America/Santiago",
+        "Jamaica", "America/Jamaica",
+        "Mexico/BajaSur", "America/Mazatlan",
+        "Canada/Eastern", "America/Toronto",
+        "Australia/Tasmania", "Australia/Hobart",
+        "NZ", "Pacific/Auckland",
+        "America/Lower_Princes", "America/Curacao",
+        "GMT-", "Etc/GMT",
+        "America/Rosario", "America/Argentina/Cordoba",
+        "Libya", "Africa/Tripoli",
+        "Asia/Ashkhabad", "Asia/Ashgabat",
+        "Australia/NSW", "Australia/Sydney",
+        "America/Marigot", "America/Guadeloupe",
+        "Europe/Bratislava", "Europe/Prague",
+        "Portugal", "Europe/Lisbon",
+        "Etc/GMT-", "Etc/GMT",
+        "Europe/San_Marino", "Europe/Rome",
+        "Europe/Sarajevo", "Europe/Belgrade",
+        "Antarctica/South_Pole", "Antarctica/McMurdo",
+        "Canada/Central", "America/Winnipeg",
+        "Etc/GMT", "Etc/GMT",
+        "Europe/Isle_of_Man", "Europe/London",
+        "America/Fort_Wayne", "America/Indiana/Indianapolis",
+        "Eire", "Europe/Dublin",
+        "America/Coral_Harbour", "America/Atikokan",
+        "Europe/Nicosia", "Asia/Nicosia",
+        "US/Samoa", "Pacific/Pago_Pago",
+        "Hongkong", "Asia/Hong_Kong",
+        "Canada/Saskatchewan", "America/Regina",
+        "Asia/Thimbu", "Asia/Thimphu",
+        "Kwajalein", "Pacific/Kwajalein",
+        "GB", "Europe/London",
+        "Chile/EasterIsland", "Pacific/Easter",
+        "US/East-Indiana", "America/Indiana/Indianapolis",
+        "Australia/LHI", "Australia/Lord_Howe",
+        "Cuba", "America/Havana",
+        "America/Jujuy", "America/Argentina/Jujuy",
+        "US/Mountain", "America/Denver",
+        "Atlantic/Jan_Mayen", "Europe/Oslo",
+        "Europe/Tiraspol", "Europe/Chisinau",
+        "Europe/Podgorica", "Europe/Belgrade",
+        "US/Arizona", "America/Phoenix",
+        "Navajo", "America/Denver",
+        "Etc/Greenwich", "Etc/GMT",
+        "Canada/Mountain", "America/Edmonton",
+        "Iceland", "Atlantic/Reykjavik",
+        "Australia/Victoria", "Australia/Melbourne",
+        "Australia/South", "Australia/Adelaide",
+        "Brazil/West", "America/Manaus",
+        "Pacific/Ponape", "Pacific/Pohnpei",
+        "Europe/Ljubljana", "Europe/Belgrade",
+        "Europe/Jersey", "Europe/London",
+        "Australia/Queensland", "Australia/Brisbane",
+        "UTC", "Etc/UTC",
+        "Canada/Newfoundland", "America/St_Johns",
+        "Europe/Skopje", "Europe/Belgrade",
+        "PRC", "Asia/Shanghai",
+        "UCT", "Etc/UCT",
+        "America/Mendoza", "America/Argentina/Mendoza",
+        "Israel", "Asia/Jerusalem",
+        "US/Eastern", "America/New_York",
+        "Asia/Ulan_Bator", "Asia/Ulaanbaatar",
+        "Turkey", "Europe/Istanbul",
+        "GMT", "Etc/GMT",
+        "US/Aleutian", "America/Adak",
+        "Brazil/DeNoronha", "America/Noronha",
+        "GB-Eire", "Europe/London",
+        "Asia/Dacca", "Asia/Dhaka",
+        "America/Ensenada", "America/Tijuana",
+        "America/Catamarca", "America/Argentina/Catamarca",
+        "Iran", "Asia/Tehran",
+        "Greenwich", "Etc/GMT",
+        "Pacific/Truk", "Pacific/Chuuk",
+        "Pacific/Samoa", "Pacific/Pago_Pago",
+        "America/Virgin", "America/St_Thomas",
+        "Asia/Katmandu", "Asia/Kathmandu",
+        "America/Indianapolis", "America/Indiana/Indianapolis",
+        "Europe/Belfast", "Europe/London",
+        "America/Kralendijk", "America/Curacao",
+        "Asia/Rangoon", "Asia/Yangon",
+    };
+
+    private static final Map<String, String> zidToMzone = new HashMap<>();
+    private static final Map<String, String> mzoneToZid = new HashMap<>();
+    private static final Map<String, Map<String, String>> mzoneToZidL = new HashMap<>();
+    private static final Map<String, String> aliases = new HashMap<>();
+
+    static {
+        for (int i = 0; i < zidMap.length; i += 3) {
+            zidToMzone.put(zidMap[i], zidMap[i + 1]);
+            mzoneToZid.put(zidMap[i + 1], zidMap[i + 2]);
+        }
+
+        for (int i = 0; i < mzoneMap.length; i += 3) {
+            String mzone = mzoneMap[i];
+            Map<String, String> map = mzoneToZidL.get(mzone);
+            if (map == null) {
+                map = new HashMap<>();
+                mzoneToZidL.put(mzone, map);
+            }
+            map.put(mzoneMap[i + 1], mzoneMap[i + 2]);
+        }
+
+        for (int i = 0; i < aliasMap.length; i += 2) {
+            aliases.put(aliasMap[i], aliasMap[i + 1]);
+        }
+    }
+}
--- a/src/java.base/share/classes/java/util/ArrayDeque.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/ArrayDeque.java	Fri Apr 13 14:55:11 2018 -0400
@@ -208,7 +208,7 @@
      */
     public ArrayDeque(Collection<? extends E> c) {
         this(c.size());
-        addAll(c);
+        copyElements(c);
     }
 
     /**
@@ -322,8 +322,12 @@
         final int s, needed;
         if ((needed = (s = size()) + c.size() + 1 - elements.length) > 0)
             grow(needed);
+        copyElements(c);
+        return size() > s;
+    }
+
+    private void copyElements(Collection<? extends E> c) {
         c.forEach(this::addLast);
-        return size() > s;
     }
 
     /**
--- a/src/java.base/share/classes/java/util/Deque.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/Deque.java	Fri Apr 13 14:55:11 2018 -0400
@@ -141,8 +141,8 @@
  * <p>Deques can also be used as LIFO (Last-In-First-Out) stacks.  This
  * interface should be used in preference to the legacy {@link Stack} class.
  * When a deque is used as a stack, elements are pushed and popped from the
- * beginning of the deque.  Stack methods are precisely equivalent to
- * {@code Deque} methods as indicated in the table below:
+ * beginning of the deque.  Stack methods are equivalent to {@code Deque}
+ * methods as indicated in the table below:
  *
  * <table class="striped">
  * <caption>Comparison of Stack and Deque methods</caption>
@@ -163,7 +163,7 @@
  *  </tr>
  *  <tr>
  *    <th scope="row">{@link #peek() peek()}</th>
- *    <td>{@link #peekFirst() peekFirst()}</td>
+ *    <td>{@link #getFirst() getFirst()}</td>
  *  </tr>
  *  </tbody>
  * </table>
--- a/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java	Fri Apr 13 14:55:11 2018 -0400
@@ -2883,7 +2883,7 @@
             STACK = l.findVarHandle(CompletableFuture.class, "stack", Completion.class);
             NEXT = l.findVarHandle(Completion.class, "next", Completion.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
 
         // Reduce the risk of rare disastrous classloading in first call to
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Fri Apr 13 14:55:11 2018 -0400
@@ -6383,7 +6383,7 @@
         ABASE = U.arrayBaseOffset(Node[].class);
         int scale = U.arrayIndexScale(Node[].class);
         if ((scale & (scale - 1)) != 0)
-            throw new Error("array index scale not a power of two");
+            throw new ExceptionInInitializerError("array index scale not a power of two");
         ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
 
         // Reduce the risk of rare disastrous classloading in first call to
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1671,7 +1671,7 @@
             NEXT = l.findVarHandle(Node.class, "next", Node.class);
             ITEM = l.findVarHandle(Node.class, "item", Object.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 }
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1069,7 +1069,7 @@
             ITEM = l.findVarHandle(Node.class, "item", Object.class);
             NEXT = l.findVarHandle(Node.class, "next", Node.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 }
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Fri Apr 13 14:55:11 2018 -0400
@@ -3412,7 +3412,7 @@
             VAL = l.findVarHandle(Node.class, "val", Object.class);
             RIGHT = l.findVarHandle(Index.class, "right", Index.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 }
--- a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Fri Apr 13 14:55:11 2018 -0400
@@ -35,7 +35,6 @@
 package java.util.concurrent;
 
 import java.lang.reflect.Field;
-import java.util.AbstractList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Comparator;
@@ -134,17 +133,17 @@
      * @throws NullPointerException if the specified collection is null
      */
     public CopyOnWriteArrayList(Collection<? extends E> c) {
-        Object[] elements;
+        Object[] es;
         if (c.getClass() == CopyOnWriteArrayList.class)
-            elements = ((CopyOnWriteArrayList<?>)c).getArray();
+            es = ((CopyOnWriteArrayList<?>)c).getArray();
         else {
-            elements = c.toArray();
+            es = c.toArray();
             // defend against c.toArray (incorrectly) not returning Object[]
             // (see e.g. https://bugs.openjdk.java.net/browse/JDK-6260652)
-            if (elements.getClass() != Object[].class)
-                elements = Arrays.copyOf(elements, elements.length, Object[].class);
+            if (es.getClass() != Object[].class)
+                es = Arrays.copyOf(es, es.length, Object[].class);
         }
-        setArray(elements);
+        setArray(es);
     }
 
     /**
@@ -180,20 +179,19 @@
      * static version of indexOf, to allow repeated calls without
      * needing to re-acquire array each time.
      * @param o element to search for
-     * @param elements the array
-     * @param index first index to search
-     * @param fence one past last index to search
+     * @param es the array
+     * @param from first index to search
+     * @param to one past last index to search
      * @return index of element, or -1 if absent
      */
-    private static int indexOf(Object o, Object[] elements,
-                               int index, int fence) {
+    private static int indexOfRange(Object o, Object[] es, int from, int to) {
         if (o == null) {
-            for (int i = index; i < fence; i++)
-                if (elements[i] == null)
+            for (int i = from; i < to; i++)
+                if (es[i] == null)
                     return i;
         } else {
-            for (int i = index; i < fence; i++)
-                if (o.equals(elements[i]))
+            for (int i = from; i < to; i++)
+                if (o.equals(es[i]))
                     return i;
         }
         return -1;
@@ -202,18 +200,19 @@
     /**
      * static version of lastIndexOf.
      * @param o element to search for
-     * @param elements the array
-     * @param index first index to search
+     * @param es the array
+     * @param from index of first element of range, last element to search
+     * @param to one past last element of range, first element to search
      * @return index of element, or -1 if absent
      */
-    private static int lastIndexOf(Object o, Object[] elements, int index) {
+    private static int lastIndexOfRange(Object o, Object[] es, int from, int to) {
         if (o == null) {
-            for (int i = index; i >= 0; i--)
-                if (elements[i] == null)
+            for (int i = to - 1; i >= from; i--)
+                if (es[i] == null)
                     return i;
         } else {
-            for (int i = index; i >= 0; i--)
-                if (o.equals(elements[i]))
+            for (int i = to - 1; i >= from; i--)
+                if (o.equals(es[i]))
                     return i;
         }
         return -1;
@@ -228,16 +227,15 @@
      * @return {@code true} if this list contains the specified element
      */
     public boolean contains(Object o) {
-        Object[] elements = getArray();
-        return indexOf(o, elements, 0, elements.length) >= 0;
+        return indexOf(o) >= 0;
     }
 
     /**
      * {@inheritDoc}
      */
     public int indexOf(Object o) {
-        Object[] elements = getArray();
-        return indexOf(o, elements, 0, elements.length);
+        Object[] es = getArray();
+        return indexOfRange(o, es, 0, es.length);
     }
 
     /**
@@ -256,16 +254,16 @@
      * @throws IndexOutOfBoundsException if the specified index is negative
      */
     public int indexOf(E e, int index) {
-        Object[] elements = getArray();
-        return indexOf(e, elements, index, elements.length);
+        Object[] es = getArray();
+        return indexOfRange(e, es, index, es.length);
     }
 
     /**
      * {@inheritDoc}
      */
     public int lastIndexOf(Object o) {
-        Object[] elements = getArray();
-        return lastIndexOf(o, elements, elements.length - 1);
+        Object[] es = getArray();
+        return lastIndexOfRange(o, es, 0, es.length);
     }
 
     /**
@@ -285,8 +283,8 @@
      *         than or equal to the current size of this list
      */
     public int lastIndexOf(E e, int index) {
-        Object[] elements = getArray();
-        return lastIndexOf(e, elements, index);
+        Object[] es = getArray();
+        return lastIndexOfRange(e, es, 0, index + 1);
     }
 
     /**
@@ -322,8 +320,7 @@
      * @return an array containing all the elements in this list
      */
     public Object[] toArray() {
-        Object[] elements = getArray();
-        return Arrays.copyOf(elements, elements.length);
+        return getArray().clone();
     }
 
     /**
@@ -366,12 +363,12 @@
      */
     @SuppressWarnings("unchecked")
     public <T> T[] toArray(T[] a) {
-        Object[] elements = getArray();
-        int len = elements.length;
+        Object[] es = getArray();
+        int len = es.length;
         if (a.length < len)
-            return (T[]) Arrays.copyOf(elements, len, a.getClass());
+            return (T[]) Arrays.copyOf(es, len, a.getClass());
         else {
-            System.arraycopy(elements, 0, a, 0, len);
+            System.arraycopy(es, 0, a, 0, len);
             if (a.length > len)
                 a[len] = null;
             return a;
@@ -406,17 +403,13 @@
      */
     public E set(int index, E element) {
         synchronized (lock) {
-            Object[] elements = getArray();
-            E oldValue = elementAt(elements, index);
+            Object[] es = getArray();
+            E oldValue = elementAt(es, index);
 
             if (oldValue != element) {
-                int len = elements.length;
-                Object[] newElements = Arrays.copyOf(elements, len);
-                newElements[index] = element;
-                setArray(newElements);
-            } else {
-                // Not quite a no-op; ensures volatile write semantics
-                setArray(elements);
+                es = es.clone();
+                es[index] = element;
+                setArray(es);
             }
             return oldValue;
         }
@@ -430,11 +423,11 @@
      */
     public boolean add(E e) {
         synchronized (lock) {
-            Object[] elements = getArray();
-            int len = elements.length;
-            Object[] newElements = Arrays.copyOf(elements, len + 1);
-            newElements[len] = e;
-            setArray(newElements);
+            Object[] es = getArray();
+            int len = es.length;
+            es = Arrays.copyOf(es, len + 1);
+            es[len] = e;
+            setArray(es);
             return true;
         }
     }
@@ -448,18 +441,18 @@
      */
     public void add(int index, E element) {
         synchronized (lock) {
-            Object[] elements = getArray();
-            int len = elements.length;
+            Object[] es = getArray();
+            int len = es.length;
             if (index > len || index < 0)
                 throw new IndexOutOfBoundsException(outOfBounds(index, len));
             Object[] newElements;
             int numMoved = len - index;
             if (numMoved == 0)
-                newElements = Arrays.copyOf(elements, len + 1);
+                newElements = Arrays.copyOf(es, len + 1);
             else {
                 newElements = new Object[len + 1];
-                System.arraycopy(elements, 0, newElements, 0, index);
-                System.arraycopy(elements, index, newElements, index + 1,
+                System.arraycopy(es, 0, newElements, 0, index);
+                System.arraycopy(es, index, newElements, index + 1,
                                  numMoved);
             }
             newElements[index] = element;
@@ -476,19 +469,20 @@
      */
     public E remove(int index) {
         synchronized (lock) {
-            Object[] elements = getArray();
-            int len = elements.length;
-            E oldValue = elementAt(elements, index);
+            Object[] es = getArray();
+            int len = es.length;
+            E oldValue = elementAt(es, index);
             int numMoved = len - index - 1;
+            Object[] newElements;
             if (numMoved == 0)
-                setArray(Arrays.copyOf(elements, len - 1));
+                newElements = Arrays.copyOf(es, len - 1);
             else {
-                Object[] newElements = new Object[len - 1];
-                System.arraycopy(elements, 0, newElements, 0, index);
-                System.arraycopy(elements, index + 1, newElements, index,
+                newElements = new Object[len - 1];
+                System.arraycopy(es, 0, newElements, 0, index);
+                System.arraycopy(es, index + 1, newElements, index,
                                  numMoved);
-                setArray(newElements);
             }
+            setArray(newElements);
             return oldValue;
         }
     }
@@ -507,7 +501,7 @@
      */
     public boolean remove(Object o) {
         Object[] snapshot = getArray();
-        int index = indexOf(o, snapshot, 0, snapshot.length);
+        int index = indexOfRange(o, snapshot, 0, snapshot.length);
         return index >= 0 && remove(o, snapshot, index);
     }
 
@@ -532,7 +526,7 @@
                     return false;
                 if (current[index] == o)
                     break findIndex;
-                index = indexOf(o, current, index, len);
+                index = indexOfRange(o, current, index, len);
                 if (index < 0)
                     return false;
             }
@@ -560,19 +554,19 @@
      */
     void removeRange(int fromIndex, int toIndex) {
         synchronized (lock) {
-            Object[] elements = getArray();
-            int len = elements.length;
+            Object[] es = getArray();
+            int len = es.length;
 
             if (fromIndex < 0 || toIndex > len || toIndex < fromIndex)
                 throw new IndexOutOfBoundsException();
             int newlen = len - (toIndex - fromIndex);
             int numMoved = len - toIndex;
             if (numMoved == 0)
-                setArray(Arrays.copyOf(elements, newlen));
+                setArray(Arrays.copyOf(es, newlen));
             else {
                 Object[] newElements = new Object[newlen];
-                System.arraycopy(elements, 0, newElements, 0, fromIndex);
-                System.arraycopy(elements, toIndex, newElements,
+                System.arraycopy(es, 0, newElements, 0, fromIndex);
+                System.arraycopy(es, toIndex, newElements,
                                  fromIndex, numMoved);
                 setArray(newElements);
             }
@@ -587,7 +581,7 @@
      */
     public boolean addIfAbsent(E e) {
         Object[] snapshot = getArray();
-        return indexOf(e, snapshot, 0, snapshot.length) < 0
+        return indexOfRange(e, snapshot, 0, snapshot.length) < 0
             && addIfAbsent(e, snapshot);
     }
 
@@ -606,7 +600,7 @@
                     if (current[i] != snapshot[i]
                         && Objects.equals(e, current[i]))
                         return false;
-                if (indexOf(e, current, common, len) >= 0)
+                if (indexOfRange(e, current, common, len) >= 0)
                         return false;
             }
             Object[] newElements = Arrays.copyOf(current, len + 1);
@@ -627,10 +621,10 @@
      * @see #contains(Object)
      */
     public boolean containsAll(Collection<?> c) {
-        Object[] elements = getArray();
-        int len = elements.length;
+        Object[] es = getArray();
+        int len = es.length;
         for (Object e : c) {
-            if (indexOf(e, elements, 0, len) < 0)
+            if (indexOfRange(e, es, 0, len) < 0)
                 return false;
         }
         return true;
@@ -694,18 +688,18 @@
         if (cs.length == 0)
             return 0;
         synchronized (lock) {
-            Object[] elements = getArray();
-            int len = elements.length;
+            Object[] es = getArray();
+            int len = es.length;
             int added = 0;
             // uniquify and compact elements in cs
             for (int i = 0; i < cs.length; ++i) {
                 Object e = cs[i];
-                if (indexOf(e, elements, 0, len) < 0 &&
-                    indexOf(e, cs, 0, added) < 0)
+                if (indexOfRange(e, es, 0, len) < 0 &&
+                    indexOfRange(e, cs, 0, added) < 0)
                     cs[added++] = e;
             }
             if (added > 0) {
-                Object[] newElements = Arrays.copyOf(elements, len + added);
+                Object[] newElements = Arrays.copyOf(es, len + added);
                 System.arraycopy(cs, 0, newElements, len, added);
                 setArray(newElements);
             }
@@ -739,15 +733,16 @@
         if (cs.length == 0)
             return false;
         synchronized (lock) {
-            Object[] elements = getArray();
-            int len = elements.length;
+            Object[] es = getArray();
+            int len = es.length;
+            Object[] newElements;
             if (len == 0 && cs.getClass() == Object[].class)
-                setArray(cs);
+                newElements = cs;
             else {
-                Object[] newElements = Arrays.copyOf(elements, len + cs.length);
+                newElements = Arrays.copyOf(es, len + cs.length);
                 System.arraycopy(cs, 0, newElements, len, cs.length);
-                setArray(newElements);
             }
+            setArray(newElements);
             return true;
         }
     }
@@ -771,8 +766,8 @@
     public boolean addAll(int index, Collection<? extends E> c) {
         Object[] cs = c.toArray();
         synchronized (lock) {
-            Object[] elements = getArray();
-            int len = elements.length;
+            Object[] es = getArray();
+            int len = es.length;
             if (index > len || index < 0)
                 throw new IndexOutOfBoundsException(outOfBounds(index, len));
             if (cs.length == 0)
@@ -780,11 +775,11 @@
             int numMoved = len - index;
             Object[] newElements;
             if (numMoved == 0)
-                newElements = Arrays.copyOf(elements, len + cs.length);
+                newElements = Arrays.copyOf(es, len + cs.length);
             else {
                 newElements = new Object[len + cs.length];
-                System.arraycopy(elements, 0, newElements, 0, index);
-                System.arraycopy(elements, index,
+                System.arraycopy(es, 0, newElements, 0, index);
+                System.arraycopy(es, index,
                                  newElements, index + cs.length,
                                  numMoved);
             }
@@ -866,14 +861,14 @@
     }
 
     public void replaceAll(UnaryOperator<E> operator) {
-        Objects.requireNonNull(operator);
         synchronized (lock) {
-            replaceAll(operator, 0, getArray().length);
+            replaceAllRange(operator, 0, getArray().length);
         }
     }
 
-    void replaceAll(UnaryOperator<E> operator, int i, int end) {
+    void replaceAllRange(UnaryOperator<E> operator, int i, int end) {
         // assert Thread.holdsLock(lock);
+        Objects.requireNonNull(operator);
         final Object[] es = getArray().clone();
         for (; i < end; i++)
             es[i] = operator.apply(elementAt(es, i));
@@ -882,12 +877,12 @@
 
     public void sort(Comparator<? super E> c) {
         synchronized (lock) {
-            sort(c, 0, getArray().length);
+            sortRange(c, 0, getArray().length);
         }
     }
 
     @SuppressWarnings("unchecked")
-    void sort(Comparator<? super E> c, int i, int end) {
+    void sortRange(Comparator<? super E> c, int i, int end) {
         // assert Thread.holdsLock(lock);
         final Object[] es = getArray().clone();
         Arrays.sort(es, i, end, (Comparator<Object>)c);
@@ -908,12 +903,12 @@
 
         s.defaultWriteObject();
 
-        Object[] elements = getArray();
+        Object[] es = getArray();
         // Write out array length
-        s.writeInt(elements.length);
+        s.writeInt(es.length);
 
         // Write out all elements in the proper order.
-        for (Object element : elements)
+        for (Object element : es)
             s.writeObject(element);
     }
 
@@ -935,12 +930,12 @@
         // Read in array length and allocate array
         int len = s.readInt();
         SharedSecrets.getJavaObjectInputStreamAccess().checkArray(s, Object[].class, len);
-        Object[] elements = new Object[len];
+        Object[] es = new Object[len];
 
         // Read in all elements in the proper order.
         for (int i = 0; i < len; i++)
-            elements[i] = s.readObject();
-        setArray(elements);
+            es[i] = s.readObject();
+        setArray(es);
     }
 
     /**
@@ -986,6 +981,15 @@
         return !it.hasNext();
     }
 
+    private static int hashCodeOfRange(Object[] es, int from, int to) {
+        int hashCode = 1;
+        for (int i = from; i < to; i++) {
+            Object x = es[i];
+            hashCode = 31 * hashCode + (x == null ? 0 : x.hashCode());
+        }
+        return hashCode;
+    }
+
     /**
      * Returns the hash code value for this list.
      *
@@ -994,10 +998,8 @@
      * @return the hash code value for this list
      */
     public int hashCode() {
-        int hashCode = 1;
-        for (Object x : getArray())
-            hashCode = 31 * hashCode + (x == null ? 0 : x.hashCode());
-        return hashCode;
+        Object[] es = getArray();
+        return hashCodeOfRange(es, 0, es.length);
     }
 
     /**
@@ -1037,12 +1039,12 @@
      * @throws IndexOutOfBoundsException {@inheritDoc}
      */
     public ListIterator<E> listIterator(int index) {
-        Object[] elements = getArray();
-        int len = elements.length;
+        Object[] es = getArray();
+        int len = es.length;
         if (index < 0 || index > len)
             throw new IndexOutOfBoundsException(outOfBounds(index, len));
 
-        return new COWIterator<E>(elements, index);
+        return new COWIterator<E>(es, index);
     }
 
     /**
@@ -1070,9 +1072,9 @@
         /** Index of element to be returned by subsequent call to next.  */
         private int cursor;
 
-        COWIterator(Object[] elements, int initialCursor) {
+        COWIterator(Object[] es, int initialCursor) {
             cursor = initialCursor;
-            snapshot = elements;
+            snapshot = es;
         }
 
         public boolean hasNext() {
@@ -1102,7 +1104,7 @@
         }
 
         public int previousIndex() {
-            return cursor-1;
+            return cursor - 1;
         }
 
         /**
@@ -1133,14 +1135,13 @@
         }
 
         @Override
-        @SuppressWarnings("unchecked")
         public void forEachRemaining(Consumer<? super E> action) {
             Objects.requireNonNull(action);
             final int size = snapshot.length;
-            for (int i = cursor; i < size; i++) {
-                action.accept((E) snapshot[i]);
-            }
+            int i = cursor;
             cursor = size;
+            for (; i < size; i++)
+                action.accept(elementAt(snapshot, i));
         }
     }
 
@@ -1161,136 +1162,264 @@
      */
     public List<E> subList(int fromIndex, int toIndex) {
         synchronized (lock) {
-            Object[] elements = getArray();
-            int len = elements.length;
-            if (fromIndex < 0 || toIndex > len || fromIndex > toIndex)
+            Object[] es = getArray();
+            int len = es.length;
+            int size = toIndex - fromIndex;
+            if (fromIndex < 0 || toIndex > len || size < 0)
                 throw new IndexOutOfBoundsException();
-            return new COWSubList<E>(this, fromIndex, toIndex);
+            return new COWSubList(es, fromIndex, size);
         }
     }
 
     /**
      * Sublist for CopyOnWriteArrayList.
      */
-    private static class COWSubList<E>
-        extends AbstractList<E>
-        implements RandomAccess
-    {
-        private final CopyOnWriteArrayList<E> l;
+    private class COWSubList implements List<E>, RandomAccess {
         private final int offset;
         private int size;
         private Object[] expectedArray;
 
-        // only call this holding l's lock
-        COWSubList(CopyOnWriteArrayList<E> list,
-                   int fromIndex, int toIndex) {
-            // assert Thread.holdsLock(list.lock);
-            l = list;
-            expectedArray = l.getArray();
-            offset = fromIndex;
-            size = toIndex - fromIndex;
+        COWSubList(Object[] es, int offset, int size) {
+            // assert Thread.holdsLock(lock);
+            expectedArray = es;
+            this.offset = offset;
+            this.size = size;
         }
 
-        // only call this holding l's lock
         private void checkForComodification() {
-            // assert Thread.holdsLock(l.lock);
-            if (l.getArray() != expectedArray)
+            // assert Thread.holdsLock(lock);
+            if (getArray() != expectedArray)
                 throw new ConcurrentModificationException();
         }
 
         private Object[] getArrayChecked() {
-            // assert Thread.holdsLock(l.lock);
-            Object[] a = l.getArray();
+            // assert Thread.holdsLock(lock);
+            Object[] a = getArray();
             if (a != expectedArray)
                 throw new ConcurrentModificationException();
             return a;
         }
 
-        // only call this holding l's lock
         private void rangeCheck(int index) {
-            // assert Thread.holdsLock(l.lock);
+            // assert Thread.holdsLock(lock);
             if (index < 0 || index >= size)
                 throw new IndexOutOfBoundsException(outOfBounds(index, size));
         }
 
+        private void rangeCheckForAdd(int index) {
+            // assert Thread.holdsLock(lock);
+            if (index < 0 || index > size)
+                throw new IndexOutOfBoundsException(outOfBounds(index, size));
+        }
+
+        public Object[] toArray() {
+            final Object[] es;
+            final int offset;
+            final int size;
+            synchronized (lock) {
+                es = getArrayChecked();
+                offset = this.offset;
+                size = this.size;
+            }
+            return Arrays.copyOfRange(es, offset, offset + size);
+        }
+
+        @SuppressWarnings("unchecked")
+        public <T> T[] toArray(T[] a) {
+            final Object[] es;
+            final int offset;
+            final int size;
+            synchronized (lock) {
+                es = getArrayChecked();
+                offset = this.offset;
+                size = this.size;
+            }
+            if (a.length < size)
+                return (T[]) Arrays.copyOfRange(
+                        es, offset, offset + size, a.getClass());
+            else {
+                System.arraycopy(es, offset, a, 0, size);
+                if (a.length > size)
+                    a[size] = null;
+                return a;
+            }
+        }
+
+        public int indexOf(Object o) {
+            final Object[] es;
+            final int offset;
+            final int size;
+            synchronized (lock) {
+                es = getArrayChecked();
+                offset = this.offset;
+                size = this.size;
+            }
+            int i = indexOfRange(o, es, offset, offset + size);
+            return (i == -1) ? -1 : i - offset;
+        }
+
+        public int lastIndexOf(Object o) {
+            final Object[] es;
+            final int offset;
+            final int size;
+            synchronized (lock) {
+                es = getArrayChecked();
+                offset = this.offset;
+                size = this.size;
+            }
+            int i = lastIndexOfRange(o, es, offset, offset + size);
+            return (i == -1) ? -1 : i - offset;
+        }
+
+        public boolean contains(Object o) {
+            return indexOf(o) >= 0;
+        }
+
+        public boolean containsAll(Collection<?> c) {
+            final Object[] es;
+            final int offset;
+            final int size;
+            synchronized (lock) {
+                es = getArrayChecked();
+                offset = this.offset;
+                size = this.size;
+            }
+            for (Object o : c)
+                if (indexOfRange(o, es, offset, offset + size) < 0)
+                    return false;
+            return true;
+        }
+
+        public boolean isEmpty() {
+            return size() == 0;
+        }
+
+        public String toString() {
+            return Arrays.toString(toArray());
+        }
+
+        public int hashCode() {
+            final Object[] es;
+            final int offset;
+            final int size;
+            synchronized (lock) {
+                es = getArrayChecked();
+                offset = this.offset;
+                size = this.size;
+            }
+            return hashCodeOfRange(es, offset, offset + size);
+        }
+
+        public boolean equals(Object o) {
+            if (o == this)
+                return true;
+            if (!(o instanceof List))
+                return false;
+            Iterator<?> it = ((List<?>)o).iterator();
+
+            final Object[] es;
+            final int offset;
+            final int size;
+            synchronized (lock) {
+                es = getArrayChecked();
+                offset = this.offset;
+                size = this.size;
+            }
+
+            for (int i = offset, end = offset + size; i < end; i++)
+                if (!it.hasNext() || !Objects.equals(es[i], it.next()))
+                    return false;
+            return !it.hasNext();
+        }
+
         public E set(int index, E element) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 rangeCheck(index);
                 checkForComodification();
-                E x = l.set(offset + index, element);
-                expectedArray = l.getArray();
+                E x = CopyOnWriteArrayList.this.set(offset + index, element);
+                expectedArray = getArray();
                 return x;
             }
         }
 
         public E get(int index) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 rangeCheck(index);
                 checkForComodification();
-                return l.get(offset + index);
+                return CopyOnWriteArrayList.this.get(offset + index);
             }
         }
 
         public int size() {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 checkForComodification();
                 return size;
             }
         }
 
         public boolean add(E element) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 checkForComodification();
-                l.add(offset + size, element);
-                expectedArray = l.getArray();
+                CopyOnWriteArrayList.this.add(offset + size, element);
+                expectedArray = getArray();
                 size++;
             }
             return true;
         }
 
         public void add(int index, E element) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 checkForComodification();
-                if (index < 0 || index > size)
-                    throw new IndexOutOfBoundsException
-                        (outOfBounds(index, size));
-                l.add(offset + index, element);
-                expectedArray = l.getArray();
+                rangeCheckForAdd(index);
+                CopyOnWriteArrayList.this.add(offset + index, element);
+                expectedArray = getArray();
                 size++;
             }
         }
 
         public boolean addAll(Collection<? extends E> c) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 final Object[] oldArray = getArrayChecked();
-                boolean modified = l.addAll(offset + size, c);
-                size += (expectedArray = l.getArray()).length - oldArray.length;
+                boolean modified =
+                    CopyOnWriteArrayList.this.addAll(offset + size, c);
+                size += (expectedArray = getArray()).length - oldArray.length;
+                return modified;
+            }
+        }
+
+        public boolean addAll(int index, Collection<? extends E> c) {
+            synchronized (lock) {
+                rangeCheckForAdd(index);
+                final Object[] oldArray = getArrayChecked();
+                boolean modified =
+                    CopyOnWriteArrayList.this.addAll(offset + index, c);
+                size += (expectedArray = getArray()).length - oldArray.length;
                 return modified;
             }
         }
 
         public void clear() {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 checkForComodification();
-                l.removeRange(offset, offset + size);
-                expectedArray = l.getArray();
+                removeRange(offset, offset + size);
+                expectedArray = getArray();
                 size = 0;
             }
         }
 
         public E remove(int index) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 rangeCheck(index);
                 checkForComodification();
-                E result = l.remove(offset + index);
-                expectedArray = l.getArray();
+                E result = CopyOnWriteArrayList.this.remove(offset + index);
+                expectedArray = getArray();
                 size--;
                 return result;
             }
         }
 
         public boolean remove(Object o) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 checkForComodification();
                 int index = indexOf(o);
                 if (index == -1)
@@ -1301,36 +1430,35 @@
         }
 
         public Iterator<E> iterator() {
-            synchronized (l.lock) {
-                checkForComodification();
-                return new COWSubListIterator<E>(l, 0, offset, size);
-            }
+            return listIterator(0);
+        }
+
+        public ListIterator<E> listIterator() {
+            return listIterator(0);
         }
 
         public ListIterator<E> listIterator(int index) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 checkForComodification();
-                if (index < 0 || index > size)
-                    throw new IndexOutOfBoundsException
-                        (outOfBounds(index, size));
-                return new COWSubListIterator<E>(l, index, offset, size);
+                rangeCheckForAdd(index);
+                return new COWSubListIterator<E>(
+                    CopyOnWriteArrayList.this, index, offset, size);
             }
         }
 
         public List<E> subList(int fromIndex, int toIndex) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 checkForComodification();
                 if (fromIndex < 0 || toIndex > size || fromIndex > toIndex)
                     throw new IndexOutOfBoundsException();
-                return new COWSubList<E>(l, fromIndex + offset,
-                                         toIndex + offset);
+                return new COWSubList(expectedArray, fromIndex + offset, toIndex - fromIndex);
             }
         }
 
         public void forEach(Consumer<? super E> action) {
             Objects.requireNonNull(action);
             int i, end; final Object[] es;
-            synchronized (l.lock) {
+            synchronized (lock) {
                 es = getArrayChecked();
                 i = offset;
                 end = i + size;
@@ -1340,19 +1468,18 @@
         }
 
         public void replaceAll(UnaryOperator<E> operator) {
-            Objects.requireNonNull(operator);
-            synchronized (l.lock) {
+            synchronized (lock) {
                 checkForComodification();
-                l.replaceAll(operator, offset, offset + size);
-                expectedArray = l.getArray();
+                replaceAllRange(operator, offset, offset + size);
+                expectedArray = getArray();
             }
         }
 
         public void sort(Comparator<? super E> c) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 checkForComodification();
-                l.sort(c, offset, offset + size);
-                expectedArray = l.getArray();
+                sortRange(c, offset, offset + size);
+                expectedArray = getArray();
             }
         }
 
@@ -1372,16 +1499,17 @@
         }
 
         private boolean bulkRemove(Predicate<? super E> filter) {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 final Object[] oldArray = getArrayChecked();
-                boolean modified = l.bulkRemove(filter, offset, offset + size);
-                size += (expectedArray = l.getArray()).length - oldArray.length;
+                boolean modified = CopyOnWriteArrayList.this.bulkRemove(
+                    filter, offset, offset + size);
+                size += (expectedArray = getArray()).length - oldArray.length;
                 return modified;
             }
         }
 
         public Spliterator<E> spliterator() {
-            synchronized (l.lock) {
+            synchronized (lock) {
                 return Spliterators.spliterator(
                         getArrayChecked(), offset, offset + size,
                         Spliterator.IMMUTABLE | Spliterator.ORDERED);
@@ -1398,7 +1526,7 @@
         COWSubListIterator(List<E> l, int index, int offset, int size) {
             this.offset = offset;
             this.size = size;
-            it = l.listIterator(index+offset);
+            it = l.listIterator(index + offset);
         }
 
         public boolean hasNext() {
@@ -1447,7 +1575,7 @@
         @SuppressWarnings("unchecked")
         public void forEachRemaining(Consumer<? super E> action) {
             Objects.requireNonNull(action);
-            while (nextIndex() < size) {
+            while (hasNext()) {
                 action.accept(it.next());
             }
         }
--- a/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java	Fri Apr 13 14:55:11 2018 -0400
@@ -775,7 +775,7 @@
             PENDING = l.findVarHandle(CountedCompleter.class, "pending", int.class);
 
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 }
--- a/src/java.base/share/classes/java/util/concurrent/Exchanger.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/Exchanger.java	Fri Apr 13 14:55:11 2018 -0400
@@ -641,7 +641,7 @@
             MATCH = l.findVarHandle(Node.class, "match", Object.class);
             AA = MethodHandles.arrayElementVarHandle(Node[].class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 
--- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Fri Apr 13 14:55:11 2018 -0400
@@ -184,17 +184,22 @@
      * functionality and control for a set of worker threads:
      * Submissions from non-FJ threads enter into submission queues.
      * Workers take these tasks and typically split them into subtasks
-     * that may be stolen by other workers.  Preference rules give
-     * first priority to processing tasks from their own queues (LIFO
-     * or FIFO, depending on mode), then to randomized FIFO steals of
-     * tasks in other queues.  This framework began as vehicle for
-     * supporting tree-structured parallelism using work-stealing.
-     * Over time, its scalability advantages led to extensions and
-     * changes to better support more diverse usage contexts.  Because
-     * most internal methods and nested classes are interrelated,
-     * their main rationale and descriptions are presented here;
-     * individual methods and nested classes contain only brief
-     * comments about details.
+     * that may be stolen by other workers. Work-stealing based on
+     * randomized scans generally leads to better throughput than
+     * "work dealing" in which producers assign tasks to idle threads,
+     * in part because threads that have finished other tasks before
+     * the signalled thread wakes up (which can be a long time) can
+     * take the task instead.  Preference rules give first priority to
+     * processing tasks from their own queues (LIFO or FIFO, depending
+     * on mode), then to randomized FIFO steals of tasks in other
+     * queues.  This framework began as vehicle for supporting
+     * tree-structured parallelism using work-stealing.  Over time,
+     * its scalability advantages led to extensions and changes to
+     * better support more diverse usage contexts.  Because most
+     * internal methods and nested classes are interrelated, their
+     * main rationale and descriptions are presented here; individual
+     * methods and nested classes contain only brief comments about
+     * details.
      *
      * WorkQueues
      * ==========
@@ -227,9 +232,10 @@
      *
      * (The actual code needs to null-check and size-check the array,
      * uses masking, not mod, for indexing a power-of-two-sized array,
-     * properly fences accesses, and possibly signals waiting workers
-     * to start scanning -- see below.)  Both a successful pop and
-     * poll mainly entail a CAS of a slot from non-null to null.
+     * adds a release fence for publication, and possibly signals
+     * waiting workers to start scanning -- see below.)  Both a
+     * successful pop and poll mainly entail a CAS of a slot from
+     * non-null to null.
      *
      * The pop operation (always performed by owner) is:
      *   if ((the task at top slot is not null) and
@@ -241,9 +247,14 @@
      *        (CAS slot to null))
      *           increment base and return task;
      *
-     * There are several variants of each of these. In particular,
-     * almost all uses of poll occur within scan operations that also
-     * interleave contention tracking (with associated code sprawl.)
+     * There are several variants of each of these. Most uses occur
+     * within operations that also interleave contention or emptiness
+     * tracking or inspection of elements before extracting them, so
+     * must interleave these with the above code. When performed by
+     * owner, getAndSet is used instead of CAS (see for example method
+     * nextLocalTask) which is usually more efficient, and possible
+     * because the top index cannot independently change during the
+     * operation.
      *
      * Memory ordering.  See "Correct and Efficient Work-Stealing for
      * Weak Memory Models" by Le, Pop, Cohen, and Nardelli, PPoPP 2013
@@ -252,30 +263,37 @@
      * algorithms similar to (but different than) the one used here.
      * Extracting tasks in array slots via (fully fenced) CAS provides
      * primary synchronization. The base and top indices imprecisely
-     * guide where to extract from. We do not always require strict
-     * orderings of array and index updates, so sometimes let them be
-     * subject to compiler and processor reorderings. However, the
-     * volatile "base" index also serves as a basis for memory
-     * ordering: Slot accesses are preceded by a read of base,
-     * ensuring happens-before ordering with respect to stealers (so
-     * the slots themselves can be read via plain array reads.)  The
-     * only other memory orderings relied on are maintained in the
-     * course of signalling and activation (see below).  A check that
-     * base == top indicates (momentary) emptiness, but otherwise may
-     * err on the side of possibly making the queue appear nonempty
-     * when a push, pop, or poll have not fully committed, or making
-     * it appear empty when an update of top has not yet been visibly
-     * written.  (Method isEmpty() checks the case of a partially
-     * completed removal of the last element.)  Because of this, the
-     * poll operation, considered individually, is not wait-free. One
-     * thief cannot successfully continue until another in-progress
-     * one (or, if previously empty, a push) visibly completes.
-     * However, in the aggregate, we ensure at least probabilistic
+     * guide where to extract from. We do not usually require strict
+     * orderings of array and index updates. Many index accesses use
+     * plain mode, with ordering constrained by surrounding context
+     * (usually with respect to element CASes or the two WorkQueue
+     * volatile fields source and phase). When not otherwise already
+     * constrained, reads of "base" by queue owners use acquire-mode,
+     * and some externally callable methods preface accesses with
+     * acquire fences.  Additionally, to ensure that index update
+     * writes are not coalesced or postponed in loops etc, "opaque"
+     * mode is used in a few cases where timely writes are not
+     * otherwise ensured. The "locked" versions of push- and pop-
+     * based methods for shared queues differ from owned versions
+     * because locking already forces some of the ordering.
+     *
+     * Because indices and slot contents cannot always be consistent,
+     * a check that base == top indicates (momentary) emptiness, but
+     * otherwise may err on the side of possibly making the queue
+     * appear nonempty when a push, pop, or poll have not fully
+     * committed, or making it appear empty when an update of top has
+     * not yet been visibly written.  (Method isEmpty() checks the
+     * case of a partially completed removal of the last element.)
+     * Because of this, the poll operation, considered individually,
+     * is not wait-free. One thief cannot successfully continue until
+     * another in-progress one (or, if previously empty, a push)
+     * visibly completes.  This can stall threads when required to
+     * consume from a given queue (see method poll()).  However, in
+     * the aggregate, we ensure at least probabilistic
      * non-blockingness.  If an attempted steal fails, a scanning
      * thief chooses a different random victim target to try next. So,
      * in order for one thief to progress, it suffices for any
-     * in-progress poll or new push on any empty queue to
-     * complete.
+     * in-progress poll or new push on any empty queue to complete.
      *
      * This approach also enables support of a user mode in which
      * local task processing is in FIFO, not LIFO order, simply by
@@ -296,7 +314,7 @@
      * different position to use or create other queues -- they block
      * only when creating and registering new queues. Because it is
      * used only as a spinlock, unlocking requires only a "releasing"
-     * store (using setRelease).
+     * store (using setRelease) unless otherwise signalling.
      *
      * Management
      * ==========
@@ -317,10 +335,10 @@
      *
      * Field "ctl" contains 64 bits holding information needed to
      * atomically decide to add, enqueue (on an event queue), and
-     * dequeue (and release)-activate workers.  To enable this
-     * packing, we restrict maximum parallelism to (1<<15)-1 (which is
-     * far in excess of normal operating range) to allow ids, counts,
-     * and their negations (used for thresholding) to fit into 16bit
+     * dequeue and release workers.  To enable this packing, we
+     * restrict maximum parallelism to (1<<15)-1 (which is far in
+     * excess of normal operating range) to allow ids, counts, and
+     * their negations (used for thresholding) to fit into 16bit
      * subfields.
      *
      * Field "mode" holds configuration parameters as well as lifetime
@@ -332,13 +350,14 @@
      * lock (using field workerNamePrefix as lock), but is otherwise
      * concurrently readable, and accessed directly. We also ensure
      * that uses of the array reference itself never become too stale
-     * in case of resizing.  To simplify index-based operations, the
-     * array size is always a power of two, and all readers must
-     * tolerate null slots. Worker queues are at odd indices. Shared
-     * (submission) queues are at even indices, up to a maximum of 64
-     * slots, to limit growth even if array needs to expand to add
-     * more workers. Grouping them together in this way simplifies and
-     * speeds up task scanning.
+     * in case of resizing, by arranging that (re-)reads are separated
+     * by at least one acquiring read access.  To simplify index-based
+     * operations, the array size is always a power of two, and all
+     * readers must tolerate null slots. Worker queues are at odd
+     * indices. Shared (submission) queues are at even indices, up to
+     * a maximum of 64 slots, to limit growth even if the array needs
+     * to expand to add more workers. Grouping them together in this
+     * way simplifies and speeds up task scanning.
      *
      * All worker thread creation is on-demand, triggered by task
      * submissions, replacement of terminated workers, and/or
@@ -416,8 +435,8 @@
      * releases so usage requires care -- seeing a negative phase does
      * not guarantee that the worker is available. When queued, the
      * lower 16 bits of scanState must hold its pool index. So we
-     * place the index there upon initialization (see registerWorker)
-     * and otherwise keep it there or restore it when necessary.
+     * place the index there upon initialization and otherwise keep it
+     * there or restore it when necessary.
      *
      * The ctl field also serves as the basis for memory
      * synchronization surrounding activation. This uses a more
@@ -425,48 +444,56 @@
      * consumers sync with each other by both writing/CASing ctl (even
      * if to its current value).  This would be extremely costly. So
      * we relax it in several ways: (1) Producers only signal when
-     * their queue is empty. Other workers propagate this signal (in
-     * method scan) when they find tasks; to further reduce flailing,
-     * each worker signals only one other per activation. (2) Workers
-     * only enqueue after scanning (see below) and not finding any
-     * tasks.  (3) Rather than CASing ctl to its current value in the
-     * common case where no action is required, we reduce write
+     * their queue is possibly empty at some point during a push
+     * operation (which requires conservatively checking size zero or
+     * one to cover races). (2) Other workers propagate this signal
+     * when they find tasks in a queue with size greater than one. (3)
+     * Workers only enqueue after scanning (see below) and not finding
+     * any tasks.  (4) Rather than CASing ctl to its current value in
+     * the common case where no action is required, we reduce write
      * contention by equivalently prefacing signalWork when called by
      * an external task producer using a memory access with
      * full-volatile semantics or a "fullFence".
      *
-     * Almost always, too many signals are issued. A task producer
-     * cannot in general tell if some existing worker is in the midst
-     * of finishing one task (or already scanning) and ready to take
-     * another without being signalled. So the producer might instead
-     * activate a different worker that does not find any work, and
-     * then inactivates. This scarcely matters in steady-state
-     * computations involving all workers, but can create contention
-     * and bookkeeping bottlenecks during ramp-up, ramp-down, and small
-     * computations involving only a few workers.
+     * Almost always, too many signals are issued, in part because a
+     * task producer cannot tell if some existing worker is in the
+     * midst of finishing one task (or already scanning) and ready to
+     * take another without being signalled. So the producer might
+     * instead activate a different worker that does not find any
+     * work, and then inactivates. This scarcely matters in
+     * steady-state computations involving all workers, but can create
+     * contention and bookkeeping bottlenecks during ramp-up,
+     * ramp-down, and small computations involving only a few workers.
      *
-     * Scanning. Method runWorker performs top-level scanning for
-     * tasks.  Each scan traverses and tries to poll from each queue
-     * starting at a random index and circularly stepping. Scans are
-     * not performed in ideal random permutation order, to reduce
-     * cacheline contention.  The pseudorandom generator need not have
+     * Scanning. Method scan (from runWorker) performs top-level
+     * scanning for tasks. (Similar scans appear in helpQuiesce and
+     * pollScan.)  Each scan traverses and tries to poll from each
+     * queue starting at a random index. Scans are not performed in
+     * ideal random permutation order, to reduce cacheline
+     * contention. The pseudorandom generator need not have
      * high-quality statistical properties in the long term, but just
      * within computations; We use Marsaglia XorShifts (often via
      * ThreadLocalRandom.nextSecondarySeed), which are cheap and
-     * suffice. Scanning also employs contention reduction: When
+     * suffice. Scanning also includes contention reduction: When
      * scanning workers fail to extract an apparently existing task,
-     * they soon restart at a different pseudorandom index.  This
-     * improves throughput when many threads are trying to take tasks
-     * from few queues, which can be common in some usages.  Scans do
-     * not otherwise explicitly take into account core affinities,
-     * loads, cache localities, etc, However, they do exploit temporal
-     * locality (which usually approximates these) by preferring to
-     * re-poll (at most #workers times) from the same queue after a
-     * successful poll before trying others.
+     * they soon restart at a different pseudorandom index.  This form
+     * of backoff improves throughput when many threads are trying to
+     * take tasks from few queues, which can be common in some usages.
+     * Scans do not otherwise explicitly take into account core
+     * affinities, loads, cache localities, etc, However, they do
+     * exploit temporal locality (which usually approximates these) by
+     * preferring to re-poll from the same queue after a successful
+     * poll before trying others (see method topLevelExec). However
+     * this preference is bounded (see TOP_BOUND_SHIFT) as a safeguard
+     * against infinitely unfair looping under unbounded user task
+     * recursion, and also to reduce long-term contention when many
+     * threads poll few queues holding many small tasks. The bound is
+     * high enough to avoid much impact on locality and scheduling
+     * overhead.
      *
      * Trimming workers. To release resources after periods of lack of
      * use, a worker starting to wait when the pool is quiescent will
-     * time out and terminate (see method scan) if the pool has
+     * time out and terminate (see method runWorker) if the pool has
      * remained quiescent for period given by field keepAlive.
      *
      * Shutdown and Termination. A call to shutdownNow invokes
@@ -534,13 +561,14 @@
      * time. Some previous versions of this class employed immediate
      * compensations for any blocked join. However, in practice, the
      * vast majority of blockages are transient byproducts of GC and
-     * other JVM or OS activities that are made worse by replacement.
-     * Rather than impose arbitrary policies, we allow users to
-     * override the default of only adding threads upon apparent
-     * starvation.  The compensation mechanism may also be bounded.
-     * Bounds for the commonPool (see COMMON_MAX_SPARES) better enable
-     * JVMs to cope with programming errors and abuse before running
-     * out of resources to do so.
+     * other JVM or OS activities that are made worse by replacement
+     * when they cause longer-term oversubscription.  Rather than
+     * impose arbitrary policies, we allow users to override the
+     * default of only adding threads upon apparent starvation.  The
+     * compensation mechanism may also be bounded.  Bounds for the
+     * commonPool (see COMMON_MAX_SPARES) better enable JVMs to cope
+     * with programming errors and abuse before running out of
+     * resources to do so.
      *
      * Common Pool
      * ===========
@@ -573,6 +601,18 @@
      * in ForkJoinWorkerThread) may be JVM-dependent and must access
      * particular Thread class fields to achieve this effect.
      *
+     * Memory placement
+     * ================
+     *
+     * Performance can be very sensitive to placement of instances of
+     * ForkJoinPool and WorkQueues and their queue arrays. To reduce
+     * false-sharing impact, the @Contended annotation isolates
+     * adjacent WorkQueue instances, as well as the ForkJoinPool.ctl
+     * field. WorkQueue arrays are allocated (by their threads) with
+     * larger initial sizes than most ever need, mostly to reduce
+     * false sharing with current garbage collectors that use cardmark
+     * tables.
+     *
      * Style notes
      * ===========
      *
@@ -580,13 +620,15 @@
      * awkward and ugly, but also reflects the need to control
      * outcomes across the unusual cases that arise in very racy code
      * with very few invariants. All fields are read into locals
-     * before use, and null-checked if they are references.  This is
-     * usually done in a "C"-like style of listing declarations at the
-     * heads of methods or blocks, and using inline assignments on
-     * first encounter.  Nearly all explicit checks lead to
-     * bypass/return, not exception throws, because they may
-     * legitimately arise due to cancellation/revocation during
-     * shutdown.
+     * before use, and null-checked if they are references.  Array
+     * accesses using masked indices include checks (that are always
+     * true) that the array length is non-zero to avoid compilers
+     * inserting more expensive traps.  This is usually done in a
+     * "C"-like style of listing declarations at the heads of methods
+     * or blocks, and using inline assignments on first encounter.
+     * Nearly all explicit checks lead to bypass/return, not exception
+     * throws, because they may legitimately arise due to
+     * cancellation/revocation during shutdown.
      *
      * There is a lot of representation-level coupling among classes
      * ForkJoinPool, ForkJoinWorkerThread, and ForkJoinTask.  The
@@ -596,10 +638,11 @@
      * representations will need to be accompanied by algorithmic
      * changes anyway. Several methods intrinsically sprawl because
      * they must accumulate sets of consistent reads of fields held in
-     * local variables.  There are also other coding oddities
-     * (including several unnecessary-looking hoisted null checks)
-     * that help some methods perform reasonably even when interpreted
-     * (not compiled).
+     * local variables. Some others are artificially broken up to
+     * reduce producer/consumer imbalances due to dynamic compilation.
+     * There are also other coding oddities (including several
+     * unnecessary-looking hoisted null checks) that help some methods
+     * perform reasonably even when interpreted (not compiled).
      *
      * The order of declarations in this file is (with a few exceptions):
      * (1) Static utility functions
@@ -703,54 +746,43 @@
     static final int DORMANT      = QUIET | UNSIGNALLED;
 
     /**
-     * The maximum number of local polls from the same queue before
-     * checking others. This is a safeguard against infinitely unfair
-     * looping under unbounded user task recursion, and must be larger
-     * than plausible cases of intentional bounded task recursion.
+     * Initial capacity of work-stealing queue array.
+     * Must be a power of two, at least 2.
      */
-    static final int POLL_LIMIT = 1 << 10;
+    static final int INITIAL_QUEUE_CAPACITY = 1 << 13;
+
+    /**
+     * Maximum capacity for queue arrays. Must be a power of two less
+     * than or equal to 1 << (31 - width of array entry) to ensure
+     * lack of wraparound of index calculations, but defined to a
+     * value a bit less than this to help users trap runaway programs
+     * before saturating systems.
+     */
+    static final int MAXIMUM_QUEUE_CAPACITY = 1 << 26; // 64M
+
+    /**
+     * The maximum number of top-level polls per worker before
+     * checking other queues, expressed as a bit shift to, in effect,
+     * multiply by pool size, and then use as random value mask, so
+     * average bound is about poolSize*(1<<TOP_BOUND_SHIFT).  See
+     * above for rationale.
+     */
+    static final int TOP_BOUND_SHIFT = 10;
 
     /**
      * Queues supporting work-stealing as well as external task
      * submission. See above for descriptions and algorithms.
-     * Performance on most platforms is very sensitive to placement of
-     * instances of both WorkQueues and their arrays -- we absolutely
-     * do not want multiple WorkQueue instances or multiple queue
-     * arrays sharing cache lines. The @Contended annotation alerts
-     * JVMs to try to keep instances apart.
      */
     @jdk.internal.vm.annotation.Contended
     static final class WorkQueue {
-
-        /**
-         * Capacity of work-stealing queue array upon initialization.
-         * Must be a power of two; at least 4, but should be larger to
-         * reduce or eliminate cacheline sharing among queues.
-         * Currently, it is much larger, as a partial workaround for
-         * the fact that JVMs often place arrays in locations that
-         * share GC bookkeeping (especially cardmarks) such that
-         * per-write accesses encounter serious memory contention.
-         */
-        static final int INITIAL_QUEUE_CAPACITY = 1 << 13;
-
-        /**
-         * Maximum size for queue arrays. Must be a power of two less
-         * than or equal to 1 << (31 - width of array entry) to ensure
-         * lack of wraparound of index calculations, but defined to a
-         * value a bit less than this to help users trap runaway
-         * programs before saturating systems.
-         */
-        static final int MAXIMUM_QUEUE_CAPACITY = 1 << 26; // 64M
-
-        // Instance fields
+        volatile int source;       // source queue id, or sentinel
+        int id;                    // pool index, mode, tag
+        int base;                  // index of next slot for poll
+        int top;                   // index of next slot for push
         volatile int phase;        // versioned, negative: queued, 1: locked
         int stackPred;             // pool stack (ctl) predecessor link
         int nsteals;               // number of steals
-        int id;                    // index, mode, tag
-        volatile int source;       // source queue id, or sentinel
-        volatile int base;         // index of next slot for poll
-        int top;                   // index of next slot for push
-        ForkJoinTask<?>[] array;   // the elements (initially unallocated)
+        ForkJoinTask<?>[] array;   // the queued tasks; power of 2 size
         final ForkJoinPool pool;   // the containing pool (may be null)
         final ForkJoinWorkerThread owner; // owning thread or null if shared
 
@@ -762,6 +794,17 @@
         }
 
         /**
+         * Tries to lock shared queue by CASing phase field.
+         */
+        final boolean tryLockPhase() {
+            return PHASE.compareAndSet(this, 0, 1);
+        }
+
+        final void releasePhaseLock() {
+            PHASE.setRelease(this, 0);
+        }
+
+        /**
          * Returns an exportable index (used by ForkJoinWorkerThread).
          */
         final int getPoolIndex() {
@@ -772,7 +815,7 @@
          * Returns the approximate number of tasks in the queue.
          */
         final int queueSize() {
-            int n = base - top;       // read base first
+            int n = (int)BASE.getAcquire(this) - top;
             return (n >= 0) ? 0 : -n; // ignore transient negative
         }
 
@@ -782,14 +825,14 @@
          * near-empty queue has at least one unclaimed task.
          */
         final boolean isEmpty() {
-            ForkJoinTask<?>[] a; int n, al, b;
+            ForkJoinTask<?>[] a; int n, cap, b;
+            VarHandle.acquireFence(); // needed by external callers
             return ((n = (b = base) - top) >= 0 || // possibly one task
                     (n == -1 && ((a = array) == null ||
-                                 (al = a.length) == 0 ||
-                                 a[(al - 1) & b] == null)));
+                                 (cap = a.length) == 0 ||
+                                 a[(cap - 1) & b] == null)));
         }
 
-
         /**
          * Pushes a task. Call only by owner in unshared queues.
          *
@@ -797,94 +840,99 @@
          * @throws RejectedExecutionException if array cannot be resized
          */
         final void push(ForkJoinTask<?> task) {
-            int s = top; ForkJoinTask<?>[] a; int al, d;
-            if ((a = array) != null && (al = a.length) > 0) {
-                int index = (al - 1) & s;
-                ForkJoinPool p = pool;
+            ForkJoinTask<?>[] a;
+            int s = top, d, cap, m;
+            ForkJoinPool p = pool;
+            if ((a = array) != null && (cap = a.length) > 0) {
+                QA.setRelease(a, (m = cap - 1) & s, task);
                 top = s + 1;
-                QA.setRelease(a, index, task);
-                if ((d = base - s) == 0 && p != null) {
+                if (((d = s - (int)BASE.getAcquire(this)) & ~1) == 0 &&
+                    p != null) {                 // size 0 or 1
                     VarHandle.fullFence();
                     p.signalWork();
                 }
-                else if (d + al == 1)
-                    growArray();
+                else if (d == m)
+                    growArray(false);
             }
         }
 
         /**
-         * Initializes or doubles the capacity of array. Call either
-         * by owner or with lock held -- it is OK for base, but not
-         * top, to move while resizings are in progress.
+         * Version of push for shared queues. Call only with phase lock held.
+         * @return true if should signal work
          */
-        final ForkJoinTask<?>[] growArray() {
-            ForkJoinTask<?>[] oldA = array;
-            int oldSize = oldA != null ? oldA.length : 0;
-            int size = oldSize > 0 ? oldSize << 1 : INITIAL_QUEUE_CAPACITY;
-            if (size < INITIAL_QUEUE_CAPACITY || size > MAXIMUM_QUEUE_CAPACITY)
-                throw new RejectedExecutionException("Queue capacity exceeded");
-            int oldMask, t, b;
-            ForkJoinTask<?>[] a = array = new ForkJoinTask<?>[size];
-            if (oldA != null && (oldMask = oldSize - 1) > 0 &&
-                (t = top) - (b = base) > 0) {
-                int mask = size - 1;
-                do { // emulate poll from old array, push to new array
-                    int index = b & oldMask;
-                    ForkJoinTask<?> x = (ForkJoinTask<?>)
-                        QA.getAcquire(oldA, index);
-                    if (x != null &&
-                        QA.compareAndSet(oldA, index, x, null))
-                        a[b & mask] = x;
-                } while (++b != t);
-                VarHandle.releaseFence();
+        final boolean lockedPush(ForkJoinTask<?> task) {
+            ForkJoinTask<?>[] a;
+            boolean signal = false;
+            int s = top, b = base, cap, d;
+            if ((a = array) != null && (cap = a.length) > 0) {
+                a[(cap - 1) & s] = task;
+                top = s + 1;
+                if (b - s + cap - 1 == 0)
+                    growArray(true);
+                else {
+                    phase = 0; // full volatile unlock
+                    if (((s - base) & ~1) == 0) // size 0 or 1
+                        signal = true;
+                }
             }
-            return a;
+            return signal;
         }
 
         /**
-         * Takes next task, if one exists, in LIFO order.  Call only
-         * by owner in unshared queues.
+         * Doubles the capacity of array. Call either by owner or with
+         * lock held -- it is OK for base, but not top, to move while
+         * resizings are in progress.
          */
-        final ForkJoinTask<?> pop() {
-            int b = base, s = top, al, i; ForkJoinTask<?>[] a;
-            if ((a = array) != null && b != s && (al = a.length) > 0) {
-                int index = (al - 1) & --s;
-                ForkJoinTask<?> t = (ForkJoinTask<?>)
-                    QA.get(a, index);
-                if (t != null &&
-                    QA.compareAndSet(a, index, t, null)) {
-                    top = s;
-                    VarHandle.releaseFence();
-                    return t;
+        final void growArray(boolean locked) {
+            ForkJoinTask<?>[] newA = null;
+            try {
+                ForkJoinTask<?>[] oldA; int oldSize, newSize;
+                if ((oldA = array) != null && (oldSize = oldA.length) > 0 &&
+                    (newSize = oldSize << 1) <= MAXIMUM_QUEUE_CAPACITY &&
+                    newSize > 0) {
+                    try {
+                        newA = new ForkJoinTask<?>[newSize];
+                    } catch (OutOfMemoryError ex) {
+                    }
+                    if (newA != null) { // poll from old array, push to new
+                        int oldMask = oldSize - 1, newMask = newSize - 1;
+                        for (int s = top - 1, k = oldMask; k >= 0; --k) {
+                            ForkJoinTask<?> x = (ForkJoinTask<?>)
+                                QA.getAndSet(oldA, s & oldMask, null);
+                            if (x != null)
+                                newA[s-- & newMask] = x;
+                            else
+                                break;
+                        }
+                        array = newA;
+                        VarHandle.releaseFence();
+                    }
                 }
+            } finally {
+                if (locked)
+                    phase = 0;
             }
-            return null;
+            if (newA == null)
+                throw new RejectedExecutionException("Queue capacity exceeded");
         }
 
         /**
          * Takes next task, if one exists, in FIFO order.
          */
         final ForkJoinTask<?> poll() {
-            for (;;) {
-                int b = base, s = top, d, al; ForkJoinTask<?>[] a;
-                if ((a = array) != null && (d = b - s) < 0 &&
-                    (al = a.length) > 0) {
-                    int index = (al - 1) & b;
-                    ForkJoinTask<?> t = (ForkJoinTask<?>)
-                        QA.getAcquire(a, index);
-                    if (b++ == base) {
-                        if (t != null) {
-                            if (QA.compareAndSet(a, index, t, null)) {
-                                base = b;
-                                return t;
-                            }
-                        }
-                        else if (d == -1)
-                            break; // now empty
+            int b, k, cap; ForkJoinTask<?>[] a;
+            while ((a = array) != null && (cap = a.length) > 0 &&
+                   top - (b = base) > 0) {
+                ForkJoinTask<?> t = (ForkJoinTask<?>)
+                    QA.getAcquire(a, k = (cap - 1) & b);
+                if (base == b++) {
+                    if (t == null)
+                        Thread.yield(); // await index advance
+                    else if (QA.compareAndSet(a, k, t, null)) {
+                        BASE.setOpaque(this, b);
+                        return t;
                     }
                 }
-                else
-                    break;
             }
             return null;
         }
@@ -893,33 +941,61 @@
          * Takes next task, if one exists, in order specified by mode.
          */
         final ForkJoinTask<?> nextLocalTask() {
-            return ((id & FIFO) != 0) ? poll() : pop();
+            ForkJoinTask<?> t = null;
+            int md = id, b, s, d, cap; ForkJoinTask<?>[] a;
+            if ((a = array) != null && (cap = a.length) > 0 &&
+                (d = (s = top) - (b = base)) > 0) {
+                if ((md & FIFO) == 0 || d == 1) {
+                    if ((t = (ForkJoinTask<?>)
+                         QA.getAndSet(a, (cap - 1) & --s, null)) != null)
+                        TOP.setOpaque(this, s);
+                }
+                else if ((t = (ForkJoinTask<?>)
+                          QA.getAndSet(a, (cap - 1) & b++, null)) != null) {
+                    BASE.setOpaque(this, b);
+                }
+                else // on contention in FIFO mode, use regular poll
+                    t = poll();
+            }
+            return t;
         }
 
         /**
          * Returns next task, if one exists, in order specified by mode.
          */
         final ForkJoinTask<?> peek() {
-            int al; ForkJoinTask<?>[] a;
-            return ((a = array) != null && (al = a.length) > 0) ?
-                a[(al - 1) &
-                  ((id & FIFO) != 0 ? base : top - 1)] : null;
+            int cap; ForkJoinTask<?>[] a;
+            return ((a = array) != null && (cap = a.length) > 0) ?
+                a[(cap - 1) & ((id & FIFO) != 0 ? base : top - 1)] : null;
         }
 
         /**
          * Pops the given task only if it is at the current top.
          */
         final boolean tryUnpush(ForkJoinTask<?> task) {
-            int b = base, s = top, al; ForkJoinTask<?>[] a;
-            if ((a = array) != null && b != s && (al = a.length) > 0) {
-                int index = (al - 1) & --s;
-                if (QA.compareAndSet(a, index, task, null)) {
+            boolean popped = false;
+            int s, cap; ForkJoinTask<?>[] a;
+            if ((a = array) != null && (cap = a.length) > 0 &&
+                (s = top) != base &&
+                (popped = QA.compareAndSet(a, (cap - 1) & --s, task, null)))
+                TOP.setOpaque(this, s);
+            return popped;
+        }
+
+        /**
+         * Shared version of tryUnpush.
+         */
+        final boolean tryLockedUnpush(ForkJoinTask<?> task) {
+            boolean popped = false;
+            int s = top - 1, k, cap; ForkJoinTask<?>[] a;
+            if ((a = array) != null && (cap = a.length) > 0 &&
+                a[k = (cap - 1) & s] == task && tryLockPhase()) {
+                if (top == s + 1 && array == a &&
+                    (popped = QA.compareAndSet(a, k, task, null)))
                     top = s;
-                    VarHandle.releaseFence();
-                    return true;
-                }
+                releasePhaseLock();
             }
-            return false;
+            return popped;
         }
 
         /**
@@ -933,58 +1009,29 @@
         // Specialized execution methods
 
         /**
-         * Pops and executes up to limit consecutive tasks or until empty.
-         *
-         * @param limit max runs, or zero for no limit
+         * Runs the given (stolen) task if nonnull, as well as
+         * remaining local tasks and others available from the given
+         * queue, up to bound n (to avoid infinite unfairness).
          */
-        final void localPopAndExec(int limit) {
-            for (;;) {
-                int b = base, s = top, al; ForkJoinTask<?>[] a;
-                if ((a = array) != null && b != s && (al = a.length) > 0) {
-                    int index = (al - 1) & --s;
-                    ForkJoinTask<?> t = (ForkJoinTask<?>)
-                        QA.getAndSet(a, index, null);
-                    if (t != null) {
-                        top = s;
-                        VarHandle.releaseFence();
-                        t.doExec();
-                        if (limit != 0 && --limit == 0)
+        final void topLevelExec(ForkJoinTask<?> t, WorkQueue q, int n) {
+            if (t != null && q != null) { // hoist checks
+                int nstolen = 1;
+                for (;;) {
+                    t.doExec();
+                    if (n-- < 0)
+                        break;
+                    else if ((t = nextLocalTask()) == null) {
+                        if ((t = q.poll()) == null)
                             break;
+                        else
+                            ++nstolen;
                     }
-                    else
-                        break;
                 }
-                else
-                    break;
-            }
-        }
-
-        /**
-         * Polls and executes up to limit consecutive tasks or until empty.
-         *
-         * @param limit, or zero for no limit
-         */
-        final void localPollAndExec(int limit) {
-            for (int polls = 0;;) {
-                int b = base, s = top, d, al; ForkJoinTask<?>[] a;
-                if ((a = array) != null && (d = b - s) < 0 &&
-                    (al = a.length) > 0) {
-                    int index = (al - 1) & b++;
-                    ForkJoinTask<?> t = (ForkJoinTask<?>)
-                        QA.getAndSet(a, index, null);
-                    if (t != null) {
-                        base = b;
-                        t.doExec();
-                        if (limit != 0 && ++polls == limit)
-                            break;
-                    }
-                    else if (d == -1)
-                        break;     // now empty
-                    else
-                        polls = 0; // stolen; reset
-                }
-                else
-                    break;
+                ForkJoinWorkerThread thread = owner;
+                nsteals += nstolen;
+                source = 0;
+                if (thread != null)
+                    thread.afterTopLevelExec();
             }
         }
 
@@ -992,25 +1039,24 @@
          * If present, removes task from queue and executes it.
          */
         final void tryRemoveAndExec(ForkJoinTask<?> task) {
-            ForkJoinTask<?>[] wa; int s, wal;
-            if (base - (s = top) < 0 && // traverse from top
-                (wa = array) != null && (wal = wa.length) > 0) {
-                for (int m = wal - 1, ns = s - 1, i = ns; ; --i) {
+            ForkJoinTask<?>[] a; int s, cap;
+            if ((a = array) != null && (cap = a.length) > 0 &&
+                (s = top) - base > 0) { // traverse from top
+                for (int m = cap - 1, ns = s - 1, i = ns; ; --i) {
                     int index = i & m;
-                    ForkJoinTask<?> t = (ForkJoinTask<?>)
-                        QA.get(wa, index);
+                    ForkJoinTask<?> t = (ForkJoinTask<?>)QA.get(a, index);
                     if (t == null)
                         break;
                     else if (t == task) {
-                        if (QA.compareAndSet(wa, index, t, null)) {
+                        if (QA.compareAndSet(a, index, t, null)) {
                             top = ns;   // safely shift down
                             for (int j = i; j != ns; ++j) {
                                 ForkJoinTask<?> f;
                                 int pindex = (j + 1) & m;
-                                f = (ForkJoinTask<?>)QA.get(wa, pindex);
-                                QA.setVolatile(wa, pindex, null);
+                                f = (ForkJoinTask<?>)QA.get(a, pindex);
+                                QA.setVolatile(a, pindex, null);
                                 int jindex = j & m;
-                                QA.setRelease(wa, jindex, f);
+                                QA.setRelease(a, jindex, f);
                             }
                             VarHandle.releaseFence();
                             t.doExec();
@@ -1022,43 +1068,52 @@
         }
 
         /**
-         * Tries to steal and run tasks within the target's
-         * computation until done, not found, or limit exceeded.
+         * Tries to pop and run tasks within the target's computation
+         * until done, not found, or limit exceeded.
          *
          * @param task root of CountedCompleter computation
          * @param limit max runs, or zero for no limit
+         * @param shared true if must lock to extract task
          * @return task status on exit
          */
-        final int localHelpCC(CountedCompleter<?> task, int limit) {
+        final int helpCC(CountedCompleter<?> task, int limit, boolean shared) {
             int status = 0;
             if (task != null && (status = task.status) >= 0) {
-                for (;;) {
-                    boolean help = false;
-                    int b = base, s = top, al; ForkJoinTask<?>[] a;
-                    if ((a = array) != null && b != s && (al = a.length) > 0) {
-                        int index = (al - 1) & (s - 1);
-                        ForkJoinTask<?> o = (ForkJoinTask<?>)
-                            QA.get(a, index);
-                        if (o instanceof CountedCompleter) {
-                            CountedCompleter<?> t = (CountedCompleter<?>)o;
-                            for (CountedCompleter<?> f = t;;) {
-                                if (f != task) {
-                                    if ((f = f.completer) == null) // try parent
-                                        break;
+                int s, k, cap; ForkJoinTask<?>[] a;
+                while ((a = array) != null && (cap = a.length) > 0 &&
+                       (s = top) - base > 0) {
+                    CountedCompleter<?> v = null;
+                    ForkJoinTask<?> o = a[k = (cap - 1) & (s - 1)];
+                    if (o instanceof CountedCompleter) {
+                        CountedCompleter<?> t = (CountedCompleter<?>)o;
+                        for (CountedCompleter<?> f = t;;) {
+                            if (f != task) {
+                                if ((f = f.completer) == null)
+                                    break;
+                            }
+                            else if (shared) {
+                                if (tryLockPhase()) {
+                                    if (top == s && array == a &&
+                                        QA.compareAndSet(a, k, t, null)) {
+                                        top = s - 1;
+                                        v = t;
+                                    }
+                                    releasePhaseLock();
                                 }
-                                else {
-                                    if (QA.compareAndSet(a, index, t, null)) {
-                                        top = s - 1;
-                                        VarHandle.releaseFence();
-                                        t.doExec();
-                                        help = true;
-                                    }
-                                    break;
+                                break;
+                            }
+                            else {
+                                if (QA.compareAndSet(a, k, t, null)) {
+                                    top = s - 1;
+                                    v = t;
                                 }
+                                break;
                             }
                         }
                     }
-                    if ((status = task.status) < 0 || !help ||
+                    if (v != null)
+                        v.doExec();
+                    if ((status = task.status) < 0 || v == null ||
                         (limit != 0 && --limit == 0))
                         break;
                 }
@@ -1066,79 +1121,31 @@
             return status;
         }
 
-        // Operations on shared queues
-
         /**
-         * Tries to lock shared queue by CASing phase field.
+         * Tries to poll and run AsynchronousCompletionTasks until
+         * none found or blocker is released
+         *
+         * @param blocker the blocker
          */
-        final boolean tryLockSharedQueue() {
-            return PHASE.compareAndSet(this, 0, QLOCK);
-        }
-
-        /**
-         * Shared version of tryUnpush.
-         */
-        final boolean trySharedUnpush(ForkJoinTask<?> task) {
-            boolean popped = false;
-            int s = top - 1, al; ForkJoinTask<?>[] a;
-            if ((a = array) != null && (al = a.length) > 0) {
-                int index = (al - 1) & s;
-                ForkJoinTask<?> t = (ForkJoinTask<?>) QA.get(a, index);
-                if (t == task &&
-                    PHASE.compareAndSet(this, 0, QLOCK)) {
-                    if (top == s + 1 && array == a &&
-                        QA.compareAndSet(a, index, task, null)) {
-                        popped = true;
-                        top = s;
+        final void helpAsyncBlocker(ManagedBlocker blocker) {
+            if (blocker != null) {
+                int b, k, cap; ForkJoinTask<?>[] a; ForkJoinTask<?> t;
+                while ((a = array) != null && (cap = a.length) > 0 &&
+                       top - (b = base) > 0) {
+                    t = (ForkJoinTask<?>)QA.getAcquire(a, k = (cap - 1) & b);
+                    if (blocker.isReleasable())
+                        break;
+                    else if (base == b++ && t != null) {
+                        if (!(t instanceof CompletableFuture.
+                              AsynchronousCompletionTask))
+                            break;
+                        else if (QA.compareAndSet(a, k, t, null)) {
+                            BASE.setOpaque(this, b);
+                            t.doExec();
+                        }
                     }
-                    PHASE.setRelease(this, 0);
                 }
             }
-            return popped;
-        }
-
-        /**
-         * Shared version of localHelpCC.
-         */
-        final int sharedHelpCC(CountedCompleter<?> task, int limit) {
-            int status = 0;
-            if (task != null && (status = task.status) >= 0) {
-                for (;;) {
-                    boolean help = false;
-                    int b = base, s = top, al; ForkJoinTask<?>[] a;
-                    if ((a = array) != null && b != s && (al = a.length) > 0) {
-                        int index = (al - 1) & (s - 1);
-                        ForkJoinTask<?> o = (ForkJoinTask<?>)
-                            QA.get(a, index);
-                        if (o instanceof CountedCompleter) {
-                            CountedCompleter<?> t = (CountedCompleter<?>)o;
-                            for (CountedCompleter<?> f = t;;) {
-                                if (f != task) {
-                                    if ((f = f.completer) == null)
-                                        break;
-                                }
-                                else {
-                                    if (PHASE.compareAndSet(this, 0, QLOCK)) {
-                                        if (top == s && array == a &&
-                                            QA.compareAndSet(a, index, t, null)) {
-                                            help = true;
-                                            top = s - 1;
-                                        }
-                                        PHASE.setRelease(this, 0);
-                                        if (help)
-                                            t.doExec();
-                                    }
-                                    break;
-                                }
-                            }
-                        }
-                    }
-                    if ((status = task.status) < 0 || !help ||
-                        (limit != 0 && --limit == 0))
-                        break;
-                }
-            }
-            return status;
         }
 
         /**
@@ -1153,13 +1160,17 @@
         }
 
         // VarHandle mechanics.
-        private static final VarHandle PHASE;
+        static final VarHandle PHASE;
+        static final VarHandle BASE;
+        static final VarHandle TOP;
         static {
             try {
                 MethodHandles.Lookup l = MethodHandles.lookup();
                 PHASE = l.findVarHandle(WorkQueue.class, "phase", int.class);
+                BASE = l.findVarHandle(WorkQueue.class, "base", int.class);
+                TOP = l.findVarHandle(WorkQueue.class, "top", int.class);
             } catch (ReflectiveOperationException e) {
-                throw new Error(e);
+                throw new ExceptionInInitializerError(e);
             }
         }
     }
@@ -1356,39 +1367,37 @@
         wt.setDaemon(true);                             // configure thread
         if ((handler = ueh) != null)
             wt.setUncaughtExceptionHandler(handler);
+        int tid = 0;                                    // for thread name
+        int idbits = mode & FIFO;
+        String prefix = workerNamePrefix;
         WorkQueue w = new WorkQueue(this, wt);
-        int tid = 0;                                    // for thread name
-        int fifo = mode & FIFO;
-        String prefix = workerNamePrefix;
         if (prefix != null) {
             synchronized (prefix) {
                 WorkQueue[] ws = workQueues; int n;
                 int s = indexSeed += SEED_INCREMENT;
+                idbits |= (s & ~(SMASK | FIFO | DORMANT));
                 if (ws != null && (n = ws.length) > 1) {
                     int m = n - 1;
-                    tid = s & m;
-                    int i = m & ((s << 1) | 1);         // odd-numbered indices
+                    tid = m & ((s << 1) | 1);           // odd-numbered indices
                     for (int probes = n >>> 1;;) {      // find empty slot
                         WorkQueue q;
-                        if ((q = ws[i]) == null || q.phase == QUIET)
+                        if ((q = ws[tid]) == null || q.phase == QUIET)
                             break;
                         else if (--probes == 0) {
-                            i = n | 1;                  // resize below
+                            tid = n | 1;                // resize below
                             break;
                         }
                         else
-                            i = (i + 2) & m;
+                            tid = (tid + 2) & m;
                     }
+                    w.phase = w.id = tid | idbits;      // now publishable
 
-                    int id = i | fifo | (s & ~(SMASK | FIFO | DORMANT));
-                    w.phase = w.id = id;                // now publishable
-
-                    if (i < n)
-                        ws[i] = w;
+                    if (tid < n)
+                        ws[tid] = w;
                     else {                              // expand array
                         int an = n << 1;
                         WorkQueue[] as = new WorkQueue[an];
-                        as[i] = w;
+                        as[tid] = w;
                         int am = an - 1;
                         for (int j = 0; j < n; ++j) {
                             WorkQueue v;                // copy external queue
@@ -1421,14 +1430,14 @@
         int phase = 0;
         if (wt != null && (w = wt.workQueue) != null) {
             Object lock = workerNamePrefix;
+            int wid = w.id;
             long ns = (long)w.nsteals & 0xffffffffL;
-            int idx = w.id & SMASK;
             if (lock != null) {
-                WorkQueue[] ws;                       // remove index from array
                 synchronized (lock) {
-                    if ((ws = workQueues) != null && ws.length > idx &&
-                        ws[idx] == w)
-                        ws[idx] = null;
+                    WorkQueue[] ws; int n, i;         // remove index from array
+                    if ((ws = workQueues) != null && (n = ws.length) > 0 &&
+                        ws[i = wid & (n - 1)] == w)
+                        ws[i] = null;
                     stealCount += ns;
                 }
             }
@@ -1480,7 +1489,7 @@
                 Thread vt = v.owner;
                 if (sp == vp && CTL.compareAndSet(this, c, nc)) {
                     v.phase = np;
-                    if (v.source < 0)
+                    if (vt != null && v.source < 0)
                         LockSupport.unpark(vt);
                     break;
                 }
@@ -1521,7 +1530,7 @@
                     long nc = ((long)v.stackPred & SP_MASK) | uc;
                     if (vp == sp && CTL.compareAndSet(this, c, nc)) {
                         v.phase = np;
-                        if (v.source < 0)
+                        if (vt != null && v.source < 0)
                             LockSupport.unpark(vt);
                         return (wp < 0) ? -1 : 1;
                     }
@@ -1578,101 +1587,88 @@
      * See above for explanation.
      */
     final void runWorker(WorkQueue w) {
-        WorkQueue[] ws;
-        w.growArray();                                  // allocate queue
-        int r = w.id ^ ThreadLocalRandom.nextSecondarySeed();
-        if (r == 0)                                     // initial nonzero seed
-            r = 1;
-        int lastSignalId = 0;                           // avoid unneeded signals
-        while ((ws = workQueues) != null) {
-            boolean nonempty = false;                   // scan
-            for (int n = ws.length, j = n, m = n - 1; j > 0; --j) {
-                WorkQueue q; int i, b, al; ForkJoinTask<?>[] a;
-                if ((i = r & m) >= 0 && i < n &&        // always true
-                    (q = ws[i]) != null && (b = q.base) - q.top < 0 &&
-                    (a = q.array) != null && (al = a.length) > 0) {
-                    int qid = q.id;                     // (never zero)
-                    int index = (al - 1) & b;
-                    ForkJoinTask<?> t = (ForkJoinTask<?>)
-                        QA.getAcquire(a, index);
-                    if (t != null && b++ == q.base &&
-                        QA.compareAndSet(a, index, t, null)) {
-                        if ((q.base = b) - q.top < 0 && qid != lastSignalId)
-                            signalWork();               // propagate signal
-                        w.source = lastSignalId = qid;
-                        t.doExec();
-                        if ((w.id & FIFO) != 0)         // run remaining locals
-                            w.localPollAndExec(POLL_LIMIT);
-                        else
-                            w.localPopAndExec(POLL_LIMIT);
-                        ForkJoinWorkerThread thread = w.owner;
-                        ++w.nsteals;
-                        w.source = 0;                   // now idle
-                        if (thread != null)
-                            thread.afterTopLevelExec();
-                    }
-                    nonempty = true;
-                }
-                else if (nonempty)
+        int r = (w.id ^ ThreadLocalRandom.nextSecondarySeed()) | FIFO; // rng
+        w.array = new ForkJoinTask<?>[INITIAL_QUEUE_CAPACITY]; // initialize
+        for (;;) {
+            int phase;
+            if (scan(w, r)) {                     // scan until apparently empty
+                r ^= r << 13; r ^= r >>> 17; r ^= r << 5; // move (xorshift)
+            }
+            else if ((phase = w.phase) >= 0) {    // enqueue, then rescan
+                long np = (w.phase = (phase + SS_SEQ) | UNSIGNALLED) & SP_MASK;
+                long c, nc;
+                do {
+                    w.stackPred = (int)(c = ctl);
+                    nc = ((c - RC_UNIT) & UC_MASK) | np;
+                } while (!CTL.weakCompareAndSet(this, c, nc));
+            }
+            else {                                // already queued
+                int pred = w.stackPred;
+                Thread.interrupted();             // clear before park
+                w.source = DORMANT;               // enable signal
+                long c = ctl;
+                int md = mode, rc = (md & SMASK) + (int)(c >> RC_SHIFT);
+                if (md < 0)                       // terminating
                     break;
-                else
-                    ++r;
-            }
-
-            if (nonempty) {                             // move (xorshift)
-                r ^= r << 13; r ^= r >>> 17; r ^= r << 5;
-            }
-            else {
-                int phase;
-                lastSignalId = 0;                       // clear for next scan
-                if ((phase = w.phase) >= 0) {           // enqueue
-                    int np = w.phase = (phase + SS_SEQ) | UNSIGNALLED;
-                    long c, nc;
-                    do {
-                        w.stackPred = (int)(c = ctl);
-                        nc = ((c - RC_UNIT) & UC_MASK) | (SP_MASK & np);
-                    } while (!CTL.weakCompareAndSet(this, c, nc));
-                }
-                else {                                  // already queued
-                    int pred = w.stackPred;
-                    w.source = DORMANT;                 // enable signal
-                    for (int steps = 0;;) {
-                        int md, rc; long c;
-                        if (w.phase >= 0) {
-                            w.source = 0;
-                            break;
-                        }
-                        else if ((md = mode) < 0)       // shutting down
-                            return;
-                        else if ((rc = ((md & SMASK) +  // possibly quiescent
-                                        (int)((c = ctl) >> RC_SHIFT))) <= 0 &&
-                                 (md & SHUTDOWN) != 0 &&
-                                 tryTerminate(false, false))
-                            return;                     // help terminate
-                        else if ((++steps & 1) == 0)
-                            Thread.interrupted();       // clear between parks
-                        else if (rc <= 0 && pred != 0 && phase == (int)c) {
-                            long d = keepAlive + System.currentTimeMillis();
-                            LockSupport.parkUntil(this, d);
-                            if (ctl == c &&
-                                d - System.currentTimeMillis() <= TIMEOUT_SLOP) {
-                                long nc = ((UC_MASK & (c - TC_UNIT)) |
-                                           (SP_MASK & pred));
-                                if (CTL.compareAndSet(this, c, nc)) {
-                                    w.phase = QUIET;
-                                    return;             // drop on timeout
-                                }
-                            }
-                        }
-                        else
-                            LockSupport.park(this);
+                else if (rc <= 0 && (md & SHUTDOWN) != 0 &&
+                         tryTerminate(false, false))
+                    break;                        // quiescent shutdown
+                else if (rc <= 0 && pred != 0 && phase == (int)c) {
+                    long nc = (UC_MASK & (c - TC_UNIT)) | (SP_MASK & pred);
+                    long d = keepAlive + System.currentTimeMillis();
+                    LockSupport.parkUntil(this, d);
+                    if (ctl == c &&               // drop on timeout if all idle
+                        d - System.currentTimeMillis() <= TIMEOUT_SLOP &&
+                        CTL.compareAndSet(this, c, nc)) {
+                        w.phase = QUIET;
+                        break;
                     }
                 }
+                else if (w.phase < 0)
+                    LockSupport.park(this);       // OK if spuriously woken
+                w.source = 0;                     // disable signal
             }
         }
     }
 
     /**
+     * Scans for and if found executes one or more top-level tasks from a queue.
+     *
+     * @return true if found an apparently non-empty queue, and
+     * possibly ran task(s).
+     */
+    private boolean scan(WorkQueue w, int r) {
+        WorkQueue[] ws; int n;
+        if ((ws = workQueues) != null && (n = ws.length) > 0 && w != null) {
+            for (int m = n - 1, j = r & m;;) {
+                WorkQueue q; int b;
+                if ((q = ws[j]) != null && q.top != (b = q.base)) {
+                    int qid = q.id;
+                    ForkJoinTask<?>[] a; int cap, k; ForkJoinTask<?> t;
+                    if ((a = q.array) != null && (cap = a.length) > 0) {
+                        t = (ForkJoinTask<?>)QA.getAcquire(a, k = (cap - 1) & b);
+                        if (q.base == b++ && t != null &&
+                            QA.compareAndSet(a, k, t, null)) {
+                            q.base = b;
+                            w.source = qid;
+                            if (q.top - b > 0)
+                                signalWork();
+                            w.topLevelExec(t, q,  // random fairness bound
+                                           r & ((n << TOP_BOUND_SHIFT) - 1));
+                        }
+                    }
+                    return true;
+                }
+                else if (--n > 0)
+                    j = (j + 1) & m;
+                else
+                    break;
+            }
+        }
+        return false;
+    }
+
+    /**
      * Helps and/or blocks until the given task is done or timeout.
      * First tries locally helping, then scans other queues for a task
      * produced by one of w's stealers; compensating and blocking if
@@ -1685,42 +1681,44 @@
      */
     final int awaitJoin(WorkQueue w, ForkJoinTask<?> task, long deadline) {
         int s = 0;
+        int seed = ThreadLocalRandom.nextSecondarySeed();
         if (w != null && task != null &&
             (!(task instanceof CountedCompleter) ||
-             (s = w.localHelpCC((CountedCompleter<?>)task, 0)) >= 0)) {
+             (s = w.helpCC((CountedCompleter<?>)task, 0, false)) >= 0)) {
             w.tryRemoveAndExec(task);
             int src = w.source, id = w.id;
+            int r = (seed >>> 16) | 1, step = (seed & ~1) | 2;
             s = task.status;
             while (s >= 0) {
                 WorkQueue[] ws;
-                boolean nonempty = false;
-                int r = ThreadLocalRandom.nextSecondarySeed() | 1; // odd indices
-                if ((ws = workQueues) != null) {       // scan for matching id
-                    for (int n = ws.length, m = n - 1, j = -n; j < n; j += 2) {
-                        WorkQueue q; int i, b, al; ForkJoinTask<?>[] a;
-                        if ((i = (r + j) & m) >= 0 && i < n &&
-                            (q = ws[i]) != null && q.source == id &&
-                            (b = q.base) - q.top < 0 &&
-                            (a = q.array) != null && (al = a.length) > 0) {
-                            int qid = q.id;
-                            int index = (al - 1) & b;
+                int n = (ws = workQueues) == null ? 0 : ws.length, m = n - 1;
+                while (n > 0) {
+                    WorkQueue q; int b;
+                    if ((q = ws[r & m]) != null && q.source == id &&
+                        q.top != (b = q.base)) {
+                        ForkJoinTask<?>[] a; int cap, k;
+                        int qid = q.id;
+                        if ((a = q.array) != null && (cap = a.length) > 0) {
                             ForkJoinTask<?> t = (ForkJoinTask<?>)
-                                QA.getAcquire(a, index);
-                            if (t != null && b++ == q.base && id == q.source &&
-                                QA.compareAndSet(a, index, t, null)) {
+                                QA.getAcquire(a, k = (cap - 1) & b);
+                            if (q.source == id && q.base == b++ &&
+                                t != null && QA.compareAndSet(a, k, t, null)) {
                                 q.base = b;
                                 w.source = qid;
                                 t.doExec();
                                 w.source = src;
                             }
-                            nonempty = true;
-                            break;
                         }
+                        break;
+                    }
+                    else {
+                        r += step;
+                        --n;
                     }
                 }
                 if ((s = task.status) < 0)
                     break;
-                else if (!nonempty) {
+                else if (n == 0) { // empty scan
                     long ms, ns; int block;
                     if (deadline == 0L)
                         ms = 0L;                       // untimed
@@ -1745,44 +1743,44 @@
      * find tasks either.
      */
     final void helpQuiescePool(WorkQueue w) {
-        int prevSrc = w.source, fifo = w.id & FIFO;
+        int prevSrc = w.source;
+        int seed = ThreadLocalRandom.nextSecondarySeed();
+        int r = seed >>> 16, step = r | 1;
         for (int source = prevSrc, released = -1;;) { // -1 until known
-            WorkQueue[] ws;
-            if (fifo != 0)
-                w.localPollAndExec(0);
-            else
-                w.localPopAndExec(0);
-            if (released == -1 && w.phase >= 0)
+            ForkJoinTask<?> localTask; WorkQueue[] ws;
+            while ((localTask = w.nextLocalTask()) != null)
+                localTask.doExec();
+            if (w.phase >= 0 && released == -1)
                 released = 1;
             boolean quiet = true, empty = true;
-            int r = ThreadLocalRandom.nextSecondarySeed();
-            if ((ws = workQueues) != null) {
-                for (int n = ws.length, j = n, m = n - 1; j > 0; --j) {
-                    WorkQueue q; int i, b, al; ForkJoinTask<?>[] a;
-                    if ((i = (r - j) & m) >= 0 && i < n && (q = ws[i]) != null) {
-                        if ((b = q.base) - q.top < 0 &&
-                            (a = q.array) != null && (al = a.length) > 0) {
-                            int qid = q.id;
+            int n = (ws = workQueues) == null ? 0 : ws.length;
+            for (int m = n - 1; n > 0; r += step, --n) {
+                WorkQueue q; int b;
+                if ((q = ws[r & m]) != null) {
+                    int qs = q.source;
+                    if (q.top != (b = q.base)) {
+                        quiet = empty = false;
+                        ForkJoinTask<?>[] a; int cap, k;
+                        int qid = q.id;
+                        if ((a = q.array) != null && (cap = a.length) > 0) {
                             if (released == 0) {    // increment
                                 released = 1;
                                 CTL.getAndAdd(this, RC_UNIT);
                             }
-                            int index = (al - 1) & b;
                             ForkJoinTask<?> t = (ForkJoinTask<?>)
-                                QA.getAcquire(a, index);
-                            if (t != null && b++ == q.base &&
-                                QA.compareAndSet(a, index, t, null)) {
+                                QA.getAcquire(a, k = (cap - 1) & b);
+                            if (q.base == b++ && t != null &&
+                                QA.compareAndSet(a, k, t, null)) {
                                 q.base = b;
-                                w.source = source = q.id;
+                                w.source = qid;
                                 t.doExec();
                                 w.source = source = prevSrc;
                             }
-                            quiet = empty = false;
-                            break;
                         }
-                        else if ((q.source & QUIET) == 0)
-                            quiet = false;
+                        break;
                     }
+                    else if ((qs & QUIET) == 0)
+                        quiet = false;
                 }
             }
             if (quiet) {
@@ -1824,28 +1822,24 @@
                 origin = r & m;
                 step = h | 1;
             }
-            for (int k = origin, oldSum = 0, checkSum = 0;;) {
-                WorkQueue q; int b, al; ForkJoinTask<?>[] a;
-                if ((q = ws[k]) != null) {
-                    checkSum += b = q.base;
-                    if (b - q.top < 0 &&
-                        (a = q.array) != null && (al = a.length) > 0) {
-                        int index = (al - 1) & b;
-                        ForkJoinTask<?> t = (ForkJoinTask<?>)
-                            QA.getAcquire(a, index);
-                        if (t != null && b++ == q.base &&
-                            QA.compareAndSet(a, index, t, null)) {
-                            q.base = b;
+            boolean nonempty = false;
+            for (int i = origin, oldSum = 0, checkSum = 0;;) {
+                WorkQueue q;
+                if ((q = ws[i]) != null) {
+                    int b; ForkJoinTask<?> t;
+                    if (q.top - (b = q.base) > 0) {
+                        nonempty = true;
+                        if ((t = q.poll()) != null)
                             return t;
-                        }
-                        else
-                            break; // restart
                     }
+                    else
+                        checkSum += b + q.id;
                 }
-                if ((k = (k + step) & m) == origin) {
-                    if (oldSum == (oldSum = checkSum))
+                if ((i = (i + step) & m) == origin) {
+                    if (!nonempty && oldSum == (oldSum = checkSum))
                         break rescan;
                     checkSum = 0;
+                    nonempty = false;
                 }
             }
         }
@@ -1859,11 +1853,9 @@
      */
     final ForkJoinTask<?> nextTaskFor(WorkQueue w) {
         ForkJoinTask<?> t;
-        if (w != null &&
-            (t = (w.id & FIFO) != 0 ? w.poll() : w.pop()) != null)
-            return t;
-        else
-            return pollScan(false);
+        if (w == null || (t = w.nextLocalTask()) == null)
+            t = pollScan(false);
+        return t;
     }
 
     // External operations
@@ -1881,64 +1873,35 @@
             r = ThreadLocalRandom.getProbe();
         }
         for (;;) {
+            WorkQueue q;
             int md = mode, n;
             WorkQueue[] ws = workQueues;
             if ((md & SHUTDOWN) != 0 || ws == null || (n = ws.length) <= 0)
                 throw new RejectedExecutionException();
-            else {
-                WorkQueue q;
-                boolean push = false, grow = false;
-                if ((q = ws[(n - 1) & r & SQMASK]) == null) {
-                    Object lock = workerNamePrefix;
-                    int qid = (r | QUIET) & ~(FIFO | OWNED);
-                    q = new WorkQueue(this, null);
-                    q.id = qid;
-                    q.source = QUIET;
-                    q.phase = QLOCK;          // lock queue
-                    if (lock != null) {
-                        synchronized (lock) { // lock pool to install
-                            int i;
-                            if ((ws = workQueues) != null &&
-                                (n = ws.length) > 0 &&
-                                ws[i = qid & (n - 1) & SQMASK] == null) {
-                                ws[i] = q;
-                                push = grow = true;
-                            }
-                        }
+            else if ((q = ws[(n - 1) & r & SQMASK]) == null) { // add queue
+                int qid = (r | QUIET) & ~(FIFO | OWNED);
+                Object lock = workerNamePrefix;
+                ForkJoinTask<?>[] qa =
+                    new ForkJoinTask<?>[INITIAL_QUEUE_CAPACITY];
+                q = new WorkQueue(this, null);
+                q.array = qa;
+                q.id = qid;
+                q.source = QUIET;
+                if (lock != null) {     // unless disabled, lock pool to install
+                    synchronized (lock) {
+                        WorkQueue[] vs; int i, vn;
+                        if ((vs = workQueues) != null && (vn = vs.length) > 0 &&
+                            vs[i = qid & (vn - 1) & SQMASK] == null)
+                            vs[i] = q;  // else another thread already installed
                     }
                 }
-                else if (q.tryLockSharedQueue()) {
-                    int b = q.base, s = q.top, al, d; ForkJoinTask<?>[] a;
-                    if ((a = q.array) != null && (al = a.length) > 0 &&
-                        al - 1 + (d = b - s) > 0) {
-                        a[(al - 1) & s] = task;
-                        q.top = s + 1;        // relaxed writes OK here
-                        q.phase = 0;
-                        if (d < 0 && q.base - s < -1)
-                            break;            // no signal needed
-                    }
-                    else
-                        grow = true;
-                    push = true;
-                }
-                if (push) {
-                    if (grow) {
-                        try {
-                            q.growArray();
-                            int s = q.top, al; ForkJoinTask<?>[] a;
-                            if ((a = q.array) != null && (al = a.length) > 0) {
-                                a[(al - 1) & s] = task;
-                                q.top = s + 1;
-                            }
-                        } finally {
-                            q.phase = 0;
-                        }
-                    }
+            }
+            else if (!q.tryLockPhase()) // move if busy
+                r = ThreadLocalRandom.advanceProbe(r);
+            else {
+                if (q.lockedPush(task))
                     signalWork();
-                    break;
-                }
-                else                          // move if busy
-                    r = ThreadLocalRandom.advanceProbe(r);
+                return;
             }
         }
     }
@@ -1980,7 +1943,7 @@
         return ((ws = workQueues) != null &&
                 (n = ws.length) > 0 &&
                 (w = ws[(n - 1) & r & SQMASK]) != null &&
-                w.trySharedUnpush(task));
+                w.tryLockedUnpush(task));
     }
 
     /**
@@ -1991,7 +1954,7 @@
         WorkQueue[] ws; WorkQueue w; int n;
         return ((ws = workQueues) != null && (n = ws.length) > 0 &&
                 (w = ws[(n - 1) & r & SQMASK]) != null) ?
-            w.sharedHelpCC(task, maxTasks) : 0;
+            w.helpCC(task, maxTasks, true) : 0;
     }
 
     /**
@@ -2006,7 +1969,7 @@
      */
     final int helpComplete(WorkQueue w, CountedCompleter<?> task,
                            int maxTasks) {
-        return (w == null) ? 0 : w.localHelpCC(task, maxTasks);
+        return (w == null) ? 0 : w.helpCC(task, maxTasks, false);
     }
 
     /**
@@ -2097,15 +2060,18 @@
                     if ((md & SMASK) + (int)(checkSum >> RC_SHIFT) > 0)
                         running = true;
                     else if (ws != null) {
-                        WorkQueue w; int b;
+                        WorkQueue w;
                         for (int i = 0; i < ws.length; ++i) {
                             if ((w = ws[i]) != null) {
-                                checkSum += (b = w.base) + w.id;
+                                int s = w.source, p = w.phase;
+                                int d = w.id, b = w.base;
                                 if (b != w.top ||
-                                    ((i & 1) == 1 && w.source >= 0)) {
+                                    ((d & 1) == 1 && (s >= 0 || p >= 0))) {
                                     running = true;
-                                    break;
+                                    break;     // working, scanning, or have work
                                 }
+                                checkSum += (((long)s << 48) + ((long)p << 32) +
+                                             ((long)b << 16) + (long)d);
                             }
                         }
                     }
@@ -2136,7 +2102,7 @@
                                 } catch (Throwable ignore) {
                                 }
                             }
-                            checkSum += w.base + w.id;
+                            checkSum += ((long)w.phase << 32) + w.base;
                         }
                     }
                 }
@@ -2629,8 +2595,9 @@
      * @return the number of worker threads
      */
     public int getRunningThreadCount() {
+        WorkQueue[] ws; WorkQueue w;
+        VarHandle.acquireFence();
         int rc = 0;
-        WorkQueue[] ws; WorkQueue w;
         if ((ws = workQueues) != null) {
             for (int i = 1; i < ws.length; i += 2) {
                 if ((w = ws[i]) != null && w.isApparentlyUnblocked())
@@ -2678,7 +2645,7 @@
                 if ((ws = workQueues) != null) {
                     for (int i = 1; i < ws.length; i += 2) {
                         if ((v = ws[i]) != null) {
-                            if ((v.source & QUIET) == 0)
+                            if (v.source > 0)
                                 return false;
                             --tc;
                         }
@@ -2724,8 +2691,9 @@
      * @return the number of queued tasks
      */
     public long getQueuedTaskCount() {
-        long count = 0;
         WorkQueue[] ws; WorkQueue w;
+        VarHandle.acquireFence();
+        int count = 0;
         if ((ws = workQueues) != null) {
             for (int i = 1; i < ws.length; i += 2) {
                 if ((w = ws[i]) != null)
@@ -2743,8 +2711,9 @@
      * @return the number of queued submissions
      */
     public int getQueuedSubmissionCount() {
+        WorkQueue[] ws; WorkQueue w;
+        VarHandle.acquireFence();
         int count = 0;
-        WorkQueue[] ws; WorkQueue w;
         if ((ws = workQueues) != null) {
             for (int i = 0; i < ws.length; i += 2) {
                 if ((w = ws[i]) != null)
@@ -2762,6 +2731,7 @@
      */
     public boolean hasQueuedSubmissions() {
         WorkQueue[] ws; WorkQueue w;
+        VarHandle.acquireFence();
         if ((ws = workQueues) != null) {
             for (int i = 0; i < ws.length; i += 2) {
                 if ((w = ws[i]) != null && !w.isEmpty())
@@ -2800,8 +2770,9 @@
      * @return the number of elements transferred
      */
     protected int drainTasksTo(Collection<? super ForkJoinTask<?>> c) {
+        WorkQueue[] ws; WorkQueue w; ForkJoinTask<?> t;
+        VarHandle.acquireFence();
         int count = 0;
-        WorkQueue[] ws; WorkQueue w; ForkJoinTask<?> t;
         if ((ws = workQueues) != null) {
             for (int i = 0; i < ws.length; ++i) {
                 if ((w = ws[i]) != null) {
@@ -2824,8 +2795,10 @@
      */
     public String toString() {
         // Use a single pass through workQueues to collect counts
+        int md = mode; // read volatile fields first
+        long c = ctl;
+        long st = stealCount;
         long qt = 0L, qs = 0L; int rc = 0;
-        long st = stealCount;
         WorkQueue[] ws; WorkQueue w;
         if ((ws = workQueues) != null) {
             for (int i = 0; i < ws.length; ++i) {
@@ -2843,9 +2816,7 @@
             }
         }
 
-        int md = mode;
         int pc = (md & SMASK);
-        long c = ctl;
         int tc = pc + (short)(c >>> TC_SHIFT);
         int ac = pc + (int)(c >> RC_SHIFT);
         if (ac < 0) // ignore transient negative
@@ -3131,6 +3102,7 @@
      */
     public static void managedBlock(ManagedBlocker blocker)
         throws InterruptedException {
+        if (blocker == null) throw new NullPointerException();
         ForkJoinPool p;
         ForkJoinWorkerThread wt;
         WorkQueue w;
@@ -3163,7 +3135,7 @@
      * available or blocker is released.
      */
     static void helpAsyncBlocker(Executor e, ManagedBlocker blocker) {
-        if (blocker != null && (e instanceof ForkJoinPool)) {
+        if (e instanceof ForkJoinPool) {
             WorkQueue w; ForkJoinWorkerThread wt; WorkQueue[] ws; int r, n;
             ForkJoinPool p = (ForkJoinPool)e;
             Thread thread = Thread.currentThread();
@@ -3175,34 +3147,8 @@
                 w = ws[(n - 1) & r & SQMASK];
             else
                 w = null;
-            if (w != null) {
-                for (;;) {
-                    int b = w.base, s = w.top, d, al; ForkJoinTask<?>[] a;
-                    if ((a = w.array) != null && (d = b - s) < 0 &&
-                        (al = a.length) > 0) {
-                        int index = (al - 1) & b;
-                        ForkJoinTask<?> t = (ForkJoinTask<?>)
-                            QA.getAcquire(a, index);
-                        if (blocker.isReleasable())
-                            break;
-                        else if (b++ == w.base) {
-                            if (t == null) {
-                                if (d == -1)
-                                    break;
-                            }
-                            else if (!(t instanceof CompletableFuture.
-                                  AsynchronousCompletionTask))
-                                break;
-                            else if (QA.compareAndSet(a, index, t, null)) {
-                                w.base = b;
-                                t.doExec();
-                            }
-                        }
-                    }
-                    else
-                        break;
-                }
-            }
+            if (w != null)
+                w.helpAsyncBlocker(blocker);
         }
     }
 
@@ -3221,7 +3167,7 @@
     // VarHandle mechanics
     private static final VarHandle CTL;
     private static final VarHandle MODE;
-    private static final VarHandle QA;
+    static final VarHandle QA;
 
     static {
         try {
@@ -3230,7 +3176,7 @@
             MODE = l.findVarHandle(ForkJoinPool.class, "mode", int.class);
             QA = MethodHandles.arrayElementVarHandle(ForkJoinTask[].class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
 
         // Reduce the risk of rare disastrous classloading in first call to
--- a/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1540,7 +1540,7 @@
             MethodHandles.Lookup l = MethodHandles.lookup();
             STATUS = l.findVarHandle(ForkJoinTask.class, "status", int.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 
--- a/src/java.base/share/classes/java/util/concurrent/FutureTask.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/FutureTask.java	Fri Apr 13 14:55:11 2018 -0400
@@ -526,7 +526,7 @@
             RUNNER = l.findVarHandle(FutureTask.class, "runner", Thread.class);
             WAITERS = l.findVarHandle(FutureTask.class, "waiters", WaitNode.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
 
         // Reduce the risk of rare disastrous classloading in first call to
--- a/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1739,7 +1739,7 @@
             NEXT = l.findVarHandle(Node.class, "next", Node.class);
             WAITER = l.findVarHandle(Node.class, "waiter", Thread.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
 
         // Reduce the risk of rare disastrous classloading in first call to
--- a/src/java.base/share/classes/java/util/concurrent/Phaser.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/Phaser.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1137,7 +1137,7 @@
             MethodHandles.Lookup l = MethodHandles.lookup();
             STATE = l.findVarHandle(Phaser.class, "state", long.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
 
         // Reduce the risk of rare disastrous classloading in first call to
--- a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1014,7 +1014,7 @@
                                                  "allocationSpinLock",
                                                  int.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 }
--- a/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1096,7 +1096,7 @@
             if (cap > 0) {
                 boolean added;
                 if (n >= cap && cap < maxCapacity) // resize
-                    added = growAndoffer(item, a, t);
+                    added = growAndOffer(item, a, t);
                 else if (n >= cap || unowned)      // need volatile CAS
                     added = QA.compareAndSet(a, i, null, item);
                 else {                             // can use release mode
@@ -1115,7 +1115,7 @@
          * Tries to expand buffer and add item, returning true on
          * success. Currently fails only if out of memory.
          */
-        final boolean growAndoffer(T item, Object[] a, int t) {
+        final boolean growAndOffer(T item, Object[] a, int t) {
             int cap = 0, newCap = 0;
             Object[] newArray = null;
             if (a != null && (cap = a.length) > 0 && (newCap = cap << 1) > 0) {
@@ -1466,7 +1466,7 @@
                                          long.class);
                 QA = MethodHandles.arrayElementVarHandle(Object[].class);
             } catch (ReflectiveOperationException e) {
-                throw new Error(e);
+                throw new ExceptionInInitializerError(e);
             }
 
             // Reduce the risk of rare disastrous classloading in first call to
--- a/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java	Fri Apr 13 14:55:11 2018 -0400
@@ -293,7 +293,7 @@
                     SMATCH = l.findVarHandle(SNode.class, "match", SNode.class);
                     SNEXT = l.findVarHandle(SNode.class, "next", SNode.class);
                 } catch (ReflectiveOperationException e) {
-                    throw new Error(e);
+                    throw new ExceptionInInitializerError(e);
                 }
             }
         }
@@ -516,7 +516,7 @@
                 MethodHandles.Lookup l = MethodHandles.lookup();
                 SHEAD = l.findVarHandle(TransferStack.class, "head", SNode.class);
             } catch (ReflectiveOperationException e) {
-                throw new Error(e);
+                throw new ExceptionInInitializerError(e);
             }
         }
     }
@@ -583,7 +583,7 @@
                     QITEM = l.findVarHandle(QNode.class, "item", Object.class);
                     QNEXT = l.findVarHandle(QNode.class, "next", QNode.class);
                 } catch (ReflectiveOperationException e) {
-                    throw new Error(e);
+                    throw new ExceptionInInitializerError(e);
                 }
             }
         }
@@ -830,7 +830,7 @@
                 QCLEANME = l.findVarHandle(TransferQueue.class, "cleanMe",
                                            QNode.class);
             } catch (ReflectiveOperationException e) {
-                throw new Error(e);
+                throw new ExceptionInInitializerError(e);
             }
         }
     }
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java	Fri Apr 13 14:55:11 2018 -0400
@@ -56,7 +56,7 @@
             MethodHandles.Lookup l = MethodHandles.lookup();
             VALUE = l.findVarHandle(AtomicBoolean.class, "value", int.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java	Fri Apr 13 14:55:11 2018 -0400
@@ -199,7 +199,7 @@
             PAIR = l.findVarHandle(AtomicMarkableReference.class, "pair",
                                    Pair.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java	Fri Apr 13 14:55:11 2018 -0400
@@ -56,7 +56,7 @@
             MethodHandles.Lookup l = MethodHandles.lookup();
             VALUE = l.findVarHandle(AtomicReference.class, "value", Object.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java	Fri Apr 13 14:55:11 2018 -0400
@@ -199,7 +199,7 @@
             PAIR = l.findVarHandle(AtomicStampedReference.class, "pair",
                                    Pair.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 
--- a/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java	Fri Apr 13 14:55:11 2018 -0400
@@ -144,7 +144,7 @@
                 MethodHandles.Lookup l = MethodHandles.lookup();
                 VALUE = l.findVarHandle(Cell.class, "value", long.class);
             } catch (ReflectiveOperationException e) {
-                throw new Error(e);
+                throw new ExceptionInInitializerError(e);
             }
         }
     }
@@ -396,13 +396,13 @@
                             try {
                                 return MethodHandles.privateLookupIn(Thread.class, MethodHandles.lookup());
                             } catch (ReflectiveOperationException e) {
-                                throw new Error(e);
+                                throw new ExceptionInInitializerError(e);
                             }
                         }});
             THREAD_PROBE = l.findVarHandle(Thread.class,
                     "threadLocalRandomProbe", int.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 
--- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1830,7 +1830,7 @@
             HEAD = l.findVarHandle(AbstractQueuedLongSynchronizer.class, "head", Node.class);
             TAIL = l.findVarHandle(AbstractQueuedLongSynchronizer.class, "tail", Node.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
 
         // Reduce the risk of rare disastrous classloading in first call to
--- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java	Fri Apr 13 14:55:11 2018 -0400
@@ -555,7 +555,7 @@
                 THREAD = l.findVarHandle(Node.class, "thread", Thread.class);
                 WAITSTATUS = l.findVarHandle(Node.class, "waitStatus", int.class);
             } catch (ReflectiveOperationException e) {
-                throw new Error(e);
+                throw new ExceptionInInitializerError(e);
             }
         }
     }
@@ -2308,7 +2308,7 @@
             HEAD = l.findVarHandle(AbstractQueuedSynchronizer.class, "head", Node.class);
             TAIL = l.findVarHandle(AbstractQueuedSynchronizer.class, "tail", Node.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
 
         // Reduce the risk of rare disastrous classloading in first call to
--- a/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1614,7 +1614,7 @@
             WNEXT = l.findVarHandle(WNode.class, "next", WNode.class);
             WCOWAIT = l.findVarHandle(WNode.class, "cowait", WNode.class);
         } catch (ReflectiveOperationException e) {
-            throw new Error(e);
+            throw new ExceptionInInitializerError(e);
         }
     }
 }
--- a/src/java.base/solaris/native/libjsig/jsig.c	Tue Apr 10 18:56:07 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,278 +0,0 @@
-/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-/* CopyrightVersion 1.2 */
-
-/* This is a special library that should be loaded before libc &
- * libthread to interpose the signal handler installation functions:
- * sigaction(), signal(), sigset().
- * Used for signal-chaining. See RFE 4381843.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
-#include <dlfcn.h>
-#include <thread.h>
-#include <synch.h>
-#include "jni.h"
-#include "jvm_md.h"
-
-#define bool int
-#define true 1
-#define false 0
-
-static struct sigaction *sact = (struct sigaction *)NULL; /* saved signal handlers */
-static sigset_t jvmsigs;
-
-/* used to synchronize the installation of signal handlers */
-static mutex_t mutex = DEFAULTMUTEX;
-static cond_t cond = DEFAULTCV;
-static thread_t tid = 0;
-
-typedef void (*sa_handler_t)(int);
-typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
-typedef sa_handler_t (*signal_t)(int, sa_handler_t);
-typedef int (*sigaction_t)(int, const struct sigaction *, struct sigaction *);
-
-static signal_t os_signal = 0; /* os's version of signal()/sigset() */
-static sigaction_t os_sigaction = 0; /* os's version of sigaction() */
-
-static bool jvm_signal_installing = false;
-static bool jvm_signal_installed = false;
-
-
-/* assume called within signal_lock */
-static void allocate_sact() {
-  size_t maxsignum;
-  maxsignum = SIGRTMAX;
-  if (sact == NULL) {
-    sact = (struct sigaction *)malloc((maxsignum+1) * (size_t)sizeof(struct sigaction));
-    memset(sact, 0, (maxsignum+1) * (size_t)sizeof(struct sigaction));
-  }
-
-  if (sact == NULL) {
-    printf("%s\n", "libjsig.so unable to allocate memory");
-    exit(0);
-  }
-
-  sigemptyset(&jvmsigs);
-}
-
-static void signal_lock() {
-  mutex_lock(&mutex);
-  /* When the jvm is installing its set of signal handlers, threads
-   * other than the jvm thread should wait */
-  if (jvm_signal_installing) {
-    if (tid != thr_self()) {
-      cond_wait(&cond, &mutex);
-    }
-  }
-}
-
-static void signal_unlock() {
-  mutex_unlock(&mutex);
-}
-
-static sa_handler_t call_os_signal(int sig, sa_handler_t disp,
-                                   bool is_sigset) {
-  if (os_signal == NULL) {
-    if (!is_sigset) {
-      os_signal = (signal_t)dlsym(RTLD_NEXT, "signal");
-    } else {
-      os_signal = (signal_t)dlsym(RTLD_NEXT, "sigset");
-    }
-    if (os_signal == NULL) {
-      printf("%s\n", dlerror());
-      exit(0);
-    }
-  }
-  return (*os_signal)(sig, disp);
-}
-
-static void save_signal_handler(int sig, sa_handler_t disp, bool is_sigset) {
-  sigset_t set;
-  if (sact == NULL) {
-    allocate_sact();
-  }
-  sact[sig].sa_handler = disp;
-  sigemptyset(&set);
-  sact[sig].sa_mask = set;
-  if (!is_sigset) {
-    sact[sig].sa_flags = SA_NODEFER;
-    if (sig != SIGILL && sig != SIGTRAP && sig != SIGPWR) {
-      sact[sig].sa_flags |= SA_RESETHAND;
-    }
-  } else {
-    sact[sig].sa_flags = 0;
-  }
-}
-
-static sa_handler_t set_signal(int sig, sa_handler_t disp, bool is_sigset) {
-  sa_handler_t oldhandler;
-  bool sigblocked;
-
-  signal_lock();
-  if (sact == NULL) {
-    allocate_sact();
-  }
-
-  if (jvm_signal_installed && sigismember(&jvmsigs, sig)) {
-    /* jvm has installed its signal handler for this signal. */
-    /* Save the handler. Don't really install it. */
-    if (is_sigset) {
-      /* We won't honor the SIG_HOLD request to change the signal mask */
-      sigblocked = sigismember(&(sact[sig].sa_mask), sig);
-    }
-    oldhandler = sact[sig].sa_handler;
-    save_signal_handler(sig, disp, is_sigset);
-
-    if (is_sigset && sigblocked) {
-      oldhandler = SIG_HOLD;
-    }
-
-    signal_unlock();
-    return oldhandler;
-  } else if (jvm_signal_installing) {
-    /* jvm is installing its signal handlers. Install the new
-     * handlers and save the old ones. jvm uses sigaction().
-     * Leave the piece here just in case. */
-    oldhandler = call_os_signal(sig, disp, is_sigset);
-    save_signal_handler(sig, oldhandler, is_sigset);
-
-    /* Record the signals used by jvm */
-    sigaddset(&jvmsigs, sig);
-
-    signal_unlock();
-    return oldhandler;
-  } else {
-    /* jvm has no relation with this signal (yet). Install the
-     * the handler. */
-    oldhandler = call_os_signal(sig, disp, is_sigset);
-
-    signal_unlock();
-    return oldhandler;
-  }
-}
-
-sa_handler_t signal(int sig, sa_handler_t disp) {
-  return set_signal(sig, disp, false);
-}
-
-sa_handler_t sigset(int sig, sa_handler_t disp) {
-  return set_signal(sig, disp, true);
-}
-
-static int call_os_sigaction(int sig, const struct sigaction  *act,
-                             struct sigaction *oact) {
-  if (os_sigaction == NULL) {
-    os_sigaction = (sigaction_t)dlsym(RTLD_NEXT, "sigaction");
-    if (os_sigaction == NULL) {
-      printf("%s\n", dlerror());
-      exit(0);
-    }
-  }
-  return (*os_sigaction)(sig, act, oact);
-}
-
-int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) {
-  int res;
-  struct sigaction oldAct;
-
-  signal_lock();
-
-  if (sact == NULL ) {
-    allocate_sact();
-  }
-  if (jvm_signal_installed && sigismember(&jvmsigs, sig)) {
-    /* jvm has installed its signal handler for this signal. */
-    /* Save the handler. Don't really install it. */
-    if (oact != NULL) {
-      *oact = sact[sig];
-    }
-    if (act != NULL) {
-      sact[sig] = *act;
-    }
-
-    signal_unlock();
-    return 0;
-  } else if (jvm_signal_installing) {
-    /* jvm is installing its signal handlers. Install the new
-     * handlers and save the old ones. */
-    res = call_os_sigaction(sig, act, &oldAct);
-    sact[sig] = oldAct;
-    if (oact != NULL) {
-      *oact = oldAct;
-    }
-
-    /* Record the signals used by jvm */
-    sigaddset(&jvmsigs, sig);
-
-    signal_unlock();
-    return res;
-  } else {
-    /* jvm has no relation with this signal (yet). Install the
-     * the handler. */
-    res = call_os_sigaction(sig, act, oact);
-
-    signal_unlock();
-    return res;
-  }
-}
-
-/* The four functions for the jvm to call into */
-JNIEXPORT void JNICALL
-JVM_begin_signal_setting() {
-  signal_lock();
-  jvm_signal_installing = true;
-  tid = thr_self();
-  signal_unlock();
-}
-
-JNIEXPORT void JNICALL
-JVM_end_signal_setting() {
-  signal_lock();
-  jvm_signal_installed = true;
-  jvm_signal_installing = false;
-  cond_broadcast(&cond);
-  signal_unlock();
-}
-
-JNIEXPORT struct sigaction * JNICALL
-JVM_get_signal_action(int sig) {
-  if (sact == NULL) {
-    allocate_sact();
-  }
-  /* Does race condition make sense here? */
-  if (sigismember(&jvmsigs, sig)) {
-    return &sact[sig];
-  }
-  return NULL;
-}
-
-JNIEXPORT int JNICALL
-JVM_get_libjsig_version() {
-  return JSIG_VERSION_1_4_1;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/unix/native/libjsig/jsig.c	Fri Apr 13 14:55:11 2018 -0400
@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/* This is a special library that should be loaded before libc &
+ * libthread to interpose the signal handler installation functions:
+ * sigaction(), signal(), sigset().
+ * Used for signal-chaining. See RFE 4381843.
+ */
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if (__STDC_VERSION__ >= 199901L)
+  #include <stdbool.h>
+#else
+  #define bool int
+  #define true 1
+  #define false 0
+#endif
+
+#ifdef SOLARIS
+#define MAX_SIGNALS (SIGRTMAX+1)
+
+/* On solaris, MAX_SIGNALS is a macro, not a constant, so we must allocate sact dynamically. */
+static struct sigaction *sact = (struct sigaction *)NULL; /* saved signal handlers */
+#else
+#define MAX_SIGNALS NSIG
+
+static struct sigaction sact[MAX_SIGNALS]; /* saved signal handlers */
+#endif
+
+static sigset_t jvmsigs; /* Signals used by jvm. */
+
+#ifdef MACOSX
+static __thread bool reentry = false; /* prevent reentry deadlock (per-thread) */
+#endif
+
+/* Used to synchronize the installation of signal handlers. */
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_t tid = 0;
+
+typedef void (*sa_handler_t)(int);
+typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
+typedef sa_handler_t (*signal_function_t)(int, sa_handler_t);
+typedef int (*sigaction_t)(int, const struct sigaction *, struct sigaction *);
+
+static signal_function_t os_signal = 0; /* os's version of signal()/sigset() */
+static sigaction_t os_sigaction = 0; /* os's version of sigaction() */
+
+static bool jvm_signal_installing = false;
+static bool jvm_signal_installed = false;
+
+
+/* assume called within signal_lock */
+static void allocate_sact() {
+#ifdef SOLARIS
+  if (sact == NULL) {
+    sact = (struct sigaction *)malloc((MAX_SIGNALS) * (size_t)sizeof(struct sigaction));
+    if (sact == NULL) {
+      printf("%s\n", "libjsig.so unable to allocate memory");
+      exit(0);
+    }
+    memset(sact, 0, (MAX_SIGNALS) * (size_t)sizeof(struct sigaction));
+  }
+#endif
+}
+
+static void signal_lock() {
+  pthread_mutex_lock(&mutex);
+  /* When the jvm is installing its set of signal handlers, threads
+   * other than the jvm thread should wait. */
+  if (jvm_signal_installing) {
+    if (tid != pthread_self()) {
+      pthread_cond_wait(&cond, &mutex);
+    }
+  }
+}
+
+static void signal_unlock() {
+  pthread_mutex_unlock(&mutex);
+}
+
+static sa_handler_t call_os_signal(int sig, sa_handler_t disp,
+                                   bool is_sigset) {
+  sa_handler_t res;
+
+  if (os_signal == NULL) {
+    if (!is_sigset) {
+      os_signal = (signal_function_t)dlsym(RTLD_NEXT, "signal");
+    } else {
+      os_signal = (signal_function_t)dlsym(RTLD_NEXT, "sigset");
+    }
+    if (os_signal == NULL) {
+      printf("%s\n", dlerror());
+      exit(0);
+    }
+  }
+
+#ifdef MACOSX
+  /* On macosx, the OS implementation of signal calls sigaction.
+   * Make sure we do not deadlock with ourself. (See JDK-8072147). */
+  reentry = true;
+#endif
+
+  res = (*os_signal)(sig, disp);
+
+#ifdef MACOSX
+  reentry = false;
+#endif
+
+  return res;
+}
+
+static void save_signal_handler(int sig, sa_handler_t disp, bool is_sigset) {
+  sigset_t set;
+
+  sact[sig].sa_handler = disp;
+  sigemptyset(&set);
+  sact[sig].sa_mask = set;
+  if (!is_sigset) {
+#ifdef SOLARIS
+    sact[sig].sa_flags = SA_NODEFER;
+    if (sig != SIGILL && sig != SIGTRAP && sig != SIGPWR) {
+      sact[sig].sa_flags |= SA_RESETHAND;
+    }
+#else
+    sact[sig].sa_flags = 0;
+#endif
+  } else {
+    sact[sig].sa_flags = 0;
+  }
+}
+
+static sa_handler_t set_signal(int sig, sa_handler_t disp, bool is_sigset) {
+  sa_handler_t oldhandler;
+  bool sigused;
+  bool sigblocked;
+
+  signal_lock();
+  allocate_sact();
+
+  sigused = sigismember(&jvmsigs, sig);
+  if (jvm_signal_installed && sigused) {
+    /* jvm has installed its signal handler for this signal. */
+    /* Save the handler. Don't really install it. */
+    if (is_sigset) {
+      sigblocked = sigismember(&(sact[sig].sa_mask), sig);
+    }
+    oldhandler = sact[sig].sa_handler;
+    save_signal_handler(sig, disp, is_sigset);
+
+#ifdef SOLARIS
+    if (is_sigset && sigblocked) {
+      /* We won't honor the SIG_HOLD request to change the signal mask */
+      oldhandler = SIG_HOLD;
+    }
+#endif
+
+    signal_unlock();
+    return oldhandler;
+  } else if (jvm_signal_installing) {
+    /* jvm is installing its signal handlers. Install the new
+     * handlers and save the old ones. jvm uses sigaction().
+     * Leave the piece here just in case. */
+    oldhandler = call_os_signal(sig, disp, is_sigset);
+    save_signal_handler(sig, oldhandler, is_sigset);
+
+    /* Record the signals used by jvm */
+    sigaddset(&jvmsigs, sig);
+
+    signal_unlock();
+    return oldhandler;
+  } else {
+    /* jvm has no relation with this signal (yet). Install the
+     * the handler. */
+    oldhandler = call_os_signal(sig, disp, is_sigset);
+
+    signal_unlock();
+    return oldhandler;
+  }
+}
+
+sa_handler_t signal(int sig, sa_handler_t disp) {
+  if (sig < 0 || sig >= MAX_SIGNALS) {
+    errno = EINVAL;
+    return SIG_ERR;
+  }
+
+  return set_signal(sig, disp, false);
+}
+
+sa_handler_t sigset(int sig, sa_handler_t disp) {
+#ifdef _ALLBSD_SOURCE
+  printf("sigset() is not supported by BSD");
+  exit(0);
+#else
+  if (sig < 0 || sig >= MAX_SIGNALS) {
+    errno = EINVAL;
+    return (sa_handler_t)-1;
+  }
+
+  return set_signal(sig, disp, true);
+#endif
+}
+
+static int call_os_sigaction(int sig, const struct sigaction  *act,
+                             struct sigaction *oact) {
+  if (os_sigaction == NULL) {
+    os_sigaction = (sigaction_t)dlsym(RTLD_NEXT, "sigaction");
+    if (os_sigaction == NULL) {
+      printf("%s\n", dlerror());
+      exit(0);
+    }
+  }
+  return (*os_sigaction)(sig, act, oact);
+}
+
+int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) {
+  int res;
+  bool sigused;
+  struct sigaction oldAct;
+
+  if (sig < 0 || sig >= MAX_SIGNALS) {
+    errno = EINVAL;
+    return -1;
+  }
+
+#ifdef MACOSX
+  if (reentry) {
+    return call_os_sigaction(sig, act, oact);
+  }
+#endif
+
+  signal_lock();
+
+  allocate_sact();
+  sigused = sigismember(&jvmsigs, sig);
+  if (jvm_signal_installed && sigused) {
+    /* jvm has installed its signal handler for this signal. */
+    /* Save the handler. Don't really install it. */
+    if (oact != NULL) {
+      *oact = sact[sig];
+    }
+    if (act != NULL) {
+      sact[sig] = *act;
+    }
+
+    signal_unlock();
+    return 0;
+  } else if (jvm_signal_installing) {
+    /* jvm is installing its signal handlers. Install the new
+     * handlers and save the old ones. */
+    res = call_os_sigaction(sig, act, &oldAct);
+    sact[sig] = oldAct;
+    if (oact != NULL) {
+      *oact = oldAct;
+    }
+
+    /* Record the signals used by jvm. */
+    sigaddset(&jvmsigs, sig);
+
+    signal_unlock();
+    return res;
+  } else {
+    /* jvm has no relation with this signal (yet). Install the
+     * the handler. */
+    res = call_os_sigaction(sig, act, oact);
+
+    signal_unlock();
+    return res;
+  }
+}
+
+/* The three functions for the jvm to call into. */
+void JVM_begin_signal_setting() {
+  signal_lock();
+  sigemptyset(&jvmsigs);
+  jvm_signal_installing = true;
+  tid = pthread_self();
+  signal_unlock();
+}
+
+void JVM_end_signal_setting() {
+  signal_lock();
+  jvm_signal_installed = true;
+  jvm_signal_installing = false;
+  pthread_cond_broadcast(&cond);
+  signal_unlock();
+}
+
+struct sigaction *JVM_get_signal_action(int sig) {
+  allocate_sact();
+  /* Does race condition make sense here? */
+  if (sigismember(&jvmsigs, sig)) {
+    return &sact[sig];
+  }
+  return NULL;
+}
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthParser.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthParser.java	Fri Apr 13 14:55:11 2018 -0400
@@ -746,12 +746,7 @@
                 value = lookup(aValue, Object.class);
                 break;
             case 1: // boolean
-                if (aValue.toUpperCase().equals("TRUE")) {
-                    value = Boolean.TRUE;
-                }
-                else {
-                    value = Boolean.FALSE;
-                }
+                value = Boolean.parseBoolean(aValue);
                 break;
             case 2: // dimension
                 StringTokenizer tok = new StringTokenizer(aValue);
@@ -939,11 +934,11 @@
                   ": destinationInsets must be top left bottom right");
             }
             else if (key.equals(ATTRIBUTE_PAINT_CENTER)) {
-                paintCenter = value.toLowerCase().equals("true");
+                paintCenter = Boolean.parseBoolean(value);
                 paintCenterSpecified = true;
             }
             else if (key.equals(ATTRIBUTE_STRETCH)) {
-                stretch = value.toLowerCase().equals("true");
+                stretch = Boolean.parseBoolean(value);
                 stretchSpecified = true;
             }
             else if (key.equals(ATTRIBUTE_DIRECTION)) {
@@ -989,7 +984,7 @@
                 }
             }
             else if (key.equals(ATTRIBUTE_CENTER)) {
-                center = value.toLowerCase().equals("true");
+                center = Boolean.parseBoolean(value);
             }
         }
         if (painter == null) {
--- a/src/java.instrument/share/native/libinstrument/Reentrancy.c	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.instrument/share/native/libinstrument/Reentrancy.c	Fri Apr 13 14:55:11 2018 -0400
@@ -90,7 +90,7 @@
                 jthread         thread,
                 const void *    expected) {
     jvmtiError  error;
-    void *      test = (void *) 0x99999999UL;
+    void *      test = (void *) 0x99999999ULL;
 
     /* now check if we do a fetch we get what we wrote */
     error = (*jvmtienv)->GetThreadLocalStorage(
--- a/src/java.management/share/classes/sun/management/MemoryPoolImpl.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.management/share/classes/sun/management/MemoryPoolImpl.java	Fri Apr 13 14:55:11 2018 -0400
@@ -55,10 +55,10 @@
     private long  usageThreshold;
     private long  collectionThreshold;
 
-    private boolean usageSensorRegistered;
-    private boolean gcSensorRegistered;
-    private Sensor  usageSensor;
-    private Sensor  gcSensor;
+    private boolean usageSensorRegistered; // VM-initialized to false
+    private boolean gcSensorRegistered;    // VM-initialized to false
+    private final Sensor usageSensor;
+    private final Sensor gcSensor;
 
     MemoryPoolImpl(String name, boolean isHeap, long usageThreshold,
                    long gcThreshold) {
@@ -72,8 +72,6 @@
         this.collectionThresholdSupported = (gcThreshold >= 0);
         this.usageSensor = new PoolSensor(this, name + " usage sensor");
         this.gcSensor = new CollectionSensor(this, name + " collection sensor");
-        this.usageSensorRegistered = false;
-        this.gcSensorRegistered = false;
     }
 
     public String getName() {
@@ -290,7 +288,7 @@
      * unless the memory usage has returned below the threshold.
      */
     class PoolSensor extends Sensor {
-        MemoryPoolImpl pool;
+        final MemoryPoolImpl pool;
 
         PoolSensor(MemoryPoolImpl pool, String name) {
             super(name);
@@ -316,10 +314,10 @@
      * when the memory usage of a memory pool after GC is crossing
      * the collection threshold.
      * The VM will trigger this sensor in subsequent crossing
-     * regardless if the memory usage has changed siince the previous GC.
+     * regardless if the memory usage has changed since the previous GC.
      */
     class CollectionSensor extends Sensor {
-        MemoryPoolImpl pool;
+        final MemoryPoolImpl pool;
         CollectionSensor(MemoryPoolImpl pool, String name) {
             super(name);
             this.pool = pool;
--- a/src/java.management/share/classes/sun/management/Sensor.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/java.management/share/classes/sun/management/Sensor.java	Fri Apr 13 14:55:11 2018 -0400
@@ -48,10 +48,10 @@
  */
 
 public abstract class Sensor {
-    private Object  lock;
-    private String  name;
-    private long    count;
-    private boolean on;
+    private final Object lock = new Object();
+    private final String name;
+    private long count;                 // VM-initialized to 0
+    private boolean on;                 // VM-initialized to false
 
     /**
      * Constructs a {@code Sensor} object.
@@ -60,9 +60,6 @@
      */
     public Sensor(String name) {
         this.name = name;
-        this.count = 0;
-        this.on = false;
-        this.lock = new Object();
     }
 
     /**
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java	Fri Apr 13 14:55:11 2018 -0400
@@ -287,7 +287,12 @@
         /**
          * Warn about potentially unsafe vararg methods
          */
-        VARARGS("varargs");
+        VARARGS("varargs"),
+
+        /**
+         * Warn about use of preview features.
+         */
+        PREVIEW("preview");
 
         LintCategory(String option) {
             this(option, false);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java	Fri Apr 13 14:55:11 2018 -0400
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.code;
+
+import com.sun.tools.javac.code.Lint.LintCategory;
+import com.sun.tools.javac.code.Source.Feature;
+import com.sun.tools.javac.comp.Infer;
+import com.sun.tools.javac.jvm.Target;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
+import com.sun.tools.javac.resources.CompilerProperties.Warnings;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.JCDiagnostic.Error;
+import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.MandatoryWarningHandler;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Options;
+
+import javax.tools.JavaFileObject;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+import static com.sun.tools.javac.main.Option.PREVIEW;
+
+/**
+ * Helper class to handle preview language features. This class maps certain language features
+ * (see {@link Feature} into 'preview' features; the mapping is completely ad-hoc, so as to allow
+ * for maximum flexibility, which allows to migrate preview feature into supported features with ease.
+ *
+ * This class acts as a centralized point against which usages of preview features are reported by
+ * clients (e.g. other javac classes). Internally, this class collects all such usages and generates
+ * diagnostics to inform the user of such usages. Such diagnostics can be enabled using the
+ * {@link LintCategory#PREVIEW} lint category, and are suppressible by usual means.
+ */
+public class Preview {
+
+    /** flag: are preview featutres enabled */
+    private final boolean enabled;
+
+    /** the diag handler to manage preview feature usage diagnostics */
+    private final MandatoryWarningHandler previewHandler;
+
+    /** test flag: should all features be considered as preview features? */
+    private final boolean forcePreview;
+
+    /** a mapping from classfile numbers to Java SE versions */
+    private final Map<Integer, Source> majorVersionToSource;
+
+
+    private final Lint lint;
+    private final Log log;
+
+    private static final Context.Key<Preview> previewKey = new Context.Key<>();
+
+    public static Preview instance(Context context) {
+        Preview instance = context.get(previewKey);
+        if (instance == null) {
+            instance = new Preview(context);
+        }
+        return instance;
+    }
+
+    Preview(Context context) {
+        context.put(previewKey, this);
+        Options options = Options.instance(context);
+        enabled = options.isSet(PREVIEW);
+        log = Log.instance(context);
+        lint = Lint.instance(context);
+        this.previewHandler =
+                new MandatoryWarningHandler(log, lint.isEnabled(LintCategory.PREVIEW), true, "preview", LintCategory.PREVIEW);
+        forcePreview = options.isSet("forcePreview");
+        majorVersionToSource = initMajorVersionToSourceMap();
+    }
+
+    private Map<Integer, Source> initMajorVersionToSourceMap() {
+        Map<Integer, Source> majorVersionToSource = new HashMap<>();
+        for (Target t : Target.values()) {
+            int major = t.majorVersion;
+            Source source = Source.lookup(t.name);
+            if (source != null) {
+                majorVersionToSource.put(major, source);
+            }
+        }
+        return majorVersionToSource;
+   }
+
+    /**
+     * Report usage of a preview feature. Usages reported through this method will affect the
+     * set of sourcefiles with dependencies on preview features.
+     * @param pos the position at which the preview feature was used.
+     * @param feature the preview feature used.
+     */
+    public void warnPreview(int pos, Feature feature) {
+        warnPreview(new SimpleDiagnosticPosition(pos), feature);
+    }
+
+    /**
+     * Report usage of a preview feature. Usages reported through this method will affect the
+     * set of sourcefiles with dependencies on preview features.
+     * @param pos the position at which the preview feature was used.
+     * @param feature the preview feature used.
+     */
+    public void warnPreview(DiagnosticPosition pos, Feature feature) {
+        Assert.check(isEnabled());
+        Assert.check(isPreview(feature));
+        if (!lint.isSuppressed(LintCategory.PREVIEW)) {
+            previewHandler.report(pos, feature.isPlural() ?
+                    Warnings.PreviewFeatureUsePlural(feature.nameFragment()) :
+                    Warnings.PreviewFeatureUse(feature.nameFragment()));
+        }
+    }
+
+    /**
+     * Report usage of a preview feature in classfile.
+     * @param classfile the name of the classfile with preview features enabled
+     * @param majorVersion the major version found in the classfile.
+     */
+    public void warnPreview(JavaFileObject classfile, int majorVersion) {
+        Assert.check(isEnabled());
+        if (!lint.isSuppressed(LintCategory.PREVIEW)) {
+            previewHandler.report(null,
+                    Warnings.PreviewFeatureUseClassfile(classfile, majorVersionToSource.get(majorVersion).name));
+        }
+    }
+
+    /**
+     * Are preview features enabled?
+     * @return true, if preview features are enabled.
+     */
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    /**
+     * Is given feature a preview feature?
+     * @param feature the feature to be tested.
+     * @return true, if given feature is a preview feature.
+     */
+    public boolean isPreview(Feature feature) {
+        //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
+        //When real preview features will be added, this method can be implemented to return 'true'
+        //for those selected features, and 'false' for all the others.
+        return forcePreview;
+    }
+
+    /**
+     * Generate an error key which captures the fact that a given preview feature could not be used
+     * due to the preview feature support being disabled.
+     * @param feature the feature for which the diagnostic has to be generated.
+     * @return the diagnostic.
+     */
+    public Error disabledError(Feature feature) {
+        Assert.check(!isEnabled());
+        return feature.isPlural() ?
+                Errors.PreviewFeatureDisabledPlural(feature.nameFragment()) :
+                Errors.PreviewFeatureDisabled(feature.nameFragment());
+    }
+
+    /**
+     * Generate an error key which captures the fact that a preview classfile cannot be loaded
+     * due to the preview feature support being disabled.
+     * @param classfile the name of the classfile with preview features enabled
+     * @param majorVersion the major version found in the classfile.
+     */
+    public Error disabledError(JavaFileObject classfile, int majorVersion) {
+        Assert.check(!isEnabled());
+        return Errors.PreviewFeatureDisabledClassfile(classfile, majorVersionToSource.get(majorVersion).name);
+    }
+
+    /**
+     * Report any deferred diagnostics.
+     */
+    public void reportDeferredDiagnostics() {
+        previewHandler.reportDeferredDiagnostic();
+    }
+}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Fri Apr 13 14:55:11 2018 -0400
@@ -217,6 +217,16 @@
                     source.compareTo(maxLevel) <= 0;
         }
 
+        public boolean isPlural() {
+            Assert.checkNonNull(optKind);
+            return optKind == DiagKind.PLURAL;
+        }
+
+        public Fragment nameFragment() {
+            Assert.checkNonNull(optFragment);
+            return optFragment;
+        }
+
         public Fragment fragment(String sourceName) {
             Assert.checkNonNull(optFragment);
             return optKind == DiagKind.NORMAL ?
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Fri Apr 13 14:55:11 2018 -0400
@@ -68,6 +68,7 @@
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 import com.sun.tools.javac.tree.JCTree.JCSwitch.SwitchKind;
+import static com.sun.tools.javac.jvm.Pool.DynamicMethod;
 
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.type.TypeKind;
@@ -209,6 +210,8 @@
 
         private Map<DedupedLambda, DedupedLambda> dedupedLambdas;
 
+        private Map<DynamicMethod, DynamicMethodSymbol> dynMethSyms = new HashMap<>();
+
         /**
          * list of deserialization cases
          */
@@ -1202,9 +1205,10 @@
                                             (MethodSymbol)bsm,
                                             indyType,
                                             staticArgs.toArray());
-
             JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
-            qualifier.sym = dynSym;
+            DynamicMethodSymbol existing = kInfo.dynMethSyms.putIfAbsent(
+                    new DynamicMethod(dynSym, types), dynSym);
+            qualifier.sym = existing != null ? existing : dynSym;
             qualifier.type = indyType.getReturnType();
 
             JCMethodInvocation proxyCall = make.Apply(List.nil(), qualifier, indyArgs);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Apr 13 14:55:11 2018 -0400
@@ -2120,6 +2120,7 @@
 
         Set<ModuleSymbol> recoverableModules = new HashSet<>(syms.getAllModules());
 
+        recoverableModules.add(syms.unnamedModule);
         recoverableModules.remove(env.toplevel.modle);
 
         for (ModuleSymbol ms : recoverableModules) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Fri Apr 13 14:55:11 2018 -0400
@@ -105,6 +105,8 @@
     public final static int MAX_LOCALS = 0xffff;
     public final static int MAX_STACK = 0xffff;
 
+    public final static int PREVIEW_MINOR_VERSION = 0xffff;
+
     public enum Version {
         V45_3(45, 3), // base level for all attributes
         V49(49, 0),   // JDK 1.5: enum, generics, annotations
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Apr 13 14:55:11 2018 -0400
@@ -148,6 +148,11 @@
 
     DeferredCompletionFailureHandler dcfh;
 
+    /**
+     * Support for preview language features.
+     */
+    Preview preview;
+
     /** The current scope where type variables are entered.
      */
     protected WriteableScope typevars;
@@ -270,6 +275,7 @@
         verbose         = options.isSet(Option.VERBOSE);
 
         Source source = Source.instance(context);
+        preview = Preview.instance(context);
         allowSimplifiedVarargs = Feature.SIMPLIFIED_VARARGS.allowedInSource(source);
         allowModules     = Feature.MODULES.allowedInSource(source);
 
@@ -2786,6 +2792,14 @@
                                    Integer.toString(maxMinor));
         }
 
+        if (minorVersion == ClassFile.PREVIEW_MINOR_VERSION) {
+            if (!preview.isEnabled()) {
+                log.error(preview.disabledError(currentClassFile, majorVersion));
+            } else {
+                preview.warnPreview(c.classfile, majorVersion);
+            }
+        }
+
         indexPool();
         if (signatureBuffer.length < bp) {
             int ns = Integer.highestOneBit(bp) << 1;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Fri Apr 13 14:55:11 2018 -0400
@@ -49,7 +49,6 @@
 import com.sun.tools.javac.jvm.Pool.Method;
 import com.sun.tools.javac.jvm.Pool.MethodHandle;
 import com.sun.tools.javac.jvm.Pool.Variable;
-import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.util.*;
 
 import static com.sun.tools.javac.code.Flags.*;
@@ -89,6 +88,10 @@
      */
     private boolean debugstackmap;
 
+    /** Preview language level.
+     */
+    private Preview preview;
+
     /**
      * Target class version.
      */
@@ -178,6 +181,7 @@
         log = Log.instance(context);
         names = Names.instance(context);
         options = Options.instance(context);
+        preview = Preview.instance(context);
         target = Target.instance(context);
         source = Source.instance(context);
         types = Types.instance(context);
@@ -1819,7 +1823,11 @@
         acount += writeExtraClassAttributes(c);
 
         poolbuf.appendInt(JAVA_MAGIC);
-        poolbuf.appendChar(target.minorVersion);
+        if (preview.isEnabled()) {
+            poolbuf.appendChar(ClassFile.PREVIEW_MINOR_VERSION);
+        } else {
+            poolbuf.appendChar(target.minorVersion);
+        }
         poolbuf.appendChar(target.majorVersion);
 
         writePool(c.pool);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -180,10 +180,10 @@
         }
     }
 
-    static class DynamicMethod extends Method {
+    public static class DynamicMethod extends Method {
         public Object[] uniqueStaticArgs;
 
-        DynamicMethod(DynamicMethodSymbol m, Types types) {
+        public DynamicMethod(DynamicMethodSymbol m, Types types) {
             super(m, types);
             uniqueStaticArgs = getUniqueTypeArray(m.staticArgs, types);
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Fri Apr 13 14:55:11 2018 -0400
@@ -536,6 +536,20 @@
             }
         }
 
+        if (options.isSet(Option.PREVIEW)) {
+            if (sourceString == null) {
+                //enable-preview must be used with explicit -source or --release
+                error("err.preview.without.source.or.release");
+                return false;
+            } else if (source != Source.DEFAULT) {
+                //enable-preview must be used with latest source version
+                error("err.preview.not.latest",
+                        sourceString,
+                        Source.DEFAULT.name);
+                return false;
+            }
+        }
+
         String profileString = options.get(Option.PROFILE);
         if (profileString != null) {
             Profile profile = Profile.lookup(profileString);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Apr 13 14:55:11 2018 -0400
@@ -275,6 +275,10 @@
      */
     protected Source source;
 
+    /** The preview language version.
+     */
+    protected Preview preview;
+
     /** The module for code generation.
      */
     protected Gen gen;
@@ -405,6 +409,7 @@
             log.error(Errors.CantAccess(ex.sym, ex.getDetailValue()));
         }
         source = Source.instance(context);
+        preview = Preview.instance(context);
         attr = Attr.instance(context);
         analyzer = Analyzer.instance(context);
         chk = Check.instance(context);
@@ -1731,6 +1736,7 @@
                 log.warning(Warnings.ProcUseProcOrImplicit);
         }
         chk.reportDeferredDiagnostics();
+        preview.reportDeferredDiagnostics();
         if (log.compressedOutput) {
             log.mandatoryNote(null, Notes.CompressedDiags);
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Fri Apr 13 14:55:11 2018 -0400
@@ -330,6 +330,8 @@
         }
     },
 
+    PREVIEW("--enable-preview", "opt.preview", STANDARD, BASIC),
+
     PROFILE("-profile", "opt.arg.profile", "opt.profile", STANDARD, BASIC) {
         @Override
         public void process(OptionHelper helper, String option, String operand) throws InvalidValueException {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Fri Apr 13 14:55:11 2018 -0400
@@ -25,6 +25,7 @@
 
 package com.sun.tools.javac.parser;
 
+import com.sun.tools.javac.code.Preview;
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.code.Source.Feature;
 import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
@@ -53,6 +54,9 @@
      */
     private Source source;
 
+    /** The preview language setting. */
+    private Preview preview;
+
     /** The log to be used for error reporting.
      */
     private final Log log;
@@ -115,12 +119,20 @@
         this.log = fac.log;
         this.tokens = fac.tokens;
         this.source = fac.source;
+        this.preview = fac.preview;
         this.reader = reader;
     }
 
-    private void checkSourceLevel(int pos, Feature feature) {
-        if (!feature.allowedInSource(source)) {
+    protected void checkSourceLevel(int pos, Feature feature) {
+        if (preview.isPreview(feature) && !preview.isEnabled()) {
+            //preview feature without --preview flag, error
+            lexError(DiagnosticFlag.SOURCE_LEVEL, pos, preview.disabledError(feature));
+        } else if (!feature.allowedInSource(source)) {
+            //incompatible source level, error
             lexError(DiagnosticFlag.SOURCE_LEVEL, pos, feature.error(source.name));
+        } else if (preview.isPreview(feature)) {
+            //use of preview feature, warn
+            preview.warnPreview(pos, feature);
         }
     }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Apr 13 14:55:11 2018 -0400
@@ -95,6 +95,9 @@
     /** The Source language setting. */
     private Source source;
 
+    /** The Preview language setting. */
+    private Preview preview;
+
     /** The name table. */
     private Names names;
 
@@ -169,6 +172,7 @@
         this.log = fac.log;
         this.names = fac.names;
         this.source = fac.source;
+        this.preview = fac.preview;
         this.allowStringFolding = fac.options.getBoolean("allowStringFolding", true);
         this.keepDocComments = keepDocComments;
         this.parseModuleInfo = parseModuleInfo;
@@ -4310,8 +4314,15 @@
     }
 
     protected void checkSourceLevel(int pos, Feature feature) {
-        if (!feature.allowedInSource(source)) {
+        if (preview.isPreview(feature) && !preview.isEnabled()) {
+            //preview feature without --preview flag, error
+            log.error(DiagnosticFlag.SOURCE_LEVEL, pos, preview.disabledError(feature));
+        } else if (!feature.allowedInSource(source)) {
+            //incompatible source level, error
             log.error(DiagnosticFlag.SOURCE_LEVEL, pos, feature.error(source.name));
+        } else if (preview.isPreview(feature)) {
+            //use of preview feature, warn
+            preview.warnPreview(pos, feature);
         }
     }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ParserFactory.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ParserFactory.java	Fri Apr 13 14:55:11 2018 -0400
@@ -27,6 +27,7 @@
 
 import java.util.Locale;
 
+import com.sun.tools.javac.code.Preview;
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.tree.DocTreeMaker;
 import com.sun.tools.javac.tree.TreeMaker;
@@ -62,6 +63,7 @@
     final Log log;
     final Tokens tokens;
     final Source source;
+    final Preview preview;
     final Names names;
     final Options options;
     final ScannerFactory scannerFactory;
@@ -76,6 +78,7 @@
         this.names = Names.instance(context);
         this.tokens = Tokens.instance(context);
         this.source = Source.instance(context);
+        this.preview = Preview.instance(context);
         this.options = Options.instance(context);
         this.scannerFactory = ScannerFactory.instance(context);
         this.locale = context.get(Locale.class);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ScannerFactory.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ScannerFactory.java	Fri Apr 13 14:55:11 2018 -0400
@@ -27,6 +27,7 @@
 
 import java.nio.CharBuffer;
 
+import com.sun.tools.javac.code.Preview;
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Log;
@@ -56,6 +57,7 @@
     final Log log;
     final Names names;
     final Source source;
+    final Preview preview;
     final Tokens tokens;
 
     /** Create a new scanner factory. */
@@ -64,6 +66,7 @@
         this.log = Log.instance(context);
         this.names = Names.instance(context);
         this.source = Source.instance(context);
+        this.preview = Preview.instance(context);
         this.tokens = Tokens.instance(context);
     }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Apr 13 14:55:11 2018 -0400
@@ -1554,6 +1554,25 @@
 compiler.note.unchecked.plural.additional=\
     Some input files additionally use unchecked or unsafe operations.
 
+# 0: file name
+compiler.note.preview.filename=\
+    {0} uses preview language features.
+
+compiler.note.preview.plural=\
+    Some input files use preview language features.
+
+# The following string may appear after one of the above deprecation
+# messages.
+compiler.note.preview.recompile=\
+    Recompile with -Xlint:preview for details.
+
+# 0: file name
+compiler.note.preview.filename.additional=\
+    {0} has additional uses of preview language features.
+
+compiler.note.preview.plural.additional=\
+    Some input files additionally use preview language features.
+
 # Notes related to annotation processing
 
 # Print a client-generated note; assumed to be localized, no translation required
@@ -2672,6 +2691,34 @@
    {0} are not supported in -source {1}\n\
     (use -source {2} or higher to enable {0})
 
+# 0: message segment (feature)
+compiler.err.preview.feature.disabled=\
+   {0} is a preview feature and is disabled by default.\n\
+   (use --enable-preview to enable {0})
+
+# 0: message segment (feature)
+compiler.err.preview.feature.disabled.plural=\
+   {0} are a preview feature and are disabled by default.\n\
+   (use --enable-preview to enable {0})
+
+# 0: file object (classfile), 1: string (expected version)
+compiler.err.preview.feature.disabled.classfile=\
+   classfile for {0} uses preview features of Java SE {1}.\n\
+   (use --enable-preview to allow loading of classfiles which contain preview features)
+
+# 0: message segment (feature)
+compiler.warn.preview.feature.use=\
+   {0} is a preview feature and may be removed in a future release.
+
+# 0: message segment (feature)
+compiler.warn.preview.feature.use.plural=\
+   {0} are a preview feature and may be removed in a future release.
+
+# 0: file object (classfile), 1: string (expected version)
+compiler.warn.preview.feature.use.classfile=\
+   classfile for {0} uses preview features of Java SE {1}.
+
+
 compiler.misc.feature.modules=\
     modules
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Fri Apr 13 14:55:11 2018 -0400
@@ -252,6 +252,9 @@
 javac.opt.Xlint.desc.varargs=\
     Warn about potentially unsafe vararg methods
 
+javac.opt.Xlint.desc.preview=\
+    Warn about use of preview language features
+
 javac.opt.Xdoclint=\
     Enable recommended checks for problems in javadoc comments
 # L10N: do not localize: all none
@@ -293,6 +296,8 @@
     Search classpath and sourcepath for classes before the bootclasspath instead of after
 javac.opt.prefer=\
     Specify which file to read when both a source file and class file are found for an implicitly compiled class
+javac.opt.preview=\
+    Enable preview language features. To be used in conjunction with either -source or --release.
 javac.opt.AT=\
     Read options and filenames from file
 javac.opt.diags=\
@@ -368,6 +373,11 @@
     target release {0} conflicts with default source release {1}
 javac.warn.profile.target.conflict=\
     profile {0} is not valid for target release {1}
+javac.err.preview.not.latest=\
+    invalid source release {0} with --enable-preview\n\
+    (preview language features are only supported for release {1})
+javac.err.preview.without.source.or.release=\
+    --enable-preview must be used with either -source or --release
 javac.err.file.not.found=\
     file not found: {0}
 javac.err.file.not.directory=\
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java	Fri Apr 13 14:55:11 2018 -0400
@@ -40,6 +40,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 
 /**
@@ -100,8 +101,11 @@
         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
                 ? HtmlTree.MAIN()
                 : body;
+        DocPath moduleSummary = configuration.useModuleDirectories
+                ? DocPaths.DOT_DOT.resolve(configuration.docPaths.moduleSummary(moduleElement))
+                : configuration.docPaths.moduleSummary(moduleElement);
         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
-                mdlgen.links.createLink(configuration.docPaths.moduleSummary(moduleElement), mdlLabel, "", "classFrame"));
+                mdlgen.links.createLink(moduleSummary, mdlLabel, "", "classFrame"));
         htmlTree.addContent(heading);
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.setStyle(HtmlStyle.indexContainer);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Fri Apr 13 14:55:11 2018 -0400
@@ -36,7 +36,6 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Fri Apr 13 14:55:11 2018 -0400
@@ -37,7 +37,6 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Links;
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
@@ -189,7 +188,10 @@
      * @param ul the Content object to which the all classes link should be added
      */
     protected void addAllClassesLink(Content ul) {
-        Content linkContent = links.createLink(DocPaths.ALLCLASSES_FRAME,
+        DocPath allClassesFrame = configuration.useModuleDirectories
+                ? DocPaths.DOT_DOT.resolve(DocPaths.ALLCLASSES_FRAME)
+                : DocPaths.ALLCLASSES_FRAME;
+        Content linkContent = links.createLink(allClassesFrame,
                 contents.allClassesLabel, "", "packageFrame");
         Content li = HtmlTree.LI(linkContent);
         ul.addContent(li);
@@ -202,7 +204,10 @@
      * @param ul the Content object to which the all packages link should be added
      */
     protected void addAllPackagesLink(Content ul) {
-        Content linkContent = links.createLink(DocPaths.OVERVIEW_FRAME,
+        DocPath overviewFrame = configuration.useModuleDirectories
+                ? DocPaths.DOT_DOT.resolve(DocPaths.OVERVIEW_FRAME)
+                : DocPaths.OVERVIEW_FRAME;
+        Content linkContent = links.createLink(overviewFrame,
                 contents.allPackagesLabel, "", "packageListFrame");
         Content li = HtmlTree.LI(linkContent);
         ul.addContent(li);
@@ -215,7 +220,10 @@
      * @param ul the Content object to which the all modules link should be added
      */
     protected void addAllModulesLink(Content ul) {
-        Content linkContent = links.createLink(DocPaths.MODULE_OVERVIEW_FRAME,
+        DocPath moduleOverviewFrame = configuration.useModuleDirectories
+                ? DocPaths.DOT_DOT.resolve(DocPaths.MODULE_OVERVIEW_FRAME)
+                : DocPaths.MODULE_OVERVIEW_FRAME;
+        Content linkContent = links.createLink(moduleOverviewFrame,
                 contents.allModulesLabel, "", "packageListFrame");
         Content li = HtmlTree.LI(linkContent);
         ul.addContent(li);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPath.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPath.java	Fri Apr 13 14:55:11 2018 -0400
@@ -30,10 +30,6 @@
 import java.util.Collections;
 import java.util.List;
 
-import javax.lang.model.element.ModuleElement;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-
 /**
  * Abstraction for immutable relative paths.
  * Paths always use '/' as a separator, and never begin or end with '/'.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java	Fri Apr 13 14:55:11 2018 -0400
@@ -49,6 +49,8 @@
         moduleSeparator = useModuleDirectories ? "/module-" : "-";
     }
 
+    public static final DocPath DOT_DOT = DocPath.create("..");
+
     /** The name of the file for all classes, without using frames, when --no-frames is specified. */
     public static final DocPath ALLCLASSES = DocPath.create("allclasses.html");
 
--- a/test/jdk/ProblemList.txt	Tue Apr 10 18:56:07 2018 +0100
+++ b/test/jdk/ProblemList.txt	Fri Apr 13 14:55:11 2018 -0400
@@ -590,7 +590,6 @@
 
 sun/security/krb5/auto/UnboundSSL.java                          8180265 windows-all
 sun/security/provider/KeyStore/DKSTest.sh                       8180266 windows-all
-sun/security/ssl/X509KeyManager/PreferredKey.java               8190333 generic-all
 
 ############################################################################
 
@@ -778,7 +777,7 @@
 
 com/sun/jndi/ldap/LdapTimeoutTest.java                          8151678 linux-all
 
-javax/rmi/ssl/SSLSocketParametersTest.sh                        8194663 generic-all
+javax/rmi/ssl/SSLSocketParametersTest.sh                        8162906 generic-all
 
 ############################################################################
 
--- a/test/jdk/java/lang/invoke/condy/CondyBSMInvocation.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/test/jdk/java/lang/invoke/condy/CondyBSMInvocation.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8186046
+ * @bug 8186046 8199875
  * @summary Test basic invocation of bootstrap methods
  * @library /lib/testlibrary/bytecode /java/lang/invoke/common
  * @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.InstructionHelper
@@ -40,8 +40,10 @@
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import java.lang.invoke.WrongMethodTypeException;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.stream.IntStream;
+import java.util.stream.Stream;
 
 import static java.lang.invoke.MethodType.methodType;
 
@@ -63,85 +65,85 @@
         }
     }
 
+    static MethodHandle[] bsms(String bsmName) {
+        return Stream.of(CondyBSMInvocation.class.getDeclaredMethods()).
+                filter(m -> m.getName().equals(bsmName)).
+                map(m -> {
+                    try {
+                        return MethodHandles.lookup().unreflect(m);
+                    } catch (IllegalAccessException e) {
+                        throw new RuntimeException();
+                    }
+                }).toArray(MethodHandle[]::new);
+    }
 
-    public static Object _bsm() {
+    public static Object shape_bsm() {
         return "0";
     }
 
-    public static Object _bsm(Object a1) {
+    public static Object shape_bsm(Object a1) {
         return "0";
     }
 
-    // Note: when pull mode is supported for a BSM this test case
-    //       will fail and must be removed
-    public static Object _bsm(Object a1, Object a2) {
+    public static Object shape_bsm(Object... args) {
+        return "0";
+    }
+
+    public static Object shape_bsm(Object a1, Object a2) {
+        return "0";
+    }
+
+    public static Object shape_bsm(Object a1, Object... args) {
+        return "0";
+    }
+
+    public static Object shape_bsm(Object a1, Object a2, Object a3) {
+        return "0";
+    }
+
+    public static Object shape_bsm(MethodHandles.Lookup a1) {
         return "0";
     }
 
     @Test
-    public void testWrongArity() throws Throwable {
-        for (int i = 0; i < 3; i++) {
-            final int n = i;
-            MethodType mt = methodType(Object.class)
-                    .appendParameterTypes(Collections.nCopies(n, Object.class));
+    public void testWrongShape() throws Throwable {
+        for (MethodHandle bsm : bsms("shape_bsm")) {
             MethodHandle mh = InstructionHelper.ldcDynamicConstant(
                     L, "name", Object.class,
-                    "_bsm", mt,
-                    S -> IntStream.range(0, n).forEach(S::add)
+                    "shape_bsm", bsm.type(),
+                    S -> {}
             );
 
             try {
                 Object r = mh.invoke();
-                Assert.fail("BootstrapMethodError expected to be thrown for arrity " + n);
+                Assert.fail("BootstrapMethodError expected to be thrown for " + bsm);
             } catch (BootstrapMethodError e) {
-                Throwable t = e.getCause();
-                Assert.assertTrue(WrongMethodTypeException.class.isAssignableFrom(t.getClass()));
             }
         }
     }
 
 
-    public static Object _bsm(String[] ss) {
+    public static Object sig_bsm(MethodHandles.Lookup a1, String[] a2) {
         return "0";
     }
 
-    public static Object _bsm(String a1, String a2, String a3) {
+    public static Object sig_bsm(MethodHandles.Lookup a1, String a2, String a3) {
         return "0";
     }
 
     @Test
     public void testWrongSignature() throws Throwable {
-        {
+        for (MethodHandle bsm : bsms("sig_bsm")) {
             MethodHandle mh = InstructionHelper.ldcDynamicConstant(
                     L, "name", Object.class,
-                    "_bsm", methodType(Object.class, String[].class),
+                    "sig_bsm", bsm.type(),
                     S -> {}
             );
 
             try {
                 Object r = mh.invoke();
-                Assert.fail("BootstrapMethodError expected to be thrown");
-            }
-            catch (BootstrapMethodError e) {
-                Throwable t = e.getCause();
-                Assert.assertTrue(WrongMethodTypeException.class.isAssignableFrom(t.getClass()));
-            }
-        }
-
-        {
-            MethodHandle mh = InstructionHelper.ldcDynamicConstant(
-                    L, "name", Object.class,
-                    "_bsm", methodType(Object.class, String.class, String.class, String.class),
-                    S -> {}
-            );
-
-            try {
-                Object r = mh.invoke();
-                Assert.fail("BootstrapMethodError expected to be thrown");
-            }
-            catch (BootstrapMethodError e) {
-                Throwable t = e.getCause();
-                Assert.assertTrue(ClassCastException.class.isAssignableFrom(t.getClass()));
+                Assert.fail("BootstrapMethodError expected to be thrown for " + bsm);
+            } catch (BootstrapMethodError e) {
             }
         }
     }
@@ -193,6 +195,12 @@
         return "7";
     }
 
+    public static Object bsm(MethodHandles.Lookup l, Object... args) {
+        Object[] staticArgs = Arrays.copyOfRange(args, 2, args.length);
+        assertAll(staticArgs);
+        return Integer.toString(staticArgs.length);
+    }
+
     static void assertAll(Object... as) {
         for (int i = 0; i < as.length; i++) {
             Assert.assertEquals(as[i], i);
@@ -214,6 +222,19 @@
             Object r = mh.invoke();
             Assert.assertEquals(r, Integer.toString(n));
         }
+
+        {
+            MethodType mt = methodType(Object.class, MethodHandles.Lookup.class, Object[].class);
+            MethodHandle mh = InstructionHelper.ldcDynamicConstant(
+                    L, "name", Object.class,
+                    "bsm", mt,
+                    S -> IntStream.range(0, 9).forEach(S::add)
+            );
+
+            Object r = mh.invoke();
+            Assert.assertEquals(r, Integer.toString(9));
+
+        }
     }
 
     @Test
--- a/test/jdk/java/net/Socket/asyncClose/Race.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/test/jdk/java/net/Socket/asyncClose/Race.java	Fri Apr 13 14:55:11 2018 -0400
@@ -30,6 +30,7 @@
 import java.io.InputStream;
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.net.ConnectException;
 import java.net.SocketException;
 import java.util.concurrent.Phaser;
 
@@ -43,33 +44,37 @@
             final int port = ss.getLocalPort();
             final Phaser phaser = new Phaser(THREADS + 1);
             for (int i=0; i<100; i++) {
-                final Socket s = new Socket("localhost", port);
-                s.setSoLinger(false, 0);
-                try (Socket sa = ss.accept()) {
-                    sa.setSoLinger(false, 0);
-                    final InputStream is = s.getInputStream();
-                    Thread[] threads = new Thread[THREADS];
-                    for (int j=0; j<THREADS; j++) {
-                        threads[j] = new Thread() {
-                        public void run() {
-                            try {
-                                phaser.arriveAndAwaitAdvance();
-                                while (is.read() != -1)
-                                    Thread.sleep(50);
-                            } catch (Exception x) {
-                                if (!(x instanceof SocketException
-                                      && x.getMessage().equalsIgnoreCase("socket closed")))
-                                    x.printStackTrace();
-                                // ok, expect Socket closed
-                            }
-                        }};
+                try {
+                    final Socket s = new Socket("localhost", port);
+                    s.setSoLinger(false, 0);
+                    try (Socket sa = ss.accept()) {
+                        sa.setSoLinger(false, 0);
+                        final InputStream is = s.getInputStream();
+                        Thread[] threads = new Thread[THREADS];
+                        for (int j=0; j<THREADS; j++) {
+                            threads[j] = new Thread() {
+                            public void run() {
+                                try {
+                                    phaser.arriveAndAwaitAdvance();
+                                    while (is.read() != -1)
+                                        Thread.sleep(50);
+                                } catch (Exception x) {
+                                    if (!(x instanceof SocketException
+                                          && x.getMessage().equalsIgnoreCase("socket closed")))
+                                        x.printStackTrace();
+                                    // ok, expect Socket closed
+                                }
+                            }};
+                        }
+                        for (int j=0; j<100; j++)
+                            threads[j].start();
+                        phaser.arriveAndAwaitAdvance();
+                        s.close();
+                        for (int j=0; j<100; j++)
+                            threads[j].join();
                     }
-                    for (int j=0; j<100; j++)
-                        threads[j].start();
-                    phaser.arriveAndAwaitAdvance();
-                    s.close();
-                    for (int j=0; j<100; j++)
-                        threads[j].join();
+                } catch (ConnectException e) {
+                    System.err.println("Exception " + e + " Port: " + port);
                 }
             }
         }
--- a/test/jdk/java/rmi/registry/reexport/Reexport.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/test/jdk/java/rmi/registry/reexport/Reexport.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,79 +29,70 @@
  *          java.rmi/sun.rmi.server
  *          java.rmi/sun.rmi.transport
  *          java.rmi/sun.rmi.transport.tcp
- * @build TestLibrary RegistryVM RegistryRunner
+ * @build TestLibrary
  * @run main/othervm Reexport
  */
 
 /*
- * If a VM could not create an RMI registry because another registry
- * usually in another process, was using the registry port, the next
+ * If a VM could not create an RMI registry because the registry port
+ * was already occupied by this or other processes, the next
  * time the VM tried to create a registry (after the other registry
  * was brought down) the attempt would fail.  The second try to create
  * a registry would fail because the registry ObjID would still be in
  * use when it should never have been allocated.
  *
- * The test creates this conflict using Runtime.exec and ensures that
- * a registry can still be created after the conflict is resolved.
+ * The test creates this conflict starting a dummy tcp server and ensures
+ * that a registry can still be created after the conflict is resolved.
  */
 
-import java.io.*;
-import java.rmi.*;
-import java.rmi.registry.*;
-import java.rmi.server.*;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.channels.ServerSocketChannel;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
 
 public class Reexport {
-    static public void main(String[] argv) {
+    static public void main(String[] argv) throws IOException {
 
-        Registry reg = null;
-        try {
-            System.err.println("\nregression test for 4120329\n");
+        for (int loop = 0; loop < 10; loop++) {
+            System.err.println("\nat loop: " + loop);
+            int port = -1;
+            try (ServerSocketChannel server = ServerSocketChannel.open();) {
+                server.bind(null);
+                InetSocketAddress addr = (InetSocketAddress)server.getLocalAddress();
+                port = addr.getPort();
 
-            // establish the registry (we hope)
-            makeRegistry();
-
-            // Get a handle to the registry
-            System.err.println("Creating duplicate registry, this should fail...");
-            reg = createReg(true);
-
-            // Kill the first registry.
-            System.err.println("Bringing down the first registry");
+                System.err.println("Creating duplicate registry, this should fail...");
+                createReg(port, true);
+            }
             try {
-                killRegistry();
-            } catch (Exception foo) {
+                if (createReg(port, false) == null) {
+                    TestLibrary.bomb("Could not create registry on second try");
+                }
+                System.err.println("Test passed");
+                return;
+            } catch (Exception e) {
+                String err = e.getMessage();
+                if (err.contains("Address already in use")
+                        || err.contains("Port already in use")) {
+                    continue;
+                }
+                TestLibrary.bomb(e);
             }
-
-            // start another registry now that the first is gone; this should work
-            System.err.println("Trying again to start our own " +
-                               "registry... this should work");
-
-            reg = createReg(false);
-
-            if (reg == null) {
-                TestLibrary.bomb("Could not create registry on second try");
-            }
-
-            System.err.println("Test passed");
-
-        } catch (Exception e) {
-            TestLibrary.bomb(e);
-        } finally {
-            // dont leave the registry around to affect other tests.
-            killRegistry();
-            reg = null;
         }
+        TestLibrary.bomb("Test failed");
     }
 
-    static Registry createReg(boolean remoteOk) {
+    static Registry createReg(int port, boolean expectException) {
         Registry reg = null;
 
         try {
             reg = LocateRegistry.createRegistry(port);
-            if (remoteOk) {
-                TestLibrary.bomb("Remote registry is up, an Exception is expected!");
+            if (expectException) {
+                TestLibrary.bomb("Registry is up, an Exception is expected!");
             }
         } catch (Throwable e) {
-            if (remoteOk) {
+            if (expectException) {
                 System.err.println("EXPECTING PORT IN USE EXCEPTION:");
                 System.err.println(e.getMessage());
                 e.printStackTrace();
@@ -111,27 +102,4 @@
         }
         return reg;
     }
-
-    public static void makeRegistry() {
-        try {
-            subreg = RegistryVM.createRegistryVM();
-            subreg.start();
-            port = subreg.getPort();
-            System.out.println("Starting registry on port " + port);
-        } catch (IOException e) {
-            // one of these is summarily dropped, can't remember which one
-            System.out.println ("Test setup failed - cannot run rmiregistry");
-            TestLibrary.bomb("Test setup failed - cannot run test", e);
-        }
-    }
-
-    private static RegistryVM subreg = null;
-    private static int port = -1;
-
-    public static void killRegistry() {
-        if (subreg != null) {
-            subreg.cleanup();
-            subreg = null;
-        }
-    }
 }
--- a/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java	Fri Apr 13 14:55:11 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,7 +49,7 @@
 
 /*
  * @test
- * @bug 8081022 8151876 8166875
+ * @bug 8081022 8151876 8166875 8189784
  * @key randomness
  */
 
@@ -158,6 +158,10 @@
             {"Australia/South",  "ACST",                  preferred_s, Locale.ENGLISH, TextStyle.SHORT},
             {"America/Chicago",  "CDT",                   none,        Locale.ENGLISH, TextStyle.SHORT},
             {"Asia/Shanghai",    "CDT",                   preferred_s, Locale.ENGLISH, TextStyle.SHORT},
+            {"America/Juneau",   "AKST",                  none,        Locale.ENGLISH, TextStyle.SHORT},
+            {"America/Juneau",   "AKDT",                  none,        Locale.ENGLISH, TextStyle.SHORT},
+            {"Pacific/Honolulu", "HST",                   none,        Locale.ENGLISH, TextStyle.SHORT},
+            {"America/Halifax",  "AST",                   none,        Locale.ENGLISH, TextStyle.SHORT},
        };
     }
 
--- a/test/jdk/java/time/test/java/time/format/ZoneName.java	Tue Apr 10 18:56:07 2018 +0100
+++ b/test/jdk/java/time/test/java/time/format/ZoneName.java	Fri Apr 13 14:55:11 2018 -0400
@@ -20,13 +20,20 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package test.java.time.format;
 
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 
+/**
+ * A helper class to map a zone name to metazone and back to the
+ * appropriate zone id for the particular locale.
+ * <p>
+ * The zid<->metazone mappings are based on CLDR metaZones.xml.
+ * The alias mappings are based on Link entries in tzdb data files and
+ * CLDR's supplementalMetadata.xml.
+ */
 class ZoneName {
 
     public static String toZid(String zid, Locale locale) {
@@ -54,699 +61,850 @@
     }
 
     private static final String[] zidMap = new String[] {
-        "Asia/Bangkok", "Indochina", "Asia/Saigon",
-        "Pacific/Pago_Pago", "Samoa", "Pacific/Apia",
+        // From metaZones.xml
+        "Africa/Abidjan", "GMT", "Atlantic/Reykjavik",
+        "Africa/Accra", "GMT", "Atlantic/Reykjavik",
+        "Africa/Addis_Ababa", "Africa_Eastern", "Africa/Nairobi",
+        "Africa/Algiers", "Europe_Central", "Europe/Paris",
+        "Africa/Asmara", "Africa_Eastern", "Africa/Nairobi",
+        "Africa/Asmera", "Africa_Eastern", "Africa/Nairobi",
+        "Africa/Bamako", "GMT", "Atlantic/Reykjavik",
+        "Africa/Bangui", "Africa_Western", "Africa/Lagos",
+        "Africa/Banjul", "GMT", "Atlantic/Reykjavik",
+        "Africa/Bissau", "GMT", "Atlantic/Reykjavik",
         "Africa/Blantyre", "Africa_Central", "Africa/Maputo",
+        "Africa/Brazzaville", "Africa_Western", "Africa/Lagos",
+        "Africa/Bujumbura", "Africa_Central", "Africa/Maputo",
+        "Africa/Cairo", "Europe_Eastern", "Europe/Bucharest",
+        "Africa/Casablanca", "Europe_Western", "Atlantic/Canary",
+        "Africa/Ceuta", "Europe_Central", "Europe/Paris",
+        "Africa/Conakry", "GMT", "Atlantic/Reykjavik",
+        "Africa/Dakar", "GMT", "Atlantic/Reykjavik",
+        "Africa/Dar_es_Salaam", "Africa_Eastern", "Africa/Nairobi",
+        "Africa/Djibouti", "Africa_Eastern", "Africa/Nairobi",
+        "Africa/Douala", "Africa_Western", "Africa/Lagos",
+        "Africa/El_Aaiun", "Europe_Western", "Atlantic/Canary",
+        "Africa/Freetown", "GMT", "Atlantic/Reykjavik",
+        "Africa/Gaborone", "Africa_Central", "Africa/Maputo",
+        "Africa/Harare", "Africa_Central", "Africa/Maputo",
+        "Africa/Johannesburg", "Africa_Southern", "Africa/Johannesburg",
+        "Africa/Juba", "Africa_Eastern", "Africa/Nairobi",
+        "Africa/Kampala", "Africa_Eastern", "Africa/Nairobi",
+        "Africa/Khartoum", "Africa_Eastern", "Africa/Nairobi",
+        "Africa/Kigali", "Africa_Central", "Africa/Maputo",
+        "Africa/Kinshasa", "Africa_Western", "Africa/Lagos",
+        "Africa/Lagos", "Africa_Western", "Africa/Lagos",
+        "Africa/Libreville", "Africa_Western", "Africa/Lagos",
+        "Africa/Lome", "GMT", "Atlantic/Reykjavik",
+        "Africa/Luanda", "Africa_Western", "Africa/Lagos",
+        "Africa/Lubumbashi", "Africa_Central", "Africa/Maputo",
+        "Africa/Lusaka", "Africa_Central", "Africa/Maputo",
+        "Africa/Malabo", "Africa_Western", "Africa/Lagos",
+        "Africa/Maputo", "Africa_Central", "Africa/Maputo",
+        "Africa/Maseru", "Africa_Southern", "Africa/Johannesburg",
+        "Africa/Mbabane", "Africa_Southern", "Africa/Johannesburg",
+        "Africa/Mogadishu", "Africa_Eastern", "Africa/Nairobi",
+        "Africa/Monrovia", "GMT", "Atlantic/Reykjavik",
+        "Africa/Nairobi", "Africa_Eastern", "Africa/Nairobi",
+        "Africa/Ndjamena", "Africa_Western", "Africa/Lagos",
+        "Africa/Niamey", "Africa_Western", "Africa/Lagos",
+        "Africa/Nouakchott", "GMT", "Atlantic/Reykjavik",
+        "Africa/Ouagadougou", "GMT", "Atlantic/Reykjavik",
+        "Africa/Porto-Novo", "Africa_Western", "Africa/Lagos",
+        "Africa/Sao_Tome", "GMT", "Atlantic/Reykjavik",
+        "Africa/Timbuktu", "GMT", "Atlantic/Reykjavik",
+        "Africa/Tripoli", "Europe_Eastern", "Europe/Bucharest",
+        "Africa/Tunis", "Europe_Central", "Europe/Paris",
+        "Africa/Windhoek", "Africa_Western", "Africa/Lagos",
+        "America/Adak", "Hawaii_Aleutian", "Pacific/Honolulu",
+        "America/Anchorage", "Alaska", "America/Juneau",
+        "America/Anguilla", "Atlantic", "America/Halifax",
+        "America/Antigua", "Atlantic", "America/Halifax",
+        "America/Araguaina", "Brasilia", "America/Sao_Paulo",
+        "America/Argentina/Buenos_Aires", "Argentina", "America/Buenos_Aires",
+        "America/Argentina/Catamarca", "Argentina", "America/Buenos_Aires",
+        "America/Argentina/ComodRivadavia", "Argentina", "America/Buenos_Aires",
+        "America/Argentina/Cordoba", "Argentina", "America/Buenos_Aires",
+        "America/Argentina/Jujuy", "Argentina", "America/Buenos_Aires",
+        "America/Argentina/La_Rioja", "Argentina", "America/Buenos_Aires",
+        "America/Argentina/Mendoza", "Argentina", "America/Buenos_Aires",
+        "America/Argentina/Rio_Gallegos", "Argentina", "America/Buenos_Aires",
+        "America/Argentina/Salta", "Argentina", "America/Buenos_Aires",
         "America/Argentina/San_Juan", "Argentina", "America/Buenos_Aires",
-        "America/Cancun", "America_Central", "America/Chicago",
+        "America/Argentina/San_Luis", "Argentina_Western", "America/Argentina/San_Luis",
+        "America/Argentina/Tucuman", "Argentina", "America/Buenos_Aires",
+        "America/Argentina/Ushuaia", "Argentina", "America/Buenos_Aires",
+        "America/Aruba", "Atlantic", "America/Halifax",
+        "America/Asuncion", "Paraguay", "America/Asuncion",
+        "America/Atikokan", "America_Eastern", "America/New_York",
+        "America/Atka", "Hawaii_Aleutian", "Pacific/Honolulu",
+        "America/Bahia", "Brasilia", "America/Sao_Paulo",
+        "America/Bahia_Banderas", "America_Central", "America/Chicago",
+        "America/Barbados", "Atlantic", "America/Halifax",
+        "America/Belem", "Brasilia", "America/Sao_Paulo",
+        "America/Belize", "America_Central", "America/Chicago",
+        "America/Blanc-Sablon", "Atlantic", "America/Halifax",
+        "America/Boa_Vista", "Amazon", "America/Manaus",
+        "America/Bogota", "Colombia", "America/Bogota",
+        "America/Boise", "America_Mountain", "America/Denver",
+        "America/Buenos_Aires", "Argentina", "America/Buenos_Aires",
+        "America/Cambridge_Bay", "America_Mountain", "America/Denver",
+        "America/Campo_Grande", "Amazon", "America/Manaus",
+        "America/Cancun", "America_Eastern", "America/New_York",
+        "America/Caracas", "Venezuela", "America/Caracas",
+        "America/Catamarca", "Argentina", "America/Buenos_Aires",
+        "America/Cayenne", "French_Guiana", "America/Cayenne",
+        "America/Cayman", "America_Eastern", "America/New_York",
+        "America/Chicago", "America_Central", "America/Chicago",
+        "America/Chihuahua", "Mexico_Pacific", "America/Mazatlan",
+        "America/Coral_Harbour", "America_Eastern", "America/New_York",
+        "America/Cordoba", "Argentina", "America/Buenos_Aires",
+        "America/Costa_Rica", "America_Central", "America/Chicago",
+        "America/Creston", "America_Mountain", "America/Denver",
+        "America/Cuiaba", "Amazon", "America/Manaus",
+        "America/Curacao", "Atlantic", "America/Halifax",
+        "America/Danmarkshavn", "GMT", "Atlantic/Reykjavik",
+        "America/Dawson", "America_Pacific", "America/Los_Angeles",
+        "America/Dawson_Creek", "America_Mountain", "America/Denver",
+        "America/Denver", "America_Mountain", "America/Denver",
+        "America/Detroit", "America_Eastern", "America/New_York",
+        "America/Dominica", "Atlantic", "America/Halifax",
+        "America/Edmonton", "America_Mountain", "America/Denver",
+        "America/Eirunepe", "Acre", "America/Rio_Branco",
+        "America/El_Salvador", "America_Central", "America/Chicago",
+        "America/Ensenada", "America_Pacific", "America/Los_Angeles",
+        "America/Fort_Nelson", "America_Mountain", "America/Denver",
+        "America/Fort_Wayne", "America_Eastern", "America/New_York",
+        "America/Fortaleza", "Brasilia", "America/Sao_Paulo",
+        "America/Glace_Bay", "Atlantic", "America/Halifax",
+        "America/Godthab", "Greenland_Western", "America/Godthab",
+        "America/Goose_Bay", "Atlantic", "America/Halifax",
+        "America/Grand_Turk", "Atlantic", "America/Halifax",
+        "America/Grenada", "Atlantic", "America/Halifax",
+        "America/Guadeloupe", "Atlantic", "America/Halifax",
+        "America/Guatemala", "America_Central", "America/Chicago",
+        "America/Guayaquil", "Ecuador", "America/Guayaquil",
+        "America/Guyana", "Guyana", "America/Guyana",
+        "America/Halifax", "Atlantic", "America/Halifax",
+        "America/Havana", "Cuba", "America/Havana",
+        "America/Hermosillo", "Mexico_Pacific", "America/Mazatlan",
+        "America/Indiana/Indianapolis", "America_Eastern", "America/New_York",
+        "America/Indiana/Knox", "America_Central", "America/Chicago",
+        "America/Indiana/Marengo", "America_Eastern", "America/New_York",
+        "America/Indiana/Petersburg", "America_Eastern", "America/New_York",
+        "America/Indiana/Tell_City", "America_Central", "America/Chicago",
+        "America/Indiana/Vevay", "America_Eastern", "America/New_York",
+        "America/Indiana/Vincennes", "America_Eastern", "America/New_York",
+        "America/Indiana/Winamac", "America_Eastern", "America/New_York",
+        "America/Indianapolis", "America_Eastern", "America/New_York",
+        "America/Inuvik", "America_Mountain", "America/Denver",
+        "America/Iqaluit", "America_Eastern", "America/New_York",
+        "America/Jamaica", "America_Eastern", "America/New_York",
+        "America/Jujuy", "Argentina", "America/Buenos_Aires",
+        "America/Juneau", "Alaska", "America/Juneau",
+        "America/Kentucky/Louisville", "America_Eastern", "America/New_York",
+        "America/Kentucky/Monticello", "America_Eastern", "America/New_York",
+        "America/Knox_IN", "America_Central", "America/Chicago",
+        "America/Kralendijk", "Atlantic", "America/Halifax",
+        "America/La_Paz", "Bolivia", "America/La_Paz",
+        "America/Lima", "Peru", "America/Lima",
+        "America/Los_Angeles", "America_Pacific", "America/Los_Angeles",
+        "America/Louisville", "America_Eastern", "America/New_York",
+        "America/Lower_Princes", "Atlantic", "America/Halifax",
+        "America/Maceio", "Brasilia", "America/Sao_Paulo",
+        "America/Managua", "America_Central", "America/Chicago",
+        "America/Manaus", "Amazon", "America/Manaus",
+        "America/Marigot", "Atlantic", "America/Halifax",
+        "America/Martinique", "Atlantic", "America/Halifax",
+        "America/Matamoros", "America_Central", "America/Chicago",
+        "America/Mazatlan", "Mexico_Pacific", "America/Mazatlan",
+        "America/Mendoza", "Argentina", "America/Buenos_Aires",
+        "America/Menominee", "America_Central", "America/Chicago",
+        "America/Merida", "America_Central", "America/Chicago",
+        "America/Metlakatla", "Alaska", "America/Juneau",
+        "America/Mexico_City", "America_Central", "America/Chicago",
+        "America/Miquelon", "Pierre_Miquelon", "America/Miquelon",
+        "America/Moncton", "Atlantic", "America/Halifax",
+        "America/Monterrey", "America_Central", "America/Chicago",
+        "America/Montevideo", "Uruguay", "America/Montevideo",
+        "America/Montserrat", "Atlantic", "America/Halifax",
+        "America/Nassau", "America_Eastern", "America/New_York",
+        "America/New_York", "America_Eastern", "America/New_York",
+        "America/Nipigon", "America_Eastern", "America/New_York",
+        "America/Nome", "Alaska", "America/Juneau",
+        "America/Noronha", "Noronha", "America/Noronha",
+        "America/North_Dakota/Beulah", "America_Central", "America/Chicago",
+        "America/North_Dakota/Center", "America_Central", "America/Chicago",
+        "America/North_Dakota/New_Salem", "America_Central", "America/Chicago",
+        "America/Ojinaga", "America_Mountain", "America/Denver",
+        "America/Panama", "America_Eastern", "America/New_York",
+        "America/Pangnirtung", "America_Eastern", "America/New_York",
+        "America/Paramaribo", "Suriname", "America/Paramaribo",
+        "America/Phoenix", "America_Mountain", "America/Denver",
+        "America/Port-au-Prince", "America_Eastern", "America/New_York",
+        "America/Port_of_Spain", "Atlantic", "America/Halifax",
+        "America/Porto_Acre", "Acre", "America/Rio_Branco",
+        "America/Porto_Velho", "Amazon", "America/Manaus",
+        "America/Puerto_Rico", "Atlantic", "America/Halifax",
+        "America/Rainy_River", "America_Central", "America/Chicago",
+        "America/Rankin_Inlet", "America_Central", "America/Chicago",
+        "America/Recife", "Brasilia", "America/Sao_Paulo",
+        "America/Regina", "America_Central", "America/Chicago",
+        "America/Resolute", "America_Central", "America/Chicago",
+        "America/Rio_Branco", "Acre", "America/Rio_Branco",
+        "America/Rosario", "Argentina", "America/Buenos_Aires",
+        "America/Santa_Isabel", "Mexico_Northwest", "America/Santa_Isabel",
+        "America/Santarem", "Brasilia", "America/Sao_Paulo",
+        "America/Santiago", "Chile", "America/Santiago",
+        "America/Santo_Domingo", "Atlantic", "America/Halifax",
+        "America/Sao_Paulo", "Brasilia", "America/Sao_Paulo",
+        "America/Scoresbysund", "Greenland_Eastern", "America/Scoresbysund",
+        "America/Shiprock", "America_Mountain", "America/Denver",
+        "America/Sitka", "Alaska", "America/Juneau",
+        "America/St_Barthelemy", "Atlantic", "America/Halifax",
+        "America/St_Johns", "Newfoundland", "America/St_Johns",
+        "America/St_Kitts", "Atlantic", "America/Halifax",
+        "America/St_Lucia", "Atlantic", "America/Halifax",
+        "America/St_Thomas", "Atlantic", "America/Halifax",
+        "America/St_Vincent", "Atlantic", "America/Halifax",
+        "America/Swift_Current", "America_Central", "America/Chicago",
+        "America/Tegucigalpa", "America_Central", "America/Chicago",
+        "America/Thule", "Atlantic", "America/Halifax",
+        "America/Thunder_Bay", "America_Eastern", "America/New_York",
+        "America/Tijuana", "America_Pacific", "America/Los_Angeles",
+        "America/Toronto", "America_Eastern", "America/New_York",
+        "America/Tortola", "Atlantic", "America/Halifax",
+        "America/Vancouver", "America_Pacific", "America/Los_Angeles",
+        "America/Virgin", "Atlantic", "America/Halifax",
+        "America/Whitehorse", "America_Pacific", "America/Los_Angeles",
+        "America/Winnipeg", "America_Central", "America/Chicago",
+        "America/Yakutat", "Alaska", "America/Juneau",
+        "America/Yellowknife", "America_Mountain", "America/Denver",
+        "Antarctica/Casey", "Australia_Western", "Australia/Perth",
+        "Antarctica/Davis", "Davis", "Antarctica/Davis",
+        "Antarctica/DumontDUrville", "DumontDUrville", "Antarctica/DumontDUrville",
+        "Antarctica/Macquarie", "Macquarie", "Antarctica/Macquarie",
+        "Antarctica/Mawson", "Mawson", "Antarctica/Mawson",
+        "Antarctica/McMurdo", "New_Zealand", "Pacific/Auckland",
+        "Antarctica/Palmer", "Chile", "America/Santiago",
+        "Antarctica/Rothera", "Rothera", "Antarctica/Rothera",
+        "Antarctica/South_Pole", "New_Zealand", "Pacific/Auckland",
+        "Antarctica/Syowa", "Syowa", "Antarctica/Syowa",
+        "Antarctica/Troll", "GMT", "Atlantic/Reykjavik",
+        "Antarctica/Vostok", "Vostok", "Antarctica/Vostok",
+        "Arctic/Longyearbyen", "Europe_Central", "Europe/Paris",
+        "Asia/Aden", "Arabian", "Asia/Riyadh",
+        "Asia/Almaty", "Kazakhstan_Eastern", "Asia/Almaty",
+        "Asia/Amman", "Europe_Eastern", "Europe/Bucharest",
+        "Asia/Anadyr", "Magadan", "Asia/Magadan",
+        "Asia/Aqtau", "Kazakhstan_Western", "Asia/Aqtobe",
+        "Asia/Aqtobe", "Kazakhstan_Western", "Asia/Aqtobe",
+        "Asia/Ashgabat", "Turkmenistan", "Asia/Ashgabat",
+        "Asia/Ashkhabad", "Turkmenistan", "Asia/Ashgabat",
+        "Asia/Baghdad", "Arabian", "Asia/Riyadh",
+        "Asia/Bahrain", "Arabian", "Asia/Riyadh",
+        "Asia/Baku", "Azerbaijan", "Asia/Baku",
+        "Asia/Bangkok", "Indochina", "Asia/Bangkok",
+        "Asia/Beirut", "Europe_Eastern", "Europe/Bucharest",
+        "Asia/Bishkek", "Kyrgystan", "Asia/Bishkek",
+        "Asia/Brunei", "Brunei", "Asia/Brunei",
+        "Asia/Calcutta", "India", "Asia/Calcutta",
+        "Asia/Chita", "Yakutsk", "Asia/Yakutsk",
+        "Asia/Choibalsan", "Choibalsan", "Asia/Choibalsan",
+        "Asia/Chongqing", "China", "Asia/Shanghai",
+        "Asia/Chungking", "China", "Asia/Shanghai",
+        "Asia/Colombo", "India", "Asia/Calcutta",
+        "Asia/Dacca", "Bangladesh", "Asia/Dhaka",
+        "Asia/Damascus", "Europe_Eastern", "Europe/Bucharest",
+        "Asia/Dhaka", "Bangladesh", "Asia/Dhaka",
+        "Asia/Dili", "East_Timor", "Asia/Dili",
+        "Asia/Dubai", "Gulf", "Asia/Dubai",
+        "Asia/Dushanbe", "Tajikistan", "Asia/Dushanbe",
+        "Asia/Gaza", "Europe_Eastern", "Europe/Bucharest",
+        "Asia/Harbin", "China", "Asia/Shanghai",
+        "Asia/Hebron", "Europe_Eastern", "Europe/Bucharest",
+        "Asia/Ho_Chi_Minh", "Indochina", "Asia/Bangkok",
+        "Asia/Hong_Kong", "Hong_Kong", "Asia/Hong_Kong",
+        "Asia/Hovd", "Hovd", "Asia/Hovd",
+        "Asia/Irkutsk", "Irkutsk", "Asia/Irkutsk",
+        "Asia/Istanbul", "Europe_Eastern", "Europe/Bucharest",
+        "Asia/Jakarta", "Indonesia_Western", "Asia/Jakarta",
+        "Asia/Jayapura", "Indonesia_Eastern", "Asia/Jayapura",
+        "Asia/Jerusalem", "Israel", "Asia/Jerusalem",
+        "Asia/Kabul", "Afghanistan", "Asia/Kabul",
+        "Asia/Kamchatka", "Kamchatka", "Asia/Kamchatka",
+        "Asia/Karachi", "Pakistan", "Asia/Karachi",
+        "Asia/Kashgar", "Urumqi", "Asia/Urumqi",
+        "Asia/Kathmandu", "Nepal", "Asia/Katmandu",
+        "Asia/Katmandu", "Nepal", "Asia/Katmandu",
+        "Asia/Khandyga", "Yakutsk", "Asia/Yakutsk",
+        "Asia/Kolkata", "India", "Asia/Calcutta",
+        "Asia/Krasnoyarsk", "Krasnoyarsk", "Asia/Krasnoyarsk",
+        "Asia/Kuala_Lumpur", "Malaysia", "Asia/Kuching",
+        "Asia/Kuching", "Malaysia", "Asia/Kuching",
+        "Asia/Kuwait", "Arabian", "Asia/Riyadh",
+        "Asia/Macao", "China", "Asia/Shanghai",
+        "Asia/Macau", "China", "Asia/Shanghai",
+        "Asia/Magadan", "Magadan", "Asia/Magadan",
+        "Asia/Makassar", "Indonesia_Central", "Asia/Makassar",
+        "Asia/Manila", "Philippines", "Asia/Manila",
+        "Asia/Muscat", "Gulf", "Asia/Dubai",
+        "Asia/Nicosia", "Europe_Eastern", "Europe/Bucharest",
+        "Asia/Novokuznetsk", "Krasnoyarsk", "Asia/Krasnoyarsk",
+        "Asia/Novosibirsk", "Novosibirsk", "Asia/Novosibirsk",
+        "Asia/Omsk", "Omsk", "Asia/Omsk",
+        "Asia/Oral", "Kazakhstan_Western", "Asia/Aqtobe",
+        "Asia/Phnom_Penh", "Indochina", "Asia/Bangkok",
+        "Asia/Pontianak", "Indonesia_Western", "Asia/Jakarta",
+        "Asia/Pyongyang", "Pyongyang", "Asia/Pyongyang",
+        "Asia/Qatar", "Arabian", "Asia/Riyadh",
+        "Asia/Qyzylorda", "Kazakhstan_Eastern", "Asia/Almaty",
+        "Asia/Rangoon", "Myanmar", "Asia/Rangoon",
+        "Asia/Riyadh", "Arabian", "Asia/Riyadh",
+        "Asia/Saigon", "Indochina", "Asia/Bangkok",
+        "Asia/Sakhalin", "Sakhalin", "Asia/Sakhalin",
+        "Asia/Samarkand", "Uzbekistan", "Asia/Tashkent",
+        "Asia/Seoul", "Korea", "Asia/Seoul",
+        "Asia/Shanghai", "China", "Asia/Shanghai",
+        "Asia/Singapore", "Singapore", "Asia/Singapore",
+        "Asia/Srednekolymsk", "Singapore", "Asia/Singapore",
+        "Asia/Taipei", "Taipei", "Asia/Taipei",
+        "Asia/Tashkent", "Uzbekistan", "Asia/Tashkent",
+        "Asia/Tbilisi", "Georgia", "Asia/Tbilisi",
+        "Asia/Tehran", "Iran", "Asia/Tehran",
+        "Asia/Tel_Aviv", "Israel", "Asia/Jerusalem",
+        "Asia/Thimbu", "Bhutan", "Asia/Thimphu",
+        "Asia/Thimphu", "Bhutan", "Asia/Thimphu",
+        "Asia/Tokyo", "Japan", "Asia/Tokyo",
+        "Asia/Ujung_Pandang", "Indonesia_Central", "Asia/Makassar",
+        "Asia/Ulaanbaatar", "Mongolia", "Asia/Ulaanbaatar",
+        "Asia/Ulan_Bator", "Mongolia", "Asia/Ulaanbaatar",
+        "Asia/Urumqi", "Urumqi", "Asia/Urumqi",
+        "Asia/Ust-Nera", "Vladivostok", "Asia/Vladivostok",
+        "Asia/Vientiane", "Indochina", "Asia/Bangkok",
+        "Asia/Vladivostok", "Vladivostok", "Asia/Vladivostok",
+        "Asia/Yakutsk", "Yakutsk", "Asia/Yakutsk",
+        "Asia/Yekaterinburg", "Yekaterinburg", "Asia/Yekaterinburg",
+        "Asia/Yerevan", "Armenia", "Asia/Yerevan",
+        "Atlantic/Azores", "Azores", "Atlantic/Azores",
+        "Atlantic/Bermuda", "Atlantic", "America/Halifax",
+        "Atlantic/Canary", "Europe_Western", "Atlantic/Canary",
+        "Atlantic/Cape_Verde", "Cape_Verde", "Atlantic/Cape_Verde",
+        "Atlantic/Faeroe", "Europe_Western", "Atlantic/Canary",
+        "Atlantic/Faroe", "Europe_Western", "Atlantic/Canary",
+        "Atlantic/Jan_Mayen", "Europe_Central", "Europe/Paris",
+        "Atlantic/Madeira", "Europe_Western", "Atlantic/Canary",
+        "Atlantic/Reykjavik", "GMT", "Atlantic/Reykjavik",
+        "Atlantic/South_Georgia", "South_Georgia", "Atlantic/South_Georgia",
+        "Atlantic/St_Helena", "GMT", "Atlantic/Reykjavik",
+        "Atlantic/Stanley", "Falkland", "Atlantic/Stanley",
+        "Australia/ACT", "Australia_Eastern", "Australia/Sydney",
+        "Australia/Adelaide", "Australia_Central", "Australia/Adelaide",
+        "Australia/Brisbane", "Australia_Eastern", "Australia/Sydney",
+        "Australia/Broken_Hill", "Australia_Central", "Australia/Adelaide",
+        "Australia/Canberra", "Australia_Eastern", "Australia/Sydney",
+        "Australia/Currie", "Australia_Eastern", "Australia/Sydney",
+        "Australia/Darwin", "Australia_Central", "Australia/Adelaide",
+        "Australia/Eucla", "Australia_CentralWestern", "Australia/Eucla",
+        "Australia/Hobart", "Australia_Eastern", "Australia/Sydney",
+        "Australia/LHI", "Lord_Howe", "Australia/Lord_Howe",
+        "Australia/Lindeman", "Australia_Eastern", "Australia/Sydney",
+        "Australia/Lord_Howe", "Lord_Howe", "Australia/Lord_Howe",
+        "Australia/Melbourne", "Australia_Eastern", "Australia/Sydney",
+        "Australia/NSW", "Australia_Eastern", "Australia/Sydney",
+        "Australia/North", "Australia_Central", "Australia/Adelaide",
+        "Australia/Perth", "Australia_Western", "Australia/Perth",
+        "Australia/Queensland", "Australia_Eastern", "Australia/Sydney",
+        "Australia/South", "Australia_Central", "Australia/Adelaide",
+        "Australia/Sydney", "Australia_Eastern", "Australia/Sydney",
+        "Australia/Tasmania", "Australia_Eastern", "Australia/Sydney",
+        "Australia/Victoria", "Australia_Eastern", "Australia/Sydney",
+        "Australia/West", "Australia_Western", "Australia/Perth",
+        "Australia/Yancowinna", "Australia_Central", "Australia/Adelaide",
+        "Brazil/Acre", "Acre", "America/Rio_Branco",
+        "Brazil/DeNoronha", "Noronha", "America/Noronha",
+        "Brazil/East", "Brasilia", "America/Sao_Paulo",
+        "Brazil/West", "Amazon", "America/Manaus",
+        "CST6CDT", "America_Central", "America/Chicago",
+        "Canada/Atlantic", "Atlantic", "America/Halifax",
+        "Canada/Central", "America_Central", "America/Chicago",
+        "Canada/East-Saskatchewan", "America_Central", "America/Chicago",
+        "Canada/Eastern", "America_Eastern", "America/New_York",
+        "Canada/Mountain", "America_Mountain", "America/Denver",
+        "Canada/Newfoundland", "Newfoundland", "America/St_Johns",
+        "Canada/Pacific", "America_Pacific", "America/Los_Angeles",
+        "Canada/Saskatchewan", "America_Central", "America/Chicago",
+        "Canada/Yukon", "America_Pacific", "America/Los_Angeles",
+        "Chile/Continental", "Chile", "America/Santiago",
+        "Chile/EasterIsland", "Easter", "Pacific/Easter",
+        "Cuba", "Cuba", "America/Havana",
+        "EST5EDT", "America_Eastern", "America/New_York",
+        "Egypt", "Europe_Eastern", "Europe/Bucharest",
+        "Eire", "GMT", "Atlantic/Reykjavik",
+        "Europe/Amsterdam", "Europe_Central", "Europe/Paris",
+        "Europe/Andorra", "Europe_Central", "Europe/Paris",
+        "Europe/Athens", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Belfast", "GMT", "Atlantic/Reykjavik",
+        "Europe/Belgrade", "Europe_Central", "Europe/Paris",
+        "Europe/Berlin", "Europe_Central", "Europe/Paris",
+        "Europe/Bratislava", "Europe_Central", "Europe/Paris",
+        "Europe/Brussels", "Europe_Central", "Europe/Paris",
+        "Europe/Bucharest", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Budapest", "Europe_Central", "Europe/Paris",
+        "Europe/Busingen", "Europe_Central", "Europe/Paris",
+        "Europe/Chisinau", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Copenhagen", "Europe_Central", "Europe/Paris",
+        "Europe/Dublin", "GMT", "Atlantic/Reykjavik",
+        "Europe/Gibraltar", "Europe_Central", "Europe/Paris",
+        "Europe/Guernsey", "GMT", "Atlantic/Reykjavik",
+        "Europe/Helsinki", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Isle_of_Man", "GMT", "Atlantic/Reykjavik",
+        "Europe/Istanbul", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Jersey", "GMT", "Atlantic/Reykjavik",
+        "Europe/Kaliningrad", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Kiev", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Lisbon", "Europe_Western", "Atlantic/Canary",
+        "Europe/Ljubljana", "Europe_Central", "Europe/Paris",
+        "Europe/London", "GMT", "Atlantic/Reykjavik",
+        "Europe/Luxembourg", "Europe_Central", "Europe/Paris",
+        "Europe/Madrid", "Europe_Central", "Europe/Paris",
+        "Europe/Malta", "Europe_Central", "Europe/Paris",
+        "Europe/Mariehamn", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Minsk", "Europe_Further_Eastern", "Europe/Minsk",
+        "Europe/Monaco", "Europe_Central", "Europe/Paris",
+        "Europe/Moscow", "Moscow", "Europe/Moscow",
+        "Europe/Nicosia", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Oslo", "Europe_Central", "Europe/Paris",
+        "Europe/Paris", "Europe_Central", "Europe/Paris",
+        "Europe/Podgorica", "Europe_Central", "Europe/Paris",
+        "Europe/Prague", "Europe_Central", "Europe/Paris",
+        "Europe/Riga", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Rome", "Europe_Central", "Europe/Paris",
+        "Europe/Samara", "Samara", "Europe/Samara",
+        "Europe/San_Marino", "Europe_Central", "Europe/Paris",
+        "Europe/Sarajevo", "Europe_Central", "Europe/Paris",
+        "Europe/Simferopol", "Moscow", "Europe/Moscow",
+        "Europe/Skopje", "Europe_Central", "Europe/Paris",
+        "Europe/Sofia", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Stockholm", "Europe_Central", "Europe/Paris",
+        "Europe/Tallinn", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Tirane", "Europe_Central", "Europe/Paris",
+        "Europe/Tiraspol", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Uzhgorod", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Vaduz", "Europe_Central", "Europe/Paris",
+        "Europe/Vatican", "Europe_Central", "Europe/Paris",
+        "Europe/Vienna", "Europe_Central", "Europe/Paris",
+        "Europe/Vilnius", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Volgograd", "Moscow", "Europe/Moscow",
+        "Europe/Warsaw", "Europe_Central", "Europe/Paris",
+        "Europe/Zagreb", "Europe_Central", "Europe/Paris",
+        "Europe/Zaporozhye", "Europe_Eastern", "Europe/Bucharest",
+        "Europe/Zurich", "Europe_Central", "Europe/Paris",
+        "GB", "GMT", "Atlantic/Reykjavik",
+        "GB-Eire", "GMT", "Atlantic/Reykjavik",
+        "Hongkong", "Hong_Kong", "Asia/Hong_Kong",
+        "Iceland", "GMT", "Atlantic/Reykjavik",
+        "Indian/Antananarivo", "Africa_Eastern", "Africa/Nairobi",
+        "Indian/Chagos", "Indian_Ocean", "Indian/Chagos",
+        "Indian/Christmas", "Christmas", "Indian/Christmas",
+        "Indian/Cocos", "Cocos", "Indian/Cocos",
+        "Indian/Comoro", "Africa_Eastern", "Africa/Nairobi",
+        "Indian/Kerguelen", "French_Southern", "Indian/Kerguelen",
+        "Indian/Mahe", "Seychelles", "Indian/Mahe",
+        "Indian/Maldives", "Maldives", "Indian/Maldives",
+        "Indian/Mauritius", "Mauritius", "Indian/Mauritius",
+        "Indian/Mayotte", "Africa_Eastern", "Africa/Nairobi",
+        "Indian/Reunion", "Reunion", "Indian/Reunion",
+        "Iran", "Iran", "Asia/Tehran",
+        "Israel", "Israel", "Asia/Jerusalem",
+        "Jamaica", "America_Eastern", "America/New_York",
+        "Japan", "Japan", "Asia/Tokyo",
+        "Kwajalein", "Marshall_Islands", "Pacific/Majuro",
+        "Libya", "Europe_Eastern", "Europe/Bucharest",
+        "MST7MDT", "America_Mountain", "America/Denver",
+        "Mexico/BajaNorte", "America_Pacific", "America/Los_Angeles",
+        "Mexico/BajaSur", "Mexico_Pacific", "America/Mazatlan",
+        "Mexico/General", "America_Central", "America/Chicago",
+        "NZ", "New_Zealand", "Pacific/Auckland",
+        "NZ-CHAT", "Chatham", "Pacific/Chatham",
+        "Navajo", "America_Mountain", "America/Denver",
+        "PRC", "China", "Asia/Shanghai",
+        "PST8PDT", "America_Pacific", "America/Los_Angeles",
+        "Pacific/Apia", "Apia", "Pacific/Apia",
+        "Pacific/Auckland", "New_Zealand", "Pacific/Auckland",
+        "Pacific/Bougainville", "New_Zealand", "Pacific/Auckland",
+        "Pacific/Chatham", "Chatham", "Pacific/Chatham",
+        "Pacific/Chuuk", "Truk", "Pacific/Truk",
+        "Pacific/Easter", "Easter", "Pacific/Easter",
+        "Pacific/Efate", "Vanuatu", "Pacific/Efate",
+        "Pacific/Enderbury", "Phoenix_Islands", "Pacific/Enderbury",
+        "Pacific/Fakaofo", "Tokelau", "Pacific/Fakaofo",
+        "Pacific/Fiji", "Fiji", "Pacific/Fiji",
+        "Pacific/Funafuti", "Tuvalu", "Pacific/Funafuti",
+        "Pacific/Galapagos", "Galapagos", "Pacific/Galapagos",
+        "Pacific/Gambier", "Gambier", "Pacific/Gambier",
+        "Pacific/Guadalcanal", "Solomon", "Pacific/Guadalcanal",
+        "Pacific/Guam", "Chamorro", "Pacific/Saipan",
+        "Pacific/Honolulu", "Hawaii_Aleutian", "Pacific/Honolulu",
+        "Pacific/Johnston", "Hawaii_Aleutian", "Pacific/Honolulu",
+        "Pacific/Kiritimati", "Line_Islands", "Pacific/Kiritimati",
+        "Pacific/Kosrae", "Kosrae", "Pacific/Kosrae",
+        "Pacific/Kwajalein", "Marshall_Islands", "Pacific/Majuro",
+        "Pacific/Majuro", "Marshall_Islands", "Pacific/Majuro",
+        "Pacific/Marquesas", "Marquesas", "Pacific/Marquesas",
+        "Pacific/Midway", "Samoa", "Pacific/Pago_Pago",
         "Pacific/Nauru", "Nauru", "Pacific/Nauru",
-        "America/Atikokan", "America_Eastern", "America/New_York",
-        "Africa/Asmara", "Africa_Eastern", "Africa/Nairobi",
-        "Europe/Berlin", "Europe_Central", "Europe/Paris",
-        "Asia/Kolkata", "India", "Asia/Calcutta",
-        "Australia/Darwin", "Australia_Central", "Australia/Adelaide",
-        "America/Guayaquil", "Ecuador", "America/Guayaquil",
-        "Europe/Vienna", "Europe_Central", "Europe/Paris",
-        "Atlantic/St_Helena", "GMT", "Atlantic/Reykjavik",
-        "Europe/London", "GMT", "Atlantic/Reykjavik",
-        "Europe/Moscow", "Moscow", "Europe/Moscow",
-        "America/St_Vincent", "Atlantic", "America/Halifax",
-        "America/Bogota", "Colombia", "America/Bogota",
-        "America/Marigot", "Atlantic", "America/Halifax",
-        "Europe/Sarajevo", "Europe_Central", "Europe/Paris",
-        "America/Hermosillo", "America_Mountain", "America/Denver",
-        "America/Winnipeg", "America_Central", "America/Chicago",
-        "America/Rainy_River", "America_Central", "America/Chicago",
-        "Indian/Mahe", "Seychelles", "Indian/Mahe",
-        "Africa/Freetown", "GMT", "Atlantic/Reykjavik",
-        "America/Grand_Turk", "America_Eastern", "America/New_York",
-        "America/Argentina/Ushuaia", "Argentina", "America/Buenos_Aires",
-        "Atlantic/Azores", "Azores", "Atlantic/Azores",
-        "Asia/Harbin", "China", "Asia/Shanghai",
-        "America/Cuiaba", "Amazon", "America/Manaus",
-        "Asia/Bahrain", "Arabian", "Asia/Riyadh",
-        "Asia/Katmandu", "Nepal", "Asia/Katmandu",
-        "Pacific/Galapagos", "Galapagos", "Pacific/Galapagos",
-        "Asia/Brunei", "Brunei", "Asia/Brunei",
-        "Africa/Kigali", "Africa_Central", "Africa/Maputo",
-        "Asia/Makassar", "Indonesia_Central", "Asia/Makassar",
-        "Africa/Maputo", "Africa_Central", "Africa/Maputo",
-        "Asia/Kamchatka", "Magadan", "Asia/Magadan",
-        "Atlantic/Faroe", "Europe_Western", "Atlantic/Canary",
-        "America/El_Salvador", "America_Central", "America/Chicago",
-        "Asia/Saigon", "Indochina", "Asia/Saigon",
-        "Africa/Kinshasa", "Africa_Western", "Africa/Lagos",
-        "Europe/Oslo", "Europe_Central", "Europe/Paris",
-        "Asia/Hong_Kong", "Hong_Kong", "Asia/Hong_Kong",
-        "Pacific/Midway", "Samoa", "Pacific/Apia",
-        "Africa/Douala", "Africa_Western", "Africa/Lagos",
-        "Europe/San_Marino", "Europe_Central", "Europe/Paris",
-        "Pacific/Chuuk", "Truk", "Pacific/Truk",
-        "Africa/Gaborone", "Africa_Central", "Africa/Maputo",
-        "Africa/Tunis", "Europe_Central", "Europe/Paris",
-        "Africa/Khartoum", "Africa_Central", "Africa/Maputo",
-        "Europe/Isle_of_Man", "GMT", "Atlantic/Reykjavik",
-        "Europe/Skopje", "Europe_Central", "Europe/Paris",
-        "America/Merida", "America_Central", "America/Chicago",
-        "Antarctica/DumontDUrville", "DumontDUrville", "Antarctica/DumontDUrville",
-        "Atlantic/Reykjavik", "GMT", "Atlantic/Reykjavik",
-        "Indian/Mauritius", "Mauritius", "Indian/Mauritius",
-        "Africa/Malabo", "Africa_Western", "Africa/Lagos",
-        "Africa/Juba", "Africa_Eastern", "Africa/Nairobi",
-        "America/Resolute", "America_Central", "America/Chicago",
-        "Africa/Abidjan", "GMT", "Atlantic/Reykjavik",
-        "Antarctica/McMurdo", "New_Zealand", "Pacific/Auckland",
-        "Asia/Thimphu", "Bhutan", "Asia/Thimphu",
-        "Europe/Zaporozhye", "Europe_Eastern", "Europe/Bucharest",
-        "Antarctica/Davis", "Davis", "Antarctica/Davis",
-        "Indian/Antananarivo", "Africa_Eastern", "Africa/Nairobi",
-        "Africa/Harare", "Africa_Central", "Africa/Maputo",
-        "Pacific/Marquesas", "Marquesas", "Pacific/Marquesas",
-        "Africa/Tripoli", "Europe_Eastern", "Europe/Bucharest",
-        "America/North_Dakota/Beulah", "America_Central", "America/Chicago",
-        "America/Buenos_Aires", "Argentina", "America/Buenos_Aires",
-        "America/Tortola", "Atlantic", "America/Halifax",
-        "Asia/Kuwait", "Arabian", "Asia/Riyadh",
-        "Europe/Rome", "Europe_Central", "Europe/Paris",
-        "America/Eirunepe", "Amazon", "America/Manaus",
-        "Australia/Hobart", "Australia_Eastern", "Australia/Sydney",
-        "America/Thule", "Atlantic", "America/Halifax",
-        "Asia/Beirut", "Europe_Eastern", "Europe/Bucharest",
-        "America/Bahia_Banderas", "America_Central", "America/Chicago",
-        "Africa/Dar_es_Salaam", "Africa_Eastern", "Africa/Nairobi",
-        "America/Argentina/Tucuman", "Argentina", "America/Buenos_Aires",
-        "America/Paramaribo", "Suriname", "America/Paramaribo",
-        "Africa/Kampala", "Africa_Eastern", "Africa/Nairobi",
+        "Pacific/Niue", "Niue", "Pacific/Niue",
+        "Pacific/Norfolk", "Norfolk", "Pacific/Norfolk",
+        "Pacific/Noumea", "New_Caledonia", "Pacific/Noumea",
+        "Pacific/Pago_Pago", "Samoa", "Pacific/Pago_Pago",
+        "Pacific/Palau", "Palau", "Pacific/Palau",
+        "Pacific/Pitcairn", "Pitcairn", "Pacific/Pitcairn",
+        "Pacific/Pohnpei", "Ponape", "Pacific/Ponape",
+        "Pacific/Ponape", "Ponape", "Pacific/Ponape",
         "Pacific/Port_Moresby", "Papua_New_Guinea", "Pacific/Port_Moresby",
-        "America/Mendoza", "Argentina", "America/Buenos_Aires",
-        "Asia/Dushanbe", "Tajikistan", "Asia/Dushanbe",
-        "Asia/Qyzylorda", "Kazakhstan_Eastern", "Asia/Almaty",
-        "Antarctica/Vostok", "Vostok", "Antarctica/Vostok",
-        "Pacific/Majuro", "Marshall_Islands", "Pacific/Majuro",
-        "Asia/Tehran", "Iran", "Asia/Tehran",
-        "Asia/Hovd", "Hovd", "Asia/Hovd",
-        "Antarctica/Rothera", "Rothera", "Antarctica/Rothera",
-        "Africa/Brazzaville", "Africa_Western", "Africa/Lagos",
-        "Europe/Tirane", "Europe_Central", "Europe/Paris",
-        "Asia/Urumqi", "China", "Asia/Shanghai",
-        "Asia/Krasnoyarsk", "Krasnoyarsk", "Asia/Krasnoyarsk",
-        "America/Tegucigalpa", "America_Central", "America/Chicago",
-        "Asia/Vientiane", "Indochina", "Asia/Saigon",
-        "Asia/Pontianak", "Indonesia_Western", "Asia/Jakarta",
-        "America/Bahia", "Brasilia", "America/Sao_Paulo",
-        "Asia/Choibalsan", "Choibalsan", "Asia/Choibalsan",
-        "America/Regina", "America_Central", "America/Chicago",
-        "Africa/Cairo", "Europe_Eastern", "Europe/Bucharest",
-        "Asia/Irkutsk", "Irkutsk", "Asia/Irkutsk",
-        "Europe/Luxembourg", "Europe_Central", "Europe/Paris",
-        "America/St_Kitts", "Atlantic", "America/Halifax",
-        "America/Manaus", "Amazon", "America/Manaus",
-        "America/Noronha", "Noronha", "America/Noronha",
-        "Pacific/Gambier", "Gambier", "Pacific/Gambier",
-        "America/Edmonton", "America_Mountain", "America/Denver",
-        "Pacific/Palau", "Palau", "Pacific/Palau",
-        "America/Lower_Princes", "Atlantic", "America/Halifax",
-        "Africa/Ouagadougou", "GMT", "Atlantic/Reykjavik",
-        "Asia/Yerevan", "Armenia", "Asia/Yerevan",
-        "America/Montevideo", "Uruguay", "America/Montevideo",
-        "Europe/Minsk", "Europe_Eastern", "Europe/Bucharest",
-        "Europe/Amsterdam", "Europe_Central", "Europe/Paris",
-        "Pacific/Efate", "Vanuatu", "Pacific/Efate",
-        "Asia/Manila", "Philippines", "Asia/Manila",
-        "America/Dawson", "America_Pacific", "America/Los_Angeles",
-        "America/Argentina/Cordoba", "Argentina", "America/Buenos_Aires",
-        "Australia/Melbourne", "Australia_Eastern", "Australia/Sydney",
-        "Asia/Rangoon", "Myanmar", "Asia/Rangoon",
-        "America/Los_Angeles", "America_Pacific", "America/Los_Angeles",
-        "Africa/Casablanca", "Europe_Western", "Atlantic/Canary",
-        "Africa/Porto-Novo", "Africa_Western", "Africa/Lagos",
-        "Asia/Macau", "China", "Asia/Shanghai",
-        "America/Boa_Vista", "Amazon", "America/Manaus",
-        "Europe/Guernsey", "GMT", "Atlantic/Reykjavik",
-        "Africa/Monrovia", "GMT", "Atlantic/Reykjavik",
-        "America/Godthab", "Greenland_Western", "America/Godthab",
-        "Africa/Ceuta", "Europe_Central", "Europe/Paris",
-        "Asia/Oral", "Kazakhstan_Western", "Asia/Aqtobe",
-        "America/Yakutat", "Alaska", "America/Juneau",
-        "Indian/Mayotte", "Africa_Eastern", "Africa/Nairobi",
-        "America/Denver", "America_Mountain", "America/Denver",
-        "America/New_York", "America_Eastern", "America/New_York",
         "Pacific/Rarotonga", "Cook", "Pacific/Rarotonga",
-        "America/Louisville", "America_Eastern", "America/New_York",
-        "Africa/El_Aaiun", "Europe_Western", "Atlantic/Canary",
-        "Africa/Sao_Tome", "Africa_Western", "Africa/Lagos",
-        "Pacific/Fiji", "Fiji", "Pacific/Fiji",
-        "Asia/Damascus", "Europe_Eastern", "Europe/Bucharest",
-        "Asia/Ulaanbaatar", "Mongolia", "Asia/Ulaanbaatar",
-        "America/Cayman", "America_Eastern", "America/New_York",
-        "America/Tijuana", "America_Pacific", "America/Los_Angeles",
-        "Atlantic/Bermuda", "Atlantic", "America/Halifax",
-        "Australia/Sydney", "Australia_Eastern", "Australia/Sydney",
-        "Asia/Aden", "Arabian", "Asia/Riyadh",
-        "Australia/Eucla", "Australia_CentralWestern", "Australia/Eucla",
-        "America/Indiana/Petersburg", "America_Eastern", "America/New_York",
-        "America/Panama", "America_Eastern", "America/New_York",
-        "Europe/Istanbul", "Europe_Eastern", "Europe/Bucharest",
-        "America/Kralendijk", "Atlantic", "America/Halifax",
-        "America/Catamarca", "Argentina", "America/Buenos_Aires",
-        "America/Nassau", "America_Eastern", "America/New_York",
-        "Europe/Paris", "Europe_Central", "Europe/Paris",
-        "Asia/Jakarta", "Indonesia_Western", "Asia/Jakarta",
-        "Australia/Lindeman", "Australia_Eastern", "Australia/Sydney",
-        "America/Sao_Paulo", "Brasilia", "America/Sao_Paulo",
-        "America/Juneau", "Alaska", "America/Juneau",
-        "America/Grenada", "Atlantic", "America/Halifax",
-        "America/Cayenne", "French_Guiana", "America/Cayenne",
-        "Antarctica/Casey", "Australia_Western", "Australia/Perth",
-        "Africa/Algiers", "Europe_Central", "Europe/Paris",
-        "America/Miquelon", "Pierre_Miquelon", "America/Miquelon",
-        "Asia/Tokyo", "Japan", "Asia/Tokyo",
-        "Africa/Windhoek", "Africa_Central", "Africa/Maputo",
-        "Africa/Bujumbura", "Africa_Central", "Africa/Maputo",
-        "America/Guatemala", "America_Central", "America/Chicago",
-        "Africa/Dakar", "GMT", "Atlantic/Reykjavik",
-        "Asia/Bishkek", "Kyrgystan", "Asia/Bishkek",
-        "America/Guadeloupe", "Atlantic", "America/Halifax",
-        "Africa/Ndjamena", "Africa_Western", "Africa/Lagos",
-        "Europe/Simferopol", "Europe_Eastern", "Europe/Bucharest",
-        "America/Santa_Isabel", "America_Pacific", "America/Los_Angeles",
-        "Asia/Dubai", "Gulf", "Asia/Dubai",
-        "America/Maceio", "Brasilia", "America/Sao_Paulo",
-        "America/Anchorage", "Alaska", "America/Juneau",
-        "Australia/Currie", "Australia_Eastern", "Australia/Sydney",
-        "Africa/Djibouti", "Africa_Eastern", "Africa/Nairobi",
-        "Europe/Budapest", "Europe_Central", "Europe/Paris",
-        "America/Argentina/Salta", "Argentina", "America/Buenos_Aires",
-        "Asia/Calcutta", "India", "Asia/Calcutta",
-        "America/Indiana/Winamac", "America_Eastern", "America/New_York",
-        "Asia/Yekaterinburg", "Yekaterinburg", "Asia/Yekaterinburg",
-        "America/Santiago", "Chile", "America/Santiago",
-        "Asia/Aqtobe", "Kazakhstan_Western", "Asia/Aqtobe",
-        "Asia/Dili", "East_Timor", "Asia/Dili",
-        "America/Detroit", "America_Eastern", "America/New_York",
-        "Africa/Libreville", "Africa_Western", "Africa/Lagos",
-        "Pacific/Ponape", "Ponape", "Pacific/Ponape",
+        "Pacific/Saipan", "Chamorro", "Pacific/Saipan",
+        "Pacific/Samoa", "Samoa", "Pacific/Pago_Pago",
+        "Pacific/Tahiti", "Tahiti", "Pacific/Tahiti",
+        "Pacific/Tarawa", "Gilbert_Islands", "Pacific/Tarawa",
+        "Pacific/Tongatapu", "Tonga", "Pacific/Tongatapu",
+        "Pacific/Truk", "Truk", "Pacific/Truk",
+        "Pacific/Wake", "Wake", "Pacific/Wake",
         "Pacific/Wallis", "Wallis", "Pacific/Wallis",
-        "Asia/Vladivostok", "Vladivostok", "Asia/Vladivostok",
-        "Africa/Lubumbashi", "Africa_Central", "Africa/Maputo",
-        "Africa/Asmera", "Africa_Eastern", "Africa/Nairobi",
-        "Pacific/Guam", "Chamorro", "Pacific/Saipan",
-        "America/Chicago", "America_Central", "America/Chicago",
-        "America/Swift_Current", "America_Central", "America/Chicago",
-        "America/Coral_Harbour", "America_Eastern", "America/New_York",
-        "America/Cambridge_Bay", "America_Mountain", "America/Denver",
-        "America/Costa_Rica", "America_Central", "America/Chicago",
-        "America/Curacao", "Atlantic", "America/Halifax",
-        "America/Recife", "Brasilia", "America/Sao_Paulo",
-        "Africa/Bangui", "Africa_Western", "Africa/Lagos",
-        "America/Cordoba", "Argentina", "America/Buenos_Aires",
-        "Asia/Baghdad", "Arabian", "Asia/Riyadh",
-        "America/Shiprock", "America_Mountain", "America/Denver",
-        "America/Glace_Bay", "Atlantic", "America/Halifax",
-        "America/North_Dakota/Center", "America_Central", "America/Chicago",
-        "Europe/Stockholm", "Europe_Central", "Europe/Paris",
-        "America/Halifax", "Atlantic", "America/Halifax",
-        "Atlantic/Canary", "Europe_Western", "Atlantic/Canary",
-        "Europe/Volgograd", "Volgograd", "Europe/Volgograd",
-        "America/Moncton", "Atlantic", "America/Halifax",<