--- old/./.hgtags	2019-01-21 18:47:43.709357310 +0100
+++ new/./.hgtags	2019-01-21 18:47:43.497357865 +0100
@@ -509,7 +509,12 @@
 9d7d74c6f2cbe522e39fa22dc557fdd3f79b32ad jdk-11+27
 700c64a45d473dffce880ab8a0ea03617c1a334d shenandoah-jdk-11+28
 76072a077ee1d815152d45d1692c4b36c53c5c49 jdk-11+28
+c01cc45790f871adec30acc90742b521d57a2fff jdk-11.0.1+0
 1353ec839c82de926bfacd2c7976b6b652d4afb0 jdk-11.0.1+1
+a285bd7cfedb40cb3086e61e17fc04c96b739d03 jdk-11.0.1+2
+a285bd7cfedb40cb3086e61e17fc04c96b739d03 jdk-11.0.1+2
+0000000000000000000000000000000000000000 jdk-11.0.1+2
+fc55f0667af5ea3b21e40a59e2a88b1b82e65e62 jdk-11.0.1+2
 781b5d8f2f75ae4dfdafc85630e5dbd31e324ed1 jdk-11.0.1+3
 fc55f0667af5ea3b21e40a59e2a88b1b82e65e62 jdk-11.0.1+2
 c01cc45790f871adec30acc90742b521d57a2fff jdk-11.0.1+0
@@ -527,3 +532,17 @@
 2fa9c7a0183f3d7126daade5006d2580a71869ad shenandoah-jdk-11.0.1+13-20181213
 eefd364ff6b555c3c86095f9a4fb1601b5af08b9 shenandoah-jdk-11.0.1+13-20190101
 19d8e8f6e552e64c11914e07c1b8e5b68e8775f2 shenandoah-jdk-11.0.2+7
+7da060835810b5fbd4a7493ea1c98e9a4338f30d jdk-11.0.2+0
+2be95a1bf50877cafba791c2f342953bd4a6412e jdk-11.0.2+1
+b4b16f510f48e2dd4bea007b60fddf69af0f6c10 jdk-11.0.2+2
+8a8606a3bdf2dbe0698bef375e6a4b47df0efb1a jdk-11.0.2+3
+0db90dec8c39bc38058afa11b7fda607ee259d01 jdk-11.0.2+4
+ff1f7723c4e88822fd60bcacd55824e1d3da6d36 jdk-11.0.2+5
+c6fd7ff3e96f3e6f4913d026a90c6c454a7a35c8 jdk-11.0.2+6
+a01e0cc0105972acc3b5e213dbe2b84acaee5be3 jdk-11.0.2+7
+a01e0cc0105972acc3b5e213dbe2b84acaee5be3 jdk-11.0.2-ga
+fe85e2f43a1c893cb410308106b0f31b814aebb8 jdk-11.0.2+8
+144d476b6efe527c5e9ebf19af93398913c5450f jdk-11.0.2+9
+a01e0cc0105972acc3b5e213dbe2b84acaee5be3 jdk-11.0.2-ga
+0000000000000000000000000000000000000000 jdk-11.0.2-ga
+144d476b6efe527c5e9ebf19af93398913c5450f jdk-11.0.2-ga
--- old/make/autoconf/flags-cflags.m4	2019-01-21 18:47:44.201356021 +0100
+++ new/make/autoconf/flags-cflags.m4	2019-01-21 18:47:43.985356588 +0100
@@ -106,11 +106,17 @@
 
 AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
 [
+  # By default don't set any specific assembler debug
+  # info flags for toolchains unless we know they work.
+  # See JDK-8207057.
+  ASFLAGS_DEBUG_SYMBOLS=""
   # Debug symbols
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     CFLAGS_DEBUG_SYMBOLS="-g"
+    ASFLAGS_DEBUG_SYMBOLS="-g"
   elif test "x$TOOLCHAIN_TYPE" = xclang; then
     CFLAGS_DEBUG_SYMBOLS="-g"
+    ASFLAGS_DEBUG_SYMBOLS="-g"
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     # -g0 enables debug symbols without disabling inlining.
     CFLAGS_DEBUG_SYMBOLS="-g0 -xs"
@@ -121,6 +127,7 @@
   fi
 
   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
+  AC_SUBST(ASFLAGS_DEBUG_SYMBOLS)
 ])
 
 AC_DEFUN([FLAGS_SETUP_WARNINGS],
@@ -366,6 +373,20 @@
 
   FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
 
+  COMPILER_FP_CONTRACT_OFF_FLAG="-ffp-contract=off"
+  # Check that the compiler supports -ffp-contract=off flag
+  # Set FDLIBM_CFLAGS to -ffp-contract=off if it does. Empty
+  # otherwise.
+  # These flags are required for GCC-based builds of
+  # fdlibm with optimization without losing precision.
+  # Notably, -ffp-contract=off needs to be added for GCC >= 4.6.
+  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
+    FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_FP_CONTRACT_OFF_FLAG}],
+	IF_TRUE: [FDLIBM_CFLAGS=${COMPILER_FP_CONTRACT_OFF_FLAG}],
+	IF_FALSE: [FDLIBM_CFLAGS=""])
+  fi
+  AC_SUBST(FDLIBM_CFLAGS)
+
   # Tests are only ever compiled for TARGET
   CFLAGS_TESTLIB="$CFLAGS_JDKLIB"
   CXXFLAGS_TESTLIB="$CXXFLAGS_JDKLIB"
--- old/make/autoconf/spec.gmk.in	2019-01-21 18:47:44.673354784 +0100
+++ new/make/autoconf/spec.gmk.in	2019-01-21 18:47:44.457355350 +0100
@@ -444,6 +444,7 @@
 LIBJSIG_HASHSTYLE_LDFLAGS := @LIBJSIG_HASHSTYLE_LDFLAGS@
 LIBJSIG_NOEXECSTACK_LDFLAGS := @LIBJSIG_NOEXECSTACK_LDFLAGS@
 
+FDLIBM_CFLAGS := @FDLIBM_CFLAGS@
 JVM_CFLAGS := @JVM_CFLAGS@
 JVM_LDFLAGS := @JVM_LDFLAGS@
 JVM_ASFLAGS := @JVM_ASFLAGS@
@@ -534,6 +535,7 @@
 ZIP_EXTERNAL_DEBUG_SYMBOLS := @ZIP_EXTERNAL_DEBUG_SYMBOLS@
 
 CFLAGS_DEBUG_SYMBOLS:=@CFLAGS_DEBUG_SYMBOLS@
+ASFLAGS_DEBUG_SYMBOLS:=@ASFLAGS_DEBUG_SYMBOLS@
 
 #
 # Compress (or not) jars
--- old/make/autoconf/version-numbers	2019-01-21 18:47:45.169353484 +0100
+++ new/make/autoconf/version-numbers	2019-01-21 18:47:44.949354060 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
--- old/make/common/NativeCompilation.gmk	2019-01-21 18:47:45.697352099 +0100
+++ new/make/common/NativeCompilation.gmk	2019-01-21 18:47:45.485352655 +0100
@@ -251,6 +251,7 @@
         $$($$($1_BASE)_SYSROOT_CFLAGS)
     $1_BASE_CXXFLAGS := $$($$($1_BASE)_CXXFLAGS) $$($$($1_BASE)_EXTRA_CXXFLAGS) \
         $$($$($1_BASE)_SYSROOT_CFLAGS) $$($1_EXTRA_CXXFLAGS)
+    $1_BASE_ASFLAGS := $$($$($1_BASE)_ASFLAGS) $$($$($1_BASE)_EXTRA_ASFLAGS)
 
     ifneq ($$(filter %.c, $$($1_FILENAME)), )
       # Compile as a C file
@@ -266,7 +267,7 @@
       $1_DEP_FLAG := $(C_FLAG_DEPS)
     else ifneq ($$(filter %.s %.S, $$($1_FILENAME)), )
       # Compile as assembler file
-      $1_FLAGS := $$($$($1_BASE)_ASFLAGS)
+      $1_FLAGS := $$($1_BASE_ASFLAGS)
       $1_COMPILER := $(AS)
       $1_DEP_FLAG :=
     else ifneq ($$(filter %.cpp %.cc %.mm, $$($1_FILENAME)), )
@@ -576,6 +577,7 @@
   ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true)
     $1_EXTRA_CFLAGS += $$(CFLAGS_DEBUG_SYMBOLS)
     $1_EXTRA_CXXFLAGS += $$(CFLAGS_DEBUG_SYMBOLS)
+    $1_EXTRA_ASFLAGS += $$(ASFLAGS_DEBUG_SYMBOLS)
   endif
 
   ifneq ($$($1_REORDER), )
--- old/make/common/TestFilesCompilation.gmk	2019-01-21 18:47:46.149350914 +0100
+++ new/make/common/TestFilesCompilation.gmk	2019-01-21 18:47:45.933351480 +0100
@@ -94,7 +94,7 @@
         CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
         LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$(name)), \
         LIBS := $$($1_LIBS_$$(name)), \
-        OPTIMIZATION := LOW, \
+        OPTIMIZATION := $$(if $$($1_OPTIMIZATION_$$(name)),$$($1_OPTIMIZATION_$$(name)),LOW), \
         COPY_DEBUG_SYMBOLS := false, \
         STRIP_SYMBOLS := false, \
     )) \
--- old/make/data/tzdata/VERSION	2019-01-21 18:47:46.641349624 +0100
+++ new/make/data/tzdata/VERSION	2019-01-21 18:47:46.421350201 +0100
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2018e
+tzdata2018g
--- old/make/data/tzdata/africa	2019-01-21 18:47:47.169348239 +0100
+++ new/make/data/tzdata/africa	2019-01-21 18:47:46.957348796 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for Africa and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -29,7 +31,7 @@
 # tz@iana.org for general use in the future).  For more, please see
 # the file CONTRIBUTING in the tz distribution.
 
-# From Paul Eggert (2017-04-09):
+# From Paul Eggert (2018-05-27):
 #
 # Unless otherwise specified, the source for data through 1990 is:
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
@@ -74,13 +76,15 @@
 # I vaguely recall 'WAT' also being used for -01 in the past but
 # cannot now come up with solid citations.
 #
-# I invented the following abbreviations; corrections are welcome!
-#	 +02	WAST	West Africa Summer Time (no longer used)
-#	 +03	CAST	Central Africa Summer Time (no longer used)
-#	 +03	SAST	South Africa Summer Time (no longer used)
+# I invented the following abbreviations in the 1990s:
+#	 +02	WAST	West Africa Summer Time
+#	 +03	CAST	Central Africa Summer Time
+#	 +03	SAST	South Africa Summer Time
 #	 +03	EAT	East Africa Time
-# 'EAT' also seems to have caught on; the others are rare but are paired
-# with better-attested non-DST abbreviations.
+# 'EAT' seems to have caught on and is in current timestamps, and though
+# the other abbreviations are rarer and are only in past timestamps,
+# they are paired with better-attested non-DST abbreviations.
+# Corrections are welcome.
 
 # Algeria
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
@@ -385,6 +389,13 @@
 # Eritrea
 # Ethiopia
 # See Africa/Nairobi.
+#
+# Unfortunately tzdb records only Western clock time in use in Ethiopia,
+# as the tzdb format is not up to properly recording a common Ethiopian
+# timekeeping practice that is based on solar time.  See:
+# Mortada D. If you have a meeting in Ethiopia, you'd better double
+# check the time. PRI's The World. 2015-01-30 15:15 -05.
+# https://www.pri.org/stories/2015-01-30/if-you-have-meeting-ethiopia-you-better-double-check-time
 
 # Gabon
 # See Africa/Lagos.
@@ -856,94 +867,61 @@
 # <https://lnt.ma/le-maroc-reculera-dune-heure-le-dimanche-14-juin/> agrees
 # with the patch.
 
-# From Paul Eggert (2015-06-08):
-# For now, guess that later spring and fall transitions will use 2015's rules,
-# and guess that Morocco will switch to standard time at 03:00 the last
-# Sunday before Ramadan, and back to DST at 02:00 the first Sunday after
-# Ramadan.  To implement this, transition dates for 2016 through 2037 were
-# determined by running the following program under GNU Emacs 24.3, with the
-# results integrated by hand into the table below.
-# (let ((islamic-year 1437))
-#   (require 'cal-islam)
-#   (while (< islamic-year 1460)
-#     (let ((a (calendar-islamic-to-absolute (list 9 1 islamic-year)))
-#           (b (calendar-islamic-to-absolute (list 10 1 islamic-year)))
-#           (sunday 0))
-#       (while (/= sunday (mod (setq a (1- a)) 7)))
-#       (while (/= sunday (mod b 7))
-#         (setq b (1+ b)))
-#       (setq a (calendar-gregorian-from-absolute a))
-#       (setq b (calendar-gregorian-from-absolute b))
-#       (insert
-#        (format
-#         (concat "Rule\tMorocco\t%d\tonly\t-\t%s\t%2d\t 3:00\t0\t-\n"
-#                 "Rule\tMorocco\t%d\tonly\t-\t%s\t%2d\t 2:00\t1:00\tS\n")
-#         (car (cdr (cdr a))) (calendar-month-name (car a) t) (car (cdr a))
-#         (car (cdr (cdr b))) (calendar-month-name (car b) t) (car (cdr b)))))
-#     (setq islamic-year (+ 1 islamic-year))))
+# From Mohamed Essedik Najd (2018-10-26):
+# Today, a Moroccan government council approved the perpetual addition
+# of 60 minutes to the regular Moroccan timezone.
+# From Brian Inglis (2018-10-26):
+# http://www.maroc.ma/fr/actualites/le-conseil-de-gouvernement-adopte-un-projet-de-decret-relatif-lheure-legale-stipulant-le
 
 # RULE	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-
-Rule	Morocco	1939	only	-	Sep	12	 0:00	1:00	S
+Rule	Morocco	1939	only	-	Sep	12	 0:00	1:00	-
 Rule	Morocco	1939	only	-	Nov	19	 0:00	0	-
-Rule	Morocco	1940	only	-	Feb	25	 0:00	1:00	S
+Rule	Morocco	1940	only	-	Feb	25	 0:00	1:00	-
 Rule	Morocco	1945	only	-	Nov	18	 0:00	0	-
-Rule	Morocco	1950	only	-	Jun	11	 0:00	1:00	S
+Rule	Morocco	1950	only	-	Jun	11	 0:00	1:00	-
 Rule	Morocco	1950	only	-	Oct	29	 0:00	0	-
-Rule	Morocco	1967	only	-	Jun	 3	12:00	1:00	S
+Rule	Morocco	1967	only	-	Jun	 3	12:00	1:00	-
 Rule	Morocco	1967	only	-	Oct	 1	 0:00	0	-
-Rule	Morocco	1974	only	-	Jun	24	 0:00	1:00	S
+Rule	Morocco	1974	only	-	Jun	24	 0:00	1:00	-
 Rule	Morocco	1974	only	-	Sep	 1	 0:00	0	-
-Rule	Morocco	1976	1977	-	May	 1	 0:00	1:00	S
+Rule	Morocco	1976	1977	-	May	 1	 0:00	1:00	-
 Rule	Morocco	1976	only	-	Aug	 1	 0:00	0	-
 Rule	Morocco	1977	only	-	Sep	28	 0:00	0	-
-Rule	Morocco	1978	only	-	Jun	 1	 0:00	1:00	S
+Rule	Morocco	1978	only	-	Jun	 1	 0:00	1:00	-
 Rule	Morocco	1978	only	-	Aug	 4	 0:00	0	-
-Rule	Morocco	2008	only	-	Jun	 1	 0:00	1:00	S
+Rule	Morocco	2008	only	-	Jun	 1	 0:00	1:00	-
 Rule	Morocco	2008	only	-	Sep	 1	 0:00	0	-
-Rule	Morocco	2009	only	-	Jun	 1	 0:00	1:00	S
+Rule	Morocco	2009	only	-	Jun	 1	 0:00	1:00	-
 Rule	Morocco	2009	only	-	Aug	21	 0:00	0	-
-Rule	Morocco	2010	only	-	May	 2	 0:00	1:00	S
+Rule	Morocco	2010	only	-	May	 2	 0:00	1:00	-
 Rule	Morocco	2010	only	-	Aug	 8	 0:00	0	-
-Rule	Morocco	2011	only	-	Apr	 3	 0:00	1:00	S
+Rule	Morocco	2011	only	-	Apr	 3	 0:00	1:00	-
 Rule	Morocco	2011	only	-	Jul	31	 0:00	0	-
-Rule	Morocco	2012	2013	-	Apr	lastSun	 2:00	1:00	S
+Rule	Morocco	2012	2013	-	Apr	lastSun	 2:00	1:00	-
 Rule	Morocco	2012	only	-	Jul	20	 3:00	0	-
-Rule	Morocco	2012	only	-	Aug	20	 2:00	1:00	S
+Rule	Morocco	2012	only	-	Aug	20	 2:00	1:00	-
 Rule	Morocco	2012	only	-	Sep	30	 3:00	0	-
 Rule	Morocco	2013	only	-	Jul	 7	 3:00	0	-
-Rule	Morocco	2013	only	-	Aug	10	 2:00	1:00	S
-Rule	Morocco	2013	max	-	Oct	lastSun	 3:00	0	-
-Rule	Morocco	2014	2021	-	Mar	lastSun	 2:00	1:00	S
+Rule	Morocco	2013	only	-	Aug	10	 2:00	1:00	-
+Rule	Morocco	2013	2018	-	Oct	lastSun	 3:00	0	-
+Rule	Morocco	2014	2018	-	Mar	lastSun	 2:00	1:00	-
 Rule	Morocco	2014	only	-	Jun	28	 3:00	0	-
-Rule	Morocco	2014	only	-	Aug	 2	 2:00	1:00	S
+Rule	Morocco	2014	only	-	Aug	 2	 2:00	1:00	-
 Rule	Morocco	2015	only	-	Jun	14	 3:00	0	-
-Rule	Morocco	2015	only	-	Jul	19	 2:00	1:00	S
+Rule	Morocco	2015	only	-	Jul	19	 2:00	1:00	-
 Rule	Morocco	2016	only	-	Jun	 5	 3:00	0	-
-Rule	Morocco	2016	only	-	Jul	10	 2:00	1:00	S
+Rule	Morocco	2016	only	-	Jul	10	 2:00	1:00	-
 Rule	Morocco	2017	only	-	May	21	 3:00	0	-
-Rule	Morocco	2017	only	-	Jul	 2	 2:00	1:00	S
+Rule	Morocco	2017	only	-	Jul	 2	 2:00	1:00	-
 Rule	Morocco	2018	only	-	May	13	 3:00	0	-
-Rule	Morocco	2018	only	-	Jun	17	 2:00	1:00	S
-Rule	Morocco	2019	only	-	May	 5	 3:00	0	-
-Rule	Morocco	2019	only	-	Jun	 9	 2:00	1:00	S
-Rule	Morocco	2020	only	-	Apr	19	 3:00	0	-
-Rule	Morocco	2020	only	-	May	24	 2:00	1:00	S
-Rule	Morocco	2021	only	-	Apr	11	 3:00	0	-
-Rule	Morocco	2021	only	-	May	16	 2:00	1:00	S
-Rule	Morocco	2022	only	-	May	 8	 2:00	1:00	S
-Rule	Morocco	2023	only	-	Apr	23	 2:00	1:00	S
-Rule	Morocco	2024	only	-	Apr	14	 2:00	1:00	S
-Rule	Morocco	2025	only	-	Apr	 6	 2:00	1:00	S
-Rule	Morocco	2026	max	-	Mar	lastSun	 2:00	1:00	S
-Rule	Morocco	2036	only	-	Oct	19	 3:00	0	-
-Rule	Morocco	2037	only	-	Oct	 4	 3:00	0	-
+Rule	Morocco	2018	only	-	Jun	17	 2:00	1:00	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Africa/Casablanca	-0:30:20 -	LMT	1913 Oct 26
-			 0:00	Morocco	WE%sT	1984 Mar 16
-			 1:00	-	CET	1986
-			 0:00	Morocco	WE%sT
+			 0:00	Morocco	+00/+01	1984 Mar 16
+			 1:00	-	+01	1986
+			 0:00	Morocco	+00/+01	2018 Oct 27
+			 1:00	-	+01
 
 # Western Sahara
 #
@@ -958,7 +936,8 @@
 
 Zone Africa/El_Aaiun	-0:52:48 -	LMT	1934 Jan # El Aaiún
 			-1:00	-	-01	1976 Apr 14
-			 0:00	Morocco	WE%sT
+			 0:00	Morocco	+00/+01	2018 Oct 27
+			 1:00	-	+01
 
 # Mozambique
 #
--- old/make/data/tzdata/antarctica	2019-01-21 18:47:47.673346917 +0100
+++ new/make/data/tzdata/antarctica	2019-01-21 18:47:47.461347473 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for Antarctica and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
--- old/make/data/tzdata/asia	2019-01-21 18:47:48.181345584 +0100
+++ new/make/data/tzdata/asia	2019-01-21 18:47:47.965346152 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for Asia and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -29,7 +31,7 @@
 # tz@iana.org for general use in the future).  For more, please see
 # the file CONTRIBUTING in the tz distribution.
 
-# From Paul Eggert (2017-01-13):
+# From Paul Eggert (2018-06-19):
 #
 # Unless otherwise specified, the source for data through 1990 is:
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
@@ -58,7 +60,8 @@
 # A reliable and entertaining source about time zones is
 # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
 #
-# The following alphabetic abbreviations appear in these tables:
+# The following alphabetic abbreviations appear in these tables
+# (corrections are welcome):
 #	     std  dst
 #	     LMT	Local Mean Time
 #	2:00 EET  EEST	Eastern European Time
@@ -67,11 +70,13 @@
 #	7:00 WIB	west Indonesia (Waktu Indonesia Barat)
 #	8:00 WITA	central Indonesia (Waktu Indonesia Tengah)
 #	8:00 CST	China
+#	8:00 PST  PDT*	Philippine Standard Time
 #	8:30 KST  KDT	Korea when at +0830
 #	9:00 WIT	east Indonesia (Waktu Indonesia Timur)
 #	9:00 JST  JDT	Japan
 #	9:00 KST  KDT	Korea when at +09
 #	9:30 ACST	Australian Central Standard Time
+# *I invented the abbreviation PDT; see "Philippines" below.
 # Otherwise, these tables typically use numeric abbreviations like +03
 # and +0330 for integer hour and minute UT offsets.  Although earlier
 # editions invented alphabetic time zone abbreviations for every
@@ -304,6 +309,29 @@
 
 # China
 
+# From Paul Eggert (2018-10-02):
+# The following comes from Table 1 of:
+# Li Yu. Research on the daylight saving movement in 1940s Shanghai.
+# Nanjing Journal of Social Sciences. 2014;(2):144-50.
+# http://oversea.cnki.net/kns55/detail.aspx?dbname=CJFD2014&filename=NJSH201402020
+# The table lists dates only; I am guessing 00:00 and 24:00 transition times.
+# Also, the table lists the planned end of DST in 1949, but the corresponding
+# zone line cuts this off on May 28, when the Communists took power.
+#
+# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	Shang	1940	only	-	Jun	 1	 0:00	1:00	D
+Rule	Shang	1940	only	-	Oct	12	24:00	0	S
+Rule	Shang	1941	only	-	Mar	15	 0:00	1:00	D
+Rule	Shang	1941	only	-	Nov	 1	24:00	0	S
+Rule	Shang	1942	only	-	Jan	31	 0:00	1:00	D
+Rule	Shang	1945	only	-	Sep	 1	24:00	0	S
+Rule	Shang	1946	only	-	May	15	 0:00	1:00	D
+Rule	Shang	1946	only	-	Sep	30	24:00	0	S
+Rule	Shang	1947	only	-	Apr	15	 0:00	1:00	D
+Rule	Shang	1947	only	-	Oct	31	24:00	0	S
+Rule	Shang	1948	1949	-	May	 1	 0:00	1:00	D
+Rule	Shang	1948	1949	-	Sep	30	24:00	0	S #plan
+
 # From Guy Harris:
 # People's Republic of China.  Yes, they really have only one time zone.
 
@@ -330,18 +358,33 @@
 # time - sort of", Los Angeles Times, 1986-05-05 ... [says] that China began
 # observing daylight saving time in 1986.
 
-# From Paul Eggert (2014-06-30):
-# Shanks & Pottenger have China switching to a single time zone in 1980, but
-# this doesn't seem to be correct.  They also write that China observed summer
-# DST from 1986 through 1991, which seems to match the above commentary, so
-# go with them for DST rules as follows:
-# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Shang	1940	only	-	Jun	 3	0:00	1:00	D
-Rule	Shang	1940	1941	-	Oct	 1	0:00	0	S
-Rule	Shang	1941	only	-	Mar	16	0:00	1:00	D
-Rule	PRC	1986	only	-	May	 4	0:00	1:00	D
-Rule	PRC	1986	1991	-	Sep	Sun>=11	0:00	0	S
-Rule	PRC	1987	1991	-	Apr	Sun>=10	0:00	1:00	D
+# From P Chan (2018-05-07):
+# The start and end time of DST in China [from 1986 on] should be 2:00
+# (i.e. 2:00 to 3:00 at the start and 2:00 to 1:00 at the end)....
+# Government notices about summer time:
+#
+# 1986-04-12 http://www.zj.gov.cn/attach/zfgb/198608.pdf p.21-22
+# (To establish summer time from 1986. On 4 May, set the clocks ahead one hour
+# at 2 am. On 14 September, set the clocks backward one hour at 2 am.)
+#
+# 1987-02-15 http://www.gov.cn/gongbao/shuju/1987/gwyb198703.pdf p.114
+# (Summer time in 1987 to start from 12 April until 13 September)
+#
+# 1987-09-09 http://www.gov.cn/gongbao/shuju/1987/gwyb198721.pdf p.709
+# (From 1988, summer time to start from 2 am of the first Sunday of mid-April
+# until 2 am of the first Sunday of mid-September)
+#
+# 1992-03-03 http://www.gov.cn/gongbao/shuju/1992/gwyb199205.pdf p.152
+# (To suspend summer time from 1992)
+#
+# The first page of People's Daily on 12 April 1988 stating that summer time
+# to begin on 17 April.
+# http://data.people.com.cn/pic/101p/1988/04/1988041201.jpg
+
+# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	PRC	1986	only	-	May	 4	 2:00	1:00	D
+Rule	PRC	1986	1991	-	Sep	Sun>=11	 2:00	0	S
+Rule	PRC	1987	1991	-	Apr	Sun>=11	 2:00	1:00	D
 
 # From Anthony Fok (2001-12-20):
 # BTW, I did some research on-line and found some info regarding these five
@@ -363,10 +406,11 @@
 # Alois Treindl kindly sent me translations of the following two sources:
 #
 # (1)
-# Guo Qingsheng (National Time-Service Center, CAS, Xi'an 710600, China)
+# Guo Qing-sheng (National Time-Service Center, CAS, Xi'an 710600, China)
 # Beijing Time at the Beginning of the PRC
 # China Historical Materials of Science and Technology
-# (Zhongguo ke ji shi liao, 中国科技史料), Vol. 24, No. 1 (2003)
+# (Zhongguo ke ji shi liao, 中国科技史料). 2003;24(1):5-9.
+# http://oversea.cnki.net/kcms/detail/detail.aspx?filename=ZGKS200301000&dbname=CJFD2003
 # It gives evidence that at the beginning of the PRC, Beijing time was
 # officially apparent solar time!  However, Guo also says that the
 # evidence is dubious, as the relevant institute of astronomy had not
@@ -543,7 +587,7 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Beijing time, used throughout China; represented by Shanghai.
 Zone	Asia/Shanghai	8:05:43	-	LMT	1901
-			8:00	Shang	C%sT	1949
+			8:00	Shang	C%sT	1949 May 28
 			8:00	PRC	C%sT
 # Xinjiang time, used by many in western China; represented by Ürümqi / Ürümchi
 # / Wulumuqi.  (Please use Asia/Shanghai if you prefer Beijing time.)
@@ -772,24 +816,140 @@
 			8:00	Taiwan	C%sT
 
 # Macau (Macao, Aomen)
-# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Macau	1961	1962	-	Mar	Sun>=16	3:30	1:00	D
-Rule	Macau	1961	1964	-	Nov	Sun>=1	3:30	0	S
-Rule	Macau	1963	only	-	Mar	Sun>=16	0:00	1:00	D
-Rule	Macau	1964	only	-	Mar	Sun>=16	3:30	1:00	D
-Rule	Macau	1965	only	-	Mar	Sun>=16	0:00	1:00	D
-Rule	Macau	1965	only	-	Oct	31	0:00	0	S
-Rule	Macau	1966	1971	-	Apr	Sun>=16	3:30	1:00	D
-Rule	Macau	1966	1971	-	Oct	Sun>=16	3:30	0	S
-Rule	Macau	1972	1974	-	Apr	Sun>=15	0:00	1:00	D
-Rule	Macau	1972	1973	-	Oct	Sun>=15	0:00	0	S
-Rule	Macau	1974	1977	-	Oct	Sun>=15	3:30	0	S
-Rule	Macau	1975	1977	-	Apr	Sun>=15	3:30	1:00	D
-Rule	Macau	1978	1980	-	Apr	Sun>=15	0:00	1:00	D
-Rule	Macau	1978	1980	-	Oct	Sun>=15	0:00	0	S
-# See Europe/Lisbon for info about the 1912 transition.
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone	Asia/Macau	7:34:20 -	LMT	1911 Dec 31 16:00u
+#
+# From P Chan (2018-05-10):
+# * LegisMac
+#   http://legismac.safp.gov.mo/legismac/descqry/Descqry.jsf?lang=pt
+#   A database for searching titles of legal documents of Macau in
+#   Chinese and Portuguese.  The term "HORÁRIO DE VERÃO" can be used for
+#   searching decrees about summer time.
+# * Archives of Macao
+#   http://www.archives.gov.mo/en/bo/
+#   It contains images of old official gazettes.
+# * The Macao Meteorological and Geophysical Bureau have a page listing the
+#   summer time history.  But it is not complete and has some mistakes.
+#   http://www.smg.gov.mo/smg/geophysics/e_t_Summer%20Time.htm
+# Macau adopted GMT+8 on 30 Oct 1904 to follow Hong Kong.  Clocks were
+# advanced by 25 minutes and 50 seconds.  Which means the LMT used was
+# +7:34:10.  As stated in the "Portaria No. 204" dated 21 October 1904
+# and published in the Official Gazette on 29 October 1904.
+# http://igallery.icm.gov.mo/Images/Archives/BO/MO_AH_PUB_BO_1904_10/MO_AH_PUB_BO_1904_10_00025_Grey.JPG
+#
+# Therefore the 1911 decree of Portugal did not change time in Macau.
+#
+# From LegisMac, here is a list of decrees that changed the time ...
+# [Decree Gazette-no. date; titles omitted in this quotation]
+#	DIL 732 BOCM 51 1941.12.20
+#	DIL 764 BOCM 9S 1942.04.30
+#	DIL 781 BOCM 21 1942.10.10
+#	PT 3434 BOCM 8S 1943.04.17
+#	PT 3504 BOCM 20 1943.09.25
+#	PT 3843 BOCM 39 1945.09.29
+#	PT 3961 BOCM 17 1946.04.27
+#	PT 4026 BOCM 39 1946.09.28
+#	PT 4153 BOCM 16 1947.04.10
+#	PT 4271 BOCM 48 1947.11.29
+#	PT 4374 BOCM 18 1948.05.01
+#	PT 4465 BOCM 44 1948.10.30
+#	PT 4590 BOCM 14 1949.04.02
+#	PT 4666 BOCM 44 1949.10.29
+#	PT 4771 BOCM 12 1950.03.25
+#	PT 4838 BOCM 43 1950.10.28
+#	PT 4946 BOCM 12 1951.03.24
+#	PT 5025 BO 43 1951.10.27
+#	PT 5149 BO 14 1952.04.05
+#	PT 5251 BO 43 1952.10.25
+#	PT 5366 BO 13 1953.03.28
+#	PT 5444 BO 44 1953.10.31
+#	PT 5540 BO 12 1954.03.20
+#	PT 5589 BO 44 1954.10.30
+#	PT 5676 BO 12 1955.03.19
+#	PT 5739 BO 45 1955.11.05
+#	PT 5823 BO 11 1956.03.17
+#	PT 5891 BO 44 1956.11.03
+#	PT 5981 BO 12 1957.03.23
+#	PT 6064 BO 43 1957.10.26
+#	PT 6172 BO 12 1958.03.22
+#	PT 6243 BO 43 1958.10.25
+#	PT 6341 BO 12 1959.03.21
+#	PT 6411 BO 43 1959.10.24
+#	PT 6514 BO 11 1960.03.12
+#	PT 6584 BO 44 1960.10.29
+#	PT 6721 BO 10 1961.03.11
+#	PT 6815 BO 43 1961.10.28
+#	PT 6947 BO 10 1962.03.10
+#	PT 7080 BO 43 1962.10.27
+#	PT 7218 BO 12 1963.03.23
+#	PT 7340 BO 43 1963.10.26
+#	PT 7491 BO 11 1964.03.14
+#	PT 7664 BO 43 1964.10.24
+#	PT 7846 BO 15 1965.04.10
+#	PT 7979 BO 42 1965.10.16
+#	PT 8146 BO 15 1966.04.09
+#	PT 8252 BO 41 1966.10.08
+#	PT 8429 BO 15 1967.04.15
+#	PT 8540 BO 41 1967.10.14
+#	PT 8735 BO 15 1968.04.13
+#	PT 8860 BO 41 1968.10.12
+#	PT 9035 BO 16 1969.04.19
+#	PT 9156 BO 42 1969.10.18
+#	PT 9328 BO 15 1970.04.11
+#	PT 9418 BO 41 1970.10.10
+#	PT 9587 BO 14 1971.04.03
+#	PT 9702 BO 41 1971.10.09
+#	PT 38-A/72 BO 14 1972.04.01
+#	PT 126-A/72 BO 41 1972.10.07
+#	PT 61/73 BO 14 1973.04.07
+#	PT 182/73 BO 40 1973.10.06
+#	PT 282/73 BO 51 1973.12.22
+#	PT 177/74 BO 41 1974.10.12
+#	PT 51/75 BO 15 1975.04.12
+#	PT 173/75 BO 41 1975.10.11
+#	PT 67/76/M BO 14 1976.04.03
+#	PT 169/76/M BO 41 1976.10.09
+#	PT 78/79/M BO 19 1979.05.12
+#	PT 166/79/M BO 42 1979.10.20
+# Note that DIL 732 does not belong to "HORÁRIO DE VERÃO" according to
+# LegisMac.... Note that between 1942 and 1945, the time switched
+# between GMT+9 and GMT+10.  Also in 1965 and 1965 the DST ended at 2:30am.
+
+# From Paul Eggert (2018-05-10):
+# The 1904 decree says that Macau changed from the meridian of
+# Fortaleza do Monte, presumably the basis for the 7:34:10 for LMT.
+
+# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	Macau	1942	1943	-	Apr	30	23:00	1:00	-
+Rule	Macau	1942	only	-	Nov	17	23:00	0	-
+Rule	Macau	1943	only	-	Sep	30	23:00	0	S
+Rule	Macau	1946	only	-	Apr	30	23:00s	1:00	D
+Rule	Macau	1946	only	-	Sep	30	23:00s	0	S
+Rule	Macau	1947	only	-	Apr	19	23:00s	1:00	D
+Rule	Macau	1947	only	-	Nov	30	23:00s	0	S
+Rule	Macau	1948	only	-	May	 2	23:00s	1:00	D
+Rule	Macau	1948	only	-	Oct	31	23:00s	0	S
+Rule	Macau	1949	1950	-	Apr	Sat>=1	23:00s	1:00	D
+Rule	Macau	1949	1950	-	Oct	lastSat	23:00s	0	S
+Rule	Macau	1951	only	-	Mar	31	23:00s	1:00	D
+Rule	Macau	1951	only	-	Oct	28	23:00s	0	S
+Rule	Macau	1952	1953	-	Apr	Sat>=1	23:00s	1:00	D
+Rule	Macau	1952	only	-	Nov	 1	23:00s	0	S
+Rule	Macau	1953	1954	-	Oct	lastSat	23:00s	0	S
+Rule	Macau	1954	1956	-	Mar	Sat>=17	23:00s	1:00	D
+Rule	Macau	1955	only	-	Nov	 5	23:00s	0	S
+Rule	Macau	1956	1964	-	Nov	Sun>=1	03:30	0	S
+Rule	Macau	1957	1964	-	Mar	Sun>=18	03:30	1:00	D
+Rule	Macau	1965	1973	-	Apr	Sun>=16	03:30	1:00	D
+Rule	Macau	1965	1966	-	Oct	Sun>=16	02:30	0	S
+Rule	Macau	1967	1976	-	Oct	Sun>=16	03:30	0	S
+Rule	Macau	1973	only	-	Dec	30	03:30	1:00	D
+Rule	Macau	1975	1976	-	Apr	Sun>=16	03:30	1:00	D
+Rule	Macau	1979	only	-	May	13	03:30	1:00	D
+Rule	Macau	1979	only	-	Oct	Sun>=16	03:30	0	S
+
+# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
+Zone	Asia/Macau	7:34:10 -	LMT	1904 Oct 30
+			8:00	-	CST	1941 Dec 21 23:00
+			9:00	Macau	+09/+10	1945 Sep 30 24:00
 			8:00	Macau	C%sT
 
 
@@ -1494,9 +1654,29 @@
 # http://www.shugiin.go.jp/internet/itdb_housei.nsf/html/houritsu/00719500331039.htm
 # ... In summary, it is written as follows.  From 24:00 on the first Saturday
 # in May, until 0:00 on the day after the second Saturday in September.
+
+# From Phake Nick (2018-09-27):
+# [T]he webpage authored by National Astronomical Observatory of Japan
+# https://eco.mtk.nao.ac.jp/koyomi/wiki/BBFEB9EF2FB2C6BBFEB9EF.html
+# ... mentioned that using Showa 23 (year 1948) as example, 13pm of September
+# 11 in summer time will equal to 0am of September 12 in standard time.
+# It cited a document issued by the Liaison Office which briefly existed
+# during the postwar period of Japan, where the detail on implementation
+# of the summer time is described in the document.
+# https://eco.mtk.nao.ac.jp/koyomi/wiki/BBFEB9EF2FB2C6BBFEB9EFB2C6BBFEB9EFA4CEBCC2BBDCA4CBA4C4A4A4A4C6.pdf
+# The text in the document do instruct a fall back to occur at
+# September 11, 13pm in summer time, while ordinary citizens can
+# change the clock before they sleep.
+#
+# From Paul Eggert (2018-09-27):
+# This instruction is equivalent to "Sat>=8 25:00", so use that.  zic treats
+# it like "Sun>=9 01:00", which is not quite the same but is the best we can
+# do in any POSIX or C platform.  The "25:00" assumes zic from 2007 or later,
+# which should be safe now.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Japan	1948	only	-	May	Sat>=1	24:00	1:00	D
-Rule	Japan	1948	1951	-	Sep	Sun>=9	 0:00	0	S
+Rule	Japan	1948	1951	-	Sep	Sun>=9	 1:00	0	S
 Rule	Japan	1949	only	-	Apr	Sat>=1	24:00	1:00	D
 Rule	Japan	1950	1951	-	May	Sat>=1	24:00	1:00	D
 
@@ -1878,7 +2058,7 @@
 			5:00	-	+05
 # Mangghystaū (KZ-MAN)
 # Aqtau was not founded until 1963, but it represents an inhabited region,
-# so include time stamps before 1963.
+# so include timestamps before 1963.
 Zone	Asia/Aqtau	3:21:04	-	LMT	1924 May  2
 			4:00	-	+04	1930 Jun 21
 			5:00	-	+05	1981 Oct  1
@@ -2018,6 +2198,10 @@
 # Assembly, as published in Rodong Sinmun.
 # From Tim Parenti (2018-04-29):
 # It appears to be the front page story at the top in the right-most column.
+#
+# From Paul Eggert (2018-05-04):
+# The BBC reported that the transition was from 23:30 to 24:00 today.
+# https://www.bbc.com/news/world-asia-44010705
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Seoul	8:27:52	-	LMT	1908 Apr  1
@@ -2030,7 +2214,7 @@
 			8:30	-	KST	1912 Jan  1
 			9:00	-	JST	1945 Aug 24
 			9:00	-	KST	2015 Aug 15 00:00
-			8:30	-	KST	2018 May  5
+			8:30	-	KST	2018 May  4 23:30
 			9:00	-	KST
 
 ###############################################################################
@@ -2780,19 +2964,35 @@
 # Philippine Star 2014-08-05
 # http://www.philstar.com/headlines/2014/08/05/1354152/pnoy-urged-declare-use-daylight-saving-time
 
-# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Phil	1936	only	-	Nov	1	0:00	1:00	-
-Rule	Phil	1937	only	-	Feb	1	0:00	0	-
-Rule	Phil	1954	only	-	Apr	12	0:00	1:00	-
-Rule	Phil	1954	only	-	Jul	1	0:00	0	-
-Rule	Phil	1978	only	-	Mar	22	0:00	1:00	-
-Rule	Phil	1978	only	-	Sep	21	0:00	0	-
+# From Paul Goyette (2018-06-15):
+# In the Philippines, there is a national law, Republic Act No. 10535
+# which declares the official time here as "Philippine Standard Time".
+# The act [1] even specifies use of PST as the abbreviation, although
+# the FAQ provided by PAGASA [2] uses the "acronym PhST to distinguish
+# it from the Pacific Standard Time (PST)."
+# [1] http://www.officialgazette.gov.ph/2013/05/15/republic-act-no-10535/
+# [2] https://www1.pagasa.dost.gov.ph/index.php/astronomy/philippine-standard-time#republic-act-10535
+#
+# From Paul Eggert (2018-06-19):
+# I surveyed recent news reports, and my impression is that "PST" is
+# more popular among reliable English-language news sources.  This is
+# not just a measure of Google hit counts: it's also the sizes and
+# influence of the sources.  There is no current abbreviation for DST,
+# so use "PDT", the usual American style.
+
+# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	Phil	1936	only	-	Nov	1	0:00	1:00	D
+Rule	Phil	1937	only	-	Feb	1	0:00	0	S
+Rule	Phil	1954	only	-	Apr	12	0:00	1:00	D
+Rule	Phil	1954	only	-	Jul	1	0:00	0	S
+Rule	Phil	1978	only	-	Mar	22	0:00	1:00	D
+Rule	Phil	1978	only	-	Sep	21	0:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Manila	-15:56:00 -	LMT	1844 Dec 31
 			8:04:00 -	LMT	1899 May 11
-			8:00	Phil	+08/+09	1942 May
-			9:00	-	+09	1944 Nov
-			8:00	Phil	+08/+09
+			8:00	Phil	P%sT	1942 May
+			9:00	-	JST	1944 Nov
+			8:00	Phil	P%sT
 
 # Qatar
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -2803,15 +3003,34 @@
 
 # Saudi Arabia
 #
-# From Paul Eggert (2014-07-15):
+# From Paul Eggert (2018-08-29):
 # Time in Saudi Arabia and other countries in the Arabian peninsula was not
-# standardized until relatively recently; we don't know when, and possibly it
+# standardized until 1968 or so; we don't know exactly when, and possibly it
 # has never been made official.  Richard P Hunt, in "Islam city yielding to
 # modern times", New York Times (1961-04-09), p 20, wrote that only airlines
 # observed standard time, and that people in Jeddah mostly observed quasi-solar
 # time, doing so by setting their watches at sunrise to 6 o'clock (or to 12
 # o'clock for "Arab" time).
 #
+# Timekeeping differed depending on who you were and which part of Saudi
+# Arabia you were in.  In 1969, Elias Antar wrote that although a common
+# practice had been to set one's watch to 12:00 (i.e., midnight) at sunset -
+# which meant that the time on one side of a mountain could differ greatly from
+# the time on the other side - many foreigners set their watches to 6pm
+# instead, while airlines instead used UTC +03 (except in Dhahran, where they
+# used UTC +04), Aramco used UTC +03 with DST, and the Trans-Arabian Pipe Line
+# Company used Aramco time in eastern Saudi Arabia and airline time in western.
+# (The American Military Aid Advisory Group used plain UTC.)  Antar writes,
+# "A man named Higgins, so the story goes, used to run a local power
+# station. One day, the whole thing became too much for Higgins and he
+# assembled his staff and laid down the law. 'I've had enough of this,' he
+# shrieked. 'It is now 12 o'clock Higgins Time, and from now on this station is
+# going to run on Higgins Time.' And so, until last year, it did."  See:
+# Antar E. Dinner at When? Saudi Aramco World, 1969 March/April. 2-3.
+# http://archive.aramcoworld.com/issue/196902/dinner.at.when.htm
+# newspapers.com says a similar story about Higgins was published in the Port
+# Angeles (WA) Evening News, 1965-03-10, page 5, but I lack access to the text.
+#
 # The TZ database cannot represent quasi-solar time; airline time is the best
 # we can do.  The 1946 foreign air news digest of the U.S. Civil Aeronautics
 # Board (OCLC 42299995) reported that the "... Arabian Government, inaugurated
@@ -2821,7 +3040,8 @@
 #
 # Shanks & Pottenger also state that until 1968-05-01 Saudi Arabia had two
 # time zones; the other zone, at UT +04, was in the far eastern part of
-# the country.  Ignore this, as it's before our 1970 cutoff.
+# the country.  Presumably this is documenting airline time.  Ignore this,
+# as it's before our 1970 cutoff.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Riyadh	3:06:52 -	LMT	1947 Mar 14
--- old/make/data/tzdata/australasia	2019-01-21 18:47:48.709344199 +0100
+++ new/make/data/tzdata/australasia	2019-01-21 18:47:48.489344776 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for Australasia and environs, and for much of the Pacific
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -384,8 +386,15 @@
 # Dominic Fok writes (2017-08-20) that DST ends 2018-01-14, citing
 # Extraordinary Government of Fiji Gazette Supplement No. 21 (2017-08-27),
 # [Legal Notice No. 41] of an order of the previous day by J Usamate.
+
+# From Raymond Kumar (2018-07-13):
+# http://www.fijitimes.com/government-approves-2018-daylight-saving/
+# ... The daylight saving period will end at 3am on Sunday January 13, 2019.
+#
+# From Paul Eggert (2018-07-15):
 # For now, guess DST from 02:00 the first Sunday in November to 03:00
-# the first Sunday on or after January 14.  Although ad hoc, it matches
+# the first Sunday on or after January 13.  January transitions reportedly
+# depend on when school terms start.  Although the guess is ad hoc, it matches
 # transitions since late 2014 and seems more likely to match future
 # practice than guessing no DST.
 
@@ -399,7 +408,7 @@
 Rule	Fiji	2012	2013	-	Jan	Sun>=18	3:00	0	-
 Rule	Fiji	2014	only	-	Jan	Sun>=18	2:00	0	-
 Rule	Fiji	2014	max	-	Nov	Sun>=1	2:00	1:00	-
-Rule	Fiji	2015	max	-	Jan	Sun>=14	3:00	0	-
+Rule	Fiji	2015	max	-	Jan	Sun>=13	3:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Fiji	11:55:44 -	LMT	1915 Oct 26 # Suva
 			12:00	Fiji	+12/+13
--- old/make/data/tzdata/backward	2019-01-21 18:47:49.265342739 +0100
+++ new/make/data/tzdata/backward	2019-01-21 18:47:49.049343306 +0100
@@ -21,10 +21,12 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb links for backward compatibility
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
-# This file provides links between current names for time zones
+# This file provides links between current names for timezones
 # and their old names.  Many names changed in late 1993.
 
 # Link	TARGET			LINK-NAME
--- old/make/data/tzdata/etcetera	2019-01-21 18:47:49.793341354 +0100
+++ new/make/data/tzdata/etcetera	2019-01-21 18:47:49.585341899 +0100
@@ -21,12 +21,14 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for ships at sea and other miscellany
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
 # These entries are mostly present for historical reasons, so that
 # people in areas not otherwise covered by the tz files could "zic -l"
-# to a time zone that was right for their area.  These days, the
+# to a timezone that was right for their area.  These days, the
 # tz files cover almost all the inhabited world, and the only practical
 # need now for the entries that are not on UTC are for ships at sea
 # that cannot use POSIX TZ settings.
--- old/make/data/tzdata/europe	2019-01-21 18:47:50.373339831 +0100
+++ new/make/data/tzdata/europe	2019-01-21 18:47:50.137340450 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for Europe and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -540,7 +542,7 @@
 #
 # To work around this problem, the build procedure can translate the
 # following data into two forms, one with negative SAVE values and the
-# other form with a traditional approximation for Irish time stamps
+# other form with a traditional approximation for Irish timestamps
 # after 1971-10-31 02:00 UTC; although this approximation has tm_isdst
 # flags that are reversed, its UTC offsets are correct and this often
 # suffices.  This source file currently uses only nonnegative SAVE
@@ -2450,6 +2452,33 @@
 # administratively part of Sakhalin oblast', they appear to have
 # remained on UTC+11 along with Magadan.
 
+# From Marat Nigametzianov (2018-07-16):
+# this is link to order from 1956 about timezone in USSR
+# http://astro.uni-altai.ru/~orion/blog/2011/11/novyie-granitsyi-chasovyih-poyasov-v-sssr/
+#
+# From Paul Eggert (2018-07-16):
+# Perhaps someone could translate the above-mentioned link and use it
+# to correct our data for the ex-Soviet Union.  It cites the following:
+# «Поясное время и новые границы часовых поясов» / сост. П.Н. Долгов,
+# отв. ред. Г.Д. Бурдун - М: Комитет стандартов, мер и измерительных
+# приборов при Совете Министров СССР, Междуведомственная комиссия
+# единой службы времени, 1956 г.
+# This book looks like it would be a helpful resource for the Soviet
+# Union through 1956.  Although a copy was in the Scientific Library
+# of Tomsk State University, I have not been able to track down a copy nearby.
+#
+# From Stepan Golosunov (2018-07-21):
+# http://astro.uni-altai.ru/~orion/blog/2015/05/center-reforma-ischisleniya-vremeni-br-na-territorii-sssr-v-1957-godu-center/
+# says that the 1956 decision to change time belts' borders was not
+# implemented as planned in 1956 and the change happened in 1957.
+# There is also the problem that actual time zones were different from
+# the official time belts (and from many time belts' maps) as there were
+# numerous exceptions to application of time belt rules.  For example,
+# https://ru.wikipedia.org/wiki/Московское_время#Перемещение_границы_применения_московского_времени_на_восток
+# says that by 1962 there were many regions in the 3rd time belt that
+# were on Moscow time, referring to a 1962 map.  By 1989 number of such
+# exceptions grew considerably.
+
 # From Tim Parenti (2014-07-06):
 # The comments detailing the coverage of each Russian zone are meant to assist
 # with maintenance only and represent our best guesses as to which regions
@@ -2460,9 +2489,6 @@
 # future stability.  ISO 3166-2:RU codes are also listed for first-level
 # divisions where available.
 
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-
-
 # From Tim Parenti (2014-07-03):
 # Europe/Kaliningrad covers...
 # 39	RU-KGD	Kaliningrad Oblast
@@ -2730,6 +2756,15 @@
 # 34	RU-VGG	Volgograd Oblast
 # The 1988 transition is from USSR act No. 5 (1988-01-04).
 
+# From Alexander Fetisov (2018-09-20):
+# Volgograd region in southern Russia (Europe/Volgograd) change
+# timezone from UTC+3 to UTC+4 from 28oct2018.
+# http://sozd.parliament.gov.ru/bill/452878-7
+#
+# From Stepan Golosunov (2018-10-11):
+# The law has been published today on
+# http://publication.pravo.gov.ru/Document/View/0001201810110037
+
 Zone Europe/Volgograd	 2:57:40 -	LMT	1920 Jan  3
 			 3:00	-	+03	1930 Jun 21
 			 4:00	-	+04	1961 Nov 11
@@ -2738,7 +2773,8 @@
 			 4:00	-	+04	1992 Mar 29  2:00s
 			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
 			 4:00	-	+04	2014 Oct 26  2:00s
-			 3:00	-	+03
+			 3:00	-	+03	2018 Oct 28  2:00s
+			 4:00	-	+04
 
 # From Paul Eggert (2016-11-11):
 # Europe/Saratov covers:
@@ -3427,7 +3463,8 @@
 #Rule NatSpain	1937	only	-	May	22	23:00	1:00	S
 #Rule NatSpain	1937	1938	-	Oct	Sat>=1	24:00s	0	-
 #Rule NatSpain	1938	only	-	Mar	26	23:00	1:00	S
-# The following rules are copied from Morocco from 1967 through 1978.
+# The following rules are copied from Morocco from 1967 through 1978,
+# except with "S" letters.
 Rule SpainAfrica 1967	only	-	Jun	 3	12:00	1:00	S
 Rule SpainAfrica 1967	only	-	Oct	 1	 0:00	0	-
 Rule SpainAfrica 1974	only	-	Jun	24	 0:00	1:00	S
@@ -3447,6 +3484,7 @@
 			 0:00	1:00	WEST	1918 Oct  7 23:00
 			 0:00	-	WET	1924
 			 0:00	Spain	WE%sT	1929
+			 0:00	-	WET	1967 # Help zishrink.awk.
 			 0:00 SpainAfrica WE%sT	1984 Mar 16
 			 1:00	-	CET	1986
 			 1:00	EU	CE%sT
@@ -3632,7 +3670,7 @@
 # http://www.resmigazete.gov.tr/eskiler/2001/03/20010324.htm#2  - for 2001
 # http://www.resmigazete.gov.tr/eskiler/2002/03/20020316.htm#2  - for 2002-2006
 # From Paul Eggert (2016-09-25):
-# Prefer the above sources to Shanks & Pottenger for time stamps after 1985.
+# Prefer the above sources to Shanks & Pottenger for timestamps after 1985.
 
 # From Steffen Thorsen (2007-03-09):
 # Starting 2007 though, it seems that they are adopting EU's 1:00 UTC
@@ -3842,10 +3880,29 @@
 # * Ukrainian Government's Resolution of 20.03.1992, No. 139.
 # http://www.uazakon.com/documents/date_8u/pg_grcasa.htm
 
+# From Paul Eggert (2018-10-03):
+# As is usual in tzdb, Ukrainian zones use the most common English spellings.
+# For example, tzdb uses Europe/Kiev, as "Kiev" is the most common spelling in
+# English for Ukraine's capital, even though it is certainly wrong as a
+# transliteration of the Ukrainian "Київ".  This is similar to tzdb's use of
+# Europe/Prague, which is certainly wrong as a transliteration of the Czech
+# "Praha".  ("Kiev" came from old Slavic via Russian to English, and "Prague"
+# came from old Slavic via French to English, so the two cases have something
+# in common.)  Admittedly English-language spelling of Ukrainian names is
+# controversial, and some day "Kyiv" may become substantially more popular in
+# English; in the meantime, stick with the traditional English "Kiev" as that
+# means less disruption for our users.
+#
+# Anyway, none of the common English-language spellings (Kiev, Kyiv, Kieff,
+# Kijeff, Kijev, Kiyef, Kiyeff) do justice to the common pronunciation in
+# Ukrainian, namely [ˈkɪjiu̯] (IPA).  This pronunciation has nothing like an
+# English "v" or "f", and instead trails off with what an English-speaker
+# would call a demure "oo" sound, and it would would be better anglicized as
+# "Kuiyu".  Here's a sound file, if you would like to do as the Kuiyuvians do:
+# https://commons.wikimedia.org/wiki/File:Uk-Київ.ogg
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-# Most of Ukraine since 1970 has been like Kiev.
-# "Kyiv" is the transliteration of the Ukrainian name, but
-# "Kiev" is more common in English.
+# This represents most of Ukraine.  See above for the spelling of "Kiev".
 Zone Europe/Kiev	2:02:04 -	LMT	1880
 			2:02:04	-	KMT	1924 May  2 # Kiev Mean Time
 			2:00	-	EET	1930 Jun 21
--- old/make/data/tzdata/factory	2019-01-21 18:47:50.941338339 +0100
+++ new/make/data/tzdata/factory	2019-01-21 18:47:50.717338928 +0100
@@ -21,11 +21,13 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for noncommittal factory settings
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
-# For distributors who don't want to put time zone specification in
-# their installation procedures.  Users that run 'date' will get the
+# For distributors who don't want to specify a timezone in their
+# installation procedures.  Users who run 'date' will get the
 # time zone abbreviation "-00", indicating that the actual time zone
 # is unknown.
 
--- old/make/data/tzdata/leapseconds	2019-01-21 18:47:51.505336858 +0100
+++ new/make/data/tzdata/leapseconds	2019-01-21 18:47:51.269337477 +0100
@@ -26,21 +26,25 @@
 # This file is in the public domain.
 
 # This file is generated automatically from the data in the public-domain
-# leap-seconds.list file, which is copied from:
-# ftp://ftp.nist.gov/pub/time/leap-seconds.list
+# leap-seconds.list file, which can be copied from
+# <ftp://ftp.nist.gov/pub/time/leap-seconds.list>
+# or <ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.list>
+# or <ftp://tycho.usno.navy.mil/pub/ntp/leap-seconds.list>.
 # For more about leap-seconds.list, please see
 # The NTP Timescale and Leap Seconds
-# https://www.eecis.udel.edu/~mills/leap.html
+# <https://www.eecis.udel.edu/~mills/leap.html>.
 
 # The International Earth Rotation and Reference Systems Service
 # periodically uses leap seconds to keep UTC to within 0.9 s of UT1
-# (which measures the true angular orientation of the earth in space); see
-# Levine J. Coordinated Universal Time and the leap second.
+# (which measures the true angular orientation of the earth in space)
+# and publishes leap second data in a copyrighted file
+# <https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat>.
+# See: Levine J. Coordinated Universal Time and the leap second.
 # URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995
-# http://ieeexplore.ieee.org/document/7909995/
+# <https://ieeexplore.ieee.org/document/7909995>.
 # There were no leap seconds before 1972, because the official mechanism
 # accounting for the discrepancy between atomic time and the earth's rotation
-# did not exist until the early 1970s.
+# did not exist.
 
 # The correction (+ or -) is made at the given time, so lines
 # will typically look like:
@@ -48,10 +52,7 @@
 # or
 #	Leap	YEAR	MON	DAY	23:59:59	-	R/S
 
-# If the leapsecond is Rolling (R) the given time is local time.
-# If the leapsecond is Stationary (S) the given time is UTC.
-
-# Leap	YEAR	MONTH	DAY	HH:MM:SS	CORR	R/S
+# If the leap second is Rolling (R) the given time is local time (unused here).
 Leap	1972	Jun	30	23:59:60	+	S
 Leap	1972	Dec	31	23:59:60	+	S
 Leap	1973	Dec	31	23:59:60	+	S
@@ -80,5 +81,9 @@
 Leap	2015	Jun	30	23:59:60	+	S
 Leap	2016	Dec	31	23:59:60	+	S
 
-#	Updated through IERS Bulletin C55
-#	File expires on:  28 December 2018
+# POSIX timestamps for the data in this file:
+#updated 1467936000
+#expires 1561680000
+
+#	Updated through IERS Bulletin C56
+#	File expires on:  28 June 2019
--- old/make/data/tzdata/northamerica	2019-01-21 18:47:51.993335576 +0100
+++ new/make/data/tzdata/northamerica	2019-01-21 18:47:51.769336164 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for North and Central America and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -71,7 +73,7 @@
 #
 # Most of the US soon followed suit.  See:
 # Bartky IR. The adoption of standard time. Technol Cult 1989 Jan;30(1):25-56.
-# http://dx.doi.org/10.2307/3105430
+# https://dx.doi.org/10.2307/3105430
 
 # From Paul Eggert (2005-04-16):
 # That 1883 transition occurred at 12:00 new time, not at 12:00 old time.
@@ -460,6 +462,19 @@
 # western South Dakota, far western Texas (El Paso County, Hudspeth County,
 # and Pine Springs and Nickel Creek in Culberson County), Utah, Wyoming
 #
+# From Paul Eggert (2018-10-25):
+# On 1921-03-04 federal law placed all of Texas into the central time zone.
+# However, El Paso ignored the law for decades and continued to observe
+# mountain time, on the grounds that that's what they had always done
+# and they weren't about to let the federal government tell them what to do.
+# Eventually the federal government gave in and changed the law on
+# 1970-04-10 to match what El Paso was actually doing.  Although
+# that's slightly after our 1970 cutoff, there is no need to create a
+# separate zone for El Paso since they were ignoring the law anyway.  See:
+# Long T. El Pasoans were time rebels, fought to stay in Mountain zone.
+# El Paso Times. 2018-10-24 06:40 -06.
+# https://www.elpasotimes.com/story/news/local/el-paso/2018/10/24/el-pasoans-were-time-rebels-fought-stay-mountain-zone/1744509002/
+#
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER
 Rule	Denver	1920	1921	-	Mar	lastSun	2:00	1:00	D
 Rule	Denver	1920	only	-	Oct	lastSun	2:00	0	S
@@ -729,9 +744,7 @@
 Zone Pacific/Honolulu	-10:31:26 -	LMT	1896 Jan 13 12:00
 			-10:30	-	HST	1933 Apr 30  2:00
 			-10:30	1:00	HDT	1933 May 21 12:00
-			-10:30	-	HST	1942 Feb  9  2:00
-			-10:30	1:00	HDT	1945 Sep 30  2:00
-			-10:30	-	HST	1947 Jun  8  2:00
+			-10:30	US	H%sT	1947 Jun  8  2:00
 			-10:00	-	HST
 
 # Now we turn to US areas that have diverged from the consensus since 1970.
--- old/make/data/tzdata/pacificnew	2019-01-21 18:47:52.505334231 +0100
+++ new/make/data/tzdata/pacificnew	2019-01-21 18:47:52.277334830 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for proposed US election time (this file is obsolete)
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
--- old/make/data/tzdata/southamerica	2019-01-21 18:47:53.033332844 +0100
+++ new/make/data/tzdata/southamerica	2019-01-21 18:47:52.809333432 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for South America and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -415,7 +417,7 @@
 # standard time, so let's do that here too.  This does not change UTC
 # offsets, only tm_isdst and the time zone abbreviations.  One minor
 # plus is that this silences a zic complaint that there's no POSIX TZ
-# setting for time stamps past 2038.
+# setting for timestamps past 2038.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
@@ -948,6 +950,14 @@
 # ... https://www.timeanddate.com/news/time/brazil-delays-dst-2018.html
 # From Steffen Thorsen (2017-12-20):
 # http://www.planalto.gov.br/ccivil_03/_ato2015-2018/2017/decreto/D9242.htm
+#
+# From Fábio Gomes (2018-10-04):
+# The Brazilian president just announced a new change on this year DST.
+# It was scheduled to start on November 4th and it was changed to November 18th.
+# From Rodrigo Brüning Wessler (2018-10-15):
+# The Brazilian government just announced that the change in DST was
+# canceled....  Maybe the president Michel Temer also woke up one hour
+# earlier today. :)
 Rule	Brazil	2018	max	-	Nov	Sun>=1	0:00	1:00	-
 Rule	Brazil	2023	only	-	Feb	Sun>=22	0:00	0	-
 Rule	Brazil	2024	2025	-	Feb	Sun>=15	0:00	0	-
@@ -1254,6 +1264,24 @@
 # they will switch from -03 to -04 one hour after Santiago does that day.
 # For now, assume that they will not revert.
 
+# From Juan Correa (2018-08-13):
+# As of moments ago, the Ministry of Energy in Chile has announced the new
+# schema for DST. ...  Announcement in video (in Spanish):
+# https://twitter.com/MinEnergia/status/1029000399129374720
+# From Yonathan Dossow (2018-08-13):
+# The video says "first Saturday of September", we all know it means Sunday at
+# midnight.
+# From Tim Parenti (2018-08-13):
+# Translating the captions on the video at 0:44-0:55, "We want to announce as
+# Government that from 2019, Winter Time will be increased to 5 months, between
+# the first Saturday of April and the first Saturday of September."
+# At 2:08-2:20, "The Magallanes region will maintain its current time, as
+# decided by the citizens during 2017, but our Government will promote a
+# regional dialogue table to gather their opinion on this matter."
+# https://twitter.com/MinEnergia/status/1029009354001973248
+# "We will keep the new time policy unchanged for at least the next 4 years."
+# So we extend the new rules on Saturdays at 24:00 mainland time indefinitely.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Chile	1927	1931	-	Sep	 1	0:00	1:00	-
 Rule	Chile	1928	1932	-	Apr	 1	0:00	0	-
@@ -1287,8 +1315,10 @@
 Rule	Chile	2011	only	-	Aug	Sun>=16	4:00u	1:00	-
 Rule	Chile	2012	2014	-	Apr	Sun>=23	3:00u	0	-
 Rule	Chile	2012	2014	-	Sep	Sun>=2	4:00u	1:00	-
-Rule	Chile	2016	max	-	May	Sun>=9	3:00u	0	-
-Rule	Chile	2016	max	-	Aug	Sun>=9	4:00u	1:00	-
+Rule	Chile	2016	2018	-	May	Sun>=9	3:00u	0	-
+Rule	Chile	2016	2018	-	Aug	Sun>=9	4:00u	1:00	-
+Rule	Chile	2019	max	-	Apr	Sun>=2	3:00u	0	-
+Rule	Chile	2019	max	-	Sep	Sun>=2	4:00u	1:00	-
 # IATA SSIM anomalies: (1992-02) says 1992-03-14;
 # (1996-09) says 1998-03-08.  Ignore these.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
--- old/make/data/tzdata/systemv	2019-01-21 18:47:53.525331551 +0100
+++ new/make/data/tzdata/systemv	2019-01-21 18:47:53.293332161 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for System V rules (this file is obsolete)
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
--- old/make/data/tzdata/zone.tab	2019-01-21 18:47:54.021330247 +0100
+++ new/make/data/tzdata/zone.tab	2019-01-21 18:47:53.801330825 +0100
@@ -21,12 +21,12 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-# tz zone descriptions (deprecated version)
+# tzdb timezone descriptions (deprecated version)
 #
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 #
-# From Paul Eggert (2014-07-31):
+# From Paul Eggert (2018-06-27):
 # This file is intended as a backward-compatibility aid for older programs.
 # New programs should use zone1970.tab.  This file is like zone1970.tab (see
 # zone1970.tab's comments), but with the following additional restrictions:
@@ -35,13 +35,13 @@
 # 2.  The first data column contains exactly one country code.
 #
 # Because of (2), each row stands for an area that is the intersection
-# of a region identified by a country code and of a zone where civil
+# of a region identified by a country code and of a timezone where civil
 # clocks have agreed since 1970; this is a narrower definition than
 # that of zone1970.tab.
 #
-# This table is intended as an aid for users, to help them select time
-# zone data entries appropriate for their practical needs.  It is not
-# intended to take or endorse any position on legal or territorial claims.
+# This table is intended as an aid for users, to help them select timezones
+# appropriate for their practical needs.  It is not intended to take or
+# endorse any position on legal or territorial claims.
 #
 #country-
 #code	coordinates	TZ			comments
@@ -291,7 +291,7 @@
 MN	+4755+10653	Asia/Ulaanbaatar	Mongolia (most areas)
 MN	+4801+09139	Asia/Hovd	Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan
 MN	+4804+11430	Asia/Choibalsan	Dornod, Sukhbaatar
-MO	+2214+11335	Asia/Macau
+MO	+221150+1133230	Asia/Macau
 MP	+1512+14545	Pacific/Saipan
 MQ	+1436-06105	America/Martinique
 MR	+1806-01557	Africa/Nouakchott
--- old/make/hotspot/lib/JvmOverrideFiles.gmk	2019-01-21 18:47:54.461329090 +0100
+++ new/make/hotspot/lib/JvmOverrideFiles.gmk	2019-01-21 18:47:54.229329700 +0100
@@ -30,7 +30,7 @@
 # status for individual files on specific platforms.
 
 ifeq ($(TOOLCHAIN_TYPE), gcc)
-  BUILD_LIBJVM_vmStructs.cpp_CXXFLAGS := -fno-var-tracking-assignments -O0
+  BUILD_LIBJVM_vmStructs.cpp_CXXFLAGS := -fno-var-tracking-assignments
   BUILD_LIBJVM_jvmciCompilerToVM.cpp_CXXFLAGS := -fno-var-tracking-assignments
   BUILD_LIBJVM_jvmciCompilerToVMInit.cpp_CXXFLAGS := -fno-var-tracking-assignments
   BUILD_LIBJVM_assembler_x86.cpp_CXXFLAGS := -Wno-maybe-uninitialized
@@ -43,20 +43,26 @@
   endif
 endif
 
+LIBJVM_FDLIBM_COPY_OPT_FLAG := $(CXX_O_FLAG_NONE)
+# If the FDLIBM_CFLAGS variable is non-empty we know
+# that the fdlibm-fork in hotspot can get optimized
+# by using -ffp-contract=off on GCC/Clang platforms.
+ifneq ($(FDLIBM_CFLAGS), )
+  LIBJVM_FDLIBM_COPY_OPT_FLAG := $(CXX_O_FLAG_NORM)
+endif
+
 ifeq ($(OPENJDK_TARGET_OS), linux)
   BUILD_LIBJVM_ostream.cpp_CXXFLAGS := -D_FILE_OFFSET_BITS=64
   BUILD_LIBJVM_logFileOutput.cpp_CXXFLAGS := -D_FILE_OFFSET_BITS=64
 
-  ifeq ($(OPENJDK_TARGET_CPU_ARCH), x86)
-    BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := -DNO_PCH $(CXX_O_FLAG_NONE)
-    BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := -DNO_PCH $(CXX_O_FLAG_NONE)
-
-    ifeq ($(TOOLCHAIN_TYPE), clang)
-      JVM_PRECOMPILED_HEADER_EXCLUDE := \
-          sharedRuntimeTrig.cpp \
-          sharedRuntimeTrans.cpp \
-          #
-    endif
+  BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := -DNO_PCH $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG)
+  BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := -DNO_PCH $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG)
+
+  ifeq ($(TOOLCHAIN_TYPE), clang)
+    JVM_PRECOMPILED_HEADER_EXCLUDE := \
+	sharedRuntimeTrig.cpp \
+	sharedRuntimeTrans.cpp \
+	#
   endif
 
   ifeq ($(OPENJDK_TARGET_CPU), x86)
@@ -125,8 +131,8 @@
 
 else ifeq ($(OPENJDK_TARGET_OS), macosx)
   # The copied fdlibm routines in these files must not be optimized
-  BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := $(CXX_O_FLAG_NONE)
-  BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := $(CXX_O_FLAG_NONE)
+  BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG)
+  BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG)
   ifeq ($(TOOLCHAIN_TYPE), clang)
     # NOTE: The old build tested clang version to make sure this workaround
     # for the clang bug was still needed.
--- old/make/lib/CoreLibraries.gmk	2019-01-21 18:47:54.965327765 +0100
+++ new/make/lib/CoreLibraries.gmk	2019-01-21 18:47:54.745328344 +0100
@@ -39,20 +39,15 @@
   BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
 endif
 
-ifeq ($(OPENJDK_TARGET_OS), linux)
-  ifeq ($(OPENJDK_TARGET_CPU), ppc64)
-    BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
-  else ifeq ($(OPENJDK_TARGET_CPU), ppc64le)
-    BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
-  else ifeq ($(OPENJDK_TARGET_CPU), s390x)
-    BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
-  else ifeq ($(OPENJDK_TARGET_CPU), aarch64)
-    BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
-  endif
+# If FDLIBM_CFLAGS is non-empty we know that we can optimize
+# fdlibm when adding those extra C flags. Currently GCC,
+# and clang only.
+ifneq ($(FDLIBM_CFLAGS), )
+  BUILD_LIBFDLIBM_OPTIMIZATION := LOW
 endif
 
 LIBFDLIBM_SRC := $(TOPDIR)/src/java.base/share/native/libfdlibm
-LIBFDLIBM_CFLAGS := -I$(LIBFDLIBM_SRC)
+LIBFDLIBM_CFLAGS := -I$(LIBFDLIBM_SRC) $(FDLIBM_CFLAGS)
 
 ifneq ($(OPENJDK_TARGET_OS), macosx)
   $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM, \
@@ -64,10 +59,6 @@
       CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \
       CFLAGS_windows_debug := -DLOGGING, \
       CFLAGS_aix := -qfloat=nomaf, \
-      CFLAGS_linux_ppc64 := -ffp-contract=off, \
-      CFLAGS_linux_ppc64le := -ffp-contract=off, \
-      CFLAGS_linux_s390x := -ffp-contract=off, \
-      CFLAGS_linux_aarch64 := -ffp-contract=off, \
       DISABLED_WARNINGS_gcc := sign-compare misleading-indentation array-bounds, \
       DISABLED_WARNINGS_microsoft := 4146 4244 4018, \
       ARFLAGS := $(ARFLAGS), \
--- old/make/lib/Lib-java.base.gmk	2019-01-21 18:47:55.497326365 +0100
+++ new/make/lib/Lib-java.base.gmk	2019-01-21 18:47:55.281326934 +0100
@@ -138,6 +138,7 @@
 
     $(eval $(call SetupJdkLibrary, BUILD_LIBJSIG, \
         NAME := jsig, \
+        OPTIMIZATION := LOW, \
         CFLAGS := $(CFLAGS_JDKLIB) $(LIBJSIG_CFLAGS), \
         LDFLAGS := $(LDFLAGS_JDKLIB) \
             $(call SET_SHARED_LIBRARY_ORIGIN), \
--- old/make/lib/Lib-jdk.hotspot.agent.gmk	2019-01-21 18:47:56.017324998 +0100
+++ new/make/lib/Lib-jdk.hotspot.agent.gmk	2019-01-21 18:47:55.801325567 +0100
@@ -44,7 +44,12 @@
   ifeq ($(OPENJDK_TARGET_CPU), x86_64)
     SA_CXXFLAGS := -DWIN64
   else
-    SA_CXXFLAGS := -RTC1
+    # Only add /RTC1 flag for debug builds as it's
+    # incompatible with release type builds. See
+    # https://msdn.microsoft.com/en-us/library/8wtf2dfz.aspx
+    ifeq ($(DEBUG_LEVEL),slowdebug)
+      SA_CXXFLAGS := -RTC1
+    endif
   endif
 endif
 
@@ -52,7 +57,7 @@
 
 $(eval $(call SetupJdkLibrary, BUILD_LIBSA, \
     NAME := saproc, \
-    OPTIMIZATION := NONE, \
+    OPTIMIZATION := HIGH, \
     DISABLED_WARNINGS_microsoft := 4267, \
     DISABLED_WARNINGS_gcc := sign-compare, \
     DISABLED_WARNINGS_CXX_solstudio := truncwarn unknownpragma, \
--- old/make/test/JtregNativeHotspot.gmk	2019-01-21 18:47:56.521323672 +0100
+++ new/make/test/JtregNativeHotspot.gmk	2019-01-21 18:47:56.293324272 +0100
@@ -139,6 +139,15 @@
     -I$(VM_TESTBASE_DIR)/nsk/share/native \
     -I$(VM_TESTBASE_DIR)/nsk/share/jni
 
+NO_FRAMEPOINTER_CFLAGS :=
+ifeq ($(OPENJDK_TARGET_OS),linux)
+   NO_FRAMEPOINTER_CFLAGS := -fomit-frame-pointer
+endif
+
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libNoFramePointer := $(NO_FRAMEPOINTER_CFLAGS)
+# Optimization -O3 needed, HIGH == -O3
+BUILD_HOTSPOT_JTREG_LIBRARIES_OPTIMIZATION_libNoFramePointer := HIGH
+
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libProcessUtils := $(VM_SHARE_INCLUDES)
 
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libThreadController := $(NSK_MONITORING_INCLUDES)
--- old/src/demo/share/jfc/J2Ddemo/java2d/DemoInstVarsAccessor.java	2019-01-21 18:47:57.013322378 +0100
+++ new/src/demo/share/jfc/J2Ddemo/java2d/DemoInstVarsAccessor.java	2019-01-21 18:47:56.809322915 +0100
@@ -1,3 +1,34 @@
+/*
+ *
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 package java2d;
 
 import java.awt.Color;
--- old/src/demo/share/jfc/J2Ddemo/java2d/DemoInstVarsAccessorImplBase.java	2019-01-21 18:47:57.473321167 +0100
+++ new/src/demo/share/jfc/J2Ddemo/java2d/DemoInstVarsAccessorImplBase.java	2019-01-21 18:47:57.253321746 +0100
@@ -1,3 +1,34 @@
+/*
+ *
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 package java2d;
 
 import java.awt.Color;
--- old/src/hotspot/os_cpu/linux_zero/os_linux_zero.hpp	2019-01-21 18:47:58.005319767 +0100
+++ new/src/hotspot/os_cpu/linux_zero/os_linux_zero.hpp	2019-01-21 18:47:57.789320336 +0100
@@ -54,6 +54,16 @@
                   "std %0, %1\n"
                   : "=&f"(tmp), "=Q"(*(volatile double*)dst)
                   : "Q"(*(volatile double*)src));
+#elif defined(__ARM_ARCH_7A__)
+    // Note that a ldrexd + clrex combination is only needed for
+    // correctness on the OS level (context-switches). In this
+    // case, clrex *may* be beneficial for performance. For now
+    // don't bother with clrex as this is Zero.
+    jlong tmp;
+    asm volatile ("ldrexd  %0, [%1]\n"
+                  : "=r"(tmp)
+                  : "r"(src), "m"(src));
+    *(jlong *) dst = tmp;
 #else
     *(jlong *) dst = *(const jlong *) src;
 #endif
--- old/src/hotspot/share/memory/filemap.cpp	2019-01-21 18:47:58.521318409 +0100
+++ new/src/hotspot/share/memory/filemap.cpp	2019-01-21 18:47:58.301318988 +0100
@@ -994,8 +994,8 @@
 }
 
 bool FileMapInfo::verify_mapped_heap_regions(int first, int num) {
-  for (int i = first;
-           i <= first + num; i++) {
+  assert(num > 0, "sanity");
+  for (int i = first; i < first + num; i++) {
     if (!verify_region_checksum(i)) {
       return false;
     }
@@ -1029,6 +1029,7 @@
 #endif // INCLUDE_CDS_JAVA_HEAP
 
 bool FileMapInfo::verify_region_checksum(int i) {
+  assert(i >= 0 && i < MetaspaceShared::n_regions, "invalid region");
   if (!VerifySharedSpaces) {
     return true;
   }
--- old/src/java.base/share/classes/com/sun/crypto/provider/HmacPKCS12PBESHA1.java	2019-01-21 18:47:59.025317083 +0100
+++ new/src/java.base/share/classes/com/sun/crypto/provider/HmacPKCS12PBESHA1.java	2019-01-21 18:47:58.813317641 +0100
@@ -73,62 +73,69 @@
             salt = pbeKey.getSalt(); // maybe null if unspecified
             iCount = pbeKey.getIterationCount(); // maybe 0 if unspecified
         } else if (key instanceof SecretKey) {
-            byte[] passwdBytes = key.getEncoded();
-            if ((passwdBytes == null) ||
-                !(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3))) {
+            byte[] passwdBytes;
+            if (!(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3)) ||
+                    (passwdBytes = key.getEncoded()) == null) {
                 throw new InvalidKeyException("Missing password");
             }
             passwdChars = new char[passwdBytes.length];
             for (int i=0; i<passwdChars.length; i++) {
                 passwdChars[i] = (char) (passwdBytes[i] & 0x7f);
             }
+            Arrays.fill(passwdBytes, (byte)0x00);
         } else {
             throw new InvalidKeyException("SecretKey of PBE type required");
         }
-        if (params == null) {
-            // should not auto-generate default values since current
-            // javax.crypto.Mac api does not have any method for caller to
-            // retrieve the generated defaults.
-            if ((salt == null) || (iCount == 0)) {
-                throw new InvalidAlgorithmParameterException
-                    ("PBEParameterSpec required for salt and iteration count");
-            }
-        } else if (!(params instanceof PBEParameterSpec)) {
-            throw new InvalidAlgorithmParameterException
-                ("PBEParameterSpec type required");
-        } else {
-            PBEParameterSpec pbeParams = (PBEParameterSpec) params;
-            // make sure the parameter values are consistent
-            if (salt != null) {
-                if (!Arrays.equals(salt, pbeParams.getSalt())) {
+
+        byte[] derivedKey;
+        try {
+            if (params == null) {
+                // should not auto-generate default values since current
+                // javax.crypto.Mac api does not have any method for caller to
+                // retrieve the generated defaults.
+                if ((salt == null) || (iCount == 0)) {
                     throw new InvalidAlgorithmParameterException
-                        ("Inconsistent value of salt between key and params");
+                            ("PBEParameterSpec required for salt and iteration count");
                 }
+            } else if (!(params instanceof PBEParameterSpec)) {
+                throw new InvalidAlgorithmParameterException
+                        ("PBEParameterSpec type required");
             } else {
-                salt = pbeParams.getSalt();
-            }
-            if (iCount != 0) {
-                if (iCount != pbeParams.getIterationCount()) {
-                    throw new InvalidAlgorithmParameterException
-                        ("Different iteration count between key and params");
+                PBEParameterSpec pbeParams = (PBEParameterSpec) params;
+                // make sure the parameter values are consistent
+                if (salt != null) {
+                    if (!Arrays.equals(salt, pbeParams.getSalt())) {
+                        throw new InvalidAlgorithmParameterException
+                                ("Inconsistent value of salt between key and params");
+                    }
+                } else {
+                    salt = pbeParams.getSalt();
+                }
+                if (iCount != 0) {
+                    if (iCount != pbeParams.getIterationCount()) {
+                        throw new InvalidAlgorithmParameterException
+                                ("Different iteration count between key and params");
+                    }
+                } else {
+                    iCount = pbeParams.getIterationCount();
                 }
-            } else {
-                iCount = pbeParams.getIterationCount();
             }
+            // For security purpose, we need to enforce a minimum length
+            // for salt; just require the minimum salt length to be 8-byte
+            // which is what PKCS#5 recommends and openssl does.
+            if (salt.length < 8) {
+                throw new InvalidAlgorithmParameterException
+                        ("Salt must be at least 8 bytes long");
+            }
+            if (iCount <= 0) {
+                throw new InvalidAlgorithmParameterException
+                        ("IterationCount must be a positive number");
+            }
+            derivedKey = PKCS12PBECipherCore.derive(passwdChars, salt,
+                    iCount, engineGetMacLength(), PKCS12PBECipherCore.MAC_KEY);
+        } finally {
+            Arrays.fill(passwdChars, '\0');
         }
-        // For security purpose, we need to enforce a minimum length
-        // for salt; just require the minimum salt length to be 8-byte
-        // which is what PKCS#5 recommends and openssl does.
-        if (salt.length < 8) {
-            throw new InvalidAlgorithmParameterException
-                ("Salt must be at least 8 bytes long");
-        }
-        if (iCount <= 0) {
-            throw new InvalidAlgorithmParameterException
-                ("IterationCount must be a positive number");
-        }
-        byte[] derivedKey = PKCS12PBECipherCore.derive(passwdChars, salt,
-            iCount, engineGetMacLength(), PKCS12PBECipherCore.MAC_KEY);
         SecretKey cipherKey = new SecretKeySpec(derivedKey, "HmacSHA1");
         super.engineInit(cipherKey, null);
     }
--- old/src/java.base/share/classes/com/sun/crypto/provider/KeyProtector.java	2019-01-21 18:47:59.505315819 +0100
+++ new/src/java.base/share/classes/com/sun/crypto/provider/KeyProtector.java	2019-01-21 18:47:59.285316398 +0100
@@ -37,12 +37,15 @@
 import java.security.AlgorithmParameters;
 import java.security.spec.InvalidParameterSpecException;
 import java.security.spec.PKCS8EncodedKeySpec;
+import java.util.Arrays;
 
 import javax.crypto.Cipher;
 import javax.crypto.CipherSpi;
 import javax.crypto.SecretKey;
 import javax.crypto.SealedObject;
 import javax.crypto.spec.*;
+import javax.security.auth.DestroyFailedException;
+
 import sun.security.x509.AlgorithmId;
 import sun.security.util.ObjectIdentifier;
 
@@ -103,15 +106,20 @@
 
         // create PBE key from password
         PBEKeySpec pbeKeySpec = new PBEKeySpec(this.password);
-        SecretKey sKey = new PBEKey(pbeKeySpec, "PBEWithMD5AndTripleDES");
-        pbeKeySpec.clearPassword();
-
-        // encrypt private key
+        SecretKey sKey = null;
         PBEWithMD5AndTripleDESCipher cipher;
-        cipher = new PBEWithMD5AndTripleDESCipher();
-        cipher.engineInit(Cipher.ENCRYPT_MODE, sKey, pbeSpec, null);
+        try {
+            sKey = new PBEKey(pbeKeySpec, "PBEWithMD5AndTripleDES", false);
+            // encrypt private key
+            cipher = new PBEWithMD5AndTripleDESCipher();
+            cipher.engineInit(Cipher.ENCRYPT_MODE, sKey, pbeSpec, null);
+        } finally {
+            pbeKeySpec.clearPassword();
+            if (sKey != null) sKey.destroy();
+        }
         byte[] plain = key.getEncoded();
         byte[] encrKey = cipher.engineDoFinal(plain, 0, plain.length);
+        Arrays.fill(plain, (byte) 0x00);
 
         // wrap encrypted private key in EncryptedPrivateKeyInfo
         // (as defined in PKCS#8)
@@ -131,8 +139,8 @@
     Key recover(EncryptedPrivateKeyInfo encrInfo)
         throws UnrecoverableKeyException, NoSuchAlgorithmException
     {
-        byte[] plain;
-
+        byte[] plain = null;
+        SecretKey sKey = null;
         try {
             String encrAlg = encrInfo.getAlgorithm().getOID().toString();
             if (!encrAlg.equals(PBE_WITH_MD5_AND_DES3_CBC_OID)
@@ -160,8 +168,7 @@
 
                 // create PBE key from password
                 PBEKeySpec pbeKeySpec = new PBEKeySpec(this.password);
-                SecretKey sKey =
-                    new PBEKey(pbeKeySpec, "PBEWithMD5AndTripleDES");
+                sKey = new PBEKey(pbeKeySpec, "PBEWithMD5AndTripleDES", false);
                 pbeKeySpec.clearPassword();
 
                 // decrypt private key
@@ -178,7 +185,6 @@
                 (new PrivateKeyInfo(plain).getAlgorithm().getOID()).getName();
             KeyFactory kFac = KeyFactory.getInstance(oidName);
             return kFac.generatePrivate(new PKCS8EncodedKeySpec(plain));
-
         } catch (NoSuchAlgorithmException ex) {
             // Note: this catch needed to be here because of the
             // later catch of GeneralSecurityException
@@ -187,6 +193,15 @@
             throw new UnrecoverableKeyException(ioe.getMessage());
         } catch (GeneralSecurityException gse) {
             throw new UnrecoverableKeyException(gse.getMessage());
+        } finally {
+            if (plain != null) Arrays.fill(plain, (byte) 0x00);
+            if (sKey != null) {
+                try {
+                    sKey.destroy();
+                } catch (DestroyFailedException e) {
+                    //shouldn't happen
+                }
+            }
         }
     }
 
@@ -262,7 +277,7 @@
         // of <code>protectedKey</code>. If the two digest values are
         // different, throw an exception.
         md.update(passwdBytes);
-        java.util.Arrays.fill(passwdBytes, (byte)0x00);
+        Arrays.fill(passwdBytes, (byte)0x00);
         passwdBytes = null;
         md.update(plainKey);
         digest = md.digest();
@@ -291,17 +306,21 @@
 
         // create PBE key from password
         PBEKeySpec pbeKeySpec = new PBEKeySpec(this.password);
-        SecretKey sKey = new PBEKey(pbeKeySpec, "PBEWithMD5AndTripleDES");
-        pbeKeySpec.clearPassword();
-
-        // seal key
+        SecretKey sKey = null;
         Cipher cipher;
+        try {
+            sKey = new PBEKey(pbeKeySpec, "PBEWithMD5AndTripleDES", false);
+            pbeKeySpec.clearPassword();
 
-        PBEWithMD5AndTripleDESCipher cipherSpi;
-        cipherSpi = new PBEWithMD5AndTripleDESCipher();
-        cipher = new CipherForKeyProtector(cipherSpi, SunJCE.getInstance(),
-                                           "PBEWithMD5AndTripleDES");
-        cipher.init(Cipher.ENCRYPT_MODE, sKey, pbeSpec);
+            // seal key
+            PBEWithMD5AndTripleDESCipher cipherSpi;
+            cipherSpi = new PBEWithMD5AndTripleDESCipher();
+            cipher = new CipherForKeyProtector(cipherSpi, SunJCE.getInstance(),
+                                               "PBEWithMD5AndTripleDES");
+            cipher.init(Cipher.ENCRYPT_MODE, sKey, pbeSpec);
+        } finally {
+            if (sKey != null) sKey.destroy();
+        }
         return new SealedObjectForKeyProtector(key, cipher);
     }
 
@@ -309,12 +328,13 @@
      * Unseals the sealed key.
      */
     Key unseal(SealedObject so)
-        throws NoSuchAlgorithmException, UnrecoverableKeyException
-    {
+        throws NoSuchAlgorithmException, UnrecoverableKeyException {
+        SecretKey sKey = null;
         try {
             // create PBE key from password
             PBEKeySpec pbeKeySpec = new PBEKeySpec(this.password);
-            SecretKey skey = new PBEKey(pbeKeySpec, "PBEWithMD5AndTripleDES");
+            sKey = new PBEKey(pbeKeySpec,
+                    "PBEWithMD5AndTripleDES", false);
             pbeKeySpec.clearPassword();
 
             SealedObjectForKeyProtector soForKeyProtector = null;
@@ -342,7 +362,7 @@
             Cipher cipher = new CipherForKeyProtector(cipherSpi,
                                                       SunJCE.getInstance(),
                                                       "PBEWithMD5AndTripleDES");
-            cipher.init(Cipher.DECRYPT_MODE, skey, params);
+            cipher.init(Cipher.DECRYPT_MODE, sKey, params);
             return soForKeyProtector.getKey(cipher);
         } catch (NoSuchAlgorithmException ex) {
             // Note: this catch needed to be here because of the
@@ -354,6 +374,14 @@
             throw new UnrecoverableKeyException(cnfe.getMessage());
         } catch (GeneralSecurityException gse) {
             throw new UnrecoverableKeyException(gse.getMessage());
+        } finally {
+            if (sKey != null) {
+                try {
+                    sKey.destroy();
+                } catch (DestroyFailedException e) {
+                    //shouldn't happen
+                }
+            }
         }
     }
 }
--- old/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java	2019-01-21 18:48:00.045314398 +0100
+++ new/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java	2019-01-21 18:47:59.837314944 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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,6 +29,7 @@
 import java.security.MessageDigest;
 import java.security.KeyRep;
 import java.security.spec.InvalidKeySpecException;
+import java.util.Arrays;
 import java.util.Locale;
 import javax.crypto.SecretKey;
 import javax.crypto.spec.PBEKeySpec;
@@ -54,7 +55,8 @@
      *
      * @param keytype the given PBE key specification
      */
-    PBEKey(PBEKeySpec keySpec, String keytype) throws InvalidKeySpecException {
+    PBEKey(PBEKeySpec keySpec, String keytype, boolean useCleaner)
+            throws InvalidKeySpecException {
         char[] passwd = keySpec.getPassword();
         if (passwd == null) {
             // Should allow an empty password.
@@ -71,13 +73,15 @@
         this.key = new byte[passwd.length];
         for (int i=0; i<passwd.length; i++)
             this.key[i] = (byte) (passwd[i] & 0x7f);
-        java.util.Arrays.fill(passwd, ' ');
+        Arrays.fill(passwd, '\0');
         type = keytype;
 
         // Use the cleaner to zero the key when no longer referenced
-        final byte[] k = this.key;
-        CleanerFactory.cleaner().register(this,
-                () -> java.util.Arrays.fill(k, (byte)0x00));
+        if (useCleaner) {
+            final byte[] k = this.key;
+            CleanerFactory.cleaner().register(this,
+                () -> Arrays.fill(k, (byte) 0x00));
+        }
     }
 
     public byte[] getEncoded() {
@@ -122,11 +126,23 @@
 
         byte[] thatEncoded = that.getEncoded();
         boolean ret = MessageDigest.isEqual(this.key, thatEncoded);
-        java.util.Arrays.fill(thatEncoded, (byte)0x00);
+        Arrays.fill(thatEncoded, (byte)0x00);
         return ret;
     }
 
     /**
+     * Clears the internal copy of the key.
+     *
+     */
+    @Override
+    public void destroy() {
+        if (key != null) {
+            Arrays.fill(key, (byte) 0x00);
+            key = null;
+        }
+    }
+
+    /**
      * readObject is called to restore the state of this key from
      * a stream.
      */
--- old/src/java.base/share/classes/com/sun/crypto/provider/PBEKeyFactory.java	2019-01-21 18:48:00.573313006 +0100
+++ new/src/java.base/share/classes/com/sun/crypto/provider/PBEKeyFactory.java	2019-01-21 18:48:00.369313543 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -216,7 +216,7 @@
         if (!(keySpec instanceof PBEKeySpec)) {
             throw new InvalidKeySpecException("Invalid key spec");
         }
-        return new PBEKey((PBEKeySpec)keySpec, type);
+        return new PBEKey((PBEKeySpec)keySpec, type, true);
     }
 
     /**
--- old/src/java.base/share/classes/com/sun/crypto/provider/PBES1Core.java	2019-01-21 18:48:01.057311732 +0100
+++ new/src/java.base/share/classes/com/sun/crypto/provider/PBES1Core.java	2019-01-21 18:48:00.841312300 +0100
@@ -27,6 +27,7 @@
 
 import java.security.*;
 import java.security.spec.*;
+import java.util.Arrays;
 import javax.crypto.*;
 import javax.crypto.spec.*;
 
@@ -213,35 +214,43 @@
             throw new InvalidAlgorithmParameterException("Parameters "
                                                          + "missing");
         }
-        if ((key == null) ||
-            (key.getEncoded() == null) ||
-            !(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3))) {
-            throw new InvalidKeyException("Missing password");
+        if (key == null) {
+            throw new InvalidKeyException("Null key");
         }
 
-        if (params == null) {
-            // create random salt and use default iteration count
-            salt = new byte[8];
-            random.nextBytes(salt);
-        } else {
-            if (!(params instanceof PBEParameterSpec)) {
-                throw new InvalidAlgorithmParameterException
-                    ("Wrong parameter type: PBE expected");
-            }
-            salt = ((PBEParameterSpec) params).getSalt();
-            // salt must be 8 bytes long (by definition)
-            if (salt.length != 8) {
-                throw new InvalidAlgorithmParameterException
-                    ("Salt must be 8 bytes long");
+        byte[] derivedKey;
+        byte[] passwdBytes = key.getEncoded();
+        try {
+            if ((passwdBytes == null) ||
+                    !(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3))) {
+                throw new InvalidKeyException("Missing password");
             }
-            iCount = ((PBEParameterSpec) params).getIterationCount();
-            if (iCount <= 0) {
-                throw new InvalidAlgorithmParameterException
-                    ("IterationCount must be a positive number");
+
+            if (params == null) {
+                // create random salt and use default iteration count
+                salt = new byte[8];
+                random.nextBytes(salt);
+            } else {
+                if (!(params instanceof PBEParameterSpec)) {
+                    throw new InvalidAlgorithmParameterException
+                            ("Wrong parameter type: PBE expected");
+                }
+                salt = ((PBEParameterSpec) params).getSalt();
+                // salt must be 8 bytes long (by definition)
+                if (salt.length != 8) {
+                    throw new InvalidAlgorithmParameterException
+                            ("Salt must be 8 bytes long");
+                }
+                iCount = ((PBEParameterSpec) params).getIterationCount();
+                if (iCount <= 0) {
+                    throw new InvalidAlgorithmParameterException
+                            ("IterationCount must be a positive number");
+                }
             }
+            derivedKey = deriveCipherKey(passwdBytes);
+        } finally {
+            if (passwdBytes != null) Arrays.fill(passwdBytes, (byte) 0x00);
         }
-
-        byte[] derivedKey = deriveCipherKey(key);
         // use all but the last 8 bytes as the key value
         SecretKeySpec cipherKey = new SecretKeySpec(derivedKey, 0,
                                                     derivedKey.length-8, algo);
@@ -253,16 +262,14 @@
         cipher.init(opmode, cipherKey, ivSpec, random);
     }
 
-    private byte[] deriveCipherKey(Key key) {
+    private byte[] deriveCipherKey(byte[] passwdBytes) {
 
         byte[] result = null;
-        byte[] passwdBytes = key.getEncoded();
 
         if (algo.equals("DES")) {
             // P || S (password concatenated with salt)
             byte[] concat = new byte[Math.addExact(passwdBytes.length, salt.length)];
             System.arraycopy(passwdBytes, 0, concat, 0, passwdBytes.length);
-            java.util.Arrays.fill(passwdBytes, (byte)0x00);
             System.arraycopy(salt, 0, concat, passwdBytes.length, salt.length);
 
             // digest P || S with c iterations
@@ -271,7 +278,7 @@
                 md.update(toBeHashed);
                 toBeHashed = md.digest(); // this resets the digest
             }
-            java.util.Arrays.fill(concat, (byte)0x00);
+            Arrays.fill(concat, (byte)0x00);
             result = toBeHashed;
         } else if (algo.equals("DESede")) {
             // if the 2 salt halves are the same, invert one of them
@@ -294,8 +301,6 @@
             // Concatenate the output from each digest round with the
             // password, and use the result as the input to the next digest
             // operation.
-            byte[] kBytes = null;
-            IvParameterSpec iv = null;
             byte[] toBeHashed = null;
             result = new byte[DESedeKeySpec.DES_EDE_KEY_LEN +
                               DESConstants.DES_BLOCK_SIZE];
@@ -306,12 +311,14 @@
                 for (int j=0; j < iCount; j++) {
                     md.update(toBeHashed);
                     md.update(passwdBytes);
-                    toBeHashed = md.digest(); // this resets the digest
+                    toBeHashed = md.digest();
                 }
                 System.arraycopy(toBeHashed, 0, result, i*16,
                                  toBeHashed.length);
             }
         }
+        // clear data used in message
+        md.reset();
         return result;
     }
 
@@ -478,9 +485,9 @@
     byte[] wrap(Key key)
         throws IllegalBlockSizeException, InvalidKeyException {
         byte[] result = null;
-
+        byte[] encodedKey = null;
         try {
-            byte[] encodedKey = key.getEncoded();
+            encodedKey = key.getEncoded();
             if ((encodedKey == null) || (encodedKey.length == 0)) {
                 throw new InvalidKeyException("Cannot get an encoding of " +
                                               "the key to be wrapped");
@@ -489,6 +496,8 @@
             result = doFinal(encodedKey, 0, encodedKey.length);
         } catch (BadPaddingException e) {
             // Should never happen
+        } finally {
+            if (encodedKey != null) Arrays.fill(encodedKey, (byte)0x00);
         }
 
         return result;
--- old/src/java.base/share/classes/com/sun/crypto/provider/PBES2Core.java	2019-01-21 18:48:01.561310403 +0100
+++ new/src/java.base/share/classes/com/sun/crypto/provider/PBES2Core.java	2019-01-21 18:48:01.353310951 +0100
@@ -27,6 +27,7 @@
 
 import java.security.*;
 import java.security.spec.*;
+import java.util.Arrays;
 import javax.crypto.*;
 import javax.crypto.spec.*;
 
@@ -173,101 +174,105 @@
                               SecureRandom random)
         throws InvalidKeyException, InvalidAlgorithmParameterException {
 
-        if ((key == null) ||
-            (key.getEncoded() == null) ||
-            !(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3))) {
-            throw new InvalidKeyException("Missing password");
+        if (key == null) {
+            throw new InvalidKeyException("Null key");
         }
 
-        // TBD: consolidate the salt, ic and IV parameter checks below
-
-        // Extract salt and iteration count from the key, if present
-        if (key instanceof javax.crypto.interfaces.PBEKey) {
-            salt = ((javax.crypto.interfaces.PBEKey)key).getSalt();
-            if (salt != null && salt.length < 8) {
-                throw new InvalidAlgorithmParameterException(
-                    "Salt must be at least 8 bytes long");
-            }
-            iCount = ((javax.crypto.interfaces.PBEKey)key).getIterationCount();
-            if (iCount == 0) {
-                iCount = DEFAULT_COUNT;
-            } else if (iCount < 0) {
-                throw new InvalidAlgorithmParameterException(
-                    "Iteration count must be a positive number");
+        byte[] passwdBytes = key.getEncoded();
+        char[] passwdChars = null;
+        PBEKeySpec pbeSpec;
+        try {
+            if ((passwdBytes == null) ||
+                    !(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3))) {
+                throw new InvalidKeyException("Missing password");
             }
-        }
 
-        // Extract salt, iteration count and IV from the params, if present
-        if (params == null) {
-            if (salt == null) {
-                // generate random salt and use default iteration count
-                salt = new byte[DEFAULT_SALT_LENGTH];
-                random.nextBytes(salt);
-                iCount = DEFAULT_COUNT;
+            // TBD: consolidate the salt, ic and IV parameter checks below
+
+            // Extract salt and iteration count from the key, if present
+            if (key instanceof javax.crypto.interfaces.PBEKey) {
+                salt = ((javax.crypto.interfaces.PBEKey)key).getSalt();
+                if (salt != null && salt.length < 8) {
+                    throw new InvalidAlgorithmParameterException(
+                            "Salt must be at least 8 bytes long");
+                }
+                iCount = ((javax.crypto.interfaces.PBEKey)key).getIterationCount();
+                if (iCount == 0) {
+                    iCount = DEFAULT_COUNT;
+                } else if (iCount < 0) {
+                    throw new InvalidAlgorithmParameterException(
+                            "Iteration count must be a positive number");
+                }
             }
-            if ((opmode == Cipher.ENCRYPT_MODE) ||
+
+            // Extract salt, iteration count and IV from the params, if present
+            if (params == null) {
+                if (salt == null) {
+                    // generate random salt and use default iteration count
+                    salt = new byte[DEFAULT_SALT_LENGTH];
+                    random.nextBytes(salt);
+                    iCount = DEFAULT_COUNT;
+                }
+                if ((opmode == Cipher.ENCRYPT_MODE) ||
                         (opmode == Cipher.WRAP_MODE)) {
-                // generate random IV
-                byte[] ivBytes = new byte[blkSize];
-                random.nextBytes(ivBytes);
-                ivSpec = new IvParameterSpec(ivBytes);
-            }
-        } else {
-            if (!(params instanceof PBEParameterSpec)) {
-                throw new InvalidAlgorithmParameterException
-                    ("Wrong parameter type: PBE expected");
-            }
-            // salt and iteration count from the params take precedence
-            byte[] specSalt = ((PBEParameterSpec) params).getSalt();
-            if (specSalt != null && specSalt.length < 8) {
-                throw new InvalidAlgorithmParameterException(
-                    "Salt must be at least 8 bytes long");
-            }
-            salt = specSalt;
-            int specICount = ((PBEParameterSpec) params).getIterationCount();
-            if (specICount == 0) {
-                specICount = DEFAULT_COUNT;
-            } else if (specICount < 0) {
-                throw new InvalidAlgorithmParameterException(
-                    "Iteration count must be a positive number");
-            }
-            iCount = specICount;
+                    // generate random IV
+                    byte[] ivBytes = new byte[blkSize];
+                    random.nextBytes(ivBytes);
+                    ivSpec = new IvParameterSpec(ivBytes);
+                }
+            } else {
+                if (!(params instanceof PBEParameterSpec)) {
+                    throw new InvalidAlgorithmParameterException
+                            ("Wrong parameter type: PBE expected");
+                }
+                // salt and iteration count from the params take precedence
+                byte[] specSalt = ((PBEParameterSpec) params).getSalt();
+                if (specSalt != null && specSalt.length < 8) {
+                    throw new InvalidAlgorithmParameterException(
+                            "Salt must be at least 8 bytes long");
+                }
+                salt = specSalt;
+                int specICount = ((PBEParameterSpec) params).getIterationCount();
+                if (specICount == 0) {
+                    specICount = DEFAULT_COUNT;
+                } else if (specICount < 0) {
+                    throw new InvalidAlgorithmParameterException(
+                            "Iteration count must be a positive number");
+                }
+                iCount = specICount;
 
-            AlgorithmParameterSpec specParams =
-                ((PBEParameterSpec) params).getParameterSpec();
-            if (specParams != null) {
-                if (specParams instanceof IvParameterSpec) {
-                    ivSpec = (IvParameterSpec)specParams;
+                AlgorithmParameterSpec specParams =
+                        ((PBEParameterSpec) params).getParameterSpec();
+                if (specParams != null) {
+                    if (specParams instanceof IvParameterSpec) {
+                        ivSpec = (IvParameterSpec)specParams;
+                    } else {
+                        throw new InvalidAlgorithmParameterException(
+                                "Wrong parameter type: IV expected");
+                    }
+                } else if ((opmode == Cipher.ENCRYPT_MODE) ||
+                        (opmode == Cipher.WRAP_MODE)) {
+                    // generate random IV
+                    byte[] ivBytes = new byte[blkSize];
+                    random.nextBytes(ivBytes);
+                    ivSpec = new IvParameterSpec(ivBytes);
                 } else {
                     throw new InvalidAlgorithmParameterException(
-                        "Wrong parameter type: IV expected");
+                            "Missing parameter type: IV expected");
                 }
-            } else if ((opmode == Cipher.ENCRYPT_MODE) ||
-                        (opmode == Cipher.WRAP_MODE)) {
-                // generate random IV
-                byte[] ivBytes = new byte[blkSize];
-                random.nextBytes(ivBytes);
-                ivSpec = new IvParameterSpec(ivBytes);
-            } else {
-                throw new InvalidAlgorithmParameterException(
-                    "Missing parameter type: IV expected");
             }
-        }
 
-        SecretKeySpec cipherKey = null;
-        byte[] derivedKey = null;
-        byte[] passwdBytes = key.getEncoded();
-        char[] passwdChars = new char[passwdBytes.length];
-
-        for (int i=0; i<passwdChars.length; i++)
-            passwdChars[i] = (char) (passwdBytes[i] & 0x7f);
+            passwdChars = new char[passwdBytes.length];
+            for (int i = 0; i < passwdChars.length; i++)
+                passwdChars[i] = (char) (passwdBytes[i] & 0x7f);
 
-        PBEKeySpec pbeSpec =
-            new PBEKeySpec(passwdChars, salt, iCount, keyLength);
+            pbeSpec = new PBEKeySpec(passwdChars, salt, iCount, keyLength);
             // password char[] was cloned in PBEKeySpec constructor,
             // so we can zero it out here
-        java.util.Arrays.fill(passwdChars, ' ');
-        java.util.Arrays.fill(passwdBytes, (byte)0x00);
+        } finally {
+            if (passwdChars != null) Arrays.fill(passwdChars, '\0');
+            if (passwdBytes != null) Arrays.fill(passwdBytes, (byte)0x00);
+        }
 
         SecretKey s = null;
 
@@ -280,8 +285,8 @@
             ike.initCause(ikse);
             throw ike;
         }
-        derivedKey = s.getEncoded();
-        cipherKey = new SecretKeySpec(derivedKey, cipherAlgo);
+        byte[] derivedKey = s.getEncoded();
+        SecretKeySpec cipherKey = new SecretKeySpec(derivedKey, cipherAlgo);
 
         // initialize the underlying cipher
         cipher.init(opmode, cipherKey, ivSpec, random);
--- old/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java	2019-01-21 18:48:02.049309117 +0100
+++ new/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java	2019-01-21 18:48:01.837309675 +0100
@@ -93,46 +93,50 @@
         }
         // Convert the password from char[] to byte[]
         byte[] passwdBytes = getPasswordBytes(this.passwd);
+        // remove local copy
+        if (passwd != null) Arrays.fill(passwd, '\0');
 
-        this.salt = keySpec.getSalt();
-        if (salt == null) {
-            throw new InvalidKeySpecException("Salt not found");
-        }
-        this.iterCount = keySpec.getIterationCount();
-        if (iterCount == 0) {
-            throw new InvalidKeySpecException("Iteration count not found");
-        } else if (iterCount < 0) {
-            throw new InvalidKeySpecException("Iteration count is negative");
-        }
-        int keyLength = keySpec.getKeyLength();
-        if (keyLength == 0) {
-            throw new InvalidKeySpecException("Key length not found");
-        } else if (keyLength < 0) {
-            throw new InvalidKeySpecException("Key length is negative");
-        }
         try {
+            this.salt = keySpec.getSalt();
+            if (salt == null) {
+                throw new InvalidKeySpecException("Salt not found");
+            }
+            this.iterCount = keySpec.getIterationCount();
+            if (iterCount == 0) {
+                throw new InvalidKeySpecException("Iteration count not found");
+            } else if (iterCount < 0) {
+                throw new InvalidKeySpecException("Iteration count is negative");
+            }
+            int keyLength = keySpec.getKeyLength();
+            if (keyLength == 0) {
+                throw new InvalidKeySpecException("Key length not found");
+            } else if (keyLength < 0) {
+                throw new InvalidKeySpecException("Key length is negative");
+            }
             this.prf = Mac.getInstance(prfAlgo);
             // SunPKCS11 requires a non-empty PBE password
             if (passwdBytes.length == 0 &&
-                this.prf.getProvider().getName().startsWith("SunPKCS11")) {
+                    this.prf.getProvider().getName().startsWith("SunPKCS11")) {
                 this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
             }
+            this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
         } catch (NoSuchAlgorithmException nsae) {
             // not gonna happen; re-throw just in case
             InvalidKeySpecException ike = new InvalidKeySpecException();
             ike.initCause(nsae);
             throw ike;
-        }
-        this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
+        } finally {
+            Arrays.fill(passwdBytes, (byte) 0x00);
 
-        // Use the cleaner to zero the key when no longer referenced
-        final byte[] k = this.key;
-        final char[] p = this.passwd;
-        CleanerFactory.cleaner().register(this,
-                () -> {
-                    java.util.Arrays.fill(k, (byte)0x00);
-                    java.util.Arrays.fill(p, '0');
-                });
+            // Use the cleaner to zero the key when no longer referenced
+            final byte[] k = this.key;
+            final char[] p = this.passwd;
+            CleanerFactory.cleaner().register(this,
+                    () -> {
+                        Arrays.fill(k, (byte) 0x00);
+                        Arrays.fill(p, '\0');
+                    });
+        }
     }
 
     private static byte[] deriveKey(final Mac prf, final byte[] password,
@@ -266,8 +270,8 @@
         if (!(that.getFormat().equalsIgnoreCase("RAW")))
             return false;
         byte[] thatEncoded = that.getEncoded();
-        boolean ret = MessageDigest.isEqual(key, that.getEncoded());
-        java.util.Arrays.fill(thatEncoded, (byte)0x00);
+        boolean ret = MessageDigest.isEqual(key, thatEncoded);
+        Arrays.fill(thatEncoded, (byte)0x00);
         return ret;
     }
 
--- old/src/java.base/share/classes/com/sun/crypto/provider/PBMAC1Core.java	2019-01-21 18:48:02.537307831 +0100
+++ new/src/java.base/share/classes/com/sun/crypto/provider/PBMAC1Core.java	2019-01-21 18:48:02.325308390 +0100
@@ -108,72 +108,76 @@
             salt = pbeKey.getSalt(); // maybe null if unspecified
             iCount = pbeKey.getIterationCount(); // maybe 0 if unspecified
         } else if (key instanceof SecretKey) {
-            byte[] passwdBytes = key.getEncoded();
-            if ((passwdBytes == null) ||
-                !(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3))) {
+            byte[] passwdBytes;
+            if (!(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3)) ||
+                    (passwdBytes = key.getEncoded()) == null) {
                 throw new InvalidKeyException("Missing password");
             }
             passwdChars = new char[passwdBytes.length];
             for (int i=0; i<passwdChars.length; i++) {
                 passwdChars[i] = (char) (passwdBytes[i] & 0x7f);
             }
+            Arrays.fill(passwdBytes, (byte)0x00);
         } else {
             throw new InvalidKeyException("SecretKey of PBE type required");
         }
-        if (params == null) {
-            // should not auto-generate default values since current
-            // javax.crypto.Mac api does not have any method for caller to
-            // retrieve the generated defaults.
-            if ((salt == null) || (iCount == 0)) {
-                throw new InvalidAlgorithmParameterException
-                    ("PBEParameterSpec required for salt and iteration count");
-            }
-        } else if (!(params instanceof PBEParameterSpec)) {
-            throw new InvalidAlgorithmParameterException
-                ("PBEParameterSpec type required");
-        } else {
-            PBEParameterSpec pbeParams = (PBEParameterSpec) params;
-            // make sure the parameter values are consistent
-            if (salt != null) {
-                if (!Arrays.equals(salt, pbeParams.getSalt())) {
+
+        PBEKeySpec pbeSpec;
+        try {
+            if (params == null) {
+                // should not auto-generate default values since current
+                // javax.crypto.Mac api does not have any method for caller to
+                // retrieve the generated defaults.
+                if ((salt == null) || (iCount == 0)) {
                     throw new InvalidAlgorithmParameterException
-                        ("Inconsistent value of salt between key and params");
+                            ("PBEParameterSpec required for salt and iteration count");
                 }
+            } else if (!(params instanceof PBEParameterSpec)) {
+                throw new InvalidAlgorithmParameterException
+                        ("PBEParameterSpec type required");
             } else {
-                salt = pbeParams.getSalt();
-            }
-            if (iCount != 0) {
-                if (iCount != pbeParams.getIterationCount()) {
-                    throw new InvalidAlgorithmParameterException
-                        ("Different iteration count between key and params");
+                PBEParameterSpec pbeParams = (PBEParameterSpec) params;
+                // make sure the parameter values are consistent
+                if (salt != null) {
+                    if (!Arrays.equals(salt, pbeParams.getSalt())) {
+                        throw new InvalidAlgorithmParameterException
+                                ("Inconsistent value of salt between key and params");
+                    }
+                } else {
+                    salt = pbeParams.getSalt();
+                }
+                if (iCount != 0) {
+                    if (iCount != pbeParams.getIterationCount()) {
+                        throw new InvalidAlgorithmParameterException
+                                ("Different iteration count between key and params");
+                    }
+                } else {
+                    iCount = pbeParams.getIterationCount();
                 }
-            } else {
-                iCount = pbeParams.getIterationCount();
             }
-        }
-        // For security purpose, we need to enforce a minimum length
-        // for salt; just require the minimum salt length to be 8-byte
-        // which is what PKCS#5 recommends and openssl does.
-        if (salt.length < 8) {
-            throw new InvalidAlgorithmParameterException
-                ("Salt must be at least 8 bytes long");
-        }
-        if (iCount <= 0) {
-            throw new InvalidAlgorithmParameterException
-                ("IterationCount must be a positive number");
-        }
+            // For security purpose, we need to enforce a minimum length
+            // for salt; just require the minimum salt length to be 8-byte
+            // which is what PKCS#5 recommends and openssl does.
+            if (salt.length < 8) {
+                throw new InvalidAlgorithmParameterException
+                        ("Salt must be at least 8 bytes long");
+            }
+            if (iCount <= 0) {
+                throw new InvalidAlgorithmParameterException
+                        ("IterationCount must be a positive number");
+            }
 
-        PBEKeySpec pbeSpec =
-            new PBEKeySpec(passwdChars, salt, iCount, blockLength);
+            pbeSpec = new PBEKeySpec(passwdChars, salt, iCount, blockLength);
             // password char[] was cloned in PBEKeySpec constructor,
             // so we can zero it out here
-        java.util.Arrays.fill(passwdChars, ' ');
+        } finally {
+            Arrays.fill(passwdChars, '\0');
+        }
 
-        SecretKey s = null;
+        SecretKey s;
         PBKDF2Core kdf = getKDFImpl(kdfAlgo);
         try {
             s = kdf.engineGenerateSecret(pbeSpec);
-
         } catch (InvalidKeySpecException ikse) {
             InvalidKeyException ike =
                 new InvalidKeyException("Cannot construct PBE key");
--- old/src/java.base/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java	2019-01-21 18:48:03.065306439 +0100
+++ new/src/java.base/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java	2019-01-21 18:48:02.849307009 +0100
@@ -104,6 +104,7 @@
             Arrays.fill(D, (byte)type);
             concat(salt, I, 0, s);
             concat(passwd, I, s, p);
+            Arrays.fill(passwd, (byte) 0x00);
 
             byte[] Ai;
             byte[] B = new byte[v];
@@ -268,87 +269,92 @@
             salt = pbeKey.getSalt(); // maybe null if unspecified
             iCount = pbeKey.getIterationCount(); // maybe 0 if unspecified
         } else if (key instanceof SecretKey) {
-            byte[] passwdBytes = key.getEncoded();
-            if ((passwdBytes == null) ||
-                !(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3))) {
+            byte[] passwdBytes;
+            if (!(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3)) ||
+                    (passwdBytes = key.getEncoded()) == null) {
                 throw new InvalidKeyException("Missing password");
             }
             passwdChars = new char[passwdBytes.length];
             for (int i=0; i<passwdChars.length; i++) {
                 passwdChars[i] = (char) (passwdBytes[i] & 0x7f);
             }
+            Arrays.fill(passwdBytes, (byte)0x00);
         } else {
             throw new InvalidKeyException("SecretKey of PBE type required");
         }
 
-        if (((opmode == Cipher.DECRYPT_MODE) ||
-             (opmode == Cipher.UNWRAP_MODE)) &&
-            ((params == null) && ((salt == null) || (iCount == 0)))) {
-            throw new InvalidAlgorithmParameterException
-                ("Parameters missing");
-        }
+        try {
+            if (((opmode == Cipher.DECRYPT_MODE) ||
+                    (opmode == Cipher.UNWRAP_MODE)) &&
+                    ((params == null) && ((salt == null) || (iCount == 0)))) {
+                throw new InvalidAlgorithmParameterException
+                        ("Parameters missing");
+            }
 
-        if (params == null) {
-            // generate default for salt and iteration count if necessary
-            if (salt == null) {
-                salt = new byte[DEFAULT_SALT_LENGTH];
-                if (random != null) {
-                    random.nextBytes(salt);
+            if (params == null) {
+                // generate default for salt and iteration count if necessary
+                if (salt == null) {
+                    salt = new byte[DEFAULT_SALT_LENGTH];
+                    if (random != null) {
+                        random.nextBytes(salt);
+                    } else {
+                        SunJCE.getRandom().nextBytes(salt);
+                    }
+                }
+                if (iCount == 0) iCount = DEFAULT_COUNT;
+            } else if (!(params instanceof PBEParameterSpec)) {
+                throw new InvalidAlgorithmParameterException
+                        ("PBEParameterSpec type required");
+            } else {
+                PBEParameterSpec pbeParams = (PBEParameterSpec) params;
+                // make sure the parameter values are consistent
+                if (salt != null) {
+                    if (!Arrays.equals(salt, pbeParams.getSalt())) {
+                        throw new InvalidAlgorithmParameterException
+                                ("Inconsistent value of salt between key and params");
+                    }
                 } else {
-                    SunJCE.getRandom().nextBytes(salt);
+                    salt = pbeParams.getSalt();
                 }
-            }
-            if (iCount == 0) iCount = DEFAULT_COUNT;
-        } else if (!(params instanceof PBEParameterSpec)) {
-            throw new InvalidAlgorithmParameterException
-                ("PBEParameterSpec type required");
-        } else {
-            PBEParameterSpec pbeParams = (PBEParameterSpec) params;
-            // make sure the parameter values are consistent
-            if (salt != null) {
-                if (!Arrays.equals(salt, pbeParams.getSalt())) {
-                    throw new InvalidAlgorithmParameterException
-                        ("Inconsistent value of salt between key and params");
+                if (iCount != 0) {
+                    if (iCount != pbeParams.getIterationCount()) {
+                        throw new InvalidAlgorithmParameterException
+                                ("Different iteration count between key and params");
+                    }
+                } else {
+                    iCount = pbeParams.getIterationCount();
                 }
-            } else {
-                salt = pbeParams.getSalt();
             }
-            if (iCount != 0) {
-                if (iCount != pbeParams.getIterationCount()) {
-                    throw new InvalidAlgorithmParameterException
-                        ("Different iteration count between key and params");
-                }
-            } else {
-                iCount = pbeParams.getIterationCount();
+            // salt is recommended to be ideally as long as the output
+            // of the hash function. However, it may be too strict to
+            // force this; so instead, we'll just require the minimum
+            // salt length to be 8-byte which is what PKCS#5 recommends
+            // and openssl does.
+            if (salt.length < 8) {
+                throw new InvalidAlgorithmParameterException
+                        ("Salt must be at least 8 bytes long");
             }
-        }
-        // salt is recommended to be ideally as long as the output
-        // of the hash function. However, it may be too strict to
-        // force this; so instead, we'll just require the minimum
-        // salt length to be 8-byte which is what PKCS#5 recommends
-        // and openssl does.
-        if (salt.length < 8) {
-            throw new InvalidAlgorithmParameterException
-                ("Salt must be at least 8 bytes long");
-        }
-        if (iCount <= 0) {
-            throw new InvalidAlgorithmParameterException
-                ("IterationCount must be a positive number");
-        }
-        byte[] derivedKey = derive(passwdChars, salt, iCount,
-                                   keySize, CIPHER_KEY);
-        SecretKey cipherKey = new SecretKeySpec(derivedKey, algo);
+            if (iCount <= 0) {
+                throw new InvalidAlgorithmParameterException
+                        ("IterationCount must be a positive number");
+            }
+            byte[] derivedKey = derive(passwdChars, salt, iCount,
+                    keySize, CIPHER_KEY);
+            SecretKey cipherKey = new SecretKeySpec(derivedKey, algo);
 
-        if (cipherImpl != null && cipherImpl instanceof ARCFOURCipher) {
-            ((ARCFOURCipher)cipherImpl).engineInit(opmode, cipherKey, random);
+            if (cipherImpl != null && cipherImpl instanceof ARCFOURCipher) {
+                ((ARCFOURCipher)cipherImpl).engineInit(opmode, cipherKey, random);
 
-        } else {
-            byte[] derivedIv = derive(passwdChars, salt, iCount, 8,
-                                  CIPHER_IV);
-            IvParameterSpec ivSpec = new IvParameterSpec(derivedIv, 0, 8);
+            } else {
+                byte[] derivedIv = derive(passwdChars, salt, iCount, 8,
+                        CIPHER_IV);
+                IvParameterSpec ivSpec = new IvParameterSpec(derivedIv, 0, 8);
 
-            // initialize the underlying cipher
-            cipher.init(opmode, cipherKey, ivSpec, random);
+                // initialize the underlying cipher
+                cipher.init(opmode, cipherKey, ivSpec, random);
+            }
+        } finally {
+           Arrays.fill(passwdChars, '\0');
         }
     }
 
--- old/src/java.base/share/classes/java/net/URL.java	2019-01-21 18:48:03.609305005 +0100
+++ new/src/java.base/share/classes/java/net/URL.java	2019-01-21 18:48:03.385305596 +0100
@@ -1393,33 +1393,33 @@
             }
         }
 
+        if (handler == null) {
+            // Try the built-in protocol handler
+            handler = defaultFactory.createURLStreamHandler(protocol);
+        }
+
         synchronized (streamHandlerLock) {
-            if (handler == null) {
-                // Try the built-in protocol handler
-                handler = defaultFactory.createURLStreamHandler(protocol);
-            } else {
-                URLStreamHandler handler2 = null;
-
-                // Check again with hashtable just in case another
-                // thread created a handler since we last checked
-                handler2 = handlers.get(protocol);
-
-                if (handler2 != null) {
-                    return handler2;
-                }
-
-                // Check with factory if another thread set a
-                // factory since our last check
-                if (!checkedWithFactory && (fac = factory) != null) {
-                    handler2 = fac.createURLStreamHandler(protocol);
-                }
-
-                if (handler2 != null) {
-                    // The handler from the factory must be given more
-                    // importance. Discard the default handler that
-                    // this thread created.
-                    handler = handler2;
-                }
+            URLStreamHandler handler2 = null;
+
+            // Check again with hashtable just in case another
+            // thread created a handler since we last checked
+            handler2 = handlers.get(protocol);
+
+            if (handler2 != null) {
+                return handler2;
+            }
+
+            // Check with factory if another thread set a
+            // factory since our last check
+            if (!checkedWithFactory && (fac = factory) != null) {
+                handler2 = fac.createURLStreamHandler(protocol);
+            }
+
+            if (handler2 != null) {
+                // The handler from the factory must be given more
+                // importance. Discard the default handler that
+                // this thread created.
+                handler = handler2;
             }
 
             // Insert this handler into the hashtable
@@ -1427,7 +1427,6 @@
                 handlers.put(protocol, handler);
             }
         }
-
         return handler;
     }
 
--- old/src/java.base/share/classes/javax/crypto/spec/PBEKeySpec.java	2019-01-21 18:48:04.133303624 +0100
+++ new/src/java.base/share/classes/javax/crypto/spec/PBEKeySpec.java	2019-01-21 18:48:03.913304204 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -26,6 +26,7 @@
 package javax.crypto.spec;
 
 import java.security.spec.KeySpec;
+import java.util.Arrays;
 
 /**
  * A user-chosen password that can be used with password-based encryption
@@ -174,9 +175,7 @@
      */
     public final void clearPassword() {
         if (password != null) {
-            for (int i = 0; i < password.length; i++) {
-                password[i] = ' ';
-            }
+            Arrays.fill(password, ' ');
             password = null;
         }
     }
--- old/src/java.base/share/classes/sun/security/provider/DigestBase.java	2019-01-21 18:48:04.625302326 +0100
+++ new/src/java.base/share/classes/sun/security/provider/DigestBase.java	2019-01-21 18:48:04.417302875 +0100
@@ -28,6 +28,7 @@
 import java.security.MessageDigestSpi;
 import java.security.DigestException;
 import java.security.ProviderException;
+import java.util.Arrays;
 import java.util.Objects;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
@@ -178,6 +179,7 @@
         implReset();
         bufOfs = 0;
         bytesProcessed = 0;
+        Arrays.fill(buffer, (byte) 0x00);
     }
 
     // return the digest. See JCA doc.
--- old/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java	2019-01-21 18:48:05.161300912 +0100
+++ new/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java	2019-01-21 18:48:04.905301588 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -133,18 +133,20 @@
             throw new UnrecoverableKeyException("Password must not be null");
         }
 
-        KeyProtector keyProtector = new KeyProtector(password);
+        byte[] passwordBytes = convertToBytes(password);
+        KeyProtector keyProtector = new KeyProtector(passwordBytes);
         byte[] encrBytes = ((KeyEntry)entry).protectedPrivKey;
         EncryptedPrivateKeyInfo encrInfo;
-        byte[] plain;
         try {
             encrInfo = new EncryptedPrivateKeyInfo(encrBytes);
+            return keyProtector.recover(encrInfo);
         } catch (IOException ioe) {
             throw new UnrecoverableKeyException("Private key not stored as "
                                                 + "PKCS #8 "
                                                 + "EncryptedPrivateKeyInfo");
+        } finally {
+            Arrays.fill(passwordBytes, (byte) 0x00);
         }
-        return keyProtector.recover(encrInfo);
     }
 
     /**
@@ -253,7 +255,8 @@
                                   Certificate[] chain)
         throws KeyStoreException
     {
-        KeyProtector keyProtector = null;
+        KeyProtector keyProtector;
+        byte[] passwordBytes = null;
 
         if (!(key instanceof java.security.PrivateKey)) {
             throw new KeyStoreException("Cannot store non-PrivateKeys");
@@ -264,7 +267,8 @@
                 entry.date = new Date();
 
                 // Protect the encoding of the key
-                keyProtector = new KeyProtector(password);
+                passwordBytes = convertToBytes(password);
+                keyProtector = new KeyProtector(passwordBytes);
                 entry.protectedPrivKey = keyProtector.protect(key);
 
                 // clone the chain
@@ -280,7 +284,8 @@
         } catch (NoSuchAlgorithmException nsae) {
             throw new KeyStoreException("Key protection algorithm not found");
         } finally {
-            keyProtector = null;
+            if (passwordBytes != null)
+                Arrays.fill(passwordBytes, (byte) 0x00);
         }
     }
 
@@ -793,19 +798,27 @@
     private MessageDigest getPreKeyedHash(char[] password)
         throws NoSuchAlgorithmException, UnsupportedEncodingException
     {
-        int i, j;
 
         MessageDigest md = MessageDigest.getInstance("SHA");
+        byte[] passwdBytes = convertToBytes(password);
+        md.update(passwdBytes);
+        Arrays.fill(passwdBytes, (byte) 0x00);
+        md.update("Mighty Aphrodite".getBytes("UTF8"));
+        return md;
+    }
+
+    /**
+     * Helper method to convert char[] to byte[]
+     */
+
+    private byte[] convertToBytes(char[] password) {
+        int i, j;
         byte[] passwdBytes = new byte[password.length * 2];
         for (i=0, j=0; i<password.length; i++) {
             passwdBytes[j++] = (byte)(password[i] >> 8);
             passwdBytes[j++] = (byte)password[i];
         }
-        md.update(passwdBytes);
-        for (i=0; i<passwdBytes.length; i++)
-            passwdBytes[i] = 0;
-        md.update("Mighty Aphrodite".getBytes("UTF8"));
-        return md;
+        return passwdBytes;
     }
 
     /**
--- old/src/java.base/share/classes/sun/security/provider/KeyProtector.java	2019-01-21 18:48:05.665299583 +0100
+++ new/src/java.base/share/classes/sun/security/provider/KeyProtector.java	2019-01-21 18:48:05.441300174 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -35,7 +35,6 @@
 import java.security.UnrecoverableKeyException;
 import java.util.*;
 
-import jdk.internal.ref.CleanerFactory;
 import sun.security.pkcs.PKCS8Key;
 import sun.security.pkcs.EncryptedPrivateKeyInfo;
 import sun.security.x509.AlgorithmId;
@@ -120,32 +119,15 @@
     /**
      * Creates an instance of this class, and initializes it with the given
      * password.
-     *
-     * <p>The password is expected to be in printable ASCII.
-     * Normal rules for good password selection apply: at least
-     * seven characters, mixed case, with punctuation encouraged.
-     * Phrases or words which are easily guessed, for example by
-     * being found in dictionaries, are bad.
      */
-    public KeyProtector(char[] password)
+    public KeyProtector(byte[] passwordBytes)
         throws NoSuchAlgorithmException
     {
-        int i, j;
-
-        if (password == null) {
+        if (passwordBytes == null) {
            throw new IllegalArgumentException("password can't be null");
         }
         md = MessageDigest.getInstance(DIGEST_ALG);
-        // Convert password to byte array, so that it can be digested
-        passwdBytes = new byte[password.length * 2];
-        for (i=0, j=0; i<password.length; i++) {
-            passwdBytes[j++] = (byte)(password[i] >> 8);
-            passwdBytes[j++] = (byte)password[i];
-        }
-        // Use the cleaner to zero the password when no longer referenced
-        final byte[] k = this.passwdBytes;
-        CleanerFactory.cleaner().register(this,
-                () -> java.util.Arrays.fill(k, (byte)0x00));
+        this.passwdBytes = passwordBytes;
     }
 
     /*
--- old/src/java.base/share/classes/sun/security/provider/MD4.java	2019-01-21 18:48:06.161298274 +0100
+++ new/src/java.base/share/classes/sun/security/provider/MD4.java	2019-01-21 18:48:05.949298833 +0100
@@ -26,6 +26,7 @@
 package sun.security.provider;
 
 import java.security.*;
+import java.util.Arrays;
 
 import static sun.security.provider.ByteArrayAccess.*;
 import static sun.security.util.SecurityConstants.PROVIDER_VER;
@@ -92,7 +93,7 @@
         super("MD4", 16, 64);
         state = new int[4];
         x = new int[16];
-        implReset();
+        resetHashes();
     }
 
     // clone this object
@@ -108,6 +109,12 @@
      */
     void implReset() {
         // Load magic initialization constants.
+        resetHashes();
+        // clear out old data
+        Arrays.fill(x, 0);
+    }
+
+    private void resetHashes() {
         state[0] = 0x67452301;
         state[1] = 0xefcdab89;
         state[2] = 0x98badcfe;
--- old/src/java.base/share/classes/sun/security/provider/MD5.java	2019-01-21 18:48:06.633297028 +0100
+++ new/src/java.base/share/classes/sun/security/provider/MD5.java	2019-01-21 18:48:06.433297556 +0100
@@ -25,6 +25,8 @@
 
 package sun.security.provider;
 
+import java.util.Arrays;
+
 import static sun.security.provider.ByteArrayAccess.*;
 
 /**
@@ -66,7 +68,7 @@
         super("MD5", 16, 64);
         state = new int[4];
         x = new int[16];
-        implReset();
+        resetHashes();
     }
 
     // clone this object
@@ -82,6 +84,12 @@
      */
     void implReset() {
         // Load magic initialization constants.
+        resetHashes();
+        // clear out old data
+        Arrays.fill(x, 0);
+    }
+
+    private void resetHashes() {
         state[0] = 0x67452301;
         state[1] = 0xefcdab89;
         state[2] = 0x98badcfe;
--- old/src/java.base/share/classes/sun/security/provider/SHA.java	2019-01-21 18:48:07.133295709 +0100
+++ new/src/java.base/share/classes/sun/security/provider/SHA.java	2019-01-21 18:48:06.913296290 +0100
@@ -25,6 +25,7 @@
 
 package sun.security.provider;
 
+import java.util.Arrays;
 import java.util.Objects;
 
 import static sun.security.provider.ByteArrayAccess.*;
@@ -62,7 +63,7 @@
         super("SHA-1", 20, 64);
         state = new int[5];
         W = new int[80];
-        implReset();
+        resetHashes();
     }
 
     /*
@@ -79,6 +80,13 @@
      * Resets the buffers and hash value to start a new hash.
      */
     void implReset() {
+        // Load magic initialization constants.
+        resetHashes();
+        // clear out old data
+        Arrays.fill(W, 0);
+    }
+
+    private void resetHashes() {
         state[0] = 0x67452301;
         state[1] = 0xefcdab89;
         state[2] = 0x98badcfe;
--- old/src/java.base/share/classes/sun/security/provider/SHA2.java	2019-01-21 18:48:07.625294411 +0100
+++ new/src/java.base/share/classes/sun/security/provider/SHA2.java	2019-01-21 18:48:07.405294992 +0100
@@ -25,6 +25,7 @@
 
 package sun.security.provider;
 
+import java.util.Arrays;
 import java.util.Objects;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
@@ -83,13 +84,18 @@
         this.initialHashes = initialHashes;
         state = new int[8];
         W = new int[64];
-        implReset();
+        resetHashes();
     }
 
     /**
      * Resets the buffers and hash value to start a new hash.
      */
     void implReset() {
+        resetHashes();
+        Arrays.fill(W, 0);
+    }
+
+    private void resetHashes() {
         System.arraycopy(initialHashes, 0, state, 0, state.length);
     }
 
--- old/src/java.base/share/classes/sun/security/provider/SHA5.java	2019-01-21 18:48:08.141293049 +0100
+++ new/src/java.base/share/classes/sun/security/provider/SHA5.java	2019-01-21 18:48:07.941293577 +0100
@@ -25,6 +25,7 @@
 
 package sun.security.provider;
 
+import java.util.Arrays;
 import java.util.Objects;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
@@ -98,10 +99,15 @@
         this.initialHashes = initialHashes;
         state = new long[8];
         W = new long[80];
-        implReset();
+        resetHashes();
     }
 
     final void implReset() {
+        resetHashes();
+        Arrays.fill(W, 0L);
+    }
+
+    private void resetHashes() {
         System.arraycopy(initialHashes, 0, state, 0, state.length);
     }
 
--- old/src/java.base/share/classes/sun/security/ssl/SSLExtensions.java	2019-01-21 18:48:08.633291749 +0100
+++ new/src/java.base/share/classes/sun/security/ssl/SSLExtensions.java	2019-01-21 18:48:08.413292330 +0100
@@ -43,7 +43,7 @@
 
     // Extension map for debug logging
     private final Map<Integer, byte[]> logMap =
-            SSLLogger.isOn ? null : new LinkedHashMap<>();
+            SSLLogger.isOn ? new LinkedHashMap<>() : null;
 
     SSLExtensions(HandshakeMessage handshakeMessage) {
         this.handshakeMessage = handshakeMessage;
@@ -65,38 +65,59 @@
                         "): no sufficient data");
             }
 
+            boolean isSupported = true;
             SSLHandshake handshakeType = hm.handshakeType();
             if (SSLExtension.isConsumable(extId) &&
                     SSLExtension.valueOf(handshakeType, extId) == null) {
-                hm.handshakeContext.conContext.fatal(
+                if (extId == SSLExtension.CH_SUPPORTED_GROUPS.id &&
+                        handshakeType == SSLHandshake.SERVER_HELLO) {
+                    // Note: It does not comply to the specification.  However,
+                    // there are servers that send the supported_groups
+                    // extension in ServerHello handshake message.
+                    //
+                    // TLS 1.3 should not send this extension.   We may want to
+                    // limit the workaround for TLS 1.2 and prior version only.
+                    // However, the implementation of the limit is complicated
+                    // and inefficient, and may not worthy the maintenance.
+                    isSupported = false;
+                    if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+                        SSLLogger.warning(
+                                "Received buggy supported_groups extension " +
+                                "in the ServerHello handshake message");
+                    }
+                } else {
+                    hm.handshakeContext.conContext.fatal(
                         Alert.UNSUPPORTED_EXTENSION,
                         "extension (" + extId +
                         ") should not be presented in " + handshakeType.name);
+                }
             }
 
-            boolean isSupported = false;
-            for (SSLExtension extension : extensions) {
-                if ((extension.id != extId) ||
-                        (extension.onLoadConsumer == null)) {
-                    continue;
-                }
+            if (isSupported) {
+                isSupported = false;
+                for (SSLExtension extension : extensions) {
+                    if ((extension.id != extId) ||
+                            (extension.onLoadConsumer == null)) {
+                        continue;
+                    }
+
+                    if (extension.handshakeType != handshakeType) {
+                        hm.handshakeContext.conContext.fatal(
+                                Alert.UNSUPPORTED_EXTENSION,
+                                "extension (" + extId + ") should not be " +
+                                "presented in " + handshakeType.name);
+                    }
+
+                    byte[] extData = new byte[extLen];
+                    m.get(extData);
+                    extMap.put(extension, extData);
+                    if (logMap != null) {
+                        logMap.put(extId, extData);
+                    }
 
-                if (extension.handshakeType != handshakeType) {
-                    hm.handshakeContext.conContext.fatal(
-                            Alert.UNSUPPORTED_EXTENSION,
-                            "extension (" + extId + ") should not be " +
-                            "presented in " + handshakeType.name);
+                    isSupported = true;
+                    break;
                 }
-
-                byte[] extData = new byte[extLen];
-                m.get(extData);
-                extMap.put(extension, extData);
-                if (logMap != null) {
-                    logMap.put(extId, extData);
-                }
-
-                isSupported = true;
-                break;
             }
 
             if (!isSupported) {
--- old/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java	2019-01-21 18:48:09.161290356 +0100
+++ new/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java	2019-01-21 18:48:08.949290914 +0100
@@ -674,9 +674,9 @@
                                            "Magadan Summer Time", "MAGST",
                                            "Magadan Time", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"Philippines Time", "PHT",
-                                          "Philippines Summer Time", "PHST",
-                                          "Philippines Time", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	2019-01-21 18:48:09.629289119 +0100
+++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	2019-01-21 18:48:09.417289679 +0100
@@ -165,8 +165,6 @@
                         : this;
             }
         }
-        // ignore focus "lost" native request as it may mistakenly
-        // deactivate active window (see 8001161)
         if (globalFocusedWindow == this) {
             responder.handleWindowFocusEvent(parentWindowActive, null);
         }
@@ -181,4 +179,19 @@
         // another window.
         return globalFocusedWindow != null ? !globalFocusedWindow.isParentWindowActive() : true;
     }
+
+    @Override
+    public void synthesizeWindowActivation(boolean doActivate) {
+        if (isParentWindowActive() != doActivate) {
+            handleWindowFocusEvent(doActivate);
+        }
+    }
+
+    public static void updateGlobalFocusedWindow(CEmbeddedFrame newGlobalFocusedWindow) {
+        synchronized (classLock) {
+            if(newGlobalFocusedWindow.isParentWindowActive()) {
+                globalFocusedWindow = newGlobalFocusedWindow;
+            }
+        }
+    }
 }
--- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	2019-01-21 18:48:10.109287851 +0100
+++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	2019-01-21 18:48:09.889288432 +0100
@@ -147,6 +147,8 @@
 
     @Override
     public boolean requestWindowFocus() {
+        CEmbeddedFrame.updateGlobalFocusedWindow(target);
+        target.synthesizeWindowActivation(true);
         return true;
     }
 
--- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	2019-01-21 18:48:10.673286361 +0100
+++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	2019-01-21 18:48:10.441286974 +0100
@@ -1286,6 +1286,21 @@
         }
     }
 
+    private Window getOwnerFrameOrDialog(Window window) {
+        Window owner = window.getOwner();
+        while(owner != null && !(owner instanceof Frame || owner instanceof Dialog)) {
+            owner = owner.getOwner();
+        }
+        return owner;
+    }
+
+    private boolean isSimpleWindowOwnedByEmbeddedFrame() {
+        if (peer != null && peer.isSimpleWindow()) {
+            return (getOwnerFrameOrDialog(target) instanceof CEmbeddedFrame);
+        }
+        return false;
+    }
+
     // ----------------------------------------------------------------------
     //                          NATIVE CALLBACKS
     // ----------------------------------------------------------------------
--- old/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m	2019-01-21 18:48:11.213284935 +0100
+++ new/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m	2019-01-21 18:48:10.997285505 +0100
@@ -537,10 +537,14 @@
 }
 
 -(BOOL) isCodePointInUnicodeBlockNeedingIMEvent: (unichar) codePoint {
-    if (((codePoint >= 0x3000) && (codePoint <= 0x303F)) ||
+    if ((codePoint == 0x0024) || (codePoint == 0x00A3) ||
+        (codePoint == 0x00A5) ||
+        ((codePoint >= 0x20A3) && (codePoint <= 0x20BF)) ||
+	((codePoint >= 0x3000) && (codePoint <= 0x303F)) ||
         ((codePoint >= 0xFF00) && (codePoint <= 0xFFEF))) {
         // Code point is in 'CJK Symbols and Punctuation' or
-        // 'Halfwidth and Fullwidth Forms' Unicode block.
+        // 'Halfwidth and Fullwidth Forms' Unicode block or
+	// currency symbols unicode
         return YES;
     }
     return NO;
--- old/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	2019-01-21 18:48:11.677283707 +0100
+++ new/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	2019-01-21 18:48:11.457284289 +0100
@@ -477,6 +477,21 @@
     return isBlocked;
 }
 
+// Test whether window is simple window and owned by embedded frame
+- (BOOL) isSimpleWindowOwnedByEmbeddedFrame {
+    BOOL isSimpleWindowOwnedByEmbeddedFrame = NO;
+
+    JNIEnv *env = [ThreadUtilities getJNIEnv];
+    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
+    if (platformWindow != NULL) {
+        static JNF_MEMBER_CACHE(jm_isBlocked, jc_CPlatformWindow, "isSimpleWindowOwnedByEmbeddedFrame", "()Z");
+        isSimpleWindowOwnedByEmbeddedFrame = JNFCallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO;
+        (*env)->DeleteLocalRef(env, platformWindow);
+    }
+
+    return isSimpleWindowOwnedByEmbeddedFrame;
+}
+
 // Tests whether the corresponding Java platform window is visible or not
 + (BOOL) isJavaPlatformWindowVisible:(NSWindow *)window {
     BOOL isVisible = NO;
@@ -543,7 +558,7 @@
 // NSWindow overrides
 - (BOOL) canBecomeKeyWindow {
 AWT_ASSERT_APPKIT_THREAD;
-    return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY);
+    return self.isEnabled && (IS(self.styleBits, SHOULD_BECOME_KEY) || [self isSimpleWindowOwnedByEmbeddedFrame]);
 }
 
 - (BOOL) canBecomeMainWindow {
--- old/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java	2019-01-21 18:48:12.177282387 +0100
+++ new/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java	2019-01-21 18:48:11.969282937 +0100
@@ -468,7 +468,7 @@
         String text;
         pos = stream.getStreamPosition();
         int textLength = (int)(chunkStart + chunkLength - pos);
-        if (textLength <= 0) {
+        if (textLength < 0) {
             throw new IIOException("iTXt chunk length is not proper");
         }
         byte[] b = new byte[textLength];
@@ -571,7 +571,7 @@
     private void parse_tEXt_chunk(int chunkLength) throws IOException {
         String keyword = readNullTerminatedString("ISO-8859-1", 80);
         int textLength = chunkLength - keyword.length() - 1;
-        if (textLength <= 0) {
+        if (textLength < 0) {
             throw new IIOException("tEXt chunk length is not proper");
         }
         metadata.tEXt_keyword.add(keyword);
@@ -669,7 +669,7 @@
     private void parse_zTXt_chunk(int chunkLength) throws IOException {
         String keyword = readNullTerminatedString("ISO-8859-1", 80);
         int textLength = chunkLength - keyword.length() - 2;
-        if (textLength <= 0) {
+        if (textLength < 0) {
             throw new IIOException("zTXt chunk length is not proper");
         }
         metadata.zTXt_keyword.add(keyword);
--- old/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java	2019-01-21 18:48:12.717280959 +0100
+++ new/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java	2019-01-21 18:48:12.501281529 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -547,14 +547,15 @@
                 getEventDispatcher().addLineMonitor(this);
             }
 
-            doIO = true;
-
-            // need to set Active and Started
-            // note: the current API always requires that
-            //       Started and Active are set at the same time...
-            if (isSource && stoppedWritten) {
-                setStarted(true);
-                setActive(true);
+            synchronized(lock) {
+                doIO = true;
+                // need to set Active and Started
+                // note: the current API always requires that
+                //       Started and Active are set at the same time...
+                if (isSource && stoppedWritten) {
+                    setStarted(true);
+                    setActive(true);
+                }
             }
 
             if (Printer.trace) Printer.trace("<< DirectDL: implStart() succeeded");
@@ -582,10 +583,10 @@
                 // read/write thread, that's why isStartedRunning()
                 // cannot be used
                 doIO = false;
+                setActive(false);
+                setStarted(false);
                 lock.notifyAll();
             }
-            setActive(false);
-            setStarted(false);
             stoppedWritten = false;
 
             if (Printer.trace) Printer.trace(" << DirectDL: implStop() succeeded");
@@ -731,12 +732,14 @@
             if ((long)off + (long)len > (long)b.length) {
                 throw new ArrayIndexOutOfBoundsException(b.length);
             }
-
-            if (!isActive() && doIO) {
-                // this is not exactly correct... would be nicer
-                // if the native sub system sent a callback when IO really starts
-                setActive(true);
-                setStarted(true);
+            synchronized(lock) {
+                if (!isActive() && doIO) {
+                    // this is not exactly correct... would be nicer
+                    // if the native sub system sent a callback when IO really
+                    // starts
+                    setActive(true);
+                    setStarted(true);
+                }
             }
             int written = 0;
             while (!flushing) {
@@ -957,11 +960,14 @@
             if ((long)off + (long)len > (long)b.length) {
                 throw new ArrayIndexOutOfBoundsException(b.length);
             }
-            if (!isActive() && doIO) {
-                // this is not exactly correct... would be nicer
-                // if the native sub system sent a callback when IO really starts
-                setActive(true);
-                setStarted(true);
+            synchronized(lock) {
+                if (!isActive() && doIO) {
+                    // this is not exactly correct... would be nicer
+                    // if the native sub system sent a callback when IO really
+                    // starts
+                    setActive(true);
+                    setStarted(true);
+                }
             }
             int read = 0;
             while (doIO && !flushing) {
--- old/src/java.desktop/share/classes/javax/swing/text/html/ImageView.java	2019-01-21 18:48:13.245279562 +0100
+++ new/src/java.desktop/share/classes/javax/swing/text/html/ImageView.java	2019-01-21 18:48:13.017280165 +0100
@@ -776,32 +776,10 @@
 
             if (newWidth > 0) {
                 newState |= WIDTH_FLAG;
-                if (newHeight <= 0) {
-                    newHeight = newWidth;
-                    newState |= HEIGHT_FLAG;
-                }
             }
 
             if (newHeight > 0) {
                 newState |= HEIGHT_FLAG;
-                if (newWidth <= 0) {
-                    newWidth = newHeight;
-                    newState |= WIDTH_FLAG;
-                }
-            }
-
-            if (newWidth <= 0) {
-                newWidth = newImage.getWidth(imageObserver);
-                if (newWidth <= 0) {
-                    newWidth = DEFAULT_WIDTH;
-                }
-            }
-
-            if (newHeight <= 0) {
-                newHeight = newImage.getHeight(imageObserver);
-                if (newHeight <= 0) {
-                    newHeight = DEFAULT_HEIGHT;
-                }
             }
 
             // Make sure the image starts loading:
@@ -965,6 +943,35 @@
                     changed |= 2;
                 }
 
+                /**
+                 * If the image properties (height and width) have been loaded,
+                 * then figure out if scaling is necessary based on the
+                 * specified HTML attributes.
+                 */
+                if (((flags & ImageObserver.HEIGHT) != 0) &&
+                    ((flags & ImageObserver.WIDTH) != 0)) {
+                    double proportion = 0.0;
+                    final int specifiedWidth = getIntAttr(HTML.Attribute.WIDTH, -1);
+                    final int specifiedHeight = getIntAttr(HTML.Attribute.HEIGHT, -1);
+                    /**
+                     * If either of the attributes are not specified, then calculate the
+                     * proportion for the specified dimension wrt actual value, and then
+                     * apply the same proportion to the unspecified dimension as well,
+                     * so that the aspect ratio of the image is maintained.
+                     */
+                    if (specifiedWidth != -1 ^ specifiedHeight != -1) {
+                        if (specifiedWidth <= 0) {
+                            proportion = specifiedHeight / ((double)newHeight);
+                            newWidth = (int)(proportion * newWidth);
+                        }
+
+                        if (specifiedHeight <= 0) {
+                            proportion = specifiedWidth / ((double)newWidth);
+                            newHeight = (int)(proportion * newHeight);
+                        }
+                        changed |= 3;
+                    }
+                }
                 synchronized(ImageView.this) {
                     if ((changed & 1) == 1 && (state & HEIGHT_FLAG) == 0) {
                         height = newHeight;
--- old/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	2019-01-21 18:48:13.789278125 +0100
+++ new/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	2019-01-21 18:48:13.569278706 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -215,6 +215,12 @@
     static long awt_defaultFg; // Pixel
     private static XMouseInfoPeer xPeer;
 
+    /**
+     * Should we check "_NET_WM_STRUT/_NET_WM_STRUT_PARTIAL" during insets
+     * calculation.
+     */
+    private static Boolean checkSTRUT;
+
     static {
         initSecurityWarning();
         if (GraphicsEnvironment.isHeadless()) {
@@ -826,13 +832,26 @@
     }
 
     /*
-     * If we're running in non-Xinerama environment and the current
-     * window manager supports _NET protocol then the screen insets
-     * are calculated using _NET_WM_WORKAREA property of the root
-     * window.
-     * Otherwise, i. e. if Xinerama is on or _NET_WM_WORKAREA is
-     * not set, we try to calculate the insets ourselves using
-     * getScreenInsetsManually method.
+     * If the current window manager supports _NET protocol then the screen
+     * insets are calculated using _NET_WORKAREA property of the root window.
+     * <p>
+     * Note that _NET_WORKAREA is a rectangular area and it does not work
+     * well in the Xinerama mode.
+     * <p>
+     * We will trust the part of this rectangular area only if it starts at the
+     * requested graphics configuration. Below is an example when the
+     * _NET_WORKAREA intersects with the requested graphics configuration but
+     * produces wrong result.
+     *
+     *         //<-x1,y1///////
+     *         //            // ////////////////
+     *         //  SCREEN1   // // SCREEN2    //
+     *         // ********** // //     x2,y2->//
+     *         //////////////// //            //
+     *                          ////////////////
+     *
+     * When two screens overlap and the first contains a dock(*****), then
+     * _NET_WORKAREA may start at point x1,y1 and end at point x2,y2.
      */
     @Override
     public Insets getScreenInsets(GraphicsConfiguration gc)
@@ -846,30 +865,33 @@
         XToolkit.awtLock();
         try
         {
-            X11GraphicsConfig x11gc = (X11GraphicsConfig)gc;
-            X11GraphicsDevice x11gd = x11gc.getDevice();
-            long root = XlibUtil.getRootWindow(x11gd.getScreen());
-            int scale = x11gc.getScale();
-            Rectangle rootBounds = XlibUtil.getWindowGeometry(root, scale);
-
             X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment)
-                GraphicsEnvironment.getLocalGraphicsEnvironment();
-            if (!x11ge.runningXinerama())
-            {
-                Insets screenInsets = getInsets(root, rootBounds, scale);
-                if (screenInsets != null) return screenInsets;
-            }
-
-            Insets insets = getScreenInsetsManually(root, rootBounds,
-                    gc.getBounds(), scale);
-            if ((insets.left | insets.top | insets.bottom | insets.right) == 0
-                    && rootBounds != null ) {
-                root = XlibWrapper.RootWindow(XToolkit.getDisplay(),
-                        x11gd.getScreen());
-                Insets screenInsets = getInsets(root, rootBounds, scale);
-                if (screenInsets != null) return screenInsets;
+                    GraphicsEnvironment.getLocalGraphicsEnvironment();
+            X11GraphicsConfig x11gc = (X11GraphicsConfig) gc;
+            long root = XlibUtil.getRootWindow(x11gc.getDevice().getScreen());
+            int scale = x11gc.getScale();
+            if (x11ge.runningXinerama() && checkSTRUT()) {
+                // implementation based on _NET_WM_STRUT/_NET_WM_STRUT_PARTIAL
+                Rectangle rootBounds = XlibUtil.getWindowGeometry(root, scale);
+                Insets insets = getScreenInsetsManually(root, rootBounds,
+                                                        gc.getBounds(), scale);
+                if ((insets.left | insets.top | insets.bottom | insets.right) != 0
+                        || rootBounds == null) {
+                    return insets;
+                }
+            }
+            Rectangle workArea = XToolkit.getWorkArea(root, scale);
+            Rectangle screen = gc.getBounds();
+            if (workArea != null && screen.contains(workArea.getLocation())) {
+                workArea = workArea.intersection(screen);
+                int top = workArea.y - screen.y;
+                int left = workArea.x - screen.x;
+                int bottom = screen.height - workArea.height - top;
+                int right = screen.width - workArea.width - left;
+                return new Insets(top, left, bottom, right);
             }
-            return insets;
+            // Note that it is better to return zeros than inadequate values
+            return new Insets(0, 0, 0, 0);
         }
         finally
         {
@@ -877,14 +899,16 @@
         }
     }
 
-    private Insets getInsets(long root, Rectangle rootBounds, int scale) {
-        Rectangle workArea = XToolkit.getWorkArea(root, scale);
-        if (workArea == null) {
-            return null;
+    /**
+     * Returns the value of "sun.awt.X11.checkSTRUT" property. Default value is
+     * {@code false}.
+     */
+    private static boolean checkSTRUT() {
+        if (checkSTRUT == null) {
+            checkSTRUT = AccessController.doPrivileged(
+                    new GetBooleanAction("sun.awt.X11.checkSTRUT"));
         }
-        return new Insets(workArea.y, workArea.x,
-                rootBounds.height - workArea.height - workArea.y,
-                rootBounds.width - workArea.width - workArea.x);
+        return checkSTRUT;
     }
 
     /*
@@ -893,6 +917,14 @@
      * hints' values to screen insets.
      *
      * This method should be called under XToolkit.awtLock()
+     *
+     * This method is unused by default because of two reasons:
+     *  - Iteration over windows may be extremely slow, and execution of
+     *    getScreenInsets() can be x100 slower than in one monitor config.
+     *  - _NET_WM_STRUT/_NET_WM_STRUT_PARTIAL are hints for the applications.
+     *    WM should take into account these hints when "_NET_WORKAREA" is
+     *    calculated, but the system panels do not necessarily contain these
+     *    hints(Gnome 3 for example).
      */
     private Insets getScreenInsetsManually(long root, Rectangle rootBounds,
                                            Rectangle screenBounds, int scale)
--- old/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java	2019-01-21 18:48:14.237276939 +0100
+++ new/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java	2019-01-21 18:48:14.021277511 +0100
@@ -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
@@ -115,7 +115,7 @@
     boolean isLdapv3;         // Used by LdapCtx
     int referenceCount = 1;   // Used by LdapCtx for check for sharing
 
-    Connection conn;  // Connection to server; has reader thread
+    final Connection conn;  // Connection to server; has reader thread
                       // used by LdapCtx for StartTLS
 
     final private PoolCallback pcb;
@@ -433,19 +433,16 @@
             (new Throwable()).printStackTrace();
         }
 
-        if (referenceCount <= 0 && conn != null) {
+        if (referenceCount <= 0) {
             if (debug > 0) System.err.println("LdapClient: closed connection " + this);
             if (!pooled) {
                 // Not being pooled; continue with closing
                 conn.cleanup(reqCtls, false);
-                conn = null;
             } else {
                 // Pooled
-
                 // Is this a real close or a request to return conn to pool
                 if (hardClose) {
                     conn.cleanup(reqCtls, false);
-                    conn = null;
                     pcb.removePooledConnection(this);
                 } else {
                     pcb.releasePooledConnection(this);
@@ -461,16 +458,13 @@
         if (debug > 1) {
             System.err.println("LdapClient: forceClose() of " + this);
         }
-
-        if (conn != null) {
-            if (debug > 0) System.err.println(
-                "LdapClient: forced close of connection " + this);
-            conn.cleanup(null, false);
-            conn = null;
-
-            if (cleanPool) {
-                pcb.removePooledConnection(this);
-            }
+        if (debug > 0) {
+            System.err.println(
+                    "LdapClient: forced close of connection " + this);
+        }
+        conn.cleanup(null, false);
+        if (cleanPool) {
+            pcb.removePooledConnection(this);
         }
     }
 
@@ -568,7 +562,7 @@
      * Abandon the search operation and remove it from the message queue.
      */
     void clearSearchReply(LdapResult res, Control[] ctls) {
-        if (res != null && conn != null) {
+        if (res != null) {
 
             // Only send an LDAP abandon operation when clearing the search
             // reply from a one-level or subtree search.
--- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java	2019-01-21 18:48:14.689275744 +0100
+++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java	2019-01-21 18:48:14.481276293 +0100
@@ -55,7 +55,15 @@
 
    public CFrame sender(ThreadProxy thread) {
       X86ThreadContext context = (X86ThreadContext) thread.getContext();
-      Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP);
+      /*
+       * Native code fills in the stack pointer register value using index
+       * X86ThreadContext.SP.
+       * See file LinuxDebuggerLocal.c macro REG_INDEX(reg).
+       *
+       * Be sure to use SP, or UESP which is aliased to SP in Java code,
+       * for the frame pointer validity check.
+       */
+      Address esp = context.getRegisterAsAddress(X86ThreadContext.SP);
 
       if ( (ebp == null) || ebp.lessThan(esp) ) {
         return null;
--- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java	2019-01-21 18:48:15.169274474 +0100
+++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java	2019-01-21 18:48:14.945275067 +0100
@@ -46,7 +46,15 @@
 
   public CFrame sender(ThreadProxy thread) {
     X86ThreadContext context = (X86ThreadContext) thread.getContext();
-    Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP);
+    /*
+     * Native code fills in the stack pointer register value using index
+     * X86ThreadContext.SP.
+     * See file sawindbg.cpp macro REG_INDEX(x).
+     *
+     * Be sure to use SP, or UESP which is aliased to SP in Java code,
+     * for the frame pointer validity check.
+     */
+    Address esp = context.getRegisterAsAddress(X86ThreadContext.SP);
 
     if ( (ebp == null) || ebp.lessThan(esp) ) {
       return null;
--- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	2019-01-21 18:48:15.673273140 +0100
+++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	2019-01-21 18:48:15.465273691 +0100
@@ -209,12 +209,6 @@
     public HtmlVersion htmlVersion = null;
 
     /**
-     * Flag to enable/disable use of module directories when generating docs for modules
-     * Default: on (module directories are enabled).
-     */
-    public boolean useModuleDirectories = true;
-
-    /**
      * Collected set of doclint options
      */
     public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
@@ -840,13 +834,6 @@
                     }
                     return true;
                 }
-            },
-            new XOption(resources, "--no-module-directories") {
-                @Override
-                public boolean process(String option, List<String> args) {
-                    useModuleDirectories = false;
-                    return true;
-                }
             }
         };
         Set<Doclet.Option> oset = new TreeSet<>();
--- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	2019-01-21 18:48:16.165271838 +0100
+++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	2019-01-21 18:48:15.949272409 +0100
@@ -609,7 +609,7 @@
             return links.createLink(pathString(packageElement, DocPaths.PACKAGE_SUMMARY),
                     label);
         } else {
-            DocLink crossPkgLink = getCrossPackageLink(utils.getPackageName(packageElement));
+            DocLink crossPkgLink = getCrossPackageLink(packageElement);
             if (crossPkgLink != null) {
                 return links.createLink(crossPkgLink, label);
             } else {
@@ -692,11 +692,10 @@
 
     /*************************************************************
      * Return a class cross link to external class documentation.
-     * The name must be fully qualified to determine which package
-     * the class is in.  The -link option does not allow users to
+     * The -link option does not allow users to
      * link to external classes in the "default" package.
      *
-     * @param qualifiedClassName the qualified name of the external class.
+     * @param classElement the class element
      * @param refMemName the name of the member being referenced.  This should
      * be null or empty string if no member is being referenced.
      * @param label the label for the external link.
@@ -704,19 +703,15 @@
      * @param code true if the label should be code font.
      * @return the link
      */
-    public Content getCrossClassLink(String qualifiedClassName, String refMemName,
+    public Content getCrossClassLink(TypeElement classElement, String refMemName,
                                     Content label, boolean strong, boolean code) {
-        String className = "";
-        String packageName = qualifiedClassName == null ? "" : qualifiedClassName;
-        int periodIndex;
-        while ((periodIndex = packageName.lastIndexOf('.')) != -1) {
-            className = packageName.substring(periodIndex + 1, packageName.length()) +
-                (className.length() > 0 ? "." + className : "");
+        if (classElement != null) {
+            String className = utils.getSimpleName(classElement);
+            PackageElement packageElement = utils.containingPackage(classElement);
             Content defaultLabel = new StringContent(className);
             if (code)
                 defaultLabel = HtmlTree.CODE(defaultLabel);
-            packageName = packageName.substring(0, periodIndex);
-            if (getCrossPackageLink(packageName) != null) {
+            if (getCrossPackageLink(packageElement) != null) {
                 /*
                 The package exists in external documentation, so link to the external
                 class (assuming that it exists).  This is definitely a limitation of
@@ -724,13 +719,13 @@
                 exists, but no way to determine if the external class exists.  We just
                 have to assume that it does.
                 */
-                DocLink link = configuration.extern.getExternalLink(packageName, pathToRoot,
+                DocLink link = configuration.extern.getExternalLink(packageElement, pathToRoot,
                                 className + ".html", refMemName);
                 return links.createLink(link,
                     (label == null) || label.isEmpty() ? defaultLabel : label,
                     strong,
-                    resources.getText("doclet.Href_Class_Or_Interface_Title", packageName),
-                    "", true);
+                    resources.getText("doclet.Href_Class_Or_Interface_Title",
+                        utils.getPackageName(packageElement)), "", true);
             }
         }
         return null;
@@ -743,14 +738,14 @@
         return configuration.extern.isExternal(typeElement);
     }
 
-    public DocLink getCrossPackageLink(String pkgName) {
-        return configuration.extern.getExternalLink(pkgName, pathToRoot,
+    public DocLink getCrossPackageLink(PackageElement element) {
+        return configuration.extern.getExternalLink(element, pathToRoot,
             DocPaths.PACKAGE_SUMMARY.getPath());
     }
 
-    public DocLink getCrossModuleLink(String mdleName) {
-        return configuration.extern.getExternalLink(mdleName, pathToRoot,
-            docPaths.moduleSummary(mdleName).getPath());
+    public DocLink getCrossModuleLink(ModuleElement element) {
+        return configuration.extern.getExternalLink(element, pathToRoot,
+            docPaths.moduleSummary(utils.getModuleName(element)).getPath());
     }
 
     /**
@@ -1020,17 +1015,13 @@
                 return getPackageLink(refPackage, label);
             } else {
                 // @see is not referencing an included class, module or package. Check for cross links.
-                Content classCrossLink;
                 DocLink elementCrossLink = (configuration.extern.isModule(refClassName))
-                        ? getCrossModuleLink(refClassName) : getCrossPackageLink(refClassName);
+                        ? getCrossModuleLink(utils.elementUtils.getModuleElement(refClassName)) :
+                        (refPackage != null) ? getCrossPackageLink(refPackage) : null;
                 if (elementCrossLink != null) {
                     // Element cross link found
                     return links.createLink(elementCrossLink,
                             (label.isEmpty() ? text : label), true);
-                } else if ((classCrossLink = getCrossClassLink(refClassName,
-                        refMemName, label, false, !isLinkPlain)) != null) {
-                    // Class cross link found (possibly to a member in the class)
-                    return classCrossLink;
                 } else {
                     // No cross link found so print warning
                     messages.warning(ch.getDocTreePath(see),
--- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java	2019-01-21 18:48:16.677270483 +0100
+++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java	2019-01-21 18:48:16.461271054 +0100
@@ -111,7 +111,7 @@
             }
         } else {
             Content crossLink = m_writer.getCrossClassLink(
-                typeElement.getQualifiedName().toString(), classLinkInfo.where,
+                typeElement, classLinkInfo.where,
                 label, classLinkInfo.isStrong, true);
             if (crossLink != null) {
                 link.addContent(crossLink);
--- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java	2019-01-21 18:48:17.181269148 +0100
+++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java	2019-01-21 18:48:16.953269752 +0100
@@ -886,8 +886,7 @@
                         contents.packageLabel)));
             } else {
                 DocLink crossPkgLink = configuration.extern.getExternalLink(
-                        configuration.utils.getPackageName(packageElement), pathToRoot,
-                        DocPaths.PACKAGE_SUMMARY.getPath());
+                        packageElement, pathToRoot, DocPaths.PACKAGE_SUMMARY.getPath());
                 if (crossPkgLink != null) {
                     tree.addContent(HtmlTree.LI(links.createLink(crossPkgLink, contents.packageLabel)));
                 } else {
--- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java	2019-01-21 18:48:17.673267847 +0100
+++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java	2019-01-21 18:48:17.453268429 +0100
@@ -295,6 +295,11 @@
      // A list of pairs containing urls and package list
     private final List<Pair<String, String>> linkOfflineList = new ArrayList<>();
 
+    /**
+     * Flag to enable/disable use of module directories when generating docs for modules
+     * Default: on (module directories are enabled).
+     */
+    public boolean useModuleDirectories = true;
 
     public boolean dumpOnError = false;
 
@@ -740,6 +745,13 @@
                         return true;
                     }
                 },
+                new XOption(resources, "--no-module-directories") {
+                    @Override
+                    public boolean process(String option, List<String> args) {
+                        useModuleDirectories = false;
+                        return true;
+                    }
+                }
         };
         Set<Doclet.Option> set = new TreeSet<>();
         set.addAll(Arrays.asList(options));
--- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties	2019-01-21 18:48:18.181266501 +0100
+++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties	2019-01-21 18:48:17.973267053 +0100
@@ -227,6 +227,10 @@
 doclet.Description=Description
 doclet.ConstantField=Constant Field
 doclet.Value=Value
+doclet.linkMismatch_PackagedLinkedtoModule=The code being documented uses packages in the unnamed module, \
+  but the packages defined in {0} are in named modules.
+doclet.linkMismatch_ModuleLinkedtoPackage=The code being documented uses modules but the packages defined \
+  in {0} are in the unnamed module.
 
 #Documentation for Enums
 doclet.enum_values_doc.fullbody=\
--- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_ja.properties	2019-01-21 18:48:18.673265198 +0100
+++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_ja.properties	2019-01-21 18:48:18.457265770 +0100
@@ -218,6 +218,8 @@
 doclet.Description=\u8AAC\u660E
 doclet.ConstantField=\u5B9A\u6570\u30D5\u30A3\u30FC\u30EB\u30C9
 doclet.Value=\u5024
+doclet.linkMismatch_PackagedLinkedtoModule=\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5316\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308B\u30B3\u30FC\u30C9\u3067\u306F\u540D\u524D\u306E\u306A\u3044\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059\u304C\u3001{0}\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u306F\u540D\u524D\u306E\u3042\u308B\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u3082\u306E\u3067\u3059\u3002
+doclet.linkMismatch_ModuleLinkedtoPackage=\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5316\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308B\u30B3\u30FC\u30C9\u3067\u306F\u30E2\u30B8\u30E5\u30FC\u30EB\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059\u304C\u3001{0}\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u306F\u540D\u524D\u306E\u306A\u3044\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u3082\u306E\u3067\u3059\u3002
 
 #Documentation for Enums
 doclet.enum_values_doc.fullbody=\u3053\u306E\u5217\u6319\u578B\u306E\u5B9A\u6570\u3092\u542B\u3080\u914D\u5217\u3092\u5BA3\u8A00\u3055\u308C\u3066\u3044\u308B\u9806\u5E8F\u3067\u8FD4\u3057\u307E\u3059\u3002\n\u3053\u306E\u30E1\u30BD\u30C3\u30C9\u306F\u6B21\u306E\u3088\u3046\u306B\u3057\u3066\u5B9A\u6570\u3092\u53CD\u5FA9\u3059\u308B\u305F\u3081\u306B\n\u4F7F\u7528\u3067\u304D\u307E\u3059:\n<pre>\nfor ({0} c : {0}.values())\n&nbsp;   System.out.println(c);\n</pre>
--- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_zh_CN.properties	2019-01-21 18:48:19.205263790 +0100
+++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_zh_CN.properties	2019-01-21 18:48:18.989264362 +0100
@@ -218,6 +218,8 @@
 doclet.Description=\u8BF4\u660E
 doclet.ConstantField=\u5E38\u91CF\u5B57\u6BB5
 doclet.Value=\u503C
+doclet.linkMismatch_PackagedLinkedtoModule=\u8FDB\u884C\u6587\u6863\u5316\u7684\u4EE3\u7801\u4F7F\u7528\u4E86\u672A\u547D\u540D\u6A21\u5757\u4E2D\u7684\u7A0B\u5E8F\u5305\uFF0C\u4F46\u5728 {0} \u4E2D\u5B9A\u4E49\u7684\u7A0B\u5E8F\u5305\u5728\u547D\u540D\u6A21\u5757\u4E2D\u3002
+doclet.linkMismatch_ModuleLinkedtoPackage=\u8FDB\u884C\u6587\u6863\u5316\u7684\u4EE3\u7801\u4F7F\u7528\u4E86\u6A21\u5757\uFF0C\u4F46\u5728 {0} \u4E2D\u5B9A\u4E49\u7684\u7A0B\u5E8F\u5305\u5728\u672A\u547D\u540D\u6A21\u5757\u4E2D\u3002
 
 #Documentation for Enums
 doclet.enum_values_doc.fullbody=\u6309\u7167\u58F0\u660E\u8BE5\u679A\u4E3E\u7C7B\u578B\u7684\u5E38\u91CF\u7684\u987A\u5E8F, \u8FD4\u56DE\n\u5305\u542B\u8FD9\u4E9B\u5E38\u91CF\u7684\u6570\u7EC4\u3002\u8BE5\u65B9\u6CD5\u53EF\u7528\u4E8E\u8FED\u4EE3\n\u5E38\u91CF, \u5982\u4E0B\u6240\u793A:\n<pre>\nfor ({0} c : {0}.values())\n&nbsp;   System.out.println(c);\n</pre>
--- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java	2019-01-21 18:48:19.705262464 +0100
+++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java	2019-01-21 18:48:19.489263036 +0100
@@ -29,8 +29,10 @@
 import java.net.*;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.TreeMap;
 
 import javax.lang.model.element.Element;
+import javax.lang.model.element.ModuleElement;
 import javax.lang.model.element.PackageElement;
 import javax.tools.Diagnostic;
 import javax.tools.DocumentationTool;
@@ -59,7 +61,8 @@
      * Map element names onto Extern Item objects.
      * Lazily initialized.
      */
-    private Map<String, Item> elementToItemMap;
+    private Map<String, Item> moduleItems = new HashMap<>();
+    private Map<String, Map<String, Item>> packageItems = new HashMap<>();
 
     /**
      * The global configuration information for this run.
@@ -85,7 +88,7 @@
          * The URL or the directory path at which the element documentation will be
          * avaliable.
          */
-        final String path;
+        final DocPath path;
 
         /**
          * If given path is directory path then true else if it is a URL then false.
@@ -93,11 +96,6 @@
         final boolean relative;
 
         /**
-         * If the item is a module then true else if it is a package then false.
-         */
-        boolean isModule = false;
-
-        /**
          * Constructor to build a Extern Item object and map it with the element name.
          * If the same element name is found in the map, then the first mapped
          * Item object or offline location will be retained.
@@ -106,19 +104,11 @@
          * @param path        URL or Directory path from where the "element-list"
          * file is picked.
          * @param relative    True if path is URL, false if directory path.
-         * @param isModule    True if the item is a module. False if it is a package.
          */
-        Item(String elementName, String path, boolean relative, boolean isModule) {
+        Item(String elementName, DocPath path, boolean relative) {
             this.elementName = elementName;
             this.path = path;
             this.relative = relative;
-            this.isModule = isModule;
-            if (elementToItemMap == null) {
-                elementToItemMap = new HashMap<>();
-            }
-            if (!elementToItemMap.containsKey(elementName)) { // save the previous
-                elementToItemMap.put(elementName, this);        // mapped location
-            }
         }
 
         /**
@@ -126,7 +116,7 @@
          */
         @Override
         public String toString() {
-            return elementName + (relative? " -> " : " => ") + path;
+            return elementName + (relative? " -> " : " => ") + path.getPath();
         }
     }
 
@@ -141,14 +131,15 @@
      * @return true if the element is externally documented
      */
     public boolean isExternal(Element element) {
-        if (elementToItemMap == null) {
+        if (packageItems.isEmpty()) {
             return false;
         }
         PackageElement pe = configuration.utils.containingPackage(element);
         if (pe.isUnnamed()) {
             return false;
         }
-        return elementToItemMap.get(configuration.utils.getPackageName(pe)) != null;
+
+        return findElementItem(pe) != null;
     }
 
     /**
@@ -158,25 +149,25 @@
      * @return true if the element is a module
      */
     public boolean isModule(String elementName) {
-        Item elem = findElementItem(elementName);
-        return (elem == null) ? false : elem.isModule;
+        Item elem = moduleItems.get(elementName);
+        return (elem == null) ? false : true;
     }
 
     /**
      * Convert a link to be an external link if appropriate.
      *
-     * @param elemName The element name.
+     * @param element The element .
      * @param relativepath    The relative path.
      * @param filename    The link to convert.
      * @return if external return converted link else return null
      */
-    public DocLink getExternalLink(String elemName, DocPath relativepath, String filename) {
-        return getExternalLink(elemName, relativepath, filename, null);
+    public DocLink getExternalLink(Element element, DocPath relativepath, String filename) {
+        return getExternalLink(element, relativepath, filename, null);
     }
 
-    public DocLink getExternalLink(String elemName, DocPath relativepath, String filename,
+    public DocLink getExternalLink(Element element, DocPath relativepath, String filename,
             String memberName) {
-        Item fnd = findElementItem(elemName);
+        Item fnd = findElementItem(element);
         if (fnd == null)
             return null;
 
@@ -184,7 +175,7 @@
         // to contain external URLs!
         DocPath p = fnd.relative ?
                 relativepath.resolve(fnd.path).resolve(filename) :
-                DocPath.create(fnd.path).resolve(filename);
+                fnd.path.resolve(filename);
         return new DocLink(p, "is-external=true", memberName);
     }
 
@@ -266,13 +257,20 @@
     /**
      * Get the Extern Item object associated with this element name.
      *
-     * @param elemName Element name.
+     * @param element Element
      */
-    private Item findElementItem(String elemName) {
-        if (elementToItemMap == null) {
-            return null;
+    private Item findElementItem(Element element) {
+        Item item = null;
+        if (element instanceof ModuleElement) {
+            item = moduleItems.get(configuration.utils.getModuleName((ModuleElement)element));
+        }
+        else if (element instanceof PackageElement) {
+            PackageElement packageElement = (PackageElement)element;
+            ModuleElement moduleElement = configuration.utils.containingModule(packageElement);
+            Map<String, Item> pkgMap = packageItems.get(configuration.utils.getModuleName(moduleElement));
+            item = (pkgMap != null) ? pkgMap.get(configuration.utils.getPackageName(packageElement)) : null;
         }
-        return elementToItemMap.get(elemName);
+        return item;
     }
 
     /**
@@ -370,23 +368,34 @@
      * @throws IOException if there is a problem reading or closing the stream
      */
     private void readElementList(InputStream input, String path, boolean relative)
-                         throws IOException {
+                         throws Fault, IOException {
         try (BufferedReader in = new BufferedReader(new InputStreamReader(input))) {
-            in.lines().forEach((elemname) -> {
+            String elemname = null;
+            String moduleName = null;
+            DocPath elempath = null;
+            DocPath basePath  = DocPath.create(path);
+            while ((elemname = in.readLine()) != null) {
                 if (elemname.length() > 0) {
-                    boolean module;
-                    String elempath;
+                    elempath = basePath;
                     if (elemname.startsWith(DocletConstants.MODULE_PREFIX)) {
-                        elemname = elemname.replace(DocletConstants.MODULE_PREFIX, "");
-                        elempath = path;
-                        module = true;
+                        moduleName = elemname.replace(DocletConstants.MODULE_PREFIX, "");
+                        Item item = new Item(moduleName, elempath, relative);
+                        moduleItems.put(moduleName, item);
                     } else {
-                        elempath = path + elemname.replace('.', '/') + '/';
-                        module = false;
+                        DocPath pkgPath = DocPath.create(elemname.replace('.', '/'));
+                        if (configuration.useModuleDirectories && moduleName != null) {
+                            elempath = elempath.resolve(DocPath.create(moduleName).resolve(pkgPath));
+                        } else {
+                            elempath = elempath.resolve(pkgPath);
+                        }
+                        checkLinkCompatibility(elemname, moduleName, path);
+                        Item item = new Item(elemname, elempath, relative);
+                        packageItems.computeIfAbsent(moduleName == null ?
+                            DocletConstants.DEFAULT_ELEMENT_NAME : moduleName, k -> new TreeMap<>())
+                            .put(elemname, item);
                     }
-                    Item ignore = new Item(elemname, elempath, relative, module);
                 }
-            });
+            }
         }
     }
 
@@ -400,4 +409,18 @@
             return false;
         }
     }
+
+    private void checkLinkCompatibility(String packageName, String moduleName, String path) throws Fault {
+        PackageElement pe = configuration.utils.elementUtils.getPackageElement(packageName);
+        if (pe != null) {
+            ModuleElement me = (ModuleElement)pe.getEnclosingElement();
+            if (me == null || me.isUnnamed()) {
+                if (moduleName != null)
+                    throw new Fault(configuration.getText("doclet.linkMismatch_PackagedLinkedtoModule",
+                            path), null);
+            } else if (moduleName == null)
+                throw new Fault(configuration.getText("doclet.linkMismatch_ModuleLinkedtoPackage",
+                        path), null);
+        }
+    }
 }
--- old/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_de.java	2019-01-21 18:48:20.209261129 +0100
+++ new/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_de.java	2019-01-21 18:48:19.989261712 +0100
@@ -667,9 +667,9 @@
                                            "Magadanische Sommerzeit", "MAGST",
                                            "Magadanische Zeit", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"Philippinische Zeit", "PHT",
-                                          "Philippinische Sommerzeit", "PHST",
-                                          "Philippinische Zeit", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- old/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_es.java	2019-01-21 18:48:20.753259687 +0100
+++ new/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_es.java	2019-01-21 18:48:20.533260271 +0100
@@ -667,9 +667,9 @@
                                            "Hora de verano de Magad\u00e1n", "MAGST",
                                            "Hora de Magad\u00E1n", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"Hora de Filipinas", "PHT",
-                                          "Hora de verano de Filipinas", "PHST",
-                                          "Hora de Filipinas", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- old/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_fr.java	2019-01-21 18:48:21.289258267 +0100
+++ new/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_fr.java	2019-01-21 18:48:21.065258860 +0100
@@ -667,9 +667,9 @@
                                            "Heure d'\u00e9t\u00e9 de Magadan", "MAGST",
                                            "Heure de Magadan", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"Heure des Philippines", "PHT",
-                                          "Heure d'\u00e9t\u00e9 des Philippines", "PHST",
-                                          "Heure des Philippines", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- old/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_it.java	2019-01-21 18:48:21.781256964 +0100
+++ new/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_it.java	2019-01-21 18:48:21.561257546 +0100
@@ -667,9 +667,9 @@
                                            "Ora estiva di Magadan", "MAGST",
                                            "Ora di Magadan", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"Ora delle Filippine", "PHT",
-                                          "Ora estiva delle Filippine", "PHST",
-                                          "Ora delle Filippine", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- old/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ja.java	2019-01-21 18:48:22.269255669 +0100
+++ new/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ja.java	2019-01-21 18:48:22.037256284 +0100
@@ -667,9 +667,9 @@
                                            "\u30de\u30ac\u30c0\u30f3\u590f\u6642\u9593", "MAGST",
                                            "\u30DE\u30AC\u30C0\u30F3\u6642\u9593", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"\u30d5\u30a3\u30ea\u30d4\u30f3\u6642\u9593", "PHT",
-                                          "\u30d5\u30a3\u30ea\u30d4\u30f3\u590f\u6642\u9593", "PHST",
-                                          "\u30D5\u30A3\u30EA\u30D4\u30F3\u6642\u9593", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- old/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ko.java	2019-01-21 18:48:22.745254407 +0100
+++ new/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ko.java	2019-01-21 18:48:22.521255000 +0100
@@ -667,9 +667,9 @@
                                            "\ub9c8\uac00\ub2e8 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "MAGST",
                                            "\uB9C8\uAC00\uB2E8 \uD45C\uC900\uC2DC", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"\ud544\ub9ac\ud540 \uc2dc\uac04", "PHT",
-                                          "\ud544\ub9ac\ud540 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "PHST",
-                                          "\uD544\uB9AC\uD540 \uD45C\uC900\uC2DC", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- old/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_pt_BR.java	2019-01-21 18:48:23.281252985 +0100
+++ new/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_pt_BR.java	2019-01-21 18:48:23.049253600 +0100
@@ -667,9 +667,9 @@
                                            "Fuso hor\u00e1rio de ver\u00e3o de Magadan", "MAGST",
                                            "Hor\u00E1rio de Magadan", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"Fuso hor\u00e1rio das Filipinas", "PHT",
-                                          "Fuso hor\u00e1rio de ver\u00e3o das Filipinas", "PHST",
-                                          "Hor\u00E1rio das Filipinas", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- old/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_sv.java	2019-01-21 18:48:23.785251650 +0100
+++ new/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_sv.java	2019-01-21 18:48:23.573252211 +0100
@@ -667,9 +667,9 @@
                                            "Magadan, sommartid", "MAGST",
                                            "Magadan-tid", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"Filippinerna, normaltid", "PHT",
-                                          "Filippinerna, sommartid", "PHST",
-                                          "Filippinsk tid", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- old/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_CN.java	2019-01-21 18:48:24.289250312 +0100
+++ new/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_CN.java	2019-01-21 18:48:24.069250895 +0100
@@ -667,9 +667,9 @@
                                            "Magadan \u590f\u4ee4\u65f6", "MAGST",
                                            "Magadan \u65F6\u95F4", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"\u83f2\u5f8b\u5bbe\u65f6\u95f4", "PHT",
-                                          "\u83f2\u5f8b\u5bbe\u590f\u4ee4\u65f6", "PHST",
-                                          "\u83F2\u5F8B\u5BBE\u65F6\u95F4", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- old/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_TW.java	2019-01-21 18:48:24.797248965 +0100
+++ new/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_TW.java	2019-01-21 18:48:24.569249570 +0100
@@ -667,9 +667,9 @@
                                            "Magadan \u590f\u4ee4\u6642\u9593", "MAGST",
                                            "\u99AC\u52A0\u4E39\u6642\u9593", "MAGT"}},
             {"Asia/Makassar", CIT},
-            {"Asia/Manila", new String[] {"\u83f2\u5f8b\u8cd3\u6642\u9593", "PHT",
-                                          "\u83f2\u5f8b\u8cd3\u590f\u4ee4\u6642\u9593", "PHST",
-                                          "\u83F2\u5F8B\u8CD3\u6642\u9593", "PHT"}},
+            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
+                                          "Philippines Daylight Time", "PDT",
+                                          "Philippines Time", "PT"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
             {"Asia/Novokuznetsk", KRAT},
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/hotspot/jtreg/runtime/ClassUnload/ConstantPoolDependsTest.java	2019-01-21 18:48:25.113248125 +0100
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test ConstantPoolDependsTest
+ * @bug 8210094
+ * @summary Create ClassLoader dependency from initiating loader to class loader through constant pool reference
+ * @requires vm.opt.final.ClassUnloading
+ * @modules java.base/jdk.internal.misc
+ *          java.compiler
+ * @library /runtime/testlibrary /test/lib
+ * @build sun.hotspot.WhiteBox
+ * @compile p2/c2.java MyDiffClassLoader.java
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ConstantPoolDependsTest
+ */
+
+import sun.hotspot.WhiteBox;
+
+
+public class ConstantPoolDependsTest {
+    public static WhiteBox wb = WhiteBox.getWhiteBox();
+    public static final String MY_TEST = "ConstantPoolDependsTest$c1c";
+
+    public static class c1c {
+        private void test() throws Exception {
+            // ConstantPool.klass_at_impl loads through constant pool and creates dependency
+            p2.c2 c2_obj = new p2.c2();
+            c2_obj.method2();
+        }
+
+        public c1c () throws Exception {
+            test();
+            ClassUnloadCommon.triggerUnloading();  // should not unload anything
+            test();
+            ClassUnloadCommon.triggerUnloading();  // should not unload anything
+        }
+    }
+
+    static void test() throws Throwable {
+
+        // now use the same loader to load class MyTest
+        Class MyTest_class = new MyDiffClassLoader(MY_TEST).loadClass(MY_TEST);
+
+        try {
+            // Call MyTest to load p2.c2 twice and call p2.c2.method2
+            MyTest_class.newInstance();
+        } catch (Exception e) {
+            throw new RuntimeException("Test FAILED if NoSuchMethodException is thrown");
+        }
+        ClassUnloadCommon.triggerUnloading();  // should not unload anything
+        ClassUnloadCommon.failIf(!wb.isClassAlive(MY_TEST), "should not be unloaded");
+        ClassUnloadCommon.failIf(!wb.isClassAlive("p2.c2"), "should not be unloaded");
+        // Unless MyTest_class is referenced here, the compiler can unload it.
+        System.out.println("Should not unload anything before here because " + MyTest_class + " is still alive.");
+    }
+
+    public static void main(String args[]) throws Throwable {
+        test();
+        ClassUnloadCommon.triggerUnloading();  // should unload
+        System.gc();
+        System.out.println("Should unload p2.c2 just now");
+        ClassUnloadCommon.failIf(wb.isClassAlive(MY_TEST), "should be unloaded");
+        ClassUnloadCommon.failIf(wb.isClassAlive("p2.c2"), "should be unloaded");
+    }
+}
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/hotspot/jtreg/runtime/ClassUnload/DictionaryDependsTest.java	2019-01-21 18:48:25.549246968 +0100
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test DictionaryDependsTest
+ * @bug 8210094
+ * @summary Create ClassLoader dependency from initiating loader to class loader through reflection
+ * @requires vm.opt.final.ClassUnloading
+ * @modules java.base/jdk.internal.misc
+ *          java.compiler
+ * @library /runtime/testlibrary /test/lib
+ * @build sun.hotspot.WhiteBox
+ * @compile p2/c2.java MyDiffClassLoader.java
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI DictionaryDependsTest
+ */
+import sun.hotspot.WhiteBox;
+import java.lang.reflect.Method;
+
+public class DictionaryDependsTest {
+    public static WhiteBox wb = WhiteBox.getWhiteBox();
+    public static final String MY_TEST = "DictionaryDependsTest$c1r";
+
+    static public class c1r {
+
+        private void test() throws Exception {
+            // forName loads through reflection and doesn't create dependency
+            Class<?> x = Class.forName("p2.c2", true, c1r.class.getClassLoader());
+            Method m = x.getMethod("method2");
+            java.lang.Object t = x.newInstance();
+            m.invoke(t);
+        }
+
+        public c1r () throws Exception {
+            test();
+            ClassUnloadCommon.triggerUnloading();  // should unload p2.c2
+            test();
+            ClassUnloadCommon.triggerUnloading();  // should unload p2.c2
+        }
+    }
+
+    public void test() throws Throwable {
+
+        // now use the same loader to load class MyTest
+        Class MyTest_class = new MyDiffClassLoader(MY_TEST).loadClass(MY_TEST);
+
+        try {
+            // Call MyTest to load p2.c2 twice and call p2.c2.method2
+            MyTest_class.newInstance();
+        } catch (Exception e) {
+            System.out.println("Not expected NSME");
+            throw new RuntimeException("Not expecting NSME");
+        }
+        ClassUnloadCommon.triggerUnloading();  // should not unload anything
+        ClassUnloadCommon.failIf(!wb.isClassAlive(MY_TEST), "should not be unloaded");
+        ClassUnloadCommon.failIf(!wb.isClassAlive("p2.c2"), "should not be unloaded");
+        // Unless MyTest_class is referenced here, the compiler can unload it.
+        System.out.println("Should not unload anything before here because " + MyTest_class + " is still alive.");
+    }
+
+    public static void main(String args[]) throws Throwable {
+        DictionaryDependsTest d = new DictionaryDependsTest();
+        d.test();
+        ClassUnloadCommon.triggerUnloading();  // should not unload anything
+        System.out.println("Should unload MyTest and p2.c2 just now");
+        ClassUnloadCommon.failIf(wb.isClassAlive(MY_TEST), "should be unloaded");
+        ClassUnloadCommon.failIf(wb.isClassAlive("p2.c2"), "should be unloaded");
+    }
+}
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/hotspot/jtreg/runtime/ClassUnload/MyDiffClassLoader.java	2019-01-21 18:48:25.985245812 +0100
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import jdk.test.lib.compiler.InMemoryJavaCompiler;
+
+public class MyDiffClassLoader extends ClassLoader {
+
+    public String loaderName;
+    public static boolean switchClassData = false;
+
+    MyDiffClassLoader(String name) {
+        this.loaderName = name;
+    }
+
+    public Class loadClass(String name) throws ClassNotFoundException {
+        if (!name.contains("c1r") &&
+            !name.contains("c1c") &&
+            !name.contains("c1s") &&
+            !name.equals("p2.c2")) {
+                return super.loadClass(name);
+        }
+
+        // new loader loads p2.c2
+        if  (name.equals("p2.c2") && !loaderName.equals("C2Loader")) {
+            Class<?> c = new MyDiffClassLoader("C2Loader").loadClass(name);
+            switchClassData = true;
+            return c;
+        }
+
+        byte[] data = switchClassData ? getNewClassData(name) : getClassData(name);
+        System.out.println("name is " + name);
+        return defineClass(name, data, 0, data.length);
+    }
+    byte[] getClassData(String name) {
+        try {
+           String TempName = name.replaceAll("\\.", "/");
+           String currentDir = System.getProperty("test.classes");
+           String filename = currentDir + File.separator + TempName + ".class";
+           FileInputStream fis = new FileInputStream(filename);
+           byte[] b = new byte[5000];
+           int cnt = fis.read(b, 0, 5000);
+           byte[] c = new byte[cnt];
+           for (int i=0; i<cnt; i++) c[i] = b[i];
+             return c;
+        } catch (IOException e) {
+           return null;
+        }
+    }
+
+    // Return p2.c2 with everything removed
+    byte[] getNewClassData(String name) {
+        return InMemoryJavaCompiler.compile("p2.c2", "package p2; public class c2 { }");
+    }
+}
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/hotspot/jtreg/runtime/ClassUnload/SuperDependsTest.java	2019-01-21 18:48:26.385244750 +0100
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test SuperDependsTest
+ * @bug 8210094
+ * @summary Create ClassLoader dependency from initiating loader to class loader through subclassing
+ * @requires vm.opt.final.ClassUnloading
+ * @modules java.base/jdk.internal.misc
+ *          java.compiler
+ * @library /runtime/testlibrary /test/lib
+ * @build sun.hotspot.WhiteBox
+ * @compile p2/c2.java MyDiffClassLoader.java
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SuperDependsTest
+ */
+import sun.hotspot.WhiteBox;
+import p2.*;
+
+public class SuperDependsTest {
+    public static WhiteBox wb = WhiteBox.getWhiteBox();
+    public static final String MY_TEST = "SuperDependsTest$c1s";
+
+
+    // p2.c2 loads through super class and creates dependency
+    public static class c1s extends p2.c2 {
+
+        private void test() throws Exception {
+            method2();
+        }
+
+        public c1s () throws Exception {
+            test();
+            ClassUnloadCommon.triggerUnloading();  // should not unload anything
+            test();
+        }
+    }
+
+    public void test() throws Throwable {
+
+        // now use the same loader to load class MyTest
+        Class MyTest_class = new MyDiffClassLoader(MY_TEST).loadClass(MY_TEST);
+
+        // Call MyTest to load p2.c2 twice and call p2.c2.method2
+        MyTest_class.newInstance();
+        ClassUnloadCommon.triggerUnloading();  // should not unload anything
+        ClassUnloadCommon.failIf(!wb.isClassAlive(MY_TEST), "should not be unloaded");
+        ClassUnloadCommon.failIf(!wb.isClassAlive("p2.c2"), "should not be unloaded");
+        // Unless MyTest_class is referenced here, the compiler can unload it.
+        System.out.println("Should not unload anything before here because " + MyTest_class + " is still alive.");
+    }
+
+    public static void main(String args[]) throws Throwable {
+        SuperDependsTest d = new SuperDependsTest();
+        d.test();
+        ClassUnloadCommon.triggerUnloading();  // should not unload anything
+        System.out.println("Should unload MyTest and p2.c2 just now");
+        ClassUnloadCommon.failIf(wb.isClassAlive(MY_TEST), "should be unloaded");
+        ClassUnloadCommon.failIf(wb.isClassAlive("p2.c2"), "should be unloaded");
+    }
+}
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/hotspot/jtreg/runtime/ClassUnload/p2/c2.java	2019-01-21 18:48:26.817243603 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package p2;
+
+public class c2 {
+    int i;
+    public void method2() { i = 5; System.out.println("c2 method2 called"); }
+}
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/hotspot/jtreg/serviceability/sa/LingeredAppWithNativeMethod.java	2019-01-21 18:48:27.253242445 +0100
@@ -0,0 +1,74 @@
+
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.test.lib.apps.LingeredApp;
+
+public class LingeredAppWithNativeMethod extends LingeredApp {
+
+    public static final String THREAD_NAME = "NoFramePointerJNIFib";
+    private static final int UPPER_BOUND = 55;
+    private static final int LOWER_BOUND = 40;
+
+    static {
+        // JNI library compiled with no frame pointer info
+        System.loadLibrary("NoFramePointer");
+    }
+
+    public void callNative() {
+        // Call JNI code which does something compute
+        // intensive: fibonacci
+        // That is to ensure that the native bits run when
+        // jstack --mixed info is to be gathered.
+        // Results of fibonacci calculation from JNI are
+        // reported via callback(). That's where the process
+        // of calculating fibonacci restarts.
+        int num = (int) (Math.random() * UPPER_BOUND);
+        while (num < LOWER_BOUND) {
+            num = (int) (Math.random() * UPPER_BOUND);
+        }
+        System.out.print("fib(" + num + ") = ");
+        callJNI(this, num);
+    }
+
+    // Called from JNI library libNoFramePointer
+    private void callback(long val) {
+        System.out.println(val);
+        // Call native again so as to increase chances of
+        // being currently in JNI code when jstack --mixed
+        // runs.
+        callNative();
+    }
+
+    public static native void callJNI(Object target, int num);
+
+    public static void main(String[] args) {
+        LingeredAppWithNativeMethod app = new LingeredAppWithNativeMethod();
+        Thread fibonacci = new Thread(() -> {
+            app.callNative();
+        });
+        fibonacci.setName(THREAD_NAME);
+        fibonacci.start();
+        LingeredApp.main(args);
+    }
+}
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java	2019-01-21 18:48:27.681241308 +0100
@@ -0,0 +1,187 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.Utils;
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.process.OutputAnalyzer;
+
+/**
+ * @test
+ * @bug 8208091
+ * @requires (os.family == "linux") & (vm.hasSAandCanAttach)
+ * @library /test/lib
+ * @run main/othervm TestJhsdbJstackMixed
+ */
+public class TestJhsdbJstackMixed {
+
+    private static final int MAX_ITERATIONS = 20;
+    private static final String NATIVE_FUNCTION_NAME = "fib";
+    private static final String LINE_MATCHER_STR = ".*" + NATIVE_FUNCTION_NAME
+            + ".*";
+    private static final Pattern LINE_PATTERN = Pattern
+            .compile(LINE_MATCHER_STR);
+    private static final String HEX_STR_PATTERN = "0x([a-fA-F0-9]+)";
+    private static final String FIB_SPLIT_PATTERN = NATIVE_FUNCTION_NAME
+            + "\\s+\\+";
+    private static final Pattern HEX_PATTERN = Pattern.compile(HEX_STR_PATTERN);
+    private static final int ADDRESS_ALIGNMENT_X86 = 4;
+
+    /*
+     * UnmappedAddressException will be thrown iff:
+     * - The JNI code is being compiled with -fomit-frame-pointer AND
+     * - The JNI code is currently executing at address A = pc() + offset
+     *   where A % ADDRESS_SIZE == 0.
+     *
+     * In the below example we have: pc() == f6401546, offset == 56,
+     * ADDRESS_SIZE == 4. Thus, A == F640159C which satisfies this condition.
+     *
+     * "NoFramePointerJNIFib" #11 prio=5 tid=0xa357bc00 nid=0x6de9 runnable [0xa365b000]
+     *    java.lang.Thread.State: RUNNABLE
+     *    JavaThread state: _thread_in_native
+     * 0xf6401546 fib + 0x56
+     */
+    private static boolean isFibAndAlignedAddress(List<String> lines) {
+        List<String> fibLines = findFibLines(lines);
+        System.out.println("DEBUG: " + fibLines);
+        // we're only interested in the first matched line.
+        if (fibLines.size() >= 1) {
+            String line = fibLines.get(0);
+            return isMatchLine(line);
+        }
+        return false;
+    }
+
+    private static boolean isMatchLine(String line) {
+        String[] tokens = line.split(FIB_SPLIT_PATTERN);
+        if (tokens.length != 2) {
+            return false; // NOT exactly two tokens, ignore.
+        }
+        String pcRaw = tokens[0].trim();
+        String offsetRaw = tokens[1].trim();
+        Matcher matcher = HEX_PATTERN.matcher(pcRaw);
+        long pcVal = 3;
+        boolean pcMatched = matcher.matches();
+        if (pcMatched) {
+            String pc = matcher.group(1);
+            pcVal = Long.parseUnsignedLong(pc, 16);
+        }
+        matcher = HEX_PATTERN.matcher(offsetRaw);
+        long offsetVal = 0;
+        boolean offsetMatched = matcher.matches();
+        if (offsetMatched) {
+            String offset = matcher.group(1);
+            offsetVal = Long.parseUnsignedLong(offset, 16);
+        }
+        if (offsetMatched && pcMatched
+                && (pcVal + offsetVal) % ADDRESS_ALIGNMENT_X86 == 0) {
+            return true;
+        }
+        return false;
+    }
+
+    private static List<String> findFibLines(List<String> lines) {
+        boolean startReached = false;
+        boolean endReached = false;
+        List<String> interestingLines = new ArrayList<>();
+        for (String line : lines) {
+            if (line.contains(LingeredAppWithNativeMethod.THREAD_NAME)) {
+                startReached = true;
+            }
+            if (startReached && line.contains("-------")) {
+                endReached = true;
+            }
+            if (startReached && !endReached) {
+                Matcher matcher = LINE_PATTERN.matcher(line);
+                if (matcher.matches()) {
+                    interestingLines.add(line);
+                }
+            }
+        }
+        return interestingLines;
+    }
+
+    private static void runJstackMixedInLoop(LingeredApp app) throws Exception {
+        for (int i = 0; i < MAX_ITERATIONS; i++) {
+            JDKToolLauncher launcher = JDKToolLauncher
+                    .createUsingTestJDK("jhsdb");
+            launcher.addToolArg("jstack");
+            launcher.addToolArg("--mixed");
+            launcher.addToolArg("--pid");
+            launcher.addToolArg(Long.toString(app.getPid()));
+
+            ProcessBuilder pb = new ProcessBuilder();
+            pb.command(launcher.getCommand());
+            Process jhsdb = pb.start();
+            OutputAnalyzer out = new OutputAnalyzer(jhsdb);
+
+            jhsdb.waitFor();
+
+            System.out.println(out.getStdout());
+            System.err.println(out.getStderr());
+
+            out.shouldContain(LingeredAppWithNativeMethod.THREAD_NAME);
+            if (isFibAndAlignedAddress(out.asLines())) {
+                System.out.println("DEBUG: Test triggered interesting condition.");
+                out.shouldNotContain("sun.jvm.hotspot.debugger.UnmappedAddressException:");
+                System.out.println("DEBUG: Test PASSED.");
+                return; // If we've reached here, all is well.
+            }
+            System.out.println("DEBUG: Iteration: " + (i + 1)
+                                 + " - Test didn't trigger interesting condition.");
+            out.shouldNotContain("sun.jvm.hotspot.debugger.UnmappedAddressException:");
+        }
+        System.out.println("DEBUG: Test didn't trigger interesting condition " +
+                             "but no UnmappedAddressException was thrown. PASS!");
+    }
+
+    public static void main(String... args) throws Exception {
+
+        LingeredApp app = null;
+
+        try {
+            List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
+            // Needed for LingeredApp to be able to resolve native library.
+            String libPath = System.getProperty("java.library.path");
+            if (libPath != null) {
+                vmArgs.add("-Djava.library.path=" + libPath);
+            }
+
+            app = new LingeredAppWithNativeMethod();
+            LingeredApp.startApp(vmArgs, app);
+            System.out.println("Started LingeredApp with pid " + app.getPid());
+            runJstackMixedInLoop(app);
+            System.out.println("Test Completed");
+        } catch (Throwable e) {
+            e.printStackTrace();
+            throw e;
+        } finally {
+            LingeredApp.stopApp(app);
+        }
+    }
+}
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/hotspot/jtreg/serviceability/sa/libNoFramePointer.c	2019-01-21 18:48:28.137240098 +0100
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+
+static jlong fib(jint num) {
+    if (num == 0) {
+        return 0;
+    }
+    if (num <= 2) {
+        return 1;
+    }
+    return fib(num - 2) + fib(num -1);
+}
+
+static void callCallback(JNIEnv *env, jclass cls, jobject target, jlong result) {
+    jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "(J)V");
+    if (mid == NULL) {
+        jclass nsme = (jclass) (*env)->NewGlobalRef(env, (*env)->FindClass(env, "java/lang/NoSuchMethodException"));
+        if (nsme != NULL) {
+            (*env)->ThrowNew(env, nsme, "Can't find method callback()");
+        }
+        return;
+    }
+    (*env)->CallVoidMethod(env, target, mid, result);
+}
+
+static void calculateAndCallCallback(JNIEnv *env, jclass cls, jobject target, jint num) {
+    jlong result = -1;
+    result = fib(num);
+    callCallback(env, cls, target, result);
+}
+
+JNIEXPORT void JNICALL
+Java_LingeredAppWithNativeMethod_callJNI(JNIEnv *env, jclass cls, jobject target, jint num) {
+    calculateAndCallCallback(env, cls, target, num);
+}
--- old/test/jdk/ProblemList.txt	2019-01-21 18:48:28.789238367 +0100
+++ new/test/jdk/ProblemList.txt	2019-01-21 18:48:28.573238941 +0100
@@ -697,7 +697,6 @@
 javax/sound/sampled/DirectAudio/bug6372428.java                      8055097 generic-all
 javax/sound/sampled/Clip/bug5070081.java                             8055097 generic-all
 javax/sound/sampled/DataLine/LongFramePosition.java                  8055097 generic-all
-javax/sound/sampled/Clip/AutoCloseTimeCheck.java                     8207150 generic-all
 
 javax/sound/sampled/Clip/Drain/ClipDrain.java          7062792 generic-all
 
--- old/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12Cipher.java	2019-01-21 18:48:29.317236964 +0100
+++ new/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12Cipher.java	2019-01-21 18:48:29.093237558 +0100
@@ -106,7 +106,7 @@
         this.salt = salt;
         this.iCount = iCount;
     }
-    public char[] getPassword() { return passwd; }
+    public char[] getPassword() { return passwd.clone(); }
     public byte[] getSalt() { return salt; }
     public int getIterationCount() { return iCount; }
     public String getAlgorithm() { return "PBE"; }
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/jdk/com/sun/jndi/ldap/DisconnectNPETest.java	2019-01-21 18:48:29.625236145 +0100
@@ -0,0 +1,193 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Hashtable;
+
+/*
+ * @test
+ * @bug 8205330
+ * @summary Test that If a connection has already been established and then
+ *          the LDAP directory server sends an (unsolicited)
+ *          "Notice of Disconnection", make sure client handle it correctly,
+ *          no NPE been thrown.
+ * @run main/othervm DisconnectNPETest
+ */
+
+public class DisconnectNPETest {
+    // Normally the NPE bug should be hit less than 100 times run, but just in
+    // case, we set repeat count to 1000 here.
+    private static final int REPEAT_COUNT = 1000;
+
+    public static void main(String[] args) throws IOException {
+        new DisconnectNPETest().run();
+    }
+
+    private ServerSocket serverSocket;
+    private Hashtable<Object, Object> env;
+    private TestLDAPServer server;
+
+    private void initRes() throws IOException {
+        serverSocket = new ServerSocket(0, 0, InetAddress.getLoopbackAddress());
+        server = new TestLDAPServer();
+        server.start();
+    }
+
+    private void initTest() {
+        env = new Hashtable<>();
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+                "com.sun.jndi.ldap.LdapCtxFactory");
+        env.put(Context.PROVIDER_URL, String.format("ldap://%s:%d/",
+                InetAddress.getLoopbackAddress().getHostName(),
+                serverSocket.getLocalPort()));
+        env.put(Context.SECURITY_AUTHENTICATION, "simple");
+        env.put(Context.SECURITY_PRINCIPAL,
+                "cn=8205330,ou=Client6,ou=Vendor1,o=IMC,c=US");
+        env.put(Context.SECURITY_CREDENTIALS, "secret123");
+    }
+
+    private void run() throws IOException {
+        initRes();
+        initTest();
+        int count = 0;
+        try {
+            while (count < REPEAT_COUNT) {
+                count++;
+                InitialDirContext context = null;
+                try {
+                    context = new InitialDirContext(env);
+                } catch (NamingException ne) {
+                    System.out.println("(" + count + "/" + REPEAT_COUNT
+                            + ") It's ok to get NamingException: " + ne);
+                    // for debug
+                    ne.printStackTrace(System.out);
+                } finally {
+                    cleanupContext(context);
+                }
+            }
+        } finally {
+            System.out.println("Test count: " + count + "/" + REPEAT_COUNT);
+            cleanupTest();
+        }
+    }
+
+    private void cleanupTest() {
+        if (server != null) {
+            server.stopServer();
+        }
+        cleanupClosableRes(serverSocket);
+    }
+
+    private void cleanupContext(DirContext context) {
+        if (context != null) {
+            try {
+                context.close();
+            } catch (NamingException e) {
+                // ignore
+            }
+        }
+    }
+
+    private static void cleanupClosableRes(Closeable res) {
+        if (res != null) {
+            try {
+                res.close();
+            } catch (Exception e) {
+                // ignore
+            }
+        }
+    }
+
+    class TestLDAPServer extends Thread {
+        private volatile boolean isRunning;
+
+        TestLDAPServer() {
+            isRunning = true;
+        }
+
+        private void stopServer() {
+            isRunning = false;
+        }
+
+        @Override
+        public void run() {
+            try {
+                while (isRunning) {
+                    Socket clientSocket = serverSocket.accept();
+                    Thread handler = new Thread(
+                            new LDAPServerHandler(clientSocket));
+                    handler.start();
+                }
+            } catch (IOException e) {
+                if (isRunning) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+    }
+
+    static class LDAPServerHandler implements Runnable {
+        // "Notice of Disconnection" message
+        private static final byte[] DISCONNECT_MSG = { 0x30, 0x4C, 0x02, 0x01,
+                0x00, 0x78, 0x47, 0x0A, 0x01, 0x34, 0x04, 0x00, 0x04, 0x28,
+                0x55, 0x4E, 0x41, 0x56, 0x41, 0x49, 0x4C, 0x41, 0x42, 0x4C,
+                0x45, 0x3A, 0x20, 0x54, 0x68, 0x65, 0x20, 0x73, 0x65, 0x72,
+                0x76, 0x65, 0x72, 0x20, 0x77, 0x69, 0x6C, 0x6C, 0x20, 0x64,
+                0x69, 0x73, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x21,
+                (byte) 0x8A, 0x16, 0x31, 0x2E, 0x33, 0x2E, 0x36, 0x2E, 0x31,
+                0x2E, 0x34, 0x2E, 0x31, 0x2E, 0x31, 0x34, 0x36, 0x36, 0x2E,
+                0x32, 0x30, 0x30, 0x33, 0x36 };
+        private static final byte[] BIND_RESPONSE = { 0x30, 0x0C, 0x02, 0x01,
+                0x01, 0x61, 0x07, 0x0A, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00 };
+        private final Socket clientSocket;
+
+        private LDAPServerHandler(final Socket clientSocket) {
+            this.clientSocket = clientSocket;
+        }
+
+        @Override
+        public void run() {
+            try (clientSocket;
+                    OutputStream out = clientSocket.getOutputStream();
+                    InputStream in = clientSocket.getInputStream()) {
+                if (in.read() > 0) {
+                    in.skip(in.available());
+                    out.write(BIND_RESPONSE);
+                    out.write(DISCONNECT_MSG);
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}
--- old/test/jdk/java/awt/Mixing/AWT_Mixing/FrameBorderCounter.java	2019-01-21 18:48:30.313234317 +0100
+++ new/test/jdk/java/awt/Mixing/AWT_Mixing/FrameBorderCounter.java	2019-01-21 18:48:30.089234912 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -20,15 +20,14 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 import java.awt.Dimension;
 import java.awt.EventQueue;
 import java.awt.Frame;
 import java.awt.Point;
 import java.awt.Robot;
-import java.awt.event.MouseEvent;
 import java.awt.event.MouseAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowAdapter;
+import java.awt.event.MouseEvent;
 
 public class FrameBorderCounter {
 
@@ -59,6 +58,7 @@
                 background.setVisible(true);
             }
         });
+        robot.waitForIdle();
         EventQueue.invokeAndWait(new Runnable() {
             public void run() {
                 frame = new Frame("Frame");
--- old/test/jdk/java/awt/Toolkit/ScreenInsetsTest/ScreenInsetsTest.java	2019-01-21 18:48:30.785233062 +0100
+++ new/test/jdk/java/awt/Toolkit/ScreenInsetsTest/ScreenInsetsTest.java	2019-01-21 18:48:30.561233658 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -32,8 +32,13 @@
   @run main ScreenInsetsTest
 */
 
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
 
 import test.java.awt.regtesthelpers.Util;
 
@@ -41,21 +46,33 @@
 {
     public static void main(String[] args)
     {
-        if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH))
-        {
-            // this state is used in the test - sorry
-            return;
-        }
-
         boolean passed = true;
 
         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
         GraphicsDevice[] gds = ge.getScreenDevices();
-        for (GraphicsDevice gd : gds)
-        {
+        for (GraphicsDevice gd : gds) {
+
             GraphicsConfiguration gc = gd.getDefaultConfiguration();
             Rectangle gcBounds = gc.getBounds();
             Insets gcInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
+            int left = gcInsets.left;
+            int right = gcInsets.right;
+            int bottom = gcInsets.bottom;
+            int top = gcInsets.top;
+            if (left < 0 || right < 0 || bottom < 0 || top < 0) {
+                throw new RuntimeException("Negative value: " + gcInsets);
+            }
+            int maxW = gcBounds.width / 3;
+            int maxH = gcBounds.height / 3;
+            if (left > maxW || right > maxW || bottom > maxH || top > maxH) {
+                throw new RuntimeException("Big value: " + gcInsets);
+            }
+
+            if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH))
+            {
+                // this state is used in the test - sorry
+                continue;
+            }
 
             Frame f = new Frame("Test", gc);
             f.setUndecorated(true);
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/jdk/java/awt/Window/WindowOwnedByEmbeddedFrameTest/WindowOwnedByEmbeddedFrameTest.java	2019-01-21 18:48:31.037232394 +0100
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @key headful
+ * @bug 8130655
+ * @summary Tests that window owned by EmbeddedFrame can receive keyboard input
+ * @requires (os.family == "mac")
+ * @modules java.desktop/sun.awt
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main WindowOwnedByEmbeddedFrameTest
+ */
+
+import sun.awt.EmbeddedFrame;
+
+import java.awt.Robot;
+import java.awt.TextField;
+import java.awt.Window;
+import java.awt.event.KeyEvent;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class WindowOwnedByEmbeddedFrameTest {
+    private static TextField textField;
+    private static EmbeddedFrame embeddedFrame;
+    private static Window window;
+
+    public static void main(String[] args) {
+        try {
+            Robot robot = Util.createRobot();
+            robot.setAutoDelay(50);
+
+            embeddedFrame = createEmbeddedFrame();
+
+            textField = new TextField("");
+
+            window = new Window(embeddedFrame);
+            window.setSize(200, 200);
+            window.setLocationRelativeTo(null);
+            window.add(textField);
+            window.setVisible(true);
+
+            Util.waitForIdle(robot);
+
+            Util.clickOnComp(textField, robot);
+            Util.waitForIdle(robot);
+
+            robot.keyPress(KeyEvent.VK_T);
+            robot.keyRelease(KeyEvent.VK_T);
+            Util.waitForIdle(robot);
+
+            robot.keyPress(KeyEvent.VK_E);
+            robot.keyRelease(KeyEvent.VK_E);
+            Util.waitForIdle(robot);
+
+            robot.keyPress(KeyEvent.VK_S);
+            robot.keyRelease(KeyEvent.VK_S);
+            Util.waitForIdle(robot);
+
+            robot.keyPress(KeyEvent.VK_T);
+            robot.keyRelease(KeyEvent.VK_T);
+            Util.waitForIdle(robot);
+
+            if ("".equals(textField.getText())) {
+                throw new RuntimeException("Keyboard input in text field isn't possible");
+            }
+        } finally {
+            if (embeddedFrame != null) {
+                embeddedFrame.dispose();
+            }
+            if (window != null) {
+                window.dispose();
+            }
+        }
+    }
+
+    private static EmbeddedFrame createEmbeddedFrame() {
+        try {
+            return (EmbeddedFrame) Class.forName("sun.lwawt.macosx.CEmbeddedFrame").newInstance();
+        } catch (Exception e) {
+            throw new RuntimeException("Cannot create EmbeddedFrame", e);
+        }
+    }
+}
+
--- old/test/jdk/java/math/BigDecimal/AddTests.java	2019-01-21 18:48:31.721230574 +0100
+++ new/test/jdk/java/math/BigDecimal/AddTests.java	2019-01-21 18:48:31.505231149 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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 6362557
+ * @bug 6362557 8200698
  * @summary Some tests of add(BigDecimal, mc)
  * @author Joseph D. Darcy
  */
@@ -290,12 +290,35 @@
         return failures;
     }
 
+    private static int arithmeticExceptionTest() {
+        int failures = 0;
+        BigDecimal x;
+        try {
+            //
+            // The string representation "1e2147483647", which is equivalent
+            // to 10^Integer.MAX_VALUE, is used to create an augend with an
+            // unscaled value of 1 and a scale of -Integer.MAX_VALUE. The
+            // addend "1" has an unscaled value of 1 with a scale of 0. The
+            // addition is performed exactly and is specified to have a
+            // preferred scale of max(-Integer.MAX_VALUE, 0). As the scale
+            // of the result is 0, a value with Integer.MAX_VALUE + 1 digits
+            // would need to be created. Therefore the next statement is
+            // expected to overflow with an ArithmeticException.
+            //
+            x = new BigDecimal("1e2147483647").add(new BigDecimal(1));
+            failures++;
+        } catch (ArithmeticException ae) {
+        }
+        return failures;
+    }
+
     public static void main(String argv[]) {
         int failures = 0;
 
         failures += extremaTests();
         failures += roundingGradationTests();
         failures += precisionConsistencyTest();
+        failures += arithmeticExceptionTest();
 
         if (failures > 0) {
             throw new RuntimeException("Incurred " + failures +
--- old/test/jdk/java/math/BigDecimal/Constructor.java	2019-01-21 18:48:32.237229203 +0100
+++ new/test/jdk/java/math/BigDecimal/Constructor.java	2019-01-21 18:48:32.021229776 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 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
@@ -23,20 +23,48 @@
 
 /*
  * @test
- * @bug 4259453
- * @summary Test string constructor of BigDecimal
+ * @bug 4259453 8200698
+ * @summary Test constructors of BigDecimal
+ * @library ..
+ * @run testng Constructor
  */
+
 import java.math.BigDecimal;
+import org.testng.annotations.Test;
 
 public class Constructor {
-    public static void main(String[] args) throws Exception {
-        boolean nfe = false;
+    @Test(expectedExceptions=NumberFormatException.class)
+    public void stringConstructor() {
+        BigDecimal bd = new BigDecimal("1.2e");
+    }
+
+    @Test(expectedExceptions=NumberFormatException.class)
+    public void charArrayConstructorNegativeOffset() {
+        BigDecimal bd = new BigDecimal(new char[5], -1, 4, null);
+    }
+
+    @Test(expectedExceptions=NumberFormatException.class)
+    public void charArrayConstructorNegativeLength() {
+        BigDecimal bd = new BigDecimal(new char[5], 0, -1, null);
+    }
+
+    @Test(expectedExceptions=NumberFormatException.class)
+    public void charArrayConstructorIntegerOverflow() {
         try {
-            BigDecimal bd = new BigDecimal("1.2e");
-        } catch (NumberFormatException e) {
-            nfe = true;
+            BigDecimal bd = new BigDecimal(new char[5], Integer.MAX_VALUE - 5,
+                6, null);
+        } catch (NumberFormatException nfe) {
+            if (nfe.getCause() instanceof IndexOutOfBoundsException) {
+                throw new RuntimeException
+                    ("NumberFormatException should not have a cause");
+            } else {
+                throw nfe;
+            }
         }
-        if (!nfe)
-            throw new Exception("Didn't throw NumberFormatException");
+    }
+
+    @Test(expectedExceptions=NumberFormatException.class)
+    public void charArrayConstructorIndexOutOfBounds() {
+        BigDecimal bd = new BigDecimal(new char[5], 1, 5, null);
     }
 }
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/jdk/java/math/BigInteger/LargeValueExceptions.java	2019-01-21 18:48:32.521228447 +0100
@@ -0,0 +1,192 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8200698
+ * @summary Tests that exceptions are thrown for ops which would overflow
+ * @requires os.maxMemory >= 4g
+ * @run testng/othervm -Xmx4g LargeValueExceptions
+ */
+import java.math.BigInteger;
+import static java.math.BigInteger.ONE;
+import org.testng.annotations.Test;
+
+//
+// The intent of this test is to probe the boundaries between overflow and
+// non-overflow, principally for multiplication and squaring, specifically
+// the largest values which should not overflow and the smallest values which
+// should. The transition values used are not necessarily at the exact
+// boundaries but should be "close." Quite a few different values were used
+// experimentally before settling on the ones in this test. For multiplication
+// and squaring all cases are exercised: definite overflow and non-overflow
+// which can be detected "up front," and "indefinite" overflow, i.e., overflow
+// which cannot be detected up front so further calculations are required.
+//
+// Testing negative values is unnecessary. For both multiplication and squaring
+// the paths lead to the Toom-Cook algorithm where the signum is used only to
+// determine the sign of the result and not in the intermediate calculations.
+// This is also true for exponentiation.
+//
+// @Test annotations with optional element "enabled" set to "false" should
+// succeed when "enabled" is set to "true" but they take too to run in the
+// course of the typical regression test execution scenario.
+//
+public class LargeValueExceptions {
+    // BigInteger.MAX_MAG_LENGTH
+    private static final int MAX_INTS = 1 << 26;
+
+    // Number of bits corresponding to MAX_INTS
+    private static final long MAX_BITS = (0xffffffffL & MAX_INTS) << 5L;
+
+    // Half BigInteger.MAX_MAG_LENGTH
+    private static final int MAX_INTS_HALF = MAX_INTS / 2;
+
+    // --- squaring ---
+
+    // Largest no overflow determined by examining data lengths alone.
+    @Test(enabled=false)
+    public void squareNoOverflow() {
+        BigInteger x = ONE.shiftLeft(16*MAX_INTS - 1).subtract(ONE);
+        BigInteger y = x.multiply(x);
+    }
+
+    // Smallest no overflow determined by extra calculations.
+    @Test(enabled=false)
+    public void squareIndefiniteOverflowSuccess() {
+        BigInteger x = ONE.shiftLeft(16*MAX_INTS - 1);
+        BigInteger y = x.multiply(x);
+    }
+
+    // Largest overflow detected by extra calculations.
+    @Test(expectedExceptions=ArithmeticException.class,enabled=false)
+    public void squareIndefiniteOverflowFailure() {
+        BigInteger x = ONE.shiftLeft(16*MAX_INTS).subtract(ONE);
+        BigInteger y = x.multiply(x);
+    }
+
+    // Smallest overflow detected by examining data lengths alone.
+    @Test(expectedExceptions=ArithmeticException.class)
+    public void squareDefiniteOverflow() {
+        BigInteger x = ONE.shiftLeft(16*MAX_INTS);
+        BigInteger y = x.multiply(x);
+    }
+
+    // --- multiplication ---
+
+    // Largest no overflow determined by examining data lengths alone.
+    @Test(enabled=false)
+    public void multiplyNoOverflow() {
+        final int halfMaxBits = MAX_INTS_HALF << 5;
+
+        BigInteger x = ONE.shiftLeft(halfMaxBits).subtract(ONE);
+        BigInteger y = ONE.shiftLeft(halfMaxBits - 1).subtract(ONE);
+        BigInteger z = x.multiply(y);
+    }
+
+    // Smallest no overflow determined by extra calculations.
+    @Test(enabled=false)
+    public void multiplyIndefiniteOverflowSuccess() {
+        BigInteger x = ONE.shiftLeft((int)(MAX_BITS/2) - 1);
+        long m = MAX_BITS - x.bitLength();
+
+        BigInteger y = ONE.shiftLeft((int)(MAX_BITS/2) - 1);
+        long n = MAX_BITS - y.bitLength();
+
+        if (m + n != MAX_BITS) {
+            throw new RuntimeException("Unexpected leading zero sum");
+        }
+
+        BigInteger z = x.multiply(y);
+    }
+
+    // Largest overflow detected by extra calculations.
+    @Test(expectedExceptions=ArithmeticException.class,enabled=false)
+    public void multiplyIndefiniteOverflowFailure() {
+        BigInteger x = ONE.shiftLeft((int)(MAX_BITS/2)).subtract(ONE);
+        long m = MAX_BITS - x.bitLength();
+
+        BigInteger y = ONE.shiftLeft((int)(MAX_BITS/2)).subtract(ONE);
+        long n = MAX_BITS - y.bitLength();
+
+        if (m + n != MAX_BITS) {
+            throw new RuntimeException("Unexpected leading zero sum");
+        }
+
+        BigInteger z = x.multiply(y);
+    }
+
+    // Smallest overflow detected by examining data lengths alone.
+    @Test(expectedExceptions=ArithmeticException.class)
+    public void multiplyDefiniteOverflow() {
+        // multiply by 4 as MAX_INTS_HALF refers to ints
+        byte[] xmag = new byte[4*MAX_INTS_HALF];
+        xmag[0] = (byte)0xff;
+        BigInteger x = new BigInteger(1, xmag);
+
+        byte[] ymag = new byte[4*MAX_INTS_HALF + 1];
+        ymag[0] = (byte)0xff;
+        BigInteger y = new BigInteger(1, ymag);
+
+        BigInteger z = x.multiply(y);
+    }
+
+    // --- exponentiation ---
+
+    @Test(expectedExceptions=ArithmeticException.class)
+    public void powOverflow() {
+        BigInteger.TEN.pow(Integer.MAX_VALUE);
+    }
+
+    @Test(expectedExceptions=ArithmeticException.class)
+    public void powOverflow1() {
+        int shift = 20;
+        int exponent = 1 << shift;
+        BigInteger x = ONE.shiftLeft((int)(MAX_BITS / exponent));
+        BigInteger y = x.pow(exponent);
+    }
+
+    @Test(expectedExceptions=ArithmeticException.class)
+    public void powOverflow2() {
+        int shift = 20;
+        int exponent = 1 << shift;
+        BigInteger x = ONE.shiftLeft((int)(MAX_BITS / exponent)).add(ONE);
+        BigInteger y = x.pow(exponent);
+    }
+
+    @Test(expectedExceptions=ArithmeticException.class,enabled=false)
+    public void powOverflow3() {
+        int shift = 20;
+        int exponent = 1 << shift;
+        BigInteger x = ONE.shiftLeft((int)(MAX_BITS / exponent)).subtract(ONE);
+        BigInteger y = x.pow(exponent);
+    }
+
+    @Test(enabled=false)
+    public void powOverflow4() {
+        int shift = 20;
+        int exponent = 1 << shift;
+        BigInteger x = ONE.shiftLeft((int)(MAX_BITS / exponent - 1)).add(ONE);
+        BigInteger y = x.pow(exponent);
+    }
+}
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/jdk/java/net/URL/RacyHandler.java	2019-01-21 18:48:32.917227395 +0100
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.IOException;
+import java.lang.reflect.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.util.concurrent.CountDownLatch;
+
+/*
+ * @test
+ * @bug 8213942
+ * @summary URLStreamHandler initialization race
+ * @run main/othervm RacyHandler
+ * @run main/othervm RacyHandler
+ * @run main/othervm RacyHandler
+ */
+
+/*
+ * This test makes reasonable effort to reproduce the race.
+ * Run repeatedly to ensure correctness.
+ */
+public class RacyHandler {
+    static volatile boolean factorySet = false;
+    static int NUM_THREADS = 2;
+    static CountDownLatch cdl = new CountDownLatch(NUM_THREADS + 1);
+
+    public static void main(String[] args) {
+        RacyHandler tester = new RacyHandler();
+        tester.runTest();
+    }
+
+    public void runTest() {
+        new Thread(() -> {
+            try {
+                cdl.await();
+                URL.setURLStreamHandlerFactory(proto -> new CustomHttpHandler());
+                factorySet = true;
+            } catch (Exception ignore) { }
+        }).start();
+        cdl.countDown();
+
+        for (int i = 0; i < NUM_THREADS; i++) {
+            new Thread(() -> {
+                try {
+                    cdl.await();
+                    while (!factorySet) {
+                        // trigger URL class load
+                        getURLStreamHandler();
+                    }
+                } catch (Exception ignore) { }
+            }).start();
+            cdl.countDown();
+        }
+
+        // wait for the factory to be set
+        while (!factorySet) { }
+        // The sleep seems to help trigger the failure
+        try {
+            Thread.sleep(500);
+        } catch (InterruptedException ie) {
+        }
+
+        URLStreamHandler httpHandler = getURLStreamHandler();
+        System.out.println("After setting factory URL handlers: http " + httpHandler);
+        if (!(httpHandler instanceof CustomHttpHandler))
+            throw new RuntimeException("FAILED: Incorrect handler type");
+    }
+
+    /*
+     * This is just so we can see what we get for the URLStreamHandler back
+     * from the factory to verify whether it really is using our Handler
+     * or something else...
+     */
+    public URLStreamHandler getURLStreamHandler() {
+        try {
+            Method method = URL.class.getDeclaredMethod("getURLStreamHandler",
+                    String.class);
+            method.setAccessible(true);
+            return (URLStreamHandler) method.invoke(null, "http");
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    class CustomHttpHandler extends URLStreamHandler {
+        @Override
+        protected URLConnection openConnection(URL u) throws IOException {
+            return null;
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/jdk/javax/imageio/plugins/png/ReadPNGWithNoTextInTEXTChunk.java	2019-01-21 18:48:33.313226341 +0100
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug     8212116
+ * @summary Test verifies that PNGImageReader doesn't throw IIOException
+ *          when reading a tEXt chunk having no text.
+ * @run     main ReadPNGWithNoTextInTEXTChunk
+ */
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.Color;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriter;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.metadata.IIOInvalidTreeException;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.metadata.IIOMetadataNode;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.IIOImage;
+
+public class ReadPNGWithNoTextInTEXTChunk {
+
+    private static BufferedImage img;
+    private static ImageWriter writer;
+    private static ImageWriteParam param;
+    private static IIOMetadata metadata;
+    private static byte[] imageByteArray;
+
+    private static void initialize(int type) {
+        int width = 1;
+        int height = 1;
+        img = new BufferedImage(width, height, type);
+        Graphics2D g2D = img.createGraphics();
+        g2D.setColor(new Color(255, 255, 255));
+        g2D.fillRect(0, 0, width, width);
+        g2D.dispose();
+
+        Iterator<ImageWriter> iterWriter =
+                ImageIO.getImageWritersBySuffix("png");
+        writer = iterWriter.next();
+
+        param = writer.getDefaultWriteParam();
+        ImageTypeSpecifier specifier =
+                ImageTypeSpecifier.
+                        createFromBufferedImageType(type);
+        metadata = writer.getDefaultImageMetadata(specifier, param);
+    }
+
+    private static void createTEXTNode()
+            throws IIOInvalidTreeException {
+        IIOMetadataNode tEXt_Entry = new IIOMetadataNode("tEXtEntry");
+        tEXt_Entry.setAttribute("keyword", "Author");
+        tEXt_Entry.setAttribute("value", "");
+
+        IIOMetadataNode tEXt = new IIOMetadataNode("tEXt");
+        tEXt.appendChild(tEXt_Entry);
+        IIOMetadataNode root = new IIOMetadataNode("javax_imageio_png_1.0");
+        root.appendChild(tEXt);
+        metadata.mergeTree("javax_imageio_png_1.0", root);
+    }
+
+    private static void writeImage() throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
+        writer.setOutput(ios);
+        writer.write(metadata, new IIOImage(img, null, metadata), param);
+        writer.dispose();
+
+        baos.flush();
+        imageByteArray = baos.toByteArray();
+        baos.close();
+    }
+
+    private static void readPNGTEXTChunk() throws IOException {
+        initialize(BufferedImage.TYPE_BYTE_GRAY);
+        // Create tEXt node with text length 0
+        createTEXTNode();
+
+        writeImage();
+
+        ByteArrayInputStream bais = new ByteArrayInputStream( imageByteArray );
+        ImageInputStream input= ImageIO.createImageInputStream(bais);
+        Iterator iter = ImageIO.getImageReaders(input);
+        ImageReader reader = (ImageReader) iter.next();
+        reader.setInput(input, false, false);
+        BufferedImage image = reader.read(0, reader.getDefaultReadParam());
+        input.close();
+        bais.close();
+    }
+
+    public static void main(String[] args) throws IOException {
+
+        // read PNG image where tEXt chunk's text length is 0
+        readPNGTEXTChunk();
+    }
+}
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/jdk/javax/net/ssl/compatibility/ClientHelloProcessing.java	2019-01-21 18:48:33.673225383 +0100
@@ -0,0 +1,781 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8210918 8210334 8209916
+ * @summary Add test to exercise server-side client hello processing
+ * @run main/othervm ClientHelloProcessing noPskNoKexModes
+ * @run main/othervm ClientHelloProcessing noPskYesKexModes
+ * @run main/othervm ClientHelloProcessing yesPskNoKexModes
+ * @run main/othervm ClientHelloProcessing yesPskYesKexModes
+ * @run main/othervm ClientHelloProcessing supGroupsSect163k1
+ */
+
+/*
+ * SunJSSE does not support dynamic system properties, no way to re-use
+ * system properties in samevm/agentvm mode.
+ */
+
+import java.io.FileInputStream;
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.HandshakeStatus;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Objects;
+
+/*
+ * If you wish to add test cases, the following must be done:
+ * 1. Add a @run line with the parameter being a name for the test case
+ * 2. Create the ClientHello as a byte[].  It should be a complete TLS
+ *    record, but does not need upper layer headers like TCP, IP, Ethernet, etc.
+ * 3. Create a new TestCase instance, see "noPskNoKexModes" as an example
+ * 4. Create a mapping between the test case name in your @run line and the
+ *    TestCase object you created in step #3.  Add this to TESTMAP.
+ */
+
+public class ClientHelloProcessing {
+
+    private static final ByteBuffer SERVOUTBUF =
+            ByteBuffer.wrap("Server Side".getBytes());
+
+    private static final String pathToStores = "../etc";
+    private static final String keyStoreFile = "keystore";
+    private static final String trustStoreFile = "truststore";
+    private static final String passwd = "passphrase";
+
+    private static final String keyFilename =
+            System.getProperty("test.src", ".") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static final String trustFilename =
+            System.getProperty("test.src", ".") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    private static TrustManagerFactory trustMgrFac = null;
+    private static KeyManagerFactory keyMgrFac = null;
+
+    // Canned client hello messages
+    // These were created from packet captures using openssl 1.1.1's
+    // s_client utility.  The captured TLS record containing the client
+    // hello was then manually edited to remove or add fields if the s_client
+    // utility could not be used to generate a message with the desired
+    // extensions.  When manually altering the hello messages, care must
+    // be taken to change the lengths of the extensions themselves, the
+    // extensions vector length, the handshake message length, and the TLS
+    // record length.
+
+    // Client Hello with the pre_shared_key and psk_key_exchange_modes
+    // both absent.  Required manual removal of the psk_key_exchange_modes
+    // extension.  Similarly formed Client Hello messages may be generated
+    // by clients that don't support pre-shared keys.
+    //
+    //    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
+    //        Content Type: Handshake (22)
+    //        Version: TLS 1.0 (0x0301)
+    //        Length: 256
+    //        Handshake Protocol: Client Hello
+    //            Handshake Type: Client Hello (1)
+    //            Length: 252
+    //            Version: TLS 1.2 (0x0303)
+    //            Random: 9b796ad0cbd559fb48fc4ba32da5bb8c1ef9a7da85231860...
+    //            Session ID Length: 32
+    //            Session ID: fe8411205bc99a506952f5c28569facb96ff0f37621be072...
+    //            Cipher Suites Length: 8
+    //            Cipher Suites (4 suites)
+    //            Compression Methods Length: 1
+    //            Compression Methods (1 method)
+    //            Extensions Length: 171
+    //            Extension: server_name (len=14)
+    //            Extension: ec_point_formats (len=4)
+    //            Extension: supported_groups (len=4)
+    //            Extension: SessionTicket TLS (len=0)
+    //            Extension: status_request (len=5)
+    //            Extension: encrypt_then_mac (len=0)
+    //            Extension: extended_master_secret (len=0)
+    //            Extension: signature_algorithms (len=30)
+    //            Extension: supported_versions (len=3)
+    //            Extension: key_share (len=71)
+    private static final byte[] CLIHELLO_NOPSK_NOPSKEXMODE = {
+        22,    3,    1,    1,    0,    1,    0,    0,
+        -4,    3,    3, -101,  121,  106,  -48,  -53,
+       -43,   89,   -5,   72,   -4,   75,  -93,   45,
+       -91,  -69, -116,   30,   -7,  -89,  -38, -123,
+        35,   24,   96,   29,  -93,  -22,   10,  -97,
+       -15,  -11,    3,   32,   -2, -124,   17,   32,
+        91,  -55, -102,   80,  105,   82,  -11,  -62,
+      -123,  105,   -6,  -53, -106,   -1,   15,   55,
+        98,   27,  -32,  114, -126,  -13,   42, -104,
+      -102,   37,  -65,   52,    0,    8,   19,    2,
+        19,    3,   19,    1,    0,   -1,    1,    0,
+         0,  -85,    0,    0,    0,   14,    0,   12,
+         0,    0,    9,  108,  111,   99,   97,  108,
+       104,  111,  115,  116,    0,   11,    0,    4,
+         3,    0,    1,    2,    0,   10,    0,    4,
+         0,    2,    0,   23,    0,   35,    0,    0,
+         0,    5,    0,    5,    1,    0,    0,    0,
+         0,    0,   22,    0,    0,    0,   23,    0,
+         0,    0,   13,    0,   30,    0,   28,    4,
+         3,    5,    3,    6,    3,    8,    7,    8,
+         8,    8,    9,    8,   10,    8,   11,    8,
+         4,    8,    5,    8,    6,    4,    1,    5,
+         1,    6,    1,    0,   43,    0,    3,    2,
+         3,    4,    0,   51,    0,   71,    0,   69,
+         0,   23,    0,   65,    4,  125,  -92,  -50,
+       -91,  -39,  -55, -114,    0,   22,    2,  -50,
+       123, -126,    0,  -94,  100, -119, -106,  125,
+       -81,  -24,   51,  -84,   25,   25, -115,   13,
+       -17,  -20,   93,   68,  -97,  -79,  -98,   91,
+        86,   91, -114,  123,  119,  -87,  -12,   32,
+        63,  -41,   50,  126,  -70,   96,   33,   -6,
+        94,   -7,  -68,   54,  -47,   53,    0,   88,
+        40,  -48, -102,  -50,   88
+    };
+
+    // Client Hello with the pre_shared_key extension absent but
+    // containing the psk_key_exchange_modes extension asserted.  No
+    // manual modification was necessary.
+    //
+    //    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
+    //        Content Type: Handshake (22)
+    //        Version: TLS 1.0 (0x0301)
+    //        Length: 262
+    //        Handshake Protocol: Client Hello
+    //            Handshake Type: Client Hello (1)
+    //            Length: 258
+    //            Version: TLS 1.2 (0x0303)
+    //            Random: 9b796ad0cbd559fb48fc4ba32da5bb8c1ef9a7da85231860...
+    //            Session ID Length: 32
+    //            Session ID: fe8411205bc99a506952f5c28569facb96ff0f37621be072...
+    //            Cipher Suites Length: 8
+    //            Cipher Suites (4 suites)
+    //            Compression Methods Length: 1
+    //            Compression Methods (1 method)
+    //            Extensions Length: 177
+    //            Extension: server_name (len=14)
+    //            Extension: ec_point_formats (len=4)
+    //            Extension: supported_groups (len=4)
+    //            Extension: SessionTicket TLS (len=0)
+    //            Extension: status_request (len=5)
+    //            Extension: encrypt_then_mac (len=0)
+    //            Extension: extended_master_secret (len=0)
+    //            Extension: signature_algorithms (len=30)
+    //            Extension: supported_versions (len=3)
+    //            Extension: psk_key_exchange_modes (len=2)
+    //                Type: psk_key_exchange_modes (45)
+    //                Length: 2
+    //                PSK Key Exchange Modes Length: 1
+    //                PSK Key Exchange Mode: PSK with (EC)DHE key establishment (psk_dhe_ke) (1)
+    //            Extension: key_share (len=71)
+    private static final byte[] CLIHELLO_NOPSK_YESPSKEXMODE = {
+        22,    3,    1,    1,    6,    1,    0,    1,
+         2,    3,    3, -101,  121,  106,  -48,  -53,
+       -43,   89,   -5,   72,   -4,   75,  -93,   45,
+       -91,  -69, -116,   30,   -7,  -89,  -38, -123,
+        35,   24,   96,   29,  -93,  -22,   10,  -97,
+       -15,  -11,    3,   32,   -2, -124,   17,   32,
+        91,  -55, -102,   80,  105,   82,  -11,  -62,
+      -123,  105,   -6,  -53, -106,   -1,   15,   55,
+        98,   27,  -32,  114, -126,  -13,   42, -104,
+      -102,   37,  -65,   52,    0,    8,   19,    2,
+        19,    3,   19,    1,    0,   -1,    1,    0,
+         0,  -79,    0,    0,    0,   14,    0,   12,
+         0,    0,    9,  108,  111,   99,   97,  108,
+       104,  111,  115,  116,    0,   11,    0,    4,
+         3,    0,    1,    2,    0,   10,    0,    4,
+         0,    2,    0,   23,    0,   35,    0,    0,
+         0,    5,    0,    5,    1,    0,    0,    0,
+         0,    0,   22,    0,    0,    0,   23,    0,
+         0,    0,   13,    0,   30,    0,   28,    4,
+         3,    5,    3,    6,    3,    8,    7,    8,
+         8,    8,    9,    8,   10,    8,   11,    8,
+         4,    8,    5,    8,    6,    4,    1,    5,
+         1,    6,    1,    0,   43,    0,    3,    2,
+         3,    4,    0,   45,    0,    2,    1,    1,
+         0,   51,    0,   71,    0,   69,    0,   23,
+         0,   65,    4,  125,  -92,  -50,  -91,  -39,
+       -55, -114,    0,   22,    2,  -50,  123, -126,
+         0,  -94,  100, -119, -106,  125,  -81,  -24,
+        51,  -84,   25,   25, -115,   13,  -17,  -20,
+        93,   68,  -97,  -79,  -98,   91,   86,   91,
+      -114,  123,  119,  -87,  -12,   32,   63,  -41,
+        50,  126,  -70,   96,   33,   -6,   94,   -7,
+       -68,   54,  -47,   53,    0,   88,   40,  -48,
+      -102,  -50,   88
+    };
+
+    // Client Hello with pre_shared_key asserted and psk_key_exchange_modes
+    // absent.  This is a violation of RFC 8446.  This required manual
+    // removal of the psk_key_exchange_modes extension.
+    //
+    //    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
+    //        Content Type: Handshake (22)
+    //        Version: TLS 1.0 (0x0301)
+    //        Length: 318
+    //        Handshake Protocol: Client Hello
+    //            Handshake Type: Client Hello (1)
+    //            Length: 314
+    //            Version: TLS 1.2 (0x0303)
+    //            Random: e730e42336a19ed9fdb42919c65769132e9e779a797f188c...
+    //            Session ID Length: 32
+    //            Session ID: 6c6ed31408042fabd0c47fdeee6d19de2d6795e37590f00e...
+    //            Cipher Suites Length: 8
+    //            Cipher Suites (4 suites)
+    //            Compression Methods Length: 1
+    //            Compression Methods (1 method)
+    //            Extensions Length: 233
+    //            Extension: server_name (len=14)
+    //            Extension: ec_point_formats (len=4)
+    //            Extension: supported_groups (len=4)
+    //            Extension: SessionTicket TLS (len=0)
+    //            Extension: status_request (len=5)
+    //            Extension: encrypt_then_mac (len=0)
+    //            Extension: extended_master_secret (len=0)
+    //            Extension: signature_algorithms (len=30)
+    //            Extension: supported_versions (len=3)
+    //            Extension: key_share (len=71)
+    //            Extension: pre_shared_key (len=58)
+    //                Type: pre_shared_key (41)
+    //                Length: 58
+    //                Pre-Shared Key extension
+    //                    Identities Length: 21
+    //                    PSK Identity (length: 15)
+    //                        Identity Length: 15
+    //                        Identity: 436c69656e745f6964656e74697479
+    //                        Obfuscated Ticket Age: 0
+    //                    PSK Binders length: 33
+    //                    PSK Binders
+    private static final byte[] CLIHELLO_YESPSK_NOPSKEXMODE = {
+        22,    3,    1,    1,   62,    1,    0,    1,
+        58,    3,    3,  -25,   48,  -28,   35,   54,
+       -95,  -98,  -39,   -3,  -76,   41,   25,  -58,
+        87,  105,   19,   46,  -98,  119, -102,  121,
+       127,   24, -116,   -9,  -99,   22,  116,  -97,
+        90,   73,  -18,   32,  108,  110,  -45,   20,
+         8,    4,   47,  -85,  -48,  -60,  127,  -34,
+       -18,  109,   25,  -34,   45,  103, -107,  -29,
+       117, -112,  -16,   14,   -5,  -24,   24,   61,
+        -9,   28, -119,  -73,    0,    8,   19,    2,
+        19,    3,   19,    1,    0,   -1,    1,    0,
+         0,  -23,    0,    0,    0,   14,    0,   12,
+         0,    0,    9,  108,  111,   99,   97,  108,
+       104,  111,  115,  116,    0,   11,    0,    4,
+         3,    0,    1,    2,    0,   10,    0,    4,
+         0,    2,    0,   23,    0,   35,    0,    0,
+         0,    5,    0,    5,    1,    0,    0,    0,
+         0,    0,   22,    0,    0,    0,   23,    0,
+         0,    0,   13,    0,   30,    0,   28,    4,
+         3,    5,    3,    6,    3,    8,    7,    8,
+         8,    8,    9,    8,   10,    8,   11,    8,
+         4,    8,    5,    8,    6,    4,    1,    5,
+         1,    6,    1,    0,   43,    0,    3,    2,
+         3,    4,    0,   51,    0,   71,    0,   69,
+         0,   23,    0,   65,    4,   -6,  101,  105,
+        -2,   -6,   85,  -99,  -37,  112,   90,   44,
+      -123, -107,    4,  -12,  -64,   92,   40,  100,
+        22,  -53, -124,   54,   56,  102,   25,   76,
+       -86,   -1,    6,  110,   95,   92,  -86,  -35,
+      -101,  115,   85,   99,   19,    6,  -43,  105,
+       -37,  -92,   53,  -97,   84,   -1,  -53,   87,
+       -53, -107,  -13,  -14,   32,  101,  -35,   39,
+       102,  -17, -119,  -25,  -51,    0,   41,    0,
+        58,    0,   21,    0,   15,   67,  108,  105,
+       101,  110,  116,   95,  105,  100,  101,  110,
+       116,  105,  116,  121,    0,    0,    0,    0,
+         0,   33,   32, -113,  -27,  -44,  -71,  -68,
+       -26,  -47,   57,  -82,  -29,  -13,  -61,   77,
+        52,  -60,   27,   74, -120, -104,  102,   21,
+       121,    0,   48,   43,  -40,  -19,  -67,   57,
+       -20,   97,   23
+    };
+
+    // Client Hello containing both pre_shared_key and psk_key_exchange_modes
+    // extensions.  Generation of this hello was done by adding
+    // "-psk a1b2c3d4" to the s_client command.
+    //
+    //    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
+    //        Content Type: Handshake (22)
+    //        Version: TLS 1.0 (0x0301)
+    //        Length: 324
+    //        Handshake Protocol: Client Hello
+    //            Handshake Type: Client Hello (1)
+    //            Length: 320
+    //            Version: TLS 1.2 (0x0303)
+    //            Random: e730e42336a19ed9fdb42919c65769132e9e779a797f188c...
+    //            Session ID Length: 32
+    //            Session ID: 6c6ed31408042fabd0c47fdeee6d19de2d6795e37590f00e...
+    //            Cipher Suites Length: 8
+    //            Cipher Suites (4 suites)
+    //            Compression Methods Length: 1
+    //            Compression Methods (1 method)
+    //            Extensions Length: 239
+    //            Extension: server_name (len=14)
+    //            Extension: ec_point_formats (len=4)
+    //            Extension: supported_groups (len=4)
+    //            Extension: SessionTicket TLS (len=0)
+    //            Extension: status_request (len=5)
+    //            Extension: encrypt_then_mac (len=0)
+    //            Extension: extended_master_secret (len=0)
+    //            Extension: signature_algorithms (len=30)
+    //            Extension: supported_versions (len=3)
+    //            Extension: psk_key_exchange_modes (len=2)
+    //                Type: psk_key_exchange_modes (45)
+    //                Length: 2
+    //                PSK Key Exchange Modes Length: 1
+    //                PSK Key Exchange Mode: PSK with (EC)DHE key establishment (psk_dhe_ke) (1)
+    //            Extension: key_share (len=71)
+    //            Extension: pre_shared_key (len=58)
+    //                Type: pre_shared_key (41)
+    //                Length: 58
+    //                Pre-Shared Key extension
+    //                    Identities Length: 21
+    //                    PSK Identity (length: 15)
+    //                        Identity Length: 15
+    //                        Identity: 436c69656e745f6964656e74697479
+    //                        Obfuscated Ticket Age: 0
+    //                    PSK Binders length: 33
+    //                    PSK Binders
+    private static final byte[] CLIHELLO_YESPSK_YESPSKEXMODE = {
+        22,    3,    1,    1,   68,    1,    0,    1,
+        64,    3,    3,  -25,   48,  -28,   35,   54,
+       -95,  -98,  -39,   -3,  -76,   41,   25,  -58,
+        87,  105,   19,   46,  -98,  119, -102,  121,
+       127,   24, -116,   -9,  -99,   22,  116,  -97,
+        90,   73,  -18,   32,  108,  110,  -45,   20,
+         8,    4,   47,  -85,  -48,  -60,  127,  -34,
+       -18,  109,   25,  -34,   45,  103, -107,  -29,
+       117, -112,  -16,   14,   -5,  -24,   24,   61,
+        -9,   28, -119,  -73,    0,    8,   19,    2,
+        19,    3,   19,    1,    0,   -1,    1,    0,
+         0,  -17,    0,    0,    0,   14,    0,   12,
+         0,    0,    9,  108,  111,   99,   97,  108,
+       104,  111,  115,  116,    0,   11,    0,    4,
+         3,    0,    1,    2,    0,   10,    0,    4,
+         0,    2,    0,   23,    0,   35,    0,    0,
+         0,    5,    0,    5,    1,    0,    0,    0,
+         0,    0,   22,    0,    0,    0,   23,    0,
+         0,    0,   13,    0,   30,    0,   28,    4,
+         3,    5,    3,    6,    3,    8,    7,    8,
+         8,    8,    9,    8,   10,    8,   11,    8,
+         4,    8,    5,    8,    6,    4,    1,    5,
+         1,    6,    1,    0,   43,    0,    3,    2,
+         3,    4,    0,   45,    0,    2,    1,    1,
+         0,   51,    0,   71,    0,   69,    0,   23,
+         0,   65,    4,   -6,  101,  105,   -2,   -6,
+        85,  -99,  -37,  112,   90,   44, -123, -107,
+         4,  -12,  -64,   92,   40,  100,   22,  -53,
+      -124,   54,   56,  102,   25,   76,  -86,   -1,
+         6,  110,   95,   92,  -86,  -35, -101,  115,
+        85,   99,   19,    6,  -43,  105,  -37,  -92,
+        53,  -97,   84,   -1,  -53,   87,  -53, -107,
+       -13,  -14,   32,  101,  -35,   39,  102,  -17,
+      -119,  -25,  -51,    0,   41,    0,   58,    0,
+        21,    0,   15,   67,  108,  105,  101,  110,
+       116,   95,  105,  100,  101,  110,  116,  105,
+       116,  121,    0,    0,    0,    0,    0,   33,
+        32, -113,  -27,  -44,  -71,  -68,  -26,  -47,
+        57,  -82,  -29,  -13,  -61,   77,   52,  -60,
+        27,   74, -120, -104,  102,   21,  121,    0,
+        48,   43,  -40,  -19,  -67,   57,  -20,   97,
+        23
+    };
+
+    // Client Hello with sect163k1 and secp256r1 as supported groups.  This
+    // test covers an error condition where a known, supported curve that is
+    // not in the default enabled set of curves would cause failures.
+    // Generation of this hello was done using "-curves sect163k1:prime256v1"
+    // as an option to s_client.
+    //
+    //    TLSv1.2 Record Layer: Handshake Protocol: Client Hello
+    //        Content Type: Handshake (22)
+    //        Version: TLS 1.0 (0x0301)
+    //        Length: 210
+    //        Handshake Protocol: Client Hello
+    //            Handshake Type: Client Hello (1)
+    //            Length: 206
+    //            Version: TLS 1.2 (0x0303)
+    //            Random: 05cbae9b834851d856355b72601cb67b7cd4eb51f29ed50b...
+    //            Session ID Length: 0
+    //            Cipher Suites Length: 56
+    //            Cipher Suites (28 suites)
+    //            Compression Methods Length: 1
+    //            Compression Methods (1 method)
+    //            Extensions Length: 109
+    //            Extension: server_name (len=14)
+    //            Extension: ec_point_formats (len=4)
+    //            Extension: supported_groups (len=6)
+    //                Type: supported_groups (10)
+    //                Length: 6
+    //                Supported Groups List Length: 4
+    //                Supported Groups (2 groups)
+    //                    Supported Group: sect163k1 (0x0001)
+    //                    Supported Group: secp256r1 (0x0017)
+    //            Extension: SessionTicket TLS (len=0)
+    //            Extension: status_request (len=5)
+    //            Extension: encrypt_then_mac (len=0)
+    //            Extension: extended_master_secret (len=0)
+    //            Extension: signature_algorithms (len=48)
+    private static final byte[] CLIHELLO_SUPGRP_SECT163K1 = {
+        22,    3,    1,    0,  -46,    1,    0,    0,
+       -50,    3,    3,    5,  -53,  -82, -101, -125,
+        72,   81,  -40,   86,   53,   91,  114,   96,
+        28,  -74,  123,  124,  -44,  -21,   81,  -14,
+       -98,  -43,   11,   90,  -87, -106,   13,   63,
+       -62,  100,  111,    0,    0,   56,  -64,   44,
+       -64,   48,    0,  -97,  -52,  -87,  -52,  -88,
+       -52,  -86,  -64,   43,  -64,   47,    0,  -98,
+       -64,   36,  -64,   40,    0,  107,  -64,   35,
+       -64,   39,    0,  103,  -64,   10,  -64,   20,
+         0,   57,  -64,    9,  -64,   19,    0,   51,
+         0,  -99,    0, -100,    0,   61,    0,   60,
+         0,   53,    0,   47,    0,   -1,    1,    0,
+         0,  109,    0,    0,    0,   14,    0,   12,
+         0,    0,    9,  108,  111,   99,   97,  108,
+       104,  111,  115,  116,    0,   11,    0,    4,
+         3,    0,    1,    2,    0,   10,    0,    6,
+         0,    4,    0,    1,    0,   23,    0,   35,
+         0,    0,    0,    5,    0,    5,    1,    0,
+         0,    0,    0,    0,   22,    0,    0,    0,
+        23,    0,    0,    0,   13,    0,   48,    0,
+        46,    4,    3,    5,    3,    6,    3,    8,
+         7,    8,    8,    8,    9,    8,   10,    8,
+        11,    8,    4,    8,    5,    8,    6,    4,
+         1,    5,    1,    6,    1,    3,    3,    2,
+         3,    3,    1,    2,    1,    3,    2,    2,
+         2,    4,    2,    5,    2,    6,    2
+    };
+
+    public static interface TestCase {
+        void execTest() throws Exception;
+    }
+
+    private static final Map<String, TestCase> TESTMAP = new HashMap<>();
+
+    public static void main(String[] args) throws Exception {
+        boolean allGood = true;
+        System.setProperty("javax.net.debug", "ssl:handshake");
+        trustMgrFac = makeTrustManagerFactory(trustFilename, passwd);
+        keyMgrFac = makeKeyManagerFactory(keyFilename, passwd);
+
+        // Populate the test map
+        TESTMAP.put("noPskNoKexModes", noPskNoKexModes);
+        TESTMAP.put("noPskYesKexModes", noPskYesKexModes);
+        TESTMAP.put("yesPskNoKexModes", yesPskNoKexModes);
+        TESTMAP.put("yesPskYesKexModes", yesPskYesKexModes);
+        TESTMAP.put("supGroupsSect163k1", supGroupsSect163k1);
+
+        if (args == null || args.length < 1) {
+            throw new Exception("FAIL: Test @run line is missing a test label");
+        }
+
+        // Pull the test to run from the test map.
+        TestCase test = Objects.requireNonNull(TESTMAP.get(args[0]),
+                "No TestCase found for test label " + args[0]);
+        test.execTest();
+    }
+
+    /**
+     * Test case to cover hellos with no pre_shared_key nor
+     * psk_key_exchange_modes extensions.  Clients not supporting PSK at all
+     * may send hellos like this.
+     */
+    private static final TestCase noPskNoKexModes = new TestCase() {
+        @Override
+        public void execTest() throws Exception {
+            System.out.println("\nTest: PSK = No, PSKEX = No");
+            processClientHello("TLS", CLIHELLO_NOPSK_NOPSKEXMODE);
+            System.out.println("PASS");
+        }
+    };
+
+    /**
+     * Test case to cover hellos with no pre_shared_key but have the
+     * psk_key_exchange_modes extension.  This kind of hello is seen from
+     * some popular browsers and test clients.
+     */
+    private static final TestCase noPskYesKexModes = new TestCase() {
+        @Override
+        public void execTest() throws Exception {
+            System.out.println("\nTest: PSK = No, PSKEX = Yes");
+            processClientHello("TLS", CLIHELLO_NOPSK_YESPSKEXMODE);
+            System.out.println("PASS");
+        }
+    };
+
+    /**
+     * Test case using a client hello with the pre_shared_key extension but
+     * no psk_key_exchange_modes extension present.  This is a violation of
+     * 8446 and should cause an exception when unwrapped and processed by
+     * SSLEngine.
+     */
+    private static final TestCase yesPskNoKexModes = new TestCase() {
+        @Override
+        public void execTest() throws Exception {
+            try {
+                System.out.println("\nTest: PSK = Yes, PSKEX = No");
+                processClientHello("TLS", CLIHELLO_YESPSK_NOPSKEXMODE);
+                throw new Exception(
+                    "FAIL: Client Hello processed without expected error");
+            } catch (SSLHandshakeException sslhe) {
+                System.out.println("PASS: Caught expected exception: " + sslhe);
+            }
+        }
+    };
+
+    /**
+     * Test case using a client hello asserting the pre_shared_key and
+     * psk_key_exchange_modes extensions.
+     */
+    private static final TestCase yesPskYesKexModes = new TestCase() {
+        @Override
+        public void execTest() throws Exception {
+            System.out.println("\nTest: PSK = Yes, PSKEX = Yes");
+            processClientHello("TLS", CLIHELLO_YESPSK_YESPSKEXMODE);
+            System.out.println("PASS");
+        }
+    };
+
+    /**
+     * Test case with a client hello asserting two named curves in the
+     * supported_groups extension: sect163k1 and secp256r1.
+     */
+    private static final TestCase supGroupsSect163k1 = new TestCase() {
+        @Override
+        public void execTest() throws Exception {
+            System.out.println("\nTest: Use of non-default-enabled " +
+                    "Supported Group (sect163k1)");
+            processClientHello("TLS", CLIHELLO_SUPGRP_SECT163K1);
+            System.out.println("PASS");
+        }
+    };
+
+    /**
+     * Send a ClientHello message to an SSLEngine instance configured as a
+     * server.
+     *
+     * @param proto the protocol used to create the SSLContext.  This will
+     *      default to "TLS" if null is passed in.
+     * @param message the ClientHello as a complete TLS record.
+     *
+     * @throws Exception if any processing errors occur.  The caller (TestCase)
+     *      is expected to deal with the exception in whatever way appropriate
+     *      for the test.
+     */
+    private static void processClientHello(String proto, byte[] message)
+            throws Exception {
+        SSLEngine serverEng = makeServerEngine(proto, keyMgrFac, trustMgrFac);
+        ByteBuffer sTOc = makePacketBuf(serverEng);
+        SSLEngineResult serverResult;
+
+        ByteBuffer cTOs = ByteBuffer.wrap(message);
+        System.out.println("CLIENT-TO-SERVER\n" +
+                dumpHexBytes(cTOs, 16, "\n", " "));
+        serverResult = serverEng.unwrap(cTOs, SERVOUTBUF);
+        printResult("server unwrap: ", serverResult);
+        runDelegatedTasks(serverResult, serverEng);
+        serverEng.wrap(SERVOUTBUF, sTOc);
+    }
+
+    /**
+     * Create a TrustManagerFactory from a given keystore.
+     *
+     * @param tsPath the path to the trust store file.
+     * @param pass the password for the trust store.
+     *
+     * @return a new TrustManagerFactory built from the trust store provided.
+     *
+     * @throws GeneralSecurityException if any processing errors occur
+     *      with the Keystore instantiation or TrustManagerFactory creation.
+     * @throws IOException if any loading error with the trust store occurs.
+     */
+    private static TrustManagerFactory makeTrustManagerFactory(String tsPath,
+            String pass) throws GeneralSecurityException, IOException {
+        KeyStore ts = KeyStore.getInstance("JKS");
+        char[] passphrase = pass.toCharArray();
+
+        ts.load(new FileInputStream(tsPath), passphrase);
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+        return tmf;
+    }
+
+    /**
+     * Create a KeyManagerFactory from a given keystore.
+     *
+     * @param ksPath the path to the keystore file.
+     * @param pass the password for the keystore.
+     *
+     * @return a new TrustManagerFactory built from the keystore provided.
+     *
+     * @throws GeneralSecurityException if any processing errors occur
+     *      with the Keystore instantiation or KeyManagerFactory creation.
+     * @throws IOException if any loading error with the keystore occurs
+     */
+    private static KeyManagerFactory makeKeyManagerFactory(String ksPath,
+            String pass) throws GeneralSecurityException, IOException {
+        KeyStore ks = KeyStore.getInstance("JKS");
+        char[] passphrase = pass.toCharArray();
+
+        ks.load(new FileInputStream(ksPath), passphrase);
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+        return kmf;
+    }
+
+    /**
+     * Create an SSLEngine instance from a given protocol specifier,
+     * KeyManagerFactory and TrustManagerFactory.
+     *
+     * @param proto the protocol specifier for the SSLContext.  This will
+     *      default to "TLS" if null is provided.
+     * @param kmf an initialized KeyManagerFactory.  May be null.
+     * @param tmf an initialized TrustManagerFactory.  May be null.
+     *
+     * @return an SSLEngine instance configured as a server and with client
+     *      authentication disabled.
+     *
+     * @throws GeneralSecurityException if any errors occur during the
+     *      creation of the SSLEngine.
+     */
+    private static SSLEngine makeServerEngine(String proto,
+            KeyManagerFactory kmf, TrustManagerFactory tmf)
+            throws GeneralSecurityException {
+        SSLContext ctx = SSLContext.getInstance(proto != null ? proto : "TLS");
+        ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+        SSLEngine ssle = ctx.createSSLEngine();
+        ssle.setUseClientMode(false);
+        ssle.setNeedClientAuth(false);
+        return ssle;
+    }
+
+    /**
+     * Make a ByteBuffer sized for TLS records that can be used by an SSLEngine.
+     *
+     * @param engine the SSLEngine used to determine the packet buffer size.
+     *
+     * @return a ByteBuffer sized for TLS packets.
+     */
+    private static ByteBuffer makePacketBuf(SSLEngine engine) {
+        SSLSession sess = engine.getSession();
+        ByteBuffer packetBuf = ByteBuffer.allocate(sess.getPacketBufferSize());
+        return packetBuf;
+    }
+
+    /**
+     * Runs any delegated tasks after unwrapping TLS records.
+     *
+     * @param result the most recent result from an unwrap operation on
+     *      an SSLEngine.
+     * @param engine the SSLEngine used to unwrap the data.
+     *
+     * @throws Exception if any errors occur while running the delegated
+     *      tasks.
+     */
+    private static void runDelegatedTasks(SSLEngineResult result,
+            SSLEngine engine) throws Exception {
+        HandshakeStatus hsStatus = result.getHandshakeStatus();
+        if (hsStatus == HandshakeStatus.NEED_TASK) {
+            Runnable runnable;
+            while ((runnable = engine.getDelegatedTask()) != null) {
+                System.out.println("\trunning delegated task...");
+                runnable.run();
+            }
+            hsStatus = engine.getHandshakeStatus();
+            if (hsStatus == HandshakeStatus.NEED_TASK) {
+                throw new Exception(
+                    "handshake shouldn't need additional tasks");
+            }
+            System.out.println("\tnew HandshakeStatus: " + hsStatus);
+        }
+    }
+
+    /**
+     * Display the results of a wrap or unwrap operation from an SSLEngine.
+     *
+     * @param str a label to be prefixed to the result display.
+     * @param result the result returned from the wrap/unwrap operation.
+     */
+    private static void printResult(String str, SSLEngineResult result) {
+        System.out.println("The format of the SSLEngineResult is: \n" +
+            "\t\"getStatus() / getHandshakeStatus()\" +\n" +
+            "\t\"bytesConsumed() / bytesProduced()\"\n");
+        HandshakeStatus hsStatus = result.getHandshakeStatus();
+        System.out.println(str + result.getStatus() + "/" + hsStatus + ", " +
+            result.bytesConsumed() + "/" + result.bytesProduced() + " bytes");
+        if (hsStatus == HandshakeStatus.FINISHED) {
+            System.out.println("\t...ready for application data");
+        }
+    }
+
+    /**
+     * Dump the hex bytes of a buffer into string form.
+     *
+     * @param data The array of bytes to dump to stdout.
+     * @param itemsPerLine The number of bytes to display per line
+     *      if the {@code lineDelim} character is blank then all bytes
+     *      will be printed on a single line.
+     * @param lineDelim The delimiter between lines
+     * @param itemDelim The delimiter between bytes
+     *
+     * @return The hexdump of the byte array
+     */
+    private static String dumpHexBytes(byte[] data, int itemsPerLine,
+            String lineDelim, String itemDelim) {
+        return dumpHexBytes(ByteBuffer.wrap(data), itemsPerLine, lineDelim,
+                itemDelim);
+    }
+
+    /**
+     * Dump the hex bytes of a buffer into string form.
+     *
+     * @param data The ByteBuffer to dump to stdout.
+     * @param itemsPerLine The number of bytes to display per line
+     *      if the {@code lineDelim} character is blank then all bytes
+     *      will be printed on a single line.
+     * @param lineDelim The delimiter between lines
+     * @param itemDelim The delimiter between bytes
+     *
+     * @return The hexdump of the byte array
+     */
+    private static String dumpHexBytes(ByteBuffer data, int itemsPerLine,
+            String lineDelim, String itemDelim) {
+        StringBuilder sb = new StringBuilder();
+        if (data != null) {
+            data.mark();
+            int i = 0;
+            while (data.remaining() > 0) {
+                if (i % itemsPerLine == 0 && i != 0) {
+                    sb.append(lineDelim);
+                }
+                sb.append(String.format("%02X", data.get())).append(itemDelim);
+                i++;
+            }
+            data.reset();
+        }
+
+        return sb.toString();
+    }
+}
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/jdk/javax/sound/sampled/Clip/ClipIsRunningAfterStop.java	2019-01-21 18:48:34.069224330 +0100
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.concurrent.TimeUnit;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Clip;
+import javax.sound.sampled.DataLine;
+import javax.sound.sampled.LineUnavailableException;
+
+import static javax.sound.sampled.AudioFormat.Encoding.PCM_SIGNED;
+
+/**
+ * @test
+ * @bug 8207150
+ * @summary Clip.isRunning() may return true after Clip.stop() was called
+ */
+public final class ClipIsRunningAfterStop {
+
+    private static volatile Exception failed;
+
+    public static void main(final String[] args) throws Exception {
+        final Runnable r = () -> {
+            try {
+                test();
+            } catch (LineUnavailableException | IllegalArgumentException ignored) {
+                // the test is not applicable
+            } catch (Exception ex) {
+                failed = ex;
+            }
+        };
+        Thread t1 = new Thread(r);
+        Thread t2 = new Thread(r);
+        Thread t3 = new Thread(r);
+        t1.start();
+        t2.start();
+        t3.start();
+        t1.join();
+        t2.join();
+        t3.join();
+        if (failed != null) {
+            throw new RuntimeException(failed);
+        }
+    }
+
+    private static void test() throws Exception {
+        // Will run the test no more than 15 seconds
+        long endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(15);
+        while (failed == null && endtime - System.nanoTime() > 0) {
+            Clip clip = createClip();
+            clip.loop(Clip.LOOP_CONTINUOUSLY);
+            clip.stop();
+            if (clip.isRunning()) {
+                if (clip.isRunning()) {
+                    throw new RuntimeException("Clip is running");
+                }
+            }
+            if (clip.isActive()) {
+                if (clip.isActive()) {
+                    throw new RuntimeException("Clip is active");
+                }
+            }
+            clip.close();
+        }
+    }
+
+    private static Clip createClip() throws LineUnavailableException {
+        AudioFormat format =
+                new AudioFormat(PCM_SIGNED, 44100, 8, 1, 1, 44100, false);
+        DataLine.Info info = new DataLine.Info(Clip.class, format);
+        Clip clip = (Clip) AudioSystem.getLine(info);
+        clip.open(format, new byte[2], 0, 2);
+        return clip;
+    }
+}
--- old/test/jdk/javax/swing/JEditorPane/8195095/ImageViewTest.java	2019-01-21 18:48:34.657222765 +0100
+++ new/test/jdk/javax/swing/JEditorPane/8195095/ImageViewTest.java	2019-01-21 18:48:34.445223329 +0100
@@ -24,7 +24,7 @@
 /**
  * @test
  * @key headful
- * @bug 8195095 8206238
+ * @bug 8195095 8206238 8208638
  * @summary Tests if Images are scaled correctly in JEditorPane.
  * @run main ImageViewTest
  */
@@ -51,8 +51,11 @@
             f.add(editorPane);
             f.setSize(WIDTH + 20, HEIGHT + 40);
             f.setLocationRelativeTo(null);
-
             f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+            //This line will trigger the imageupdate, and consequently, the view
+            //will be populated with the appropriate color when the pixel color
+            //is queried by robot.
+            editorPane.getUI().getPreferredSize(editorPane);
             f.setVisible(true);
         });
 
--- old/test/jdk/sun/util/calendar/zi/tzdata/VERSION	2019-01-21 18:48:35.093221606 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/VERSION	2019-01-21 18:48:34.889222149 +0100
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2018e
+tzdata2018g
--- old/test/jdk/sun/util/calendar/zi/tzdata/africa	2019-01-21 18:48:35.589220286 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/africa	2019-01-21 18:48:35.373220861 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for Africa and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -29,7 +31,7 @@
 # tz@iana.org for general use in the future).  For more, please see
 # the file CONTRIBUTING in the tz distribution.
 
-# From Paul Eggert (2017-04-09):
+# From Paul Eggert (2018-05-27):
 #
 # Unless otherwise specified, the source for data through 1990 is:
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
@@ -74,13 +76,15 @@
 # I vaguely recall 'WAT' also being used for -01 in the past but
 # cannot now come up with solid citations.
 #
-# I invented the following abbreviations; corrections are welcome!
-#	 +02	WAST	West Africa Summer Time (no longer used)
-#	 +03	CAST	Central Africa Summer Time (no longer used)
-#	 +03	SAST	South Africa Summer Time (no longer used)
+# I invented the following abbreviations in the 1990s:
+#	 +02	WAST	West Africa Summer Time
+#	 +03	CAST	Central Africa Summer Time
+#	 +03	SAST	South Africa Summer Time
 #	 +03	EAT	East Africa Time
-# 'EAT' also seems to have caught on; the others are rare but are paired
-# with better-attested non-DST abbreviations.
+# 'EAT' seems to have caught on and is in current timestamps, and though
+# the other abbreviations are rarer and are only in past timestamps,
+# they are paired with better-attested non-DST abbreviations.
+# Corrections are welcome.
 
 # Algeria
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
@@ -385,6 +389,13 @@
 # Eritrea
 # Ethiopia
 # See Africa/Nairobi.
+#
+# Unfortunately tzdb records only Western clock time in use in Ethiopia,
+# as the tzdb format is not up to properly recording a common Ethiopian
+# timekeeping practice that is based on solar time.  See:
+# Mortada D. If you have a meeting in Ethiopia, you'd better double
+# check the time. PRI's The World. 2015-01-30 15:15 -05.
+# https://www.pri.org/stories/2015-01-30/if-you-have-meeting-ethiopia-you-better-double-check-time
 
 # Gabon
 # See Africa/Lagos.
@@ -856,94 +867,61 @@
 # <https://lnt.ma/le-maroc-reculera-dune-heure-le-dimanche-14-juin/> agrees
 # with the patch.
 
-# From Paul Eggert (2015-06-08):
-# For now, guess that later spring and fall transitions will use 2015's rules,
-# and guess that Morocco will switch to standard time at 03:00 the last
-# Sunday before Ramadan, and back to DST at 02:00 the first Sunday after
-# Ramadan.  To implement this, transition dates for 2016 through 2037 were
-# determined by running the following program under GNU Emacs 24.3, with the
-# results integrated by hand into the table below.
-# (let ((islamic-year 1437))
-#   (require 'cal-islam)
-#   (while (< islamic-year 1460)
-#     (let ((a (calendar-islamic-to-absolute (list 9 1 islamic-year)))
-#           (b (calendar-islamic-to-absolute (list 10 1 islamic-year)))
-#           (sunday 0))
-#       (while (/= sunday (mod (setq a (1- a)) 7)))
-#       (while (/= sunday (mod b 7))
-#         (setq b (1+ b)))
-#       (setq a (calendar-gregorian-from-absolute a))
-#       (setq b (calendar-gregorian-from-absolute b))
-#       (insert
-#        (format
-#         (concat "Rule\tMorocco\t%d\tonly\t-\t%s\t%2d\t 3:00\t0\t-\n"
-#                 "Rule\tMorocco\t%d\tonly\t-\t%s\t%2d\t 2:00\t1:00\tS\n")
-#         (car (cdr (cdr a))) (calendar-month-name (car a) t) (car (cdr a))
-#         (car (cdr (cdr b))) (calendar-month-name (car b) t) (car (cdr b)))))
-#     (setq islamic-year (+ 1 islamic-year))))
+# From Mohamed Essedik Najd (2018-10-26):
+# Today, a Moroccan government council approved the perpetual addition
+# of 60 minutes to the regular Moroccan timezone.
+# From Brian Inglis (2018-10-26):
+# http://www.maroc.ma/fr/actualites/le-conseil-de-gouvernement-adopte-un-projet-de-decret-relatif-lheure-legale-stipulant-le
 
 # RULE	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-
-Rule	Morocco	1939	only	-	Sep	12	 0:00	1:00	S
+Rule	Morocco	1939	only	-	Sep	12	 0:00	1:00	-
 Rule	Morocco	1939	only	-	Nov	19	 0:00	0	-
-Rule	Morocco	1940	only	-	Feb	25	 0:00	1:00	S
+Rule	Morocco	1940	only	-	Feb	25	 0:00	1:00	-
 Rule	Morocco	1945	only	-	Nov	18	 0:00	0	-
-Rule	Morocco	1950	only	-	Jun	11	 0:00	1:00	S
+Rule	Morocco	1950	only	-	Jun	11	 0:00	1:00	-
 Rule	Morocco	1950	only	-	Oct	29	 0:00	0	-
-Rule	Morocco	1967	only	-	Jun	 3	12:00	1:00	S
+Rule	Morocco	1967	only	-	Jun	 3	12:00	1:00	-
 Rule	Morocco	1967	only	-	Oct	 1	 0:00	0	-
-Rule	Morocco	1974	only	-	Jun	24	 0:00	1:00	S
+Rule	Morocco	1974	only	-	Jun	24	 0:00	1:00	-
 Rule	Morocco	1974	only	-	Sep	 1	 0:00	0	-
-Rule	Morocco	1976	1977	-	May	 1	 0:00	1:00	S
+Rule	Morocco	1976	1977	-	May	 1	 0:00	1:00	-
 Rule	Morocco	1976	only	-	Aug	 1	 0:00	0	-
 Rule	Morocco	1977	only	-	Sep	28	 0:00	0	-
-Rule	Morocco	1978	only	-	Jun	 1	 0:00	1:00	S
+Rule	Morocco	1978	only	-	Jun	 1	 0:00	1:00	-
 Rule	Morocco	1978	only	-	Aug	 4	 0:00	0	-
-Rule	Morocco	2008	only	-	Jun	 1	 0:00	1:00	S
+Rule	Morocco	2008	only	-	Jun	 1	 0:00	1:00	-
 Rule	Morocco	2008	only	-	Sep	 1	 0:00	0	-
-Rule	Morocco	2009	only	-	Jun	 1	 0:00	1:00	S
+Rule	Morocco	2009	only	-	Jun	 1	 0:00	1:00	-
 Rule	Morocco	2009	only	-	Aug	21	 0:00	0	-
-Rule	Morocco	2010	only	-	May	 2	 0:00	1:00	S
+Rule	Morocco	2010	only	-	May	 2	 0:00	1:00	-
 Rule	Morocco	2010	only	-	Aug	 8	 0:00	0	-
-Rule	Morocco	2011	only	-	Apr	 3	 0:00	1:00	S
+Rule	Morocco	2011	only	-	Apr	 3	 0:00	1:00	-
 Rule	Morocco	2011	only	-	Jul	31	 0:00	0	-
-Rule	Morocco	2012	2013	-	Apr	lastSun	 2:00	1:00	S
+Rule	Morocco	2012	2013	-	Apr	lastSun	 2:00	1:00	-
 Rule	Morocco	2012	only	-	Jul	20	 3:00	0	-
-Rule	Morocco	2012	only	-	Aug	20	 2:00	1:00	S
+Rule	Morocco	2012	only	-	Aug	20	 2:00	1:00	-
 Rule	Morocco	2012	only	-	Sep	30	 3:00	0	-
 Rule	Morocco	2013	only	-	Jul	 7	 3:00	0	-
-Rule	Morocco	2013	only	-	Aug	10	 2:00	1:00	S
-Rule	Morocco	2013	max	-	Oct	lastSun	 3:00	0	-
-Rule	Morocco	2014	2021	-	Mar	lastSun	 2:00	1:00	S
+Rule	Morocco	2013	only	-	Aug	10	 2:00	1:00	-
+Rule	Morocco	2013	2018	-	Oct	lastSun	 3:00	0	-
+Rule	Morocco	2014	2018	-	Mar	lastSun	 2:00	1:00	-
 Rule	Morocco	2014	only	-	Jun	28	 3:00	0	-
-Rule	Morocco	2014	only	-	Aug	 2	 2:00	1:00	S
+Rule	Morocco	2014	only	-	Aug	 2	 2:00	1:00	-
 Rule	Morocco	2015	only	-	Jun	14	 3:00	0	-
-Rule	Morocco	2015	only	-	Jul	19	 2:00	1:00	S
+Rule	Morocco	2015	only	-	Jul	19	 2:00	1:00	-
 Rule	Morocco	2016	only	-	Jun	 5	 3:00	0	-
-Rule	Morocco	2016	only	-	Jul	10	 2:00	1:00	S
+Rule	Morocco	2016	only	-	Jul	10	 2:00	1:00	-
 Rule	Morocco	2017	only	-	May	21	 3:00	0	-
-Rule	Morocco	2017	only	-	Jul	 2	 2:00	1:00	S
+Rule	Morocco	2017	only	-	Jul	 2	 2:00	1:00	-
 Rule	Morocco	2018	only	-	May	13	 3:00	0	-
-Rule	Morocco	2018	only	-	Jun	17	 2:00	1:00	S
-Rule	Morocco	2019	only	-	May	 5	 3:00	0	-
-Rule	Morocco	2019	only	-	Jun	 9	 2:00	1:00	S
-Rule	Morocco	2020	only	-	Apr	19	 3:00	0	-
-Rule	Morocco	2020	only	-	May	24	 2:00	1:00	S
-Rule	Morocco	2021	only	-	Apr	11	 3:00	0	-
-Rule	Morocco	2021	only	-	May	16	 2:00	1:00	S
-Rule	Morocco	2022	only	-	May	 8	 2:00	1:00	S
-Rule	Morocco	2023	only	-	Apr	23	 2:00	1:00	S
-Rule	Morocco	2024	only	-	Apr	14	 2:00	1:00	S
-Rule	Morocco	2025	only	-	Apr	 6	 2:00	1:00	S
-Rule	Morocco	2026	max	-	Mar	lastSun	 2:00	1:00	S
-Rule	Morocco	2036	only	-	Oct	19	 3:00	0	-
-Rule	Morocco	2037	only	-	Oct	 4	 3:00	0	-
+Rule	Morocco	2018	only	-	Jun	17	 2:00	1:00	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Africa/Casablanca	-0:30:20 -	LMT	1913 Oct 26
-			 0:00	Morocco	WE%sT	1984 Mar 16
-			 1:00	-	CET	1986
-			 0:00	Morocco	WE%sT
+			 0:00	Morocco	+00/+01	1984 Mar 16
+			 1:00	-	+01	1986
+			 0:00	Morocco	+00/+01	2018 Oct 27
+			 1:00	-	+01
 
 # Western Sahara
 #
@@ -958,7 +936,8 @@
 
 Zone Africa/El_Aaiun	-0:52:48 -	LMT	1934 Jan # El Aaiún
 			-1:00	-	-01	1976 Apr 14
-			 0:00	Morocco	WE%sT
+			 0:00	Morocco	+00/+01	2018 Oct 27
+			 1:00	-	+01
 
 # Mozambique
 #
--- old/test/jdk/sun/util/calendar/zi/tzdata/antarctica	2019-01-21 18:48:36.097218933 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/antarctica	2019-01-21 18:48:35.881219508 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for Antarctica and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
--- old/test/jdk/sun/util/calendar/zi/tzdata/asia	2019-01-21 18:48:36.601217592 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/asia	2019-01-21 18:48:36.377218188 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for Asia and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -29,7 +31,7 @@
 # tz@iana.org for general use in the future).  For more, please see
 # the file CONTRIBUTING in the tz distribution.
 
-# From Paul Eggert (2017-01-13):
+# From Paul Eggert (2018-06-19):
 #
 # Unless otherwise specified, the source for data through 1990 is:
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
@@ -58,7 +60,8 @@
 # A reliable and entertaining source about time zones is
 # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
 #
-# The following alphabetic abbreviations appear in these tables:
+# The following alphabetic abbreviations appear in these tables
+# (corrections are welcome):
 #	     std  dst
 #	     LMT	Local Mean Time
 #	2:00 EET  EEST	Eastern European Time
@@ -67,11 +70,13 @@
 #	7:00 WIB	west Indonesia (Waktu Indonesia Barat)
 #	8:00 WITA	central Indonesia (Waktu Indonesia Tengah)
 #	8:00 CST	China
+#	8:00 PST  PDT*	Philippine Standard Time
 #	8:30 KST  KDT	Korea when at +0830
 #	9:00 WIT	east Indonesia (Waktu Indonesia Timur)
 #	9:00 JST  JDT	Japan
 #	9:00 KST  KDT	Korea when at +09
 #	9:30 ACST	Australian Central Standard Time
+# *I invented the abbreviation PDT; see "Philippines" below.
 # Otherwise, these tables typically use numeric abbreviations like +03
 # and +0330 for integer hour and minute UT offsets.  Although earlier
 # editions invented alphabetic time zone abbreviations for every
@@ -304,6 +309,29 @@
 
 # China
 
+# From Paul Eggert (2018-10-02):
+# The following comes from Table 1 of:
+# Li Yu. Research on the daylight saving movement in 1940s Shanghai.
+# Nanjing Journal of Social Sciences. 2014;(2):144-50.
+# http://oversea.cnki.net/kns55/detail.aspx?dbname=CJFD2014&filename=NJSH201402020
+# The table lists dates only; I am guessing 00:00 and 24:00 transition times.
+# Also, the table lists the planned end of DST in 1949, but the corresponding
+# zone line cuts this off on May 28, when the Communists took power.
+#
+# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	Shang	1940	only	-	Jun	 1	 0:00	1:00	D
+Rule	Shang	1940	only	-	Oct	12	24:00	0	S
+Rule	Shang	1941	only	-	Mar	15	 0:00	1:00	D
+Rule	Shang	1941	only	-	Nov	 1	24:00	0	S
+Rule	Shang	1942	only	-	Jan	31	 0:00	1:00	D
+Rule	Shang	1945	only	-	Sep	 1	24:00	0	S
+Rule	Shang	1946	only	-	May	15	 0:00	1:00	D
+Rule	Shang	1946	only	-	Sep	30	24:00	0	S
+Rule	Shang	1947	only	-	Apr	15	 0:00	1:00	D
+Rule	Shang	1947	only	-	Oct	31	24:00	0	S
+Rule	Shang	1948	1949	-	May	 1	 0:00	1:00	D
+Rule	Shang	1948	1949	-	Sep	30	24:00	0	S #plan
+
 # From Guy Harris:
 # People's Republic of China.  Yes, they really have only one time zone.
 
@@ -330,18 +358,33 @@
 # time - sort of", Los Angeles Times, 1986-05-05 ... [says] that China began
 # observing daylight saving time in 1986.
 
-# From Paul Eggert (2014-06-30):
-# Shanks & Pottenger have China switching to a single time zone in 1980, but
-# this doesn't seem to be correct.  They also write that China observed summer
-# DST from 1986 through 1991, which seems to match the above commentary, so
-# go with them for DST rules as follows:
-# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Shang	1940	only	-	Jun	 3	0:00	1:00	D
-Rule	Shang	1940	1941	-	Oct	 1	0:00	0	S
-Rule	Shang	1941	only	-	Mar	16	0:00	1:00	D
-Rule	PRC	1986	only	-	May	 4	0:00	1:00	D
-Rule	PRC	1986	1991	-	Sep	Sun>=11	0:00	0	S
-Rule	PRC	1987	1991	-	Apr	Sun>=10	0:00	1:00	D
+# From P Chan (2018-05-07):
+# The start and end time of DST in China [from 1986 on] should be 2:00
+# (i.e. 2:00 to 3:00 at the start and 2:00 to 1:00 at the end)....
+# Government notices about summer time:
+#
+# 1986-04-12 http://www.zj.gov.cn/attach/zfgb/198608.pdf p.21-22
+# (To establish summer time from 1986. On 4 May, set the clocks ahead one hour
+# at 2 am. On 14 September, set the clocks backward one hour at 2 am.)
+#
+# 1987-02-15 http://www.gov.cn/gongbao/shuju/1987/gwyb198703.pdf p.114
+# (Summer time in 1987 to start from 12 April until 13 September)
+#
+# 1987-09-09 http://www.gov.cn/gongbao/shuju/1987/gwyb198721.pdf p.709
+# (From 1988, summer time to start from 2 am of the first Sunday of mid-April
+# until 2 am of the first Sunday of mid-September)
+#
+# 1992-03-03 http://www.gov.cn/gongbao/shuju/1992/gwyb199205.pdf p.152
+# (To suspend summer time from 1992)
+#
+# The first page of People's Daily on 12 April 1988 stating that summer time
+# to begin on 17 April.
+# http://data.people.com.cn/pic/101p/1988/04/1988041201.jpg
+
+# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	PRC	1986	only	-	May	 4	 2:00	1:00	D
+Rule	PRC	1986	1991	-	Sep	Sun>=11	 2:00	0	S
+Rule	PRC	1987	1991	-	Apr	Sun>=11	 2:00	1:00	D
 
 # From Anthony Fok (2001-12-20):
 # BTW, I did some research on-line and found some info regarding these five
@@ -363,10 +406,11 @@
 # Alois Treindl kindly sent me translations of the following two sources:
 #
 # (1)
-# Guo Qingsheng (National Time-Service Center, CAS, Xi'an 710600, China)
+# Guo Qing-sheng (National Time-Service Center, CAS, Xi'an 710600, China)
 # Beijing Time at the Beginning of the PRC
 # China Historical Materials of Science and Technology
-# (Zhongguo ke ji shi liao, 中国科技史料), Vol. 24, No. 1 (2003)
+# (Zhongguo ke ji shi liao, 中国科技史料). 2003;24(1):5-9.
+# http://oversea.cnki.net/kcms/detail/detail.aspx?filename=ZGKS200301000&dbname=CJFD2003
 # It gives evidence that at the beginning of the PRC, Beijing time was
 # officially apparent solar time!  However, Guo also says that the
 # evidence is dubious, as the relevant institute of astronomy had not
@@ -543,7 +587,7 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Beijing time, used throughout China; represented by Shanghai.
 Zone	Asia/Shanghai	8:05:43	-	LMT	1901
-			8:00	Shang	C%sT	1949
+			8:00	Shang	C%sT	1949 May 28
 			8:00	PRC	C%sT
 # Xinjiang time, used by many in western China; represented by Ürümqi / Ürümchi
 # / Wulumuqi.  (Please use Asia/Shanghai if you prefer Beijing time.)
@@ -772,24 +816,140 @@
 			8:00	Taiwan	C%sT
 
 # Macau (Macao, Aomen)
-# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Macau	1961	1962	-	Mar	Sun>=16	3:30	1:00	D
-Rule	Macau	1961	1964	-	Nov	Sun>=1	3:30	0	S
-Rule	Macau	1963	only	-	Mar	Sun>=16	0:00	1:00	D
-Rule	Macau	1964	only	-	Mar	Sun>=16	3:30	1:00	D
-Rule	Macau	1965	only	-	Mar	Sun>=16	0:00	1:00	D
-Rule	Macau	1965	only	-	Oct	31	0:00	0	S
-Rule	Macau	1966	1971	-	Apr	Sun>=16	3:30	1:00	D
-Rule	Macau	1966	1971	-	Oct	Sun>=16	3:30	0	S
-Rule	Macau	1972	1974	-	Apr	Sun>=15	0:00	1:00	D
-Rule	Macau	1972	1973	-	Oct	Sun>=15	0:00	0	S
-Rule	Macau	1974	1977	-	Oct	Sun>=15	3:30	0	S
-Rule	Macau	1975	1977	-	Apr	Sun>=15	3:30	1:00	D
-Rule	Macau	1978	1980	-	Apr	Sun>=15	0:00	1:00	D
-Rule	Macau	1978	1980	-	Oct	Sun>=15	0:00	0	S
-# See Europe/Lisbon for info about the 1912 transition.
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone	Asia/Macau	7:34:20 -	LMT	1911 Dec 31 16:00u
+#
+# From P Chan (2018-05-10):
+# * LegisMac
+#   http://legismac.safp.gov.mo/legismac/descqry/Descqry.jsf?lang=pt
+#   A database for searching titles of legal documents of Macau in
+#   Chinese and Portuguese.  The term "HORÁRIO DE VERÃO" can be used for
+#   searching decrees about summer time.
+# * Archives of Macao
+#   http://www.archives.gov.mo/en/bo/
+#   It contains images of old official gazettes.
+# * The Macao Meteorological and Geophysical Bureau have a page listing the
+#   summer time history.  But it is not complete and has some mistakes.
+#   http://www.smg.gov.mo/smg/geophysics/e_t_Summer%20Time.htm
+# Macau adopted GMT+8 on 30 Oct 1904 to follow Hong Kong.  Clocks were
+# advanced by 25 minutes and 50 seconds.  Which means the LMT used was
+# +7:34:10.  As stated in the "Portaria No. 204" dated 21 October 1904
+# and published in the Official Gazette on 29 October 1904.
+# http://igallery.icm.gov.mo/Images/Archives/BO/MO_AH_PUB_BO_1904_10/MO_AH_PUB_BO_1904_10_00025_Grey.JPG
+#
+# Therefore the 1911 decree of Portugal did not change time in Macau.
+#
+# From LegisMac, here is a list of decrees that changed the time ...
+# [Decree Gazette-no. date; titles omitted in this quotation]
+#	DIL 732 BOCM 51 1941.12.20
+#	DIL 764 BOCM 9S 1942.04.30
+#	DIL 781 BOCM 21 1942.10.10
+#	PT 3434 BOCM 8S 1943.04.17
+#	PT 3504 BOCM 20 1943.09.25
+#	PT 3843 BOCM 39 1945.09.29
+#	PT 3961 BOCM 17 1946.04.27
+#	PT 4026 BOCM 39 1946.09.28
+#	PT 4153 BOCM 16 1947.04.10
+#	PT 4271 BOCM 48 1947.11.29
+#	PT 4374 BOCM 18 1948.05.01
+#	PT 4465 BOCM 44 1948.10.30
+#	PT 4590 BOCM 14 1949.04.02
+#	PT 4666 BOCM 44 1949.10.29
+#	PT 4771 BOCM 12 1950.03.25
+#	PT 4838 BOCM 43 1950.10.28
+#	PT 4946 BOCM 12 1951.03.24
+#	PT 5025 BO 43 1951.10.27
+#	PT 5149 BO 14 1952.04.05
+#	PT 5251 BO 43 1952.10.25
+#	PT 5366 BO 13 1953.03.28
+#	PT 5444 BO 44 1953.10.31
+#	PT 5540 BO 12 1954.03.20
+#	PT 5589 BO 44 1954.10.30
+#	PT 5676 BO 12 1955.03.19
+#	PT 5739 BO 45 1955.11.05
+#	PT 5823 BO 11 1956.03.17
+#	PT 5891 BO 44 1956.11.03
+#	PT 5981 BO 12 1957.03.23
+#	PT 6064 BO 43 1957.10.26
+#	PT 6172 BO 12 1958.03.22
+#	PT 6243 BO 43 1958.10.25
+#	PT 6341 BO 12 1959.03.21
+#	PT 6411 BO 43 1959.10.24
+#	PT 6514 BO 11 1960.03.12
+#	PT 6584 BO 44 1960.10.29
+#	PT 6721 BO 10 1961.03.11
+#	PT 6815 BO 43 1961.10.28
+#	PT 6947 BO 10 1962.03.10
+#	PT 7080 BO 43 1962.10.27
+#	PT 7218 BO 12 1963.03.23
+#	PT 7340 BO 43 1963.10.26
+#	PT 7491 BO 11 1964.03.14
+#	PT 7664 BO 43 1964.10.24
+#	PT 7846 BO 15 1965.04.10
+#	PT 7979 BO 42 1965.10.16
+#	PT 8146 BO 15 1966.04.09
+#	PT 8252 BO 41 1966.10.08
+#	PT 8429 BO 15 1967.04.15
+#	PT 8540 BO 41 1967.10.14
+#	PT 8735 BO 15 1968.04.13
+#	PT 8860 BO 41 1968.10.12
+#	PT 9035 BO 16 1969.04.19
+#	PT 9156 BO 42 1969.10.18
+#	PT 9328 BO 15 1970.04.11
+#	PT 9418 BO 41 1970.10.10
+#	PT 9587 BO 14 1971.04.03
+#	PT 9702 BO 41 1971.10.09
+#	PT 38-A/72 BO 14 1972.04.01
+#	PT 126-A/72 BO 41 1972.10.07
+#	PT 61/73 BO 14 1973.04.07
+#	PT 182/73 BO 40 1973.10.06
+#	PT 282/73 BO 51 1973.12.22
+#	PT 177/74 BO 41 1974.10.12
+#	PT 51/75 BO 15 1975.04.12
+#	PT 173/75 BO 41 1975.10.11
+#	PT 67/76/M BO 14 1976.04.03
+#	PT 169/76/M BO 41 1976.10.09
+#	PT 78/79/M BO 19 1979.05.12
+#	PT 166/79/M BO 42 1979.10.20
+# Note that DIL 732 does not belong to "HORÁRIO DE VERÃO" according to
+# LegisMac.... Note that between 1942 and 1945, the time switched
+# between GMT+9 and GMT+10.  Also in 1965 and 1965 the DST ended at 2:30am.
+
+# From Paul Eggert (2018-05-10):
+# The 1904 decree says that Macau changed from the meridian of
+# Fortaleza do Monte, presumably the basis for the 7:34:10 for LMT.
+
+# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	Macau	1942	1943	-	Apr	30	23:00	1:00	-
+Rule	Macau	1942	only	-	Nov	17	23:00	0	-
+Rule	Macau	1943	only	-	Sep	30	23:00	0	S
+Rule	Macau	1946	only	-	Apr	30	23:00s	1:00	D
+Rule	Macau	1946	only	-	Sep	30	23:00s	0	S
+Rule	Macau	1947	only	-	Apr	19	23:00s	1:00	D
+Rule	Macau	1947	only	-	Nov	30	23:00s	0	S
+Rule	Macau	1948	only	-	May	 2	23:00s	1:00	D
+Rule	Macau	1948	only	-	Oct	31	23:00s	0	S
+Rule	Macau	1949	1950	-	Apr	Sat>=1	23:00s	1:00	D
+Rule	Macau	1949	1950	-	Oct	lastSat	23:00s	0	S
+Rule	Macau	1951	only	-	Mar	31	23:00s	1:00	D
+Rule	Macau	1951	only	-	Oct	28	23:00s	0	S
+Rule	Macau	1952	1953	-	Apr	Sat>=1	23:00s	1:00	D
+Rule	Macau	1952	only	-	Nov	 1	23:00s	0	S
+Rule	Macau	1953	1954	-	Oct	lastSat	23:00s	0	S
+Rule	Macau	1954	1956	-	Mar	Sat>=17	23:00s	1:00	D
+Rule	Macau	1955	only	-	Nov	 5	23:00s	0	S
+Rule	Macau	1956	1964	-	Nov	Sun>=1	03:30	0	S
+Rule	Macau	1957	1964	-	Mar	Sun>=18	03:30	1:00	D
+Rule	Macau	1965	1973	-	Apr	Sun>=16	03:30	1:00	D
+Rule	Macau	1965	1966	-	Oct	Sun>=16	02:30	0	S
+Rule	Macau	1967	1976	-	Oct	Sun>=16	03:30	0	S
+Rule	Macau	1973	only	-	Dec	30	03:30	1:00	D
+Rule	Macau	1975	1976	-	Apr	Sun>=16	03:30	1:00	D
+Rule	Macau	1979	only	-	May	13	03:30	1:00	D
+Rule	Macau	1979	only	-	Oct	Sun>=16	03:30	0	S
+
+# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
+Zone	Asia/Macau	7:34:10 -	LMT	1904 Oct 30
+			8:00	-	CST	1941 Dec 21 23:00
+			9:00	Macau	+09/+10	1945 Sep 30 24:00
 			8:00	Macau	C%sT
 
 
@@ -1494,9 +1654,29 @@
 # http://www.shugiin.go.jp/internet/itdb_housei.nsf/html/houritsu/00719500331039.htm
 # ... In summary, it is written as follows.  From 24:00 on the first Saturday
 # in May, until 0:00 on the day after the second Saturday in September.
+
+# From Phake Nick (2018-09-27):
+# [T]he webpage authored by National Astronomical Observatory of Japan
+# https://eco.mtk.nao.ac.jp/koyomi/wiki/BBFEB9EF2FB2C6BBFEB9EF.html
+# ... mentioned that using Showa 23 (year 1948) as example, 13pm of September
+# 11 in summer time will equal to 0am of September 12 in standard time.
+# It cited a document issued by the Liaison Office which briefly existed
+# during the postwar period of Japan, where the detail on implementation
+# of the summer time is described in the document.
+# https://eco.mtk.nao.ac.jp/koyomi/wiki/BBFEB9EF2FB2C6BBFEB9EFB2C6BBFEB9EFA4CEBCC2BBDCA4CBA4C4A4A4A4C6.pdf
+# The text in the document do instruct a fall back to occur at
+# September 11, 13pm in summer time, while ordinary citizens can
+# change the clock before they sleep.
+#
+# From Paul Eggert (2018-09-27):
+# This instruction is equivalent to "Sat>=8 25:00", so use that.  zic treats
+# it like "Sun>=9 01:00", which is not quite the same but is the best we can
+# do in any POSIX or C platform.  The "25:00" assumes zic from 2007 or later,
+# which should be safe now.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Japan	1948	only	-	May	Sat>=1	24:00	1:00	D
-Rule	Japan	1948	1951	-	Sep	Sun>=9	 0:00	0	S
+Rule	Japan	1948	1951	-	Sep	Sun>=9	 1:00	0	S
 Rule	Japan	1949	only	-	Apr	Sat>=1	24:00	1:00	D
 Rule	Japan	1950	1951	-	May	Sat>=1	24:00	1:00	D
 
@@ -1878,7 +2058,7 @@
 			5:00	-	+05
 # Mangghystaū (KZ-MAN)
 # Aqtau was not founded until 1963, but it represents an inhabited region,
-# so include time stamps before 1963.
+# so include timestamps before 1963.
 Zone	Asia/Aqtau	3:21:04	-	LMT	1924 May  2
 			4:00	-	+04	1930 Jun 21
 			5:00	-	+05	1981 Oct  1
@@ -2018,6 +2198,10 @@
 # Assembly, as published in Rodong Sinmun.
 # From Tim Parenti (2018-04-29):
 # It appears to be the front page story at the top in the right-most column.
+#
+# From Paul Eggert (2018-05-04):
+# The BBC reported that the transition was from 23:30 to 24:00 today.
+# https://www.bbc.com/news/world-asia-44010705
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Seoul	8:27:52	-	LMT	1908 Apr  1
@@ -2030,7 +2214,7 @@
 			8:30	-	KST	1912 Jan  1
 			9:00	-	JST	1945 Aug 24
 			9:00	-	KST	2015 Aug 15 00:00
-			8:30	-	KST	2018 May  5
+			8:30	-	KST	2018 May  4 23:30
 			9:00	-	KST
 
 ###############################################################################
@@ -2780,19 +2964,35 @@
 # Philippine Star 2014-08-05
 # http://www.philstar.com/headlines/2014/08/05/1354152/pnoy-urged-declare-use-daylight-saving-time
 
-# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Phil	1936	only	-	Nov	1	0:00	1:00	-
-Rule	Phil	1937	only	-	Feb	1	0:00	0	-
-Rule	Phil	1954	only	-	Apr	12	0:00	1:00	-
-Rule	Phil	1954	only	-	Jul	1	0:00	0	-
-Rule	Phil	1978	only	-	Mar	22	0:00	1:00	-
-Rule	Phil	1978	only	-	Sep	21	0:00	0	-
+# From Paul Goyette (2018-06-15):
+# In the Philippines, there is a national law, Republic Act No. 10535
+# which declares the official time here as "Philippine Standard Time".
+# The act [1] even specifies use of PST as the abbreviation, although
+# the FAQ provided by PAGASA [2] uses the "acronym PhST to distinguish
+# it from the Pacific Standard Time (PST)."
+# [1] http://www.officialgazette.gov.ph/2013/05/15/republic-act-no-10535/
+# [2] https://www1.pagasa.dost.gov.ph/index.php/astronomy/philippine-standard-time#republic-act-10535
+#
+# From Paul Eggert (2018-06-19):
+# I surveyed recent news reports, and my impression is that "PST" is
+# more popular among reliable English-language news sources.  This is
+# not just a measure of Google hit counts: it's also the sizes and
+# influence of the sources.  There is no current abbreviation for DST,
+# so use "PDT", the usual American style.
+
+# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	Phil	1936	only	-	Nov	1	0:00	1:00	D
+Rule	Phil	1937	only	-	Feb	1	0:00	0	S
+Rule	Phil	1954	only	-	Apr	12	0:00	1:00	D
+Rule	Phil	1954	only	-	Jul	1	0:00	0	S
+Rule	Phil	1978	only	-	Mar	22	0:00	1:00	D
+Rule	Phil	1978	only	-	Sep	21	0:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Manila	-15:56:00 -	LMT	1844 Dec 31
 			8:04:00 -	LMT	1899 May 11
-			8:00	Phil	+08/+09	1942 May
-			9:00	-	+09	1944 Nov
-			8:00	Phil	+08/+09
+			8:00	Phil	P%sT	1942 May
+			9:00	-	JST	1944 Nov
+			8:00	Phil	P%sT
 
 # Qatar
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -2803,15 +3003,34 @@
 
 # Saudi Arabia
 #
-# From Paul Eggert (2014-07-15):
+# From Paul Eggert (2018-08-29):
 # Time in Saudi Arabia and other countries in the Arabian peninsula was not
-# standardized until relatively recently; we don't know when, and possibly it
+# standardized until 1968 or so; we don't know exactly when, and possibly it
 # has never been made official.  Richard P Hunt, in "Islam city yielding to
 # modern times", New York Times (1961-04-09), p 20, wrote that only airlines
 # observed standard time, and that people in Jeddah mostly observed quasi-solar
 # time, doing so by setting their watches at sunrise to 6 o'clock (or to 12
 # o'clock for "Arab" time).
 #
+# Timekeeping differed depending on who you were and which part of Saudi
+# Arabia you were in.  In 1969, Elias Antar wrote that although a common
+# practice had been to set one's watch to 12:00 (i.e., midnight) at sunset -
+# which meant that the time on one side of a mountain could differ greatly from
+# the time on the other side - many foreigners set their watches to 6pm
+# instead, while airlines instead used UTC +03 (except in Dhahran, where they
+# used UTC +04), Aramco used UTC +03 with DST, and the Trans-Arabian Pipe Line
+# Company used Aramco time in eastern Saudi Arabia and airline time in western.
+# (The American Military Aid Advisory Group used plain UTC.)  Antar writes,
+# "A man named Higgins, so the story goes, used to run a local power
+# station. One day, the whole thing became too much for Higgins and he
+# assembled his staff and laid down the law. 'I've had enough of this,' he
+# shrieked. 'It is now 12 o'clock Higgins Time, and from now on this station is
+# going to run on Higgins Time.' And so, until last year, it did."  See:
+# Antar E. Dinner at When? Saudi Aramco World, 1969 March/April. 2-3.
+# http://archive.aramcoworld.com/issue/196902/dinner.at.when.htm
+# newspapers.com says a similar story about Higgins was published in the Port
+# Angeles (WA) Evening News, 1965-03-10, page 5, but I lack access to the text.
+#
 # The TZ database cannot represent quasi-solar time; airline time is the best
 # we can do.  The 1946 foreign air news digest of the U.S. Civil Aeronautics
 # Board (OCLC 42299995) reported that the "... Arabian Government, inaugurated
@@ -2821,7 +3040,8 @@
 #
 # Shanks & Pottenger also state that until 1968-05-01 Saudi Arabia had two
 # time zones; the other zone, at UT +04, was in the far eastern part of
-# the country.  Ignore this, as it's before our 1970 cutoff.
+# the country.  Presumably this is documenting airline time.  Ignore this,
+# as it's before our 1970 cutoff.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Riyadh	3:06:52 -	LMT	1947 Mar 14
--- old/test/jdk/sun/util/calendar/zi/tzdata/australasia	2019-01-21 18:48:37.137216164 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/australasia	2019-01-21 18:48:36.917216750 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for Australasia and environs, and for much of the Pacific
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -384,8 +386,15 @@
 # Dominic Fok writes (2017-08-20) that DST ends 2018-01-14, citing
 # Extraordinary Government of Fiji Gazette Supplement No. 21 (2017-08-27),
 # [Legal Notice No. 41] of an order of the previous day by J Usamate.
+
+# From Raymond Kumar (2018-07-13):
+# http://www.fijitimes.com/government-approves-2018-daylight-saving/
+# ... The daylight saving period will end at 3am on Sunday January 13, 2019.
+#
+# From Paul Eggert (2018-07-15):
 # For now, guess DST from 02:00 the first Sunday in November to 03:00
-# the first Sunday on or after January 14.  Although ad hoc, it matches
+# the first Sunday on or after January 13.  January transitions reportedly
+# depend on when school terms start.  Although the guess is ad hoc, it matches
 # transitions since late 2014 and seems more likely to match future
 # practice than guessing no DST.
 
@@ -399,7 +408,7 @@
 Rule	Fiji	2012	2013	-	Jan	Sun>=18	3:00	0	-
 Rule	Fiji	2014	only	-	Jan	Sun>=18	2:00	0	-
 Rule	Fiji	2014	max	-	Nov	Sun>=1	2:00	1:00	-
-Rule	Fiji	2015	max	-	Jan	Sun>=14	3:00	0	-
+Rule	Fiji	2015	max	-	Jan	Sun>=13	3:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Fiji	11:55:44 -	LMT	1915 Oct 26 # Suva
 			12:00	Fiji	+12/+13
--- old/test/jdk/sun/util/calendar/zi/tzdata/backward	2019-01-21 18:48:37.633214843 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/backward	2019-01-21 18:48:37.425215397 +0100
@@ -21,10 +21,12 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb links for backward compatibility
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
-# This file provides links between current names for time zones
+# This file provides links between current names for timezones
 # and their old names.  Many names changed in late 1993.
 
 # Link	TARGET			LINK-NAME
--- old/test/jdk/sun/util/calendar/zi/tzdata/etcetera	2019-01-21 18:48:38.141213490 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/etcetera	2019-01-21 18:48:37.929214055 +0100
@@ -21,12 +21,14 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for ships at sea and other miscellany
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
 # These entries are mostly present for historical reasons, so that
 # people in areas not otherwise covered by the tz files could "zic -l"
-# to a time zone that was right for their area.  These days, the
+# to a timezone that was right for their area.  These days, the
 # tz files cover almost all the inhabited world, and the only practical
 # need now for the entries that are not on UTC are for ships at sea
 # that cannot use POSIX TZ settings.
--- old/test/jdk/sun/util/calendar/zi/tzdata/europe	2019-01-21 18:48:38.617212222 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/europe	2019-01-21 18:48:38.389212830 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for Europe and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -540,7 +542,7 @@
 #
 # To work around this problem, the build procedure can translate the
 # following data into two forms, one with negative SAVE values and the
-# other form with a traditional approximation for Irish time stamps
+# other form with a traditional approximation for Irish timestamps
 # after 1971-10-31 02:00 UTC; although this approximation has tm_isdst
 # flags that are reversed, its UTC offsets are correct and this often
 # suffices.  This source file currently uses only nonnegative SAVE
@@ -2450,6 +2452,33 @@
 # administratively part of Sakhalin oblast', they appear to have
 # remained on UTC+11 along with Magadan.
 
+# From Marat Nigametzianov (2018-07-16):
+# this is link to order from 1956 about timezone in USSR
+# http://astro.uni-altai.ru/~orion/blog/2011/11/novyie-granitsyi-chasovyih-poyasov-v-sssr/
+#
+# From Paul Eggert (2018-07-16):
+# Perhaps someone could translate the above-mentioned link and use it
+# to correct our data for the ex-Soviet Union.  It cites the following:
+# «Поясное время и новые границы часовых поясов» / сост. П.Н. Долгов,
+# отв. ред. Г.Д. Бурдун - М: Комитет стандартов, мер и измерительных
+# приборов при Совете Министров СССР, Междуведомственная комиссия
+# единой службы времени, 1956 г.
+# This book looks like it would be a helpful resource for the Soviet
+# Union through 1956.  Although a copy was in the Scientific Library
+# of Tomsk State University, I have not been able to track down a copy nearby.
+#
+# From Stepan Golosunov (2018-07-21):
+# http://astro.uni-altai.ru/~orion/blog/2015/05/center-reforma-ischisleniya-vremeni-br-na-territorii-sssr-v-1957-godu-center/
+# says that the 1956 decision to change time belts' borders was not
+# implemented as planned in 1956 and the change happened in 1957.
+# There is also the problem that actual time zones were different from
+# the official time belts (and from many time belts' maps) as there were
+# numerous exceptions to application of time belt rules.  For example,
+# https://ru.wikipedia.org/wiki/Московское_время#Перемещение_границы_применения_московского_времени_на_восток
+# says that by 1962 there were many regions in the 3rd time belt that
+# were on Moscow time, referring to a 1962 map.  By 1989 number of such
+# exceptions grew considerably.
+
 # From Tim Parenti (2014-07-06):
 # The comments detailing the coverage of each Russian zone are meant to assist
 # with maintenance only and represent our best guesses as to which regions
@@ -2460,9 +2489,6 @@
 # future stability.  ISO 3166-2:RU codes are also listed for first-level
 # divisions where available.
 
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-
-
 # From Tim Parenti (2014-07-03):
 # Europe/Kaliningrad covers...
 # 39	RU-KGD	Kaliningrad Oblast
@@ -2730,6 +2756,15 @@
 # 34	RU-VGG	Volgograd Oblast
 # The 1988 transition is from USSR act No. 5 (1988-01-04).
 
+# From Alexander Fetisov (2018-09-20):
+# Volgograd region in southern Russia (Europe/Volgograd) change
+# timezone from UTC+3 to UTC+4 from 28oct2018.
+# http://sozd.parliament.gov.ru/bill/452878-7
+#
+# From Stepan Golosunov (2018-10-11):
+# The law has been published today on
+# http://publication.pravo.gov.ru/Document/View/0001201810110037
+
 Zone Europe/Volgograd	 2:57:40 -	LMT	1920 Jan  3
 			 3:00	-	+03	1930 Jun 21
 			 4:00	-	+04	1961 Nov 11
@@ -2738,7 +2773,8 @@
 			 4:00	-	+04	1992 Mar 29  2:00s
 			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
 			 4:00	-	+04	2014 Oct 26  2:00s
-			 3:00	-	+03
+			 3:00	-	+03	2018 Oct 28  2:00s
+			 4:00	-	+04
 
 # From Paul Eggert (2016-11-11):
 # Europe/Saratov covers:
@@ -3427,7 +3463,8 @@
 #Rule NatSpain	1937	only	-	May	22	23:00	1:00	S
 #Rule NatSpain	1937	1938	-	Oct	Sat>=1	24:00s	0	-
 #Rule NatSpain	1938	only	-	Mar	26	23:00	1:00	S
-# The following rules are copied from Morocco from 1967 through 1978.
+# The following rules are copied from Morocco from 1967 through 1978,
+# except with "S" letters.
 Rule SpainAfrica 1967	only	-	Jun	 3	12:00	1:00	S
 Rule SpainAfrica 1967	only	-	Oct	 1	 0:00	0	-
 Rule SpainAfrica 1974	only	-	Jun	24	 0:00	1:00	S
@@ -3447,6 +3484,7 @@
 			 0:00	1:00	WEST	1918 Oct  7 23:00
 			 0:00	-	WET	1924
 			 0:00	Spain	WE%sT	1929
+			 0:00	-	WET	1967 # Help zishrink.awk.
 			 0:00 SpainAfrica WE%sT	1984 Mar 16
 			 1:00	-	CET	1986
 			 1:00	EU	CE%sT
@@ -3632,7 +3670,7 @@
 # http://www.resmigazete.gov.tr/eskiler/2001/03/20010324.htm#2  - for 2001
 # http://www.resmigazete.gov.tr/eskiler/2002/03/20020316.htm#2  - for 2002-2006
 # From Paul Eggert (2016-09-25):
-# Prefer the above sources to Shanks & Pottenger for time stamps after 1985.
+# Prefer the above sources to Shanks & Pottenger for timestamps after 1985.
 
 # From Steffen Thorsen (2007-03-09):
 # Starting 2007 though, it seems that they are adopting EU's 1:00 UTC
@@ -3842,10 +3880,29 @@
 # * Ukrainian Government's Resolution of 20.03.1992, No. 139.
 # http://www.uazakon.com/documents/date_8u/pg_grcasa.htm
 
+# From Paul Eggert (2018-10-03):
+# As is usual in tzdb, Ukrainian zones use the most common English spellings.
+# For example, tzdb uses Europe/Kiev, as "Kiev" is the most common spelling in
+# English for Ukraine's capital, even though it is certainly wrong as a
+# transliteration of the Ukrainian "Київ".  This is similar to tzdb's use of
+# Europe/Prague, which is certainly wrong as a transliteration of the Czech
+# "Praha".  ("Kiev" came from old Slavic via Russian to English, and "Prague"
+# came from old Slavic via French to English, so the two cases have something
+# in common.)  Admittedly English-language spelling of Ukrainian names is
+# controversial, and some day "Kyiv" may become substantially more popular in
+# English; in the meantime, stick with the traditional English "Kiev" as that
+# means less disruption for our users.
+#
+# Anyway, none of the common English-language spellings (Kiev, Kyiv, Kieff,
+# Kijeff, Kijev, Kiyef, Kiyeff) do justice to the common pronunciation in
+# Ukrainian, namely [ˈkɪjiu̯] (IPA).  This pronunciation has nothing like an
+# English "v" or "f", and instead trails off with what an English-speaker
+# would call a demure "oo" sound, and it would would be better anglicized as
+# "Kuiyu".  Here's a sound file, if you would like to do as the Kuiyuvians do:
+# https://commons.wikimedia.org/wiki/File:Uk-Київ.ogg
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-# Most of Ukraine since 1970 has been like Kiev.
-# "Kyiv" is the transliteration of the Ukrainian name, but
-# "Kiev" is more common in English.
+# This represents most of Ukraine.  See above for the spelling of "Kiev".
 Zone Europe/Kiev	2:02:04 -	LMT	1880
 			2:02:04	-	KMT	1924 May  2 # Kiev Mean Time
 			2:00	-	EET	1930 Jun 21
--- old/test/jdk/sun/util/calendar/zi/tzdata/factory	2019-01-21 18:48:39.181210720 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/factory	2019-01-21 18:48:38.953211327 +0100
@@ -21,11 +21,13 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for noncommittal factory settings
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
-# For distributors who don't want to put time zone specification in
-# their installation procedures.  Users that run 'date' will get the
+# For distributors who don't want to specify a timezone in their
+# installation procedures.  Users who run 'date' will get the
 # time zone abbreviation "-00", indicating that the actual time zone
 # is unknown.
 
--- old/test/jdk/sun/util/calendar/zi/tzdata/leapseconds	2019-01-21 18:48:39.653209463 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/leapseconds	2019-01-21 18:48:39.445210017 +0100
@@ -26,21 +26,25 @@
 # This file is in the public domain.
 
 # This file is generated automatically from the data in the public-domain
-# leap-seconds.list file, which is copied from:
-# ftp://ftp.nist.gov/pub/time/leap-seconds.list
+# leap-seconds.list file, which can be copied from
+# <ftp://ftp.nist.gov/pub/time/leap-seconds.list>
+# or <ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.list>
+# or <ftp://tycho.usno.navy.mil/pub/ntp/leap-seconds.list>.
 # For more about leap-seconds.list, please see
 # The NTP Timescale and Leap Seconds
-# https://www.eecis.udel.edu/~mills/leap.html
+# <https://www.eecis.udel.edu/~mills/leap.html>.
 
 # The International Earth Rotation and Reference Systems Service
 # periodically uses leap seconds to keep UTC to within 0.9 s of UT1
-# (which measures the true angular orientation of the earth in space); see
-# Levine J. Coordinated Universal Time and the leap second.
+# (which measures the true angular orientation of the earth in space)
+# and publishes leap second data in a copyrighted file
+# <https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat>.
+# See: Levine J. Coordinated Universal Time and the leap second.
 # URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995
-# http://ieeexplore.ieee.org/document/7909995/
+# <https://ieeexplore.ieee.org/document/7909995>.
 # There were no leap seconds before 1972, because the official mechanism
 # accounting for the discrepancy between atomic time and the earth's rotation
-# did not exist until the early 1970s.
+# did not exist.
 
 # The correction (+ or -) is made at the given time, so lines
 # will typically look like:
@@ -48,10 +52,7 @@
 # or
 #	Leap	YEAR	MON	DAY	23:59:59	-	R/S
 
-# If the leapsecond is Rolling (R) the given time is local time.
-# If the leapsecond is Stationary (S) the given time is UTC.
-
-# Leap	YEAR	MONTH	DAY	HH:MM:SS	CORR	R/S
+# If the leap second is Rolling (R) the given time is local time (unused here).
 Leap	1972	Jun	30	23:59:60	+	S
 Leap	1972	Dec	31	23:59:60	+	S
 Leap	1973	Dec	31	23:59:60	+	S
@@ -80,5 +81,9 @@
 Leap	2015	Jun	30	23:59:60	+	S
 Leap	2016	Dec	31	23:59:60	+	S
 
-#	Updated through IERS Bulletin C55
-#	File expires on:  28 December 2018
+# POSIX timestamps for the data in this file:
+#updated 1467936000
+#expires 1561680000
+
+#	Updated through IERS Bulletin C56
+#	File expires on:  28 June 2019
--- old/test/jdk/sun/util/calendar/zi/tzdata/northamerica	2019-01-21 18:48:40.121208215 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/northamerica	2019-01-21 18:48:39.905208791 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for North and Central America and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -71,7 +73,7 @@
 #
 # Most of the US soon followed suit.  See:
 # Bartky IR. The adoption of standard time. Technol Cult 1989 Jan;30(1):25-56.
-# http://dx.doi.org/10.2307/3105430
+# https://dx.doi.org/10.2307/3105430
 
 # From Paul Eggert (2005-04-16):
 # That 1883 transition occurred at 12:00 new time, not at 12:00 old time.
@@ -460,6 +462,19 @@
 # western South Dakota, far western Texas (El Paso County, Hudspeth County,
 # and Pine Springs and Nickel Creek in Culberson County), Utah, Wyoming
 #
+# From Paul Eggert (2018-10-25):
+# On 1921-03-04 federal law placed all of Texas into the central time zone.
+# However, El Paso ignored the law for decades and continued to observe
+# mountain time, on the grounds that that's what they had always done
+# and they weren't about to let the federal government tell them what to do.
+# Eventually the federal government gave in and changed the law on
+# 1970-04-10 to match what El Paso was actually doing.  Although
+# that's slightly after our 1970 cutoff, there is no need to create a
+# separate zone for El Paso since they were ignoring the law anyway.  See:
+# Long T. El Pasoans were time rebels, fought to stay in Mountain zone.
+# El Paso Times. 2018-10-24 06:40 -06.
+# https://www.elpasotimes.com/story/news/local/el-paso/2018/10/24/el-pasoans-were-time-rebels-fought-stay-mountain-zone/1744509002/
+#
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER
 Rule	Denver	1920	1921	-	Mar	lastSun	2:00	1:00	D
 Rule	Denver	1920	only	-	Oct	lastSun	2:00	0	S
@@ -729,9 +744,7 @@
 Zone Pacific/Honolulu	-10:31:26 -	LMT	1896 Jan 13 12:00
 			-10:30	-	HST	1933 Apr 30  2:00
 			-10:30	1:00	HDT	1933 May 21 12:00
-			-10:30	-	HST	1942 Feb  9  2:00
-			-10:30	1:00	HDT	1945 Sep 30  2:00
-			-10:30	-	HST	1947 Jun  8  2:00
+			-10:30	US	H%sT	1947 Jun  8  2:00
 			-10:00	-	HST
 
 # Now we turn to US areas that have diverged from the consensus since 1970.
--- old/test/jdk/sun/util/calendar/zi/tzdata/pacificnew	2019-01-21 18:48:40.641206830 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/pacificnew	2019-01-21 18:48:40.437207374 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for proposed US election time (this file is obsolete)
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
--- old/test/jdk/sun/util/calendar/zi/tzdata/southamerica	2019-01-21 18:48:41.141205497 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/southamerica	2019-01-21 18:48:40.921206083 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for South America and environs
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -415,7 +417,7 @@
 # standard time, so let's do that here too.  This does not change UTC
 # offsets, only tm_isdst and the time zone abbreviations.  One minor
 # plus is that this silences a zic complaint that there's no POSIX TZ
-# setting for time stamps past 2038.
+# setting for timestamps past 2038.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
@@ -948,6 +950,14 @@
 # ... https://www.timeanddate.com/news/time/brazil-delays-dst-2018.html
 # From Steffen Thorsen (2017-12-20):
 # http://www.planalto.gov.br/ccivil_03/_ato2015-2018/2017/decreto/D9242.htm
+#
+# From Fábio Gomes (2018-10-04):
+# The Brazilian president just announced a new change on this year DST.
+# It was scheduled to start on November 4th and it was changed to November 18th.
+# From Rodrigo Brüning Wessler (2018-10-15):
+# The Brazilian government just announced that the change in DST was
+# canceled....  Maybe the president Michel Temer also woke up one hour
+# earlier today. :)
 Rule	Brazil	2018	max	-	Nov	Sun>=1	0:00	1:00	-
 Rule	Brazil	2023	only	-	Feb	Sun>=22	0:00	0	-
 Rule	Brazil	2024	2025	-	Feb	Sun>=15	0:00	0	-
@@ -1254,6 +1264,24 @@
 # they will switch from -03 to -04 one hour after Santiago does that day.
 # For now, assume that they will not revert.
 
+# From Juan Correa (2018-08-13):
+# As of moments ago, the Ministry of Energy in Chile has announced the new
+# schema for DST. ...  Announcement in video (in Spanish):
+# https://twitter.com/MinEnergia/status/1029000399129374720
+# From Yonathan Dossow (2018-08-13):
+# The video says "first Saturday of September", we all know it means Sunday at
+# midnight.
+# From Tim Parenti (2018-08-13):
+# Translating the captions on the video at 0:44-0:55, "We want to announce as
+# Government that from 2019, Winter Time will be increased to 5 months, between
+# the first Saturday of April and the first Saturday of September."
+# At 2:08-2:20, "The Magallanes region will maintain its current time, as
+# decided by the citizens during 2017, but our Government will promote a
+# regional dialogue table to gather their opinion on this matter."
+# https://twitter.com/MinEnergia/status/1029009354001973248
+# "We will keep the new time policy unchanged for at least the next 4 years."
+# So we extend the new rules on Saturdays at 24:00 mainland time indefinitely.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Chile	1927	1931	-	Sep	 1	0:00	1:00	-
 Rule	Chile	1928	1932	-	Apr	 1	0:00	0	-
@@ -1287,8 +1315,10 @@
 Rule	Chile	2011	only	-	Aug	Sun>=16	4:00u	1:00	-
 Rule	Chile	2012	2014	-	Apr	Sun>=23	3:00u	0	-
 Rule	Chile	2012	2014	-	Sep	Sun>=2	4:00u	1:00	-
-Rule	Chile	2016	max	-	May	Sun>=9	3:00u	0	-
-Rule	Chile	2016	max	-	Aug	Sun>=9	4:00u	1:00	-
+Rule	Chile	2016	2018	-	May	Sun>=9	3:00u	0	-
+Rule	Chile	2016	2018	-	Aug	Sun>=9	4:00u	1:00	-
+Rule	Chile	2019	max	-	Apr	Sun>=2	3:00u	0	-
+Rule	Chile	2019	max	-	Sep	Sun>=2	4:00u	1:00	-
 # IATA SSIM anomalies: (1992-02) says 1992-03-14;
 # (1996-09) says 1998-03-08.  Ignore these.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
--- old/test/jdk/sun/util/calendar/zi/tzdata/systemv	2019-01-21 18:48:41.689204036 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/systemv	2019-01-21 18:48:41.457204655 +0100
@@ -21,6 +21,8 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+# tzdb data for System V rules (this file is obsolete)
+
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
--- old/test/jdk/sun/util/calendar/zi/tzdata/zone.tab	2019-01-21 18:48:42.193202692 +0100
+++ new/test/jdk/sun/util/calendar/zi/tzdata/zone.tab	2019-01-21 18:48:41.981203257 +0100
@@ -21,12 +21,12 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-# tz zone descriptions (deprecated version)
+# tzdb timezone descriptions (deprecated version)
 #
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 #
-# From Paul Eggert (2014-07-31):
+# From Paul Eggert (2018-06-27):
 # This file is intended as a backward-compatibility aid for older programs.
 # New programs should use zone1970.tab.  This file is like zone1970.tab (see
 # zone1970.tab's comments), but with the following additional restrictions:
@@ -35,13 +35,13 @@
 # 2.  The first data column contains exactly one country code.
 #
 # Because of (2), each row stands for an area that is the intersection
-# of a region identified by a country code and of a zone where civil
+# of a region identified by a country code and of a timezone where civil
 # clocks have agreed since 1970; this is a narrower definition than
 # that of zone1970.tab.
 #
-# This table is intended as an aid for users, to help them select time
-# zone data entries appropriate for their practical needs.  It is not
-# intended to take or endorse any position on legal or territorial claims.
+# This table is intended as an aid for users, to help them select timezones
+# appropriate for their practical needs.  It is not intended to take or
+# endorse any position on legal or territorial claims.
 #
 #country-
 #code	coordinates	TZ			comments
@@ -291,7 +291,7 @@
 MN	+4755+10653	Asia/Ulaanbaatar	Mongolia (most areas)
 MN	+4801+09139	Asia/Hovd	Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan
 MN	+4804+11430	Asia/Choibalsan	Dornod, Sukhbaatar
-MO	+2214+11335	Asia/Macau
+MO	+221150+1133230	Asia/Macau
 MP	+1512+14545	Pacific/Saipan
 MQ	+1436-06105	America/Martinique
 MR	+1806-01557	Africa/Nouakchott
--- old/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java	2019-01-21 18:48:42.661201445 +0100
+++ new/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java	2019-01-21 18:48:42.453201998 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4645058 4747738 4855054 8024756 8141492 8196202
+ * @bug 4645058 4747738 4855054 8024756 8141492 8196202 8205593
  * @summary  Javascript IE load error when linked by -linkoffline
  *           Window title shouldn't change when loading left frames (javascript)
  * @author dkramer
@@ -43,6 +43,7 @@
     @Test
     void test() {
         javadoc("-d", "out",
+                "-source", "8",
                 "--frames",
                 "-doctitle", "Document Title",
                 "-windowtitle", "Window Title",
--- old/test/langtools/jdk/javadoc/doclet/testClassCrossReferences/C.java	2019-01-21 18:48:43.165200099 +0100
+++ new/test/langtools/jdk/javadoc/doclet/testClassCrossReferences/C.java	2019-01-21 18:48:42.949200676 +0100
@@ -26,7 +26,7 @@
  * Cross link to inner class: {@link javax.swing.text.AbstractDocument.AttributeContext Link to AttributeContext innerclass} <br>
  * Cross link to class: {@link java.math.BigDecimal Link to external class BigDecimal}<br>
  * Cross link to member: {@link java.math.BigInteger#gcd(java.math.BigInteger) Link to external member gcd}<br>
- * Cross link to package: {@link javax.tools.SimpleJavaFileObject#URI Link to external member URI}<br>
+ * Cross link to package: {@link javax.tools.SimpleJavaFileObject#uri Link to external member URI}<br>
  */
 public class C {
 
--- old/test/langtools/jdk/javadoc/doclet/testClassCrossReferences/TestClassCrossReferences.java	2019-01-21 18:48:43.657198787 +0100
+++ new/test/langtools/jdk/javadoc/doclet/testClassCrossReferences/TestClassCrossReferences.java	2019-01-21 18:48:43.453199332 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4652655 4857717 8025633 8026567 8071982 8164407 8182765
+ * @bug 4652655 4857717 8025633 8026567 8071982 8164407 8182765 8205593
  * @summary This test verifies that class cross references work properly.
  * @author jamieh
  * @library ../lib
@@ -45,6 +45,7 @@
     @Test
     void test() {
         javadoc("-d", "out",
+                "-source", "8",
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-linkoffline", uri, testSrc,
@@ -60,7 +61,7 @@
                 + "title=\"class or interface in java.math\" class=\"externalLink\"><code>Link to external class BigDecimal</code></a>",
                 "<a href=\"" + uri + "java/math/BigInteger.html?is-external=true#gcd(java.math.BigInteger)\" "
                 + "title=\"class or interface in java.math\" class=\"externalLink\"><code>Link to external member gcd</code></a>",
-                "<a href=\"" + uri + "javax/tools/SimpleJavaFileObject.html?is-external=true#URI\" "
+                "<a href=\"" + uri + "javax/tools/SimpleJavaFileObject.html?is-external=true#uri\" "
                 + "title=\"class or interface in javax.tools\" class=\"externalLink\"><code>Link to external member URI</code></a>",
                 "<dl>\n"
                 + "<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n"
@@ -69,8 +70,22 @@
     }
 
     @Test
+    void test_error() {
+        javadoc("-d", "out-error",
+                "-Xdoclint:none",
+                "-sourcepath", testSrc,
+                "-linkoffline", uri, testSrc,
+                testSrc("C.java"));
+        checkExit(Exit.ERROR);
+        checkOutput(Output.OUT, true,
+                "The code being documented uses modules but the packages defined"
+                + " in http://docs.oracle.com/javase/8/docs/api/ are in the unnamed module");
+    }
+
+    @Test
     void test_html4() {
         javadoc("-d", "out-html4",
+                "-source", "8",
                 "-html4",
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
--- old/test/langtools/jdk/javadoc/doclet/testDocRootInlineTag/TestDocRootInlineTag.java	2019-01-21 18:48:44.125197539 +0100
+++ new/test/langtools/jdk/javadoc/doclet/testDocRootInlineTag/TestDocRootInlineTag.java	2019-01-21 18:48:43.925198072 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4369014 4851991 8164407
+ * @bug 4369014 4851991 8164407 8205593
  * @summary Determine if the docRoot inline tag works properly.
  * If docRoot performs as documented, the test passes.
  * Make sure that the docRoot tag works with the -bottom option.
@@ -47,6 +47,7 @@
 
         javadoc("-bottom", "The value of @docRoot is \"{@docRoot}\"",
                 "-d", "out",
+                "-source", "8",
                 "-sourcepath", testSrc,
                 "-linkoffline", uri, testSrc,
                 testSrc("TestDocRootTag.java"), "pkg");
--- old/test/langtools/jdk/javadoc/doclet/testExternalOverridenMethod/TestExternalOverridenMethod.java	2019-01-21 18:48:44.609196247 +0100
+++ new/test/langtools/jdk/javadoc/doclet/testExternalOverridenMethod/TestExternalOverridenMethod.java	2019-01-21 18:48:44.397196814 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4857717 8025633 8026567 8164407 8182765
+ * @bug 4857717 8025633 8026567 8164407 8182765 8205593
  * @summary Test to make sure that externally overriden and implemented methods
  * are documented properly.  The method should still include "implements" or
  * "overrides" documentation even though the method is external.
@@ -45,6 +45,7 @@
     @Test
     void test() {
         javadoc("-d", "out",
+                "-source","8",
                 "-sourcepath", testSrc,
                 "-linkoffline", uri, testSrc,
                 "pkg");
@@ -67,6 +68,7 @@
     @Test
     void test_html4() {
         javadoc("-d", "out-html4",
+                "-source", "8",
                 "-html4",
                 "-sourcepath", testSrc,
                 "-linkoffline", uri, testSrc,
--- old/test/langtools/jdk/javadoc/doclet/testHref/TestHref.java	2019-01-21 18:48:45.133194849 +0100
+++ new/test/langtools/jdk/javadoc/doclet/testHref/TestHref.java	2019-01-21 18:48:44.913195436 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4663254 8016328 8025633 8026567 8081854 8182765
+ * @bug      4663254 8016328 8025633 8026567 8081854 8182765 8205593
  * @summary  Verify that spaces do not appear in hrefs and anchors.
  * @author   jamieh
  * @library  ../lib
@@ -43,6 +43,7 @@
     void test() {
         javadoc("-Xdoclint:none",
                 "-d", "out",
+                "-source", "8",
                 "-sourcepath", testSrc,
                 "-linkoffline", "http://java.sun.com/j2se/1.4/docs/api/", testSrc,
                 "pkg");
@@ -85,6 +86,7 @@
     void test_html4() {
         javadoc("-Xdoclint:none",
                 "-d", "out-html4",
+                "-source", "8",
                 "-html4",
                 "-sourcepath", testSrc,
                 "-linkoffline", "http://java.sun.com/j2se/1.4/docs/api/", testSrc,
--- old/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java	2019-01-21 18:48:45.653193461 +0100
+++ new/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java	2019-01-21 18:48:45.425194069 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4720957 5020118 8026567 8038976 8184969 8164407 8182765
+ * @bug 4720957 5020118 8026567 8038976 8184969 8164407 8182765 8205593
  * @summary Test to make sure that -link and -linkoffline link to
  * right files, and URLs with and without trailing slash are accepted.
  * @author jamieh
@@ -61,6 +61,7 @@
         String out1 = "out1";
         String url = "http://acme.com/jdk/";
         javadoc("-d", out1,
+                "-source", "8",
                 "-classpath", mylib,
                 "-sourcepath", testSrc,
                 "-linkoffline", url, testSrc + "/jdk",
@@ -113,6 +114,7 @@
 
         String out1_html4 = "out1-html4";
         javadoc("-d", out1_html4,
+                "-source", "8",
                 "-html4",
                 "-classpath", mylib,
                 "-sourcepath", testSrc,
--- /dev/null	2019-01-19 16:38:04.551977405 +0100
+++ new/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOptionWithModule.java	2019-01-21 18:48:45.985192576 +0100
@@ -0,0 +1,166 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8205593
+ * @summary Javadoc -link makes broken links if module name matches package name
+ * @library /tools/lib ../lib
+ * @modules
+ *      jdk.javadoc/jdk.javadoc.internal.tool
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @build JavadocTester
+ * @run main TestLinkOptionWithModule
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import builder.ClassBuilder;
+import builder.ClassBuilder.*;
+import toolbox.ModuleBuilder;
+import toolbox.ToolBox;
+
+
+public class TestLinkOptionWithModule extends JavadocTester {
+
+    final ToolBox tb;
+    private final Path src;
+
+    public static void main(String... args) throws Exception {
+        TestLinkOptionWithModule tester = new TestLinkOptionWithModule();
+        tester.runTests(m -> new Object[]{Paths.get(m.getName())});
+    }
+
+    TestLinkOptionWithModule() throws Exception {
+        tb = new ToolBox();
+        src = Paths.get("src");
+        initModulesAndPackages();
+    }
+
+    @Test
+    void testModuleLinkedToModule(Path base) throws Exception {
+        Path out1 = base.resolve("out1a"), out2 = base.resolve("out1b");
+
+        javadoc("-d", out1.toString(),
+                "--module-source-path", src.toString(),
+                "--module", "com.ex1");
+
+        javadoc("-d", out2.toString(),
+                "--module-source-path", src.toString(),
+                "--module", "com.ex2",
+                "-link", "../" + out1.getFileName());
+
+        checkExit(Exit.OK);
+        checkOutput("com.ex2/com/ex2/B.html", true,
+                "<a href=\"../../../../out1a/com.ex1/com/ex1/A.html?is-external=true\" "
+                + "title=\"class or interface in com.ex1\" class=\"externalLink\">A</a>");
+    }
+
+    @Test
+    void testPackageLinkedToPackage(Path base) throws Exception {
+        Path out1 = base.resolve("out2a"), out2 = base.resolve("out2b");
+
+        javadoc("-d", out1.toString(),
+                "-sourcepath", src.toString(),
+                "-subpackages", "com.ex1");
+
+        javadoc("-d", out2.toString(),
+                "-sourcepath", src.toString(),
+                "-subpackages", "com.ex2",
+                "-link", "../" + out1.getFileName());
+
+        checkExit(Exit.OK);
+        checkOutput("com/ex2/B.html", true,
+                "<a href=\"../../../out2a/com/ex1/A.html?is-external=true\" title=\"class or interface in com.ex1\" "
+                + "class=\"externalLink\">A</a>");
+    }
+
+    @Test
+    void testModuleLinkedToPackage(Path base) throws Exception {
+        Path out1 = base.resolve("out3a"), out2 = base.resolve("out3b");
+
+        javadoc("-d", out1.toString(),
+                "-sourcepath", src.toString(),
+                "-subpackages", "com.ex1");
+
+        javadoc("-d", out2.toString(),
+                "--module-source-path", src.toString(),
+                "--module", "com.ex2",
+                "-link", "../" + out1.getFileName());
+
+        checkExit(Exit.ERROR);
+        checkOutput(Output.OUT, true,
+                "The code being documented uses modules but the packages defined "
+                + "in ../out3a/ are in the unnamed module");
+    }
+
+    @Test
+    void testPackageLinkedToModule(Path base) throws Exception {
+        Path out1 = base.resolve("out4a"), out2 = base.resolve("out4b");
+
+        javadoc("-d", out1.toString(),
+                "--module-source-path", src.toString(),
+                "--module", "com.ex1");
+
+        javadoc("-d", out2.toString(),
+                "-sourcepath", src.toString(),
+                "-subpackages", "com.ex2",
+                "-link", "../" + out1.getFileName());
+
+        checkExit(Exit.ERROR);
+        checkOutput(Output.OUT, true,
+                "The code being documented uses packages in the unnamed module, but the packages defined "
+                + "in ../out4a/ are in named modules");
+    }
+
+
+    void initModulesAndPackages() throws Exception{
+        new ModuleBuilder(tb, "com.ex1")
+                .exports("com.ex1")
+                .classes("package com.ex1; public class A{}")
+                .write(src);
+
+        new ModuleBuilder(tb, "com.ex2")
+                .requires("com.ex1")
+                .exports("com.ex2")
+                .classes("package com.ex2; \n"
+                        + "import com.ex1.A;\n"
+                        + "public class B{\n"
+                        + "public B(A obj){}\n"
+                        + "}\n")
+                .write(src);
+
+        new ClassBuilder(tb, "com.ex1.A")
+                .setModifiers("public","class")
+                .write(src);
+
+        new ClassBuilder(tb, "com.ex2.B")
+                .addImports("com.ex1.A")
+                .setModifiers("public","class")
+                .addMembers(MethodBuilder.parse("public void foo(A a)"))
+                .write(src);
+    }
+
+}
--- old/test/langtools/jdk/javadoc/doclet/testLinkOption/TestNewLineInLink.java	2019-01-21 18:48:46.637190834 +0100
+++ new/test/langtools/jdk/javadoc/doclet/testLinkOption/TestNewLineInLink.java	2019-01-21 18:48:46.417191422 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4739870
+ * @bug 4739870 8205593
  * @summary Make sure that a new line may act as a separator between
  * link and label.
  * @author jamieh
@@ -43,6 +43,7 @@
     @Test
     void test() {
         javadoc("-d", "out",
+                "-source", "8",
                 "-sourcepath", testSrc,
                 "-linkoffline", "http://www.java.sun.com/j2se/1.4/docs/api", testSrc("jdk"),
                 "testNewLineInLink");
--- old/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	2019-01-21 18:48:47.129189520 +0100
+++ new/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	2019-01-21 18:48:46.905190120 +0100
@@ -26,7 +26,7 @@
  * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363
  *      8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218
  *      8175823 8166306 8178043 8181622 8183511 8169819 8074407 8183037 8191464
-        8164407 8192007 8182765 8196200 8196201 8196202 8196202
+        8164407 8192007 8182765 8196200 8196201 8196202 8196202 8205593
  * @summary Test modules support in javadoc.
  * @author bpatel
  * @library ../lib
@@ -1616,10 +1616,10 @@
 
     void checkLinkOffline() {
         checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
-                "<a href=\"https://docs.oracle.com/javase/9/docs/api/java/lang/String.html?is-external=true\" "
+                "<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/java/lang/String.html?is-external=true\" "
                 + "title=\"class or interface in java.lang\" class=\"externalLink\"><code>Link to String Class</code></a>");
         checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
-                "<a href=\"https://docs.oracle.com/javase/9/docs/api/java/lang/package-summary.html?is-external=true\" "
+                "<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/java/lang/package-summary.html?is-external=true\" "
                 + "class=\"externalLink\"><code>Link to java.lang package</code></a>");
         checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
                 "<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/module-summary.html?is-external=true\" "
--- old/test/langtools/jdk/javadoc/doclet/testTitleInHref/TestTitleInHref.java	2019-01-21 18:48:47.653188121 +0100
+++ new/test/langtools/jdk/javadoc/doclet/testTitleInHref/TestTitleInHref.java	2019-01-21 18:48:47.445188677 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4714257 8164407
+ * @bug 4714257 8164407 8205593
  * @summary Test to make sure that the title attribute shows up in links.
  * @author jamieh
  * @library ../lib
@@ -43,6 +43,7 @@
     void test() {
         String uri = "http://java.sun.com/j2se/1.4/docs/api";
         javadoc("-d", "out",
+                "-source", "8",
                 "-sourcepath", testSrc,
                 "-linkoffline", uri, testSrc,
                 "pkg");
--- old/test/nashorn/script/nosecurity/treeapi/diagnostic.js.EXPECTED	2019-01-21 18:48:48.129186851 +0100
+++ new/test/nashorn/script/nosecurity/treeapi/diagnostic.js.EXPECTED	2019-01-21 18:48:47.917187416 +0100
@@ -80,7 +80,7 @@
     "columnNumber": "15",
     "kind": "ERROR",
     "position": "15",
-    "message": "test.js:1:15 Unclosed group near index 9\n([a-z])+(\n         ^\n    /([a-z])+(/;\n               ^",
+    "message": "test.js:1:15 Unclosed group near index 9\n([a-z])+(\n    /([a-z])+(/;\n               ^",
     "lineNumber": "1"
   },
   {