changeset 8699:d918a2d9dbc2

Merge from main OpenJDK repository
author Greg Lewis <glewis@eyesbeyond.com>
date Sun, 28 May 2017 23:44:03 -0700
parents d468376d877c 15ba571f7278
children 6b21d823f6e6
files .hgtags make/java/java/Makefile src/macosx/classes/sun/lwawt/SelectionClearListener.java src/share/classes/sun/awt/TextureSizeConstraining.java src/share/classes/sun/tools/jar/resources/jar.properties test/sun/misc/URLClassPath/ClassnameCharTest.sh
diffstat 188 files changed, 7591 insertions(+), 3249 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed May 24 00:32:01 2017 -0700
+++ b/.hgtags	Sun May 28 23:44:03 2017 -0700
@@ -598,3 +598,6 @@
 cc1ed9a351886645eb729144696e41d187564ec2 jdk7u111-b01
 c16fb4099a2bafe701d533d9a0fd869e7f8e5408 jdk7u121-b00
 86d0df91308912e45e1b00f8699e0b157a8857af jdk7u131-b00
+e890a6aef6223d428376aac846c1d1f3e40dbda7 jdk7u141-b00
+a319566e15f5611bae9cfda2696e8217020a9269 jdk7u141-b01
+19a085e656145471455d7fbd648717f94281a729 jdk7u141-b02
--- a/make/java/java/Makefile	Wed May 24 00:32:01 2017 -0700
+++ b/make/java/java/Makefile	Sun May 28 23:44:03 2017 -0700
@@ -218,7 +218,7 @@
 ifeq ($(PLATFORM),windows)
 OTHER_LDLIBS += $(JVMLIB) -libpath:$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) fdlibm.lib \
 		       -libpath:$(OBJDIR)/../../../verify/$(OBJDIRNAME) verify.lib \
-		       shell32.lib delayimp.lib /DELAYLOAD:shell32.dll
+		       shell32.lib delayimp.lib /DELAYLOAD:shell32.dll version.lib
 else
 OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) $(LIBSCF) $(LIBDL) \
 		-L$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) -lfdlibm.$(ARCH)
--- a/make/sun/javazic/tzdata/VERSION	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/VERSION	Sun May 28 23:44:03 2017 -0700
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2016i
+tzdata2017a
--- a/make/sun/javazic/tzdata/africa	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/africa	Sun May 28 23:44:03 2017 -0700
@@ -29,15 +29,15 @@
 # tz@iana.org for general use in the future).  For more, please see
 # the file CONTRIBUTING in the tz distribution.
 
-# From Paul Eggert (2014-10-31):
+# From Paul Eggert (2017-02-20):
 #
 # Unless otherwise specified, the source for data through 1990 is:
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
 # San Diego: ACS Publications, Inc. (2003).
 # Unfortunately this book contains many errors and cites no sources.
 #
-# Gwillim Law writes that a good source
-# for recent time zone data is the International Air Transport
+# Many years ago Gwillim Law wrote that a good source
+# for time zone data was the International Air Transport
 # Association's Standard Schedules Information Manual (IATA SSIM),
 # published semiannually.  Law sent in several helpful summaries
 # of the IATA's data after 1990.  Except where otherwise noted,
@@ -54,39 +54,33 @@
 # A reliable and entertaining source about time zones is
 # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
 #
+# European-style abbreviations are commonly used along the Mediterranean.
+# For sub-Saharan Africa abbreviations were less standardized.
 # Previous editions of this database used WAT, CAT, SAT, and EAT
-# for +0:00 through +3:00, respectively,
-# but Mark R V Murray reports that
-# 'SAST' is the official abbreviation for +2:00 in the country of South Africa,
-# 'CAT' is commonly used for +2:00 in countries north of South Africa, and
-# 'WAT' is probably the best name for +1:00, as the common phrase for
+# for UT +00 through +03, respectively,
+# but in 1997 Mark R V Murray reported that
+# 'SAST' is the official abbreviation for +02 in the country of South Africa,
+# 'CAT' is commonly used for +02 in countries north of South Africa, and
+# 'WAT' is probably the best name for +01, as the common phrase for
 # the area that includes Nigeria is "West Africa".
-# He has heard of "Western Sahara Time" for +0:00 but can find no reference.
 #
-# To make things confusing, 'WAT' seems to have been used for -1:00 long ago;
-# I'd guess that this was because people needed _some_ name for -1:00,
-# and at the time, far west Africa was the only major land area in -1:00.
-# This usage is now obsolete, as the last use of -1:00 on the African
-# mainland seems to have been 1976 in Western Sahara.
-#
-# To summarize, the following abbreviations seem to have some currency:
-#	-1:00	WAT	West Africa Time (no longer used)
-#	 0:00	GMT	Greenwich Mean Time
-#	 2:00	CAT	Central Africa Time
-#	 2:00	SAST	South Africa Standard Time
-# and Murray suggests the following abbreviation:
-#	 1:00	WAT	West Africa Time
-# I realize that this leads to 'WAT' being used for both -1:00 and 1:00
-# for times before 1976, but this is the best I can think of
-# until we get more information.
+# To summarize, the following abbreviations seemed to have some currency:
+#	 +00	GMT	Greenwich Mean Time
+#	 +02	CAT	Central Africa Time
+#	 +02	SAST	South Africa Standard Time
+# and Murray suggested the following abbreviation:
+#	 +01	WAT	West Africa Time
+# Murray's suggestion seems to have caught on in news reports and the like.
+# 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!
-#	 2:00	WAST	West Africa Summer Time
-#	 2:30	BEAT	British East Africa Time (no longer used)
-#	 2:45	BEAUT	British East Africa Unified Time (no longer used)
-#	 3:00	CAST	Central Africa Summer Time (no longer used)
-#	 3:00	SAST	South Africa Summer Time (no longer used)
-#	 3:00	EAT	East Africa Time
+#	 +02	WAST	West Africa Summer Time
+#	 +03	CAST	Central Africa Summer Time (no longer used)
+#	 +03	SAST	South Africa Summer Time (no longer used)
+#	 +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.
 
 # Algeria
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
@@ -142,19 +136,19 @@
 # Cameroon
 # See Africa/Lagos.
 
-# Cape Verde
+# Cape Verde / Cabo Verde
 #
-# Shanks gives 1907 for the transition to CVT.
+# Shanks gives 1907 for the transition to +02.
 # Perhaps the 1911-05-26 Portuguese decree
-# http://dre.pt/pdf1sdip/1911/05/12500/23132313.pdf
+# https://dre.pt/pdf1sdip/1911/05/12500/23132313.pdf
 # merely made it official?
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Atlantic/Cape_Verde -1:34:04 -	LMT	1907        # Praia
-			-2:00	-	CVT	1942 Sep
-			-2:00	1:00	CVST	1945 Oct 15
-			-2:00	-	CVT	1975 Nov 25  2:00
-			-1:00	-	CVT
+			-2:00	-	-02	1942 Sep
+			-2:00	1:00	-01	1945 Oct 15
+			-2:00	-	-02	1975 Nov 25  2:00
+			-1:00	-	-01
 
 # Central African Republic
 # See Africa/Lagos.
@@ -411,7 +405,7 @@
 Rule	Ghana	1920	1942	-	Dec	31	0:00	0	GMT
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Accra	-0:00:52 -	LMT	1918
-			 0:00	Ghana	%s
+			 0:00	Ghana	GMT/+0020
 
 # Guinea
 # See Africa/Abidjan.
@@ -420,20 +414,20 @@
 #
 # Shanks gives 1911-05-26 for the transition to WAT,
 # evidently confusing the date of the Portuguese decree
-# http://dre.pt/pdf1sdip/1911/05/12500/23132313.pdf
+# https://dre.pt/pdf1sdip/1911/05/12500/23132313.pdf
 # with the date that it took effect, namely 1912-01-01.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Bissau	-1:02:20 -	LMT	1912 Jan  1
-			-1:00	-	WAT	1975
+			-1:00	-	-01	1975
 			 0:00	-	GMT
 
 # Kenya
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Nairobi	2:27:16	-	LMT	1928 Jul
 			3:00	-	EAT	1930
-			2:30	-	BEAT	1940
-			2:45	-	BEAUT	1960
+			2:30	-	+0230	1940
+			2:45	-	+0245	1960
 			3:00	-	EAT
 Link Africa/Nairobi Africa/Addis_Ababa	 # Ethiopia
 Link Africa/Nairobi Africa/Asmara	 # Eritrea
@@ -460,7 +454,7 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Monrovia	-0:43:08 -	LMT	1882
 			-0:43:08 -	MMT	1919 Mar # Monrovia Mean Time
-			-0:44:30 -	LRT	1972 May # Liberia Time
+			-0:44:30 -	-004430	1972 May
 			 0:00	-	GMT
 
 ###############################################################################
@@ -619,7 +613,7 @@
 Rule Mauritius	2009	only	-	Mar	lastSun	2:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Indian/Mauritius	3:50:00 -	LMT	1907 # Port Louis
-			4:00 Mauritius	MU%sT	# Mauritius Time
+			4:00 Mauritius	+04/+05
 # Agalega Is, Rodriguez
 # no information; probably like Indian/Mauritius
 
@@ -938,14 +932,14 @@
 # since most of it was then controlled by Morocco.
 
 Zone Africa/El_Aaiun	-0:52:48 -	LMT	1934 Jan # El Aaiún
-			-1:00	-	WAT	1976 Apr 14
+			-1:00	-	-01	1976 Apr 14
 			 0:00	Morocco	WE%sT
 
 # Mozambique
 #
 # Shanks gives 1903-03-01 for the transition to CAT.
 # Perhaps the 1911-05-26 Portuguese decree
-# http://dre.pt/pdf1sdip/1911/05/12500/23132313.pdf
+# https://dre.pt/pdf1sdip/1911/05/12500/23132313.pdf
 # merely made it official?
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -972,16 +966,19 @@
 # the country are close to 40 minutes earlier in sunrise than the rest
 # of the country.
 #
-# From Paul Eggert (2007-03-31):
-# Apparently the Caprivi Strip informally observes Botswana time, but
-# we have no details.  In the meantime people there can use Africa/Gaborone.
+# From Paul Eggert (2017-02-22):
+# Although the Zambezi Region (formerly known as Caprivi) informally
+# observes Botswana time, we have no details about historical practice.
+# In the meantime people there can use Africa/Gaborone.
+# See: Immanuel S. The Namibian. 2017-02-23.
+# http://www.namibian.com.na/51480/read/Time-change-divides-lawmakers
 
 # RULE	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Namibia	1994	max	-	Sep	Sun>=1	2:00	1:00	S
 Rule	Namibia	1995	max	-	Apr	Sun>=1	2:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Windhoek	1:08:24 -	LMT	1892 Feb 8
-			1:30	-	SWAT	1903 Mar    # SW Africa Time
+			1:30	-	+0130	1903 Mar
 			2:00	-	SAST	1942 Sep 20  2:00
 			2:00	1:00	SAST	1943 Mar 21  2:00
 			2:00	-	SAST	1990 Mar 21 # independence
@@ -1008,7 +1005,7 @@
 # Réunion
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Indian/Reunion	3:41:52 -	LMT	1911 Jun # Saint-Denis
-			4:00	-	RET	# Réunion Time
+			4:00	-	+04
 #
 # Crozet Islands also observes Réunion time; see the 'antarctica' file.
 #
@@ -1043,7 +1040,7 @@
 # Seychelles
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Indian/Mahe	3:41:48 -	LMT	1906 Jun # Victoria
-			4:00	-	SCT	# Seychelles Time
+			4:00	-	+04
 # From Paul Eggert (2001-05-30):
 # Aldabra, Farquhar, and Desroches, originally dependencies of the
 # Seychelles, were transferred to the British Indian Ocean Territory
--- a/make/sun/javazic/tzdata/antarctica	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/antarctica	Sun May 28 23:44:03 2017 -0700
@@ -133,7 +133,8 @@
 # O'Higgins, Antarctic Peninsula, -6319-05704, since 1948-02
 # Prat, -6230-05941
 # Villa Las Estrellas (a town), around the Frei base, since 1984-04-09
-# These locations have always used Santiago time; use TZ='America/Santiago'.
+# These locations employ Region of Magallanes time; use
+# TZ='America/Punta_Arenas'.
 
 # China - year-round bases
 # Great Wall, King George Island, -6213-05858, since 1985-02-20
--- a/make/sun/javazic/tzdata/asia	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/asia	Sun May 28 23:44:03 2017 -0700
@@ -29,15 +29,15 @@
 # tz@iana.org for general use in the future).  For more, please see
 # the file CONTRIBUTING in the tz distribution.
 
-# From Paul Eggert (2015-08-08):
+# From Paul Eggert (2017-01-13):
 #
 # Unless otherwise specified, the source for data through 1990 is:
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
 # San Diego: ACS Publications, Inc. (2003).
 # Unfortunately this book contains many errors and cites no sources.
 #
-# Gwillim Law writes that a good source
-# for recent time zone data is the International Air Transport
+# Many years ago Gwillim Law wrote that a good source
+# for time zone data was the International Air Transport
 # Association's Standard Schedules Information Manual (IATA SSIM),
 # published semiannually.  Law sent in several helpful summaries
 # of the IATA's data after 1990.  Except where otherwise noted,
@@ -58,29 +58,24 @@
 # A reliable and entertaining source about time zones is
 # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
 #
-# I invented the abbreviations marked '*' in the following table;
-# the rest are from earlier versions of this file, or from other sources.
-# Corrections are welcome!
+# The following alphabetic abbreviations appear in these tables:
 #	     std  dst
 #	     LMT	Local Mean Time
 #	2:00 EET  EEST	Eastern European Time
 #	2:00 IST  IDT	Israel
-#	3:00 AST  ADT	Arabia*
-#	3:30 IRST IRDT	Iran*
-#	4:00 GST	Gulf*
 #	5:30 IST	India
-#	7:00 ICT	Indochina, most times and locations*
 #	7:00 WIB	west Indonesia (Waktu Indonesia Barat)
 #	8:00 WITA	central Indonesia (Waktu Indonesia Tengah)
 #	8:00 CST	China
-#	8:00 IDT	Indochina, 1943-45, 1947-55, 1960-75 (some locations)*
-#	8:00 JWST	Western Standard Time (Japan, 1896/1937)*
-#	8:30 KST  KDT	Korea when at +0830*
-#	9:00 JCST	Central Standard Time (Japan, 1896/1937)
+#	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
+# Otherwise, these tables typically use numeric abbreviations like +03
+# and +0330 for integer hour and minute UTC offsets.  Although earlier
+# editions invented alphabetic time zone abbreviations for every
+# offset, this did not reflect common practice.
 #
 # See the 'europe' file for Russia and Turkey in Asia.
 
@@ -88,7 +83,7 @@
 # Incorporates data for Singapore from Robert Elz' asia 1.1, as well as
 # additional information from Tom Yap, Sun Microsystems Intercontinental
 # Technical Support (including a page from the Official Airline Guide -
-# Worldwide Edition).  The names for time zones are guesses.
+# Worldwide Edition).
 
 ###############################################################################
 
@@ -109,8 +104,8 @@
 # Afghanistan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Kabul	4:36:48 -	LMT	1890
-			4:00	-	AFT	1945
-			4:30	-	AFT
+			4:00	-	+04	1945
+			4:30	-	+0430
 
 # Armenia
 # From Paul Eggert (2006-03-22):
@@ -253,18 +248,17 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dhaka	6:01:40 -	LMT	1890
 			5:53:20	-	HMT	1941 Oct    # Howrah Mean Time?
-			6:30	-	BURT	1942 May 15 # Burma Time
-			5:30	-	IST	1942 Sep
-			6:30	-	BURT	1951 Sep 30
-			6:00	-	DACT	1971 Mar 26 # Dacca Time
-			6:00	-	BDT	2009
-			6:00	Dhaka	BD%sT
+			6:30	-	+0630	1942 May 15
+			5:30	-	+0530	1942 Sep
+			6:30	-	+0630	1951 Sep 30
+			6:00	-	+06	2009
+			6:00	Dhaka	+06/+07
 
 # Bhutan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Thimphu	5:58:36 -	LMT	1947 Aug 15 # or Thimbu
-			5:30	-	IST	1987 Oct
-			6:00	-	BTT	# Bhutan Time
+			5:30	-	+0530	1987 Oct
+			6:00	-	+06
 
 # British Indian Ocean Territory
 # Whitman and the 1995 CIA time zone map say 5:00, but the
@@ -274,14 +268,14 @@
 # then contained the Chagos Archipelago).
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Indian/Chagos	4:49:40	-	LMT	1907
-			5:00	-	IOT	1996 # BIOT Time
-			6:00	-	IOT
+			5:00	-	+05	1996
+			6:00	-	+06
 
 # Brunei
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Brunei	7:39:40 -	LMT	1926 Mar # Bandar Seri Begawan
-			7:30	-	BNT	1933
-			8:00	-	BNT
+			7:30	-	+0730	1933
+			8:00	-	+08
 
 # Burma / Myanmar
 
@@ -290,9 +284,9 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Yangon	6:24:40 -	LMT	1880        # or Rangoon
 			6:24:40	-	RMT	1920        # Rangoon Mean Time?
-			6:30	-	BURT	1942 May    # Burma Time
-			9:00	-	JST	1945 May  3
-			6:30	-	MMT	# Myanmar Time
+			6:30	-	+0630	1942 May
+			9:00	-	+09	1945 May  3
+			6:30	-	+0630
 
 # Cambodia
 # See Asia/Bangkok.
@@ -355,7 +349,7 @@
 # (could be true), for the moment I am assuming that those two
 # counties are mistakes in the astro.com data.
 
-# From Paul Eggert (2014-06-30):
+# From Paul Eggert (2017-01-05):
 # Alois Treindl kindly sent me translations of the following two sources:
 #
 # (1)
@@ -413,28 +407,26 @@
 # mainly observed in coastal areas), the five zones were:
 #
 # Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT +08:30
-# Asia/Harbin (currently a link to Asia/Shanghai)
+# Now part of Asia/Shanghai; its pre-1970 times are not recorded here.
 # Heilongjiang (except Mohe county), Jilin
 #
 # Zhongyuan Time ("Central plain Time") UT +08
-# Asia/Shanghai
+# Now part of Asia/Shanghai.
 # most of China
-# This currently represents most other zones as well,
-# as apparently these regions have been the same since 1970.
 # Milne gives 8:05:43.2 for Xujiahui Observatory time; round to nearest.
 # Guo says Shanghai switched to UT +08 "from the end of the 19th century".
 #
-# Long-shu Time (probably due to Long and Shu being two names of the area) UT +07
-# Asia/Chongqing (currently a link to Asia/Shanghai)
+# Long-shu Time (probably as Long and Shu were two names of the area) UT +07
+# Now part of Asia/Shanghai; its pre-1970 times are not recorded here.
 # Guangxi, Guizhou, Hainan, Ningxia, Sichuan, Shaanxi, and Yunnan;
-# most of Gansu; west Inner Mongolia; west Qinghai; and the Guangdong
+# most of Gansu; west Inner Mongolia; east Qinghai; and the Guangdong
 # counties Deqing, Enping, Kaiping, Luoding, Taishan, Xinxing,
 # Yangchun, Yangjiang, Yu'nan, and Yunfu.
 #
 # Xin-zang Time ("Xinjiang-Tibet Time") UT +06
-# Asia/Urumqi
-# This currently represents Kunlun Time as well,
-# as apparently the two regions have been the same since 1970.
+# This region is now part of either Asia/Urumqi or Asia/Shanghai with
+# current boundaries uncertain; times before 1970 for areas that
+# disagree with Ürümqi or Shanghai are not recorded here.
 # The Gansu counties Aksay, Anxi, Dunhuang, Subei; west Qinghai;
 # the Guangdong counties  Xuwen, Haikang, Suixi, Lianjiang,
 # Zhanjiang, Wuchuan, Huazhou, Gaozhou, Maoming, Dianbai, and Xinyi;
@@ -445,7 +437,7 @@
 # Fukang, Kuitun, Kumukuli, Miquan, Qitai, and Turfan.
 #
 # Kunlun Time UT +05:30
-# Asia/Kashgar (currently a link to Asia/Urumqi)
+# This region is now in the same status as Xin-zang Time (see above).
 # West Tibet, including Pulan, Aheqi, Shufu, Shule;
 # West Xinjiang, including Aksu, Atushi, Yining, Hetian, Cele, Luopu, Nileke,
 # Zhaosu, Tekesi, Gongliu, Chabuchaer, Huocheng, Bole, Pishan, Suiding,
@@ -546,7 +538,7 @@
 # Xinjiang time, used by many in western China; represented by Ürümqi / Ürümchi
 # / Wulumuqi.  (Please use Asia/Shanghai if you prefer Beijing time.)
 Zone	Asia/Urumqi	5:50:20	-	LMT	1928
-			6:00	-	XJT
+			6:00	-	+06
 
 
 # Hong Kong (Xianggang)
@@ -765,30 +757,29 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Taipei or Taibei or T'ai-pei
 Zone	Asia/Taipei	8:06:00 -	LMT	1896 Jan  1
-			8:00	-	JWST	1937 Oct  1
+			8:00	-	CST	1937 Oct  1
 			9:00	-	JST	1945 Sep 21  1:00
 			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	S
-Rule	Macau	1961	1964	-	Nov	Sun>=1	3:30	0	-
-Rule	Macau	1963	only	-	Mar	Sun>=16	0:00	1:00	S
-Rule	Macau	1964	only	-	Mar	Sun>=16	3:30	1:00	S
-Rule	Macau	1965	only	-	Mar	Sun>=16	0:00	1:00	S
-Rule	Macau	1965	only	-	Oct	31	0:00	0	-
-Rule	Macau	1966	1971	-	Apr	Sun>=16	3:30	1:00	S
-Rule	Macau	1966	1971	-	Oct	Sun>=16	3:30	0	-
-Rule	Macau	1972	1974	-	Apr	Sun>=15	0:00	1:00	S
-Rule	Macau	1972	1973	-	Oct	Sun>=15	0:00	0	-
-Rule	Macau	1974	1977	-	Oct	Sun>=15	3:30	0	-
-Rule	Macau	1975	1977	-	Apr	Sun>=15	3:30	1:00	S
-Rule	Macau	1978	1980	-	Apr	Sun>=15	0:00	1:00	S
-Rule	Macau	1978	1980	-	Oct	Sun>=15	0:00	0	-
+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
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Macau	7:34:20 -	LMT	1912 Jan  1
-			8:00	Macau	MO%sT	1999 Dec 20 # return to China
-			8:00	PRC	C%sT
+			8:00	Macau	C%sT
 
 
 ###############################################################################
@@ -904,11 +895,10 @@
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dili	8:22:20 -	LMT	1912 Jan  1
-			8:00	-	TLT	1942 Feb 21 23:00 # E Timor Time
-			9:00	-	JST	1945 Sep 23
-			9:00	-	TLT	1976 May  3
-			8:00	-	WITA	2000 Sep 17  0:00
-			9:00	-	TLT
+			8:00	-	+08	1942 Feb 21 23:00
+			9:00	-	+09	1976 May  3
+			8:00	-	+08	2000 Sep 17  0:00
+			9:00	-	+09
 
 # India
 
@@ -923,9 +913,9 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Kolkata	5:53:28 -	LMT	1880        # Kolkata
 			5:53:20	-	HMT	1941 Oct    # Howrah Mean Time?
-			6:30	-	BURT	1942 May 15 # Burma Time
+			6:30	-	+0630	1942 May 15
 			5:30	-	IST	1942 Sep
-			5:30	1:00	IST	1945 Oct 15
+			5:30	1:00	+0630	1945 Oct 15
 			5:30	-	IST
 # The following are like Asia/Kolkata:
 #	Andaman Is
@@ -976,33 +966,33 @@
 # Shanks & Pottenger say the next transition was at 1924 Jan 1 0:13,
 # but this must be a typo.
 			7:07:12	-	BMT	1923 Dec 31 23:47:12 # Batavia
-			7:20	-	JAVT	1932 Nov    # Java Time
-			7:30	-	WIB	1942 Mar 23
-			9:00	-	JST	1945 Sep 23
-			7:30	-	WIB	1948 May
-			8:00	-	WIB	1950 May
-			7:30	-	WIB	1964
+			7:20	-	+0720	1932 Nov
+			7:30	-	+0730	1942 Mar 23
+			9:00	-	+09	1945 Sep 23
+			7:30	-	+0730	1948 May
+			8:00	-	+08	1950 May
+			7:30	-	+0730	1964
 			7:00	-	WIB
 # west and central Borneo
 Zone Asia/Pontianak	7:17:20	-	LMT	1908 May
 			7:17:20	-	PMT	1932 Nov    # Pontianak MT
-			7:30	-	WIB	1942 Jan 29
-			9:00	-	JST	1945 Sep 23
-			7:30	-	WIB	1948 May
-			8:00	-	WIB	1950 May
-			7:30	-	WIB	1964
+			7:30	-	+0730	1942 Jan 29
+			9:00	-	+09	1945 Sep 23
+			7:30	-	+0730	1948 May
+			8:00	-	+08	1950 May
+			7:30	-	+0730	1964
 			8:00	-	WITA	1988 Jan  1
 			7:00	-	WIB
 # Sulawesi, Lesser Sundas, east and south Borneo
 Zone Asia/Makassar	7:57:36 -	LMT	1920
 			7:57:36	-	MMT	1932 Nov    # Macassar MT
-			8:00	-	WITA	1942 Feb  9
-			9:00	-	JST	1945 Sep 23
+			8:00	-	+08	1942 Feb  9
+			9:00	-	+09	1945 Sep 23
 			8:00	-	WITA
 # Maluku Islands, West Papua, Papua
 Zone Asia/Jayapura	9:22:48 -	LMT	1932 Nov
-			9:00	-	WIT	1944 Sep  1
-			9:30	-	ACST	1964
+			9:00	-	+09	1944 Sep  1
+			9:30	-	+0930	1964
 			9:00	-	WIT
 
 # Iran
@@ -1034,8 +1024,6 @@
 # for at least the last 5 years.  Before that, for a few years, the
 # date used was the first Thursday night of Farvardin and the last
 # Thursday night of Shahrivar, but I can't give exact dates....
-# I have also changed the abbreviations to what is considered correct
-# here in Iran, IRST for regular time and IRDT for daylight saving time.
 #
 # From Roozbeh Pournader (2005-04-05):
 # The text of the Iranian law, in effect since 1925, clearly mentions
@@ -1142,9 +1130,9 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Tehran	3:25:44	-	LMT	1916
 			3:25:44	-	TMT	1946     # Tehran Mean Time
-			3:30	-	IRST	1977 Nov
-			4:00	Iran	IR%sT	1979
-			3:30	Iran	IR%sT
+			3:30	-	+0330	1977 Nov
+			4:00	Iran	+04/+05	1979
+			3:30	Iran	+0330/+0430
 
 
 # Iraq
@@ -1187,8 +1175,8 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Baghdad	2:57:40	-	LMT	1890
 			2:57:36	-	BMT	1918     # Baghdad Mean Time?
-			3:00	-	AST	1982 May
-			3:00	Iraq	A%sT
+			3:00	-	+03	1982 May
+			3:00	Iraq	+03/+04
 
 
 ###############################################################################
@@ -1487,8 +1475,6 @@
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Tokyo	9:18:59	-	LMT	1887 Dec 31 15:00u
-			9:00	-	JST	1896 Jan  1
-			9:00	-	JCST	1937 Oct  1
 			9:00	Japan	J%sT
 # Since 1938, all Japanese possessions have been like Asia/Tokyo.
 
@@ -1606,12 +1592,12 @@
 # was "blended" with the Central zone.  Therefore, Kazakhstan now has
 # two time zones, and difference between them is one hour.  The zone
 # closer to UTC is the former Western zone (probably still called the
-# same), encompassing four provinces in the west: Aqtobe, Atyrau,
-# Mangghystau, and West Kazakhstan.  The other zone encompasses
+# same), encompassing four provinces in the west: Aqtöbe, Atyraū,
+# Mangghystaū, and West Kazakhstan.  The other zone encompasses
 # everything else....  I guess that would make Kazakhstan time zones
 # de jure UTC+5 and UTC+6 respectively.
 
-# From Stepan Golosunov (2016-03-27) ([*] means see later comments below):
+# From Stepan Golosunov (2016-03-27):
 # Review of the linked documents from http://adilet.zan.kz/
 # produced the following data for post-1991 Kazakhstan:
 #
@@ -1657,7 +1643,7 @@
 #
 # This implies that on 1991-03-31 Asia/Oral remained on +04/+05 while
 # the rest of Kazakhstan switched from +06/+07 to +05/06 or from +05/06
-# to +04/+05. It's unclear how Kzyl-Orda oblast moved into the fifth
+# to +04/+05. It's unclear how Qyzylorda oblast moved into the fifth
 # time belt. (By switching from +04/+05 to +05/+06 on 1991-09-29?) ...
 #
 # 1. Act of the Cabinet of Ministers of the Republic of Kazakhstan
@@ -1670,25 +1656,25 @@
 # on the whole territory of Kazakhstan 1 hour forward on 1992-01-19 at
 # 2:00, specified DST rules.  It acknowledged that Kazakhstan was
 # located in the fourth and the fifth time belts and specified the
-# border between them to be located east of Kustanay and Aktyubinsk
-# oblasts (notably including Turgai and Kzyl-Orda oblasts into the fifth
+# border between them to be located east of Qostanay and Aktyubinsk
+# oblasts (notably including Turgai and Qyzylorda oblasts into the fifth
 # time belt).
 #
 # This means switch on 1992-01-19 at 2:00 from +04/+05 to +05/+06 for
-# Asia/Aqtau, Asia/Aqtobe, Asia/Oral, Atyrau and Kustanay oblasts; from
-# +05/+06 to +06/+07 for Asia/Almaty and Asia/Qyzylorda (and Arkalyk) [*]....
+# Asia/Aqtau, Asia/Aqtobe, Asia/Oral, Atyraū and Qostanay oblasts; from
+# +05/+06 to +06/+07 for Asia/Almaty and Asia/Qyzylorda (and Arkalyk)....
 #
 # 2. Act of the Cabinet of Ministers of the Republic of Kazakhstan
 # from 1992-03-27 No. 284
 # http://adilet.zan.kz/rus/docs/P920000284_
-# cancels extra hour ("decree time") for Uralsk and Kzyl-Orda oblasts
+# cancels extra hour ("decree time") for Uralsk and Qyzylorda oblasts
 # since the last Sunday of March 1992, while keeping them in the fourth
 # and the fifth time belts respectively.
 #
 # 3. Order of the Prime Minister of the Republic of Kazakhstan
 # from 1994-09-23 No. 384
 # http://adilet.zan.kz/rus/docs/R940000384_
-# cancels the extra hour ("decree time") on the territory of Mangystau
+# cancels the extra hour ("decree time") on the territory of Mangghystaū
 # oblast since the last Sunday of September 1994 (saying that time on
 # the territory would correspond to the third time belt as a
 # result)....
@@ -1702,14 +1688,11 @@
 # 5. Act of the Government of the Republic of Kazakhstan
 # from 1999-03-26 No. 305
 # http://adilet.zan.kz/rus/docs/P990000305_
-# cancels the extra hour ("decree time") for Atyrau oblast since the
+# cancels the extra hour ("decree time") for Atyraū oblast since the
 # last Sunday of March 1999 while retaining the oblast in the fourth
 # time belt.
 #
-# This means change from +05/+06 to +04/+05.
-#
-# There is no zone for Atyrau currently (listed under Asia/Aqtau in
-# zone1970.tab).[*]
+# This means change from +05/+06 to +04/+05....
 #
 # 6. Act of the Government of the Republic of Kazakhstan
 # from 2000-11-23 No. 1749
@@ -1719,10 +1702,10 @@
 # The only changes I noticed are in definition of the border between the
 # fourth and the fifth time belts.  They account for changes in spelling
 # and administrative division (splitting of Turgai oblast in 1997
-# probably changed time in territories incorporated into Kostanay oblast
-# (including Arkalyk) from +06/+07 to +05/+06) and move Kyzylorda oblast
+# probably changed time in territories incorporated into Qostanay oblast
+# (including Arkalyk) from +06/+07 to +05/+06) and move Qyzylorda oblast
 # from being in the fifth time belt and not using decree time into the
-# fourth time belt (no change in practice).[*]
+# fourth time belt (no change in practice).
 #
 # 7. Act of the Government of the Republic of Kazakhstan
 # from 2003-12-29 No. 1342
@@ -1732,7 +1715,7 @@
 # 8. Act of the Government of the Republic of Kazakhstan
 # from 2004-07-20 No. 775
 # http://adilet.zan.kz/rus/archive/docs/P040000775_/20.07.2004
-# modified the 2000-11-23 act to move Kostanay and Kyzylorda oblasts into
+# modified the 2000-11-23 act to move Qostanay and Qyzylorda oblasts into
 # the fifth time belt and add Aktobe oblast to the list of regions not
 # using extra hour ("decree time"), leaving Kazakhstan with only 2 time
 # zones (+04/+05 and +06/+07).  The changes were to be implemented
@@ -1744,14 +1727,14 @@
 # http://adilet.zan.kz/rus/docs/P040001059_
 # modified the 2000-11-23 act to remove exceptions from the "decree time"
 # (leaving Kazakhstan in +05/+06 and +06/+07 zones), amended the
-# 2004-07-20 act to implement changes for Atyrau, West Kazakhstan,
-# Kostanay, Kyzylorda and Mangystau oblasts by not moving clocks
-# during the 2014 transition to "winter" time.
+# 2004-07-20 act to implement changes for Atyraū, West Kazakhstan,
+# Qostanay, Qyzylorda and Mangghystaū oblasts by not moving clocks
+# during the 2004 transition to "winter" time.
 #
-# This means transition from +04/+05 to +05/+06 for Atyrau oblast (no
+# This means transition from +04/+05 to +05/+06 for Atyraū oblast (no
 # zone currently), Asia/Oral, Asia/Aqtau and transition from +05/+06 to
-# +06/+07 for Kostanay oblast (Kostanay and Arkalyk, no zones currently)
-# and Asia/Qyzylorda on 2004-10-31 at 3:00....[*]
+# +06/+07 for Qostanay oblast (Qostanay and Arkalyk, no zones currently)
+# and Asia/Qyzylorda on 2004-10-31 at 3:00....
 #
 # 10. Act of the Government of the Republic of Kazakhstan
 # from 2005-03-15 No. 231
@@ -1767,14 +1750,25 @@
 # Kazakh 1992-01-13 act appears to provide the same rules and 1992-03-27
 # act was to be enacted on the last Sunday of March 1992.
 
-# From Paul Eggert (2016-04-15):
-# The tables below should reflect Stepan Golosunov's remarks above,
-# except for the items marked "[*]" which I haven't gotten to yet.
-# It looks like we will need new zones Asia/Atyrau and Asia/Qostanay
-# to handle changes from 1992 through 2004 that we did not previously
-# know about.
+# From Stepan Golosunov (2016-11-08):
+# Turgai reorganization should affect only southern part of Qostanay
+# oblast.  Which should probably be separated into Asia/Arkalyk zone.
+# (There were also 1970, 1988 and 1990 Turgai oblast reorganizations
+# according to wikipedia.)
+#
+# [For Qostanay] http://www.ng.kz/gazeta/195/hranit/
+# suggests that clocks were to be moved 40 minutes backwards on
+# 1920-01-01 to the fourth time belt.  But I do not understand
+# how that could happen....
+#
+# [For Atyrau and Oral] 1919 decree
+# (http://www.worldtimezone.com/dst_news/dst_news_russia-1919-02-08.html
+# and in Byalokoz) lists Ural river (plus 10 versts on its left bank) in
+# the third time belt (before 1930 this means +03).
 
-#
+# From Paul Eggert (2016-12-06):
+# The tables below reflect Golosunov's remarks, with exceptions as noted.
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
 # Almaty (formerly Alma-Ata), representing most locations in Kazakhstan
@@ -1787,6 +1781,8 @@
 			6:00 RussiaAsia	+06/+07	2004 Oct 31  2:00s
 			6:00	-	+06
 # Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) (KZ-KZY)
+# This currently includes Qostanay (aka Kostanay, Kustanay) (KZ-KUS);
+# see comments below.
 Zone	Asia/Qyzylorda	4:21:52 -	LMT	1924 May  2
 			4:00	-	+04	1930 Jun 21
 			5:00	-	+05	1981 Apr  1
@@ -1798,7 +1794,21 @@
 			6:00 RussiaAsia	+06/+07	1992 Mar 29  2:00s
 			5:00 RussiaAsia	+05/+06	2004 Oct 31  2:00s
 			6:00	-	+06
-# Aqtobe (aka Aktobe, formerly Aktyubinsk) (KZ-AKT)
+# The following zone is like Asia/Qyzylorda except for being one
+# hour earlier from 1991-09-29 to 1992-03-29.  The 1991/2 rules for
+# Qostanay are unclear partly because of the 1997 Turgai
+# reorganization, so this zone is commented out for now.
+#Zone	Asia/Qostanay	4:14:20 -	LMT	1924 May  2
+#			4:00	-	+04	1930 Jun 21
+#			5:00	-	+05	1981 Apr  1
+#			5:00	1:00	+06	1981 Oct  1
+#			6:00	-	+06	1982 Apr  1
+#			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00s
+#			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00s
+#			5:00 RussiaAsia	+05/+06	2004 Oct 31  2:00s
+#			6:00	-	+06
+#
+# Aqtöbe (aka Aktobe, formerly Aktyubinsk) (KZ-AKT)
 Zone	Asia/Aqtobe	3:48:40	-	LMT	1924 May  2
 			4:00	-	+04	1930 Jun 21
 			5:00	-	+05	1981 Apr  1
@@ -1808,14 +1818,11 @@
 			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00s
 			5:00 RussiaAsia	+05/+06	2004 Oct 31  2:00s
 			5:00	-	+05
-# Qostanay (KZ-KUS)
-
-# Mangghystau (KZ-MAN)
+# Mangghystaū (KZ-MAN)
 # Aqtau was not founded until 1963, but it represents an inhabited region,
 # so include time stamps before 1963.
 Zone	Asia/Aqtau	3:21:04	-	LMT	1924 May  2
 			4:00	-	+04	1930 Jun 21
-			5:00	-	+05	1963
 			5:00	-	+05	1981 Oct  1
 			6:00	-	+06	1982 Apr  1
 			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00s
@@ -1823,12 +1830,22 @@
 			5:00 RussiaAsia	+05/+06	1994 Sep 25  2:00s
 			4:00 RussiaAsia	+04/+05	2004 Oct 31  2:00s
 			5:00	-	+05
-
+# Atyraū (KZ-ATY) is like Mangghystaū except it switched from
+# +04/+05 to +05/+06 in spring 1999, not fall 1994.
+Zone	Asia/Atyrau	3:27:44	-	LMT	1924 May  2
+			3:00	-	+03	1930 Jun 21
+			5:00	-	+05	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00s
+			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00s
+			5:00 RussiaAsia	+05/+06	1999 Mar 28  2:00s
+			4:00 RussiaAsia	+04/+05	2004 Oct 31  2:00s
+			5:00	-	+05
 # West Kazakhstan (KZ-ZAP)
 # From Paul Eggert (2016-03-18):
 # The 1989 transition is from USSR act No. 227 (1989-03-14).
 Zone	Asia/Oral	3:25:24	-	LMT	1924 May  2 # or Ural'sk
-			4:00	-	+04	1930 Jun 21
+			3:00	-	+03	1930 Jun 21
 			5:00	-	+05	1981 Apr  1
 			5:00	1:00	+06	1981 Oct  1
 			6:00	-	+06	1982 Apr  1
@@ -1934,14 +1951,12 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Seoul	8:27:52	-	LMT	1908 Apr  1
 			8:30	-	KST	1912 Jan  1
-			9:00	-	JCST	1937 Oct  1
 			9:00	-	JST	1945 Sep  8
 			9:00	-	KST	1954 Mar 21
 			8:30	ROK	K%sT	1961 Aug 10
 			9:00	ROK	K%sT
 Zone	Asia/Pyongyang	8:23:00 -	LMT	1908 Apr  1
 			8:30	-	KST	1912 Jan  1
-			9:00	-	JCST	1937 Oct  1
 			9:00	-	JST	1945 Aug 24
 			9:00	-	KST	2015 Aug 15 00:00
 			8:30	-	KST
@@ -1996,30 +2011,29 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Asia/Kuala_Lumpur	6:46:46 -	LMT	1901 Jan  1
 			6:55:25	-	SMT	1905 Jun  1 # Singapore M.T.
-			7:00	-	MALT	1933 Jan  1 # Malaya Time
-			7:00	0:20	MALST	1936 Jan  1
-			7:20	-	MALT	1941 Sep  1
-			7:30	-	MALT	1942 Feb 16
-			9:00	-	JST	1945 Sep 12
-			7:30	-	MALT	1982 Jan  1
-			8:00	-	MYT	# Malaysia Time
+			7:00	-	+07	1933 Jan  1
+			7:00	0:20	+0720	1936 Jan  1
+			7:20	-	+0720	1941 Sep  1
+			7:30	-	+0730	1942 Feb 16
+			9:00	-	+09	1945 Sep 12
+			7:30	-	+0730	1982 Jan  1
+			8:00	-	+08
 # Sabah & Sarawak
 # From Paul Eggert (2014-08-12):
 # The data entries here are mostly from Shanks & Pottenger, but the 1942, 1945
 # and 1982 transition dates are from Mok Ly Yng.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Asia/Kuching	7:21:20	-	LMT	1926 Mar
-			7:30	-	BORT	1933        # Borneo Time
-			8:00	NBorneo	BOR%sT	1942 Feb 16
-			9:00	-	JST	1945 Sep 12
-			8:00	-	BORT	1982 Jan  1
-			8:00	-	MYT
+			7:30	-	+0730	1933
+			8:00 NBorneo  +08/+0820	1942 Feb 16
+			9:00	-	+09	1945 Sep 12
+			8:00	-	+08
 
 # Maldives
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Indian/Maldives	4:54:00 -	LMT	1880 # Male
 			4:54:00	-	MMT	1960 # Male Mean Time
-			5:00	-	MVT	# Maldives Time
+			5:00	-	+05
 
 # Mongolia
 
@@ -2146,37 +2160,41 @@
 # correction of 02:00 (in the previous edition) not being done correctly
 # in the latest edition; so ignore it for now.
 
+# From Ganbold Tsagaankhuu (2017-02-09):
+# Mongolian Government meeting has concluded today to cancel daylight
+# saving time adoption in Mongolia.  Source: http://zasag.mn/news/view/16192
+
 Rule	Mongol	1985	1998	-	Mar	lastSun	0:00	1:00	S
 Rule	Mongol	1984	1998	-	Sep	lastSun	0:00	0	-
 # IATA SSIM (1999-09) says Mongolia no longer observes DST.
 Rule	Mongol	2001	only	-	Apr	lastSat	2:00	1:00	S
 Rule	Mongol	2001	2006	-	Sep	lastSat	2:00	0	-
 Rule	Mongol	2002	2006	-	Mar	lastSat	2:00	1:00	S
-Rule	Mongol	2015	max	-	Mar	lastSat	2:00	1:00	S
-Rule	Mongol	2015	max	-	Sep	lastSat	0:00	0	-
+Rule	Mongol	2015	2016	-	Mar	lastSat	2:00	1:00	S
+Rule	Mongol	2015	2016	-	Sep	lastSat	0:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Hovd, a.k.a. Chovd, Dund-Us, Dzhargalant, Khovd, Jirgalanta
 Zone	Asia/Hovd	6:06:36 -	LMT	1905 Aug
-			6:00	-	HOVT	1978     # Hovd Time
-			7:00	Mongol	HOV%sT
+			6:00	-	+06	1978
+			7:00	Mongol	+07/+08
 # Ulaanbaatar, a.k.a. Ulan Bataar, Ulan Bator, Urga
 Zone	Asia/Ulaanbaatar 7:07:32 -	LMT	1905 Aug
-			7:00	-	ULAT	1978     # Ulaanbaatar Time
-			8:00	Mongol	ULA%sT
+			7:00	-	+07	1978
+			8:00	Mongol	+08/+09
 # Choibalsan, a.k.a. Bajan Tümen, Bajan Tumen, Chojbalsan,
 # Choybalsan, Sanbejse, Tchoibalsan
 Zone	Asia/Choibalsan	7:38:00 -	LMT	1905 Aug
-			7:00	-	ULAT	1978
-			8:00	-	ULAT	1983 Apr
-			9:00	Mongol	CHO%sT	2008 Mar 31 # Choibalsan Time
-			8:00	Mongol	CHO%sT
+			7:00	-	+07	1978
+			8:00	-	+08	1983 Apr
+			9:00	Mongol	+09/+10	2008 Mar 31
+			8:00	Mongol	+08/+09
 
 # Nepal
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Kathmandu	5:41:16 -	LMT	1920
-			5:30	-	IST	1986
-			5:45	-	NPT	# Nepal Time
+			5:30	-	+0530	1986
+			5:45	-	+0545
 
 # Oman
 # See Asia/Dubai.
@@ -2325,10 +2343,10 @@
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Karachi	4:28:12 -	LMT	1907
-			5:30	-	IST	1942 Sep
-			5:30	1:00	IST	1945 Oct 15
-			5:30	-	IST	1951 Sep 30
-			5:00	-	KART	1971 Mar 26 # Karachi Time
+			5:30	-	+0530	1942 Sep
+			5:30	1:00	+0630	1945 Oct 15
+			5:30	-	+0530	1951 Sep 30
+			5:00	-	+05	1971 Mar 26
 			5:00 Pakistan	PK%sT	# Pakistan Time
 
 # Palestine
@@ -2639,7 +2657,7 @@
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Gaza	2:17:52	-	LMT	1900 Oct
-			2:00	Zion	EET	1948 May 15
+			2:00	Zion	EET/EEST 1948 May 15
 			2:00 EgyptAsia	EE%sT	1967 Jun  5
 			2:00	Zion	I%sT	1996
 			2:00	Jordan	EE%sT	1999
@@ -2652,7 +2670,7 @@
 			2:00 Palestine	EE%sT
 
 Zone	Asia/Hebron	2:20:23	-	LMT	1900 Oct
-			2:00	Zion	EET	1948 May 15
+			2:00	Zion	EET/EEST 1948 May 15
 			2:00 EgyptAsia	EE%sT	1967 Jun  5
 			2:00	Zion	I%sT	1996
 			2:00	Jordan	EE%sT	1999
@@ -2693,15 +2711,15 @@
 # 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	PH%sT	1942 May
-			9:00	-	JST	1944 Nov
-			8:00	Phil	PH%sT
+			8:00	Phil	+08/+09	1942 May
+			9:00	-	+09	1944 Nov
+			8:00	Phil	+08/+09
 
 # Qatar
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Qatar	3:26:08 -	LMT	1920     # Al Dawhah / Doha
-			4:00	-	GST	1972 Jun
-			3:00	-	AST
+			4:00	-	+04	1972 Jun
+			3:00	-	+03
 Link Asia/Qatar Asia/Bahrain
 
 # Saudi Arabia
@@ -2728,7 +2746,7 @@
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Riyadh	3:06:52 -	LMT	1947 Mar 14
-			3:00	-	AST
+			3:00	-	+03
 Link Asia/Riyadh Asia/Aden	# Yemen
 Link Asia/Riyadh Asia/Kuwait
 
@@ -2738,14 +2756,13 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Singapore	6:55:25 -	LMT	1901 Jan  1
 			6:55:25	-	SMT	1905 Jun  1 # Singapore M.T.
-			7:00	-	MALT	1933 Jan  1 # Malaya Time
-			7:00	0:20	MALST	1936 Jan  1
-			7:20	-	MALT	1941 Sep  1
-			7:30	-	MALT	1942 Feb 16
-			9:00	-	JST	1945 Sep 12
-			7:30	-	MALT	1965 Aug  9 # independence
-			7:30	-	SGT	1982 Jan  1 # Singapore Time
-			8:00	-	SGT
+			7:00	-	+07	1933 Jan  1
+			7:00	0:20	+0720	1936 Jan  1
+			7:20	-	+0720	1941 Sep  1
+			7:30	-	+0730	1942 Feb 16
+			9:00	-	+09	1945 Sep 12
+			7:30	-	+0730	1982 Jan  1
+			8:00	-	+08
 
 # Spratly Is
 # no information
@@ -2804,8 +2821,8 @@
 Zone	Asia/Colombo	5:19:24 -	LMT	1880
 			5:19:32	-	MMT	1906        # Moratuwa Mean Time
 			5:30	-	+0530	1942 Jan  5
-			5:30	0:30	+0530/+06 1942 Sep
-			5:30	1:00	+0530/+0630 1945 Oct 16  2:00
+			5:30	0:30	+06	1942 Sep
+			5:30	1:00	+0630	1945 Oct 16  2:00
 			5:30	-	+0530	1996 May 25  0:00
 			6:30	-	+0630	1996 Oct 26  0:30
 			6:00	-	+06	2006 Apr 15  0:30
@@ -2987,7 +3004,7 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Bangkok	6:42:04	-	LMT	1880
 			6:42:04	-	BMT	1920 Apr # Bangkok Mean Time
-			7:00	-	ICT
+			7:00	-	+07
 Link Asia/Bangkok Asia/Phnom_Penh	# Cambodia
 Link Asia/Bangkok Asia/Vientiane	# Laos
 
@@ -3003,7 +3020,7 @@
 # United Arab Emirates
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dubai	3:41:12 -	LMT	1920
-			4:00	-	GST
+			4:00	-	+04
 Link Asia/Dubai Asia/Muscat	# Oman
 
 # Uzbekistan
@@ -3076,15 +3093,15 @@
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Asia/Ho_Chi_Minh	7:06:40 -	LMT	1906 Jul  1
-			7:06:30	-	PLMT	1911 May  1
-			7:00	-	ICT	1942 Dec 31 23:00
-			8:00	-	IDT	1945 Mar 14 23:00
-			9:00	-	JST	1945 Sep  2
-			7:00	-	ICT	1947 Apr  1
-			8:00	-	IDT	1955 Jul  1
-			7:00	-	ICT	1959 Dec 31 23:00
-			8:00	-	IDT	1975 Jun 13
-			7:00	-	ICT
+			7:06:30	-	PLMT	1911 May  1 # Phù Liễn MT
+			7:00	-	+07	1942 Dec 31 23:00
+			8:00	-	+08	1945 Mar 14 23:00
+			9:00	-	+09	1945 Sep  2
+			7:00	-	+07	1947 Apr  1
+			8:00	-	+08	1955 Jul  1
+			7:00	-	+07	1959 Dec 31 23:00
+			8:00	-	+08	1975 Jun 13
+			7:00	-	+07
 
 # Yemen
 # See Asia/Riyadh.
--- a/make/sun/javazic/tzdata/australasia	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/australasia	Sun May 28 23:44:03 2017 -0700
@@ -67,8 +67,8 @@
 			 8:00	Aus	AW%sT	1943 Jul
 			 8:00	AW	AW%sT
 Zone Australia/Eucla	 8:35:28 -	LMT	1895 Dec
-			 8:45	Aus	ACW%sT	1943 Jul
-			 8:45	AW	ACW%sT
+			 8:45	Aus +0845/+0945	1943 Jul
+			 8:45	AW  +0845/+0945
 
 # Queensland
 #
@@ -235,7 +235,8 @@
 Rule	LH	2008	max	-	Oct	Sun>=1	2:00	0:30	D
 Zone Australia/Lord_Howe 10:36:20 -	LMT	1895 Feb
 			10:00	-	AEST	1981 Mar
-			10:30	LH	LH%sT
+			10:30	LH	+1030/+1130 1985 Jul
+			10:30	LH	+1030/+11
 
 # Australian miscellany
 #
@@ -273,19 +274,19 @@
 			0	-	-00	1948 Mar 25
 			10:00	Aus	AE%sT	1967
 			10:00	AT	AE%sT	2010 Apr  4  3:00
-			11:00	-	MIST	# Macquarie I Standard Time
+			11:00	-	+11
 
 # Christmas
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Indian/Christmas	7:02:52 -	LMT	1895 Feb
-			7:00	-	CXT	# Christmas Island Time
+			7:00	-	+07
 
 # Cocos (Keeling) Is
 # These islands were ruled by the Ross family from about 1830 to 1978.
 # We don't know when standard time was introduced; for now, we guess 1900.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Indian/Cocos	6:27:40	-	LMT	1900
-			6:30	-	CCT	# Cocos Islands Time
+			6:30	-	+0630
 
 
 # Fiji
@@ -398,16 +399,16 @@
 Rule	Fiji	2015	max	-	Jan	Sun>=15	3:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Fiji	11:55:44 -	LMT	1915 Oct 26 # Suva
-			12:00	Fiji	FJ%sT	# Fiji Time
+			12:00	Fiji	+12/+13
 
 # French Polynesia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Gambier	 -8:59:48 -	LMT	1912 Oct # Rikitea
-			 -9:00	-	GAMT	# Gambier Time
+			 -9:00	-	-09
 Zone	Pacific/Marquesas -9:18:00 -	LMT	1912 Oct
-			 -9:30	-	MART	# Marquesas Time
+			 -9:30	-	-0930
 Zone	Pacific/Tahiti	 -9:58:16 -	LMT	1912 Oct # Papeete
-			-10:00	-	TAHT	# Tahiti Time
+			-10:00	-	-10
 # Clipperton (near North America) is administered from French Polynesia;
 # it is uninhabited.
 
@@ -422,15 +423,15 @@
 # Kiribati
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Tarawa	 11:32:04 -	LMT	1901 # Bairiki
-			 12:00	-	GILT	# Gilbert Is Time
+			 12:00	-	+12
 Zone Pacific/Enderbury	-11:24:20 -	LMT	1901
-			-12:00	-	PHOT	1979 Oct # Phoenix Is Time
-			-11:00	-	PHOT	1995
-			 13:00	-	PHOT
+			-12:00	-	-12	1979 Oct
+			-11:00	-	-11	1995
+			 13:00	-	+13
 Zone Pacific/Kiritimati	-10:29:20 -	LMT	1901
-			-10:40	-	LINT	1979 Oct # Line Is Time
-			-10:00	-	LINT	1995
-			 14:00	-	LINT
+			-10:40	-	-1040	1979 Oct
+			-10:00	-	-10	1995
+			 14:00	-	+14
 
 # N Mariana Is
 # See Pacific/Guam.
@@ -438,31 +439,31 @@
 # Marshall Is
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Majuro	11:24:48 -	LMT	1901
-			11:00	-	MHT	1969 Oct # Marshall Islands Time
-			12:00	-	MHT
+			11:00	-	+11	1969 Oct
+			12:00	-	+12
 Zone Pacific/Kwajalein	11:09:20 -	LMT	1901
-			11:00	-	MHT	1969 Oct
-			-12:00	-	KWAT	1993 Aug 20 # Kwajalein Time
-			12:00	-	MHT
+			11:00	-	+11	1969 Oct
+			-12:00	-	-12	1993 Aug 20
+			12:00	-	+12
 
 # Micronesia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Chuuk	10:07:08 -	LMT	1901
-			10:00	-	CHUT	# Chuuk Time
+			10:00	-	+10
 Zone Pacific/Pohnpei	10:32:52 -	LMT	1901 # Kolonia
-			11:00	-	PONT	# Pohnpei Time
+			11:00	-	+11
 Zone Pacific/Kosrae	10:51:56 -	LMT	1901
-			11:00	-	KOST	1969 Oct # Kosrae Time
-			12:00	-	KOST	1999
-			11:00	-	KOST
+			11:00	-	+11	1969 Oct
+			12:00	-	+12	1999
+			11:00	-	+11
 
 # Nauru
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Nauru	11:07:40 -	LMT	1921 Jan 15 # Uaobe
-			11:30	-	NRT	1942 Mar 15 # Nauru Time
-			9:00	-	JST	1944 Aug 15
-			11:30	-	NRT	1979 May
-			12:00	-	NRT
+			11:30	-	+1130	1942 Mar 15
+			9:00	-	+09	1944 Aug 15
+			11:30	-	+1130	1979 May
+			12:00	-	+12
 
 # New Caledonia
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
@@ -473,7 +474,7 @@
 Rule	NC	1997	only	-	Mar	 2	2:00s	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Noumea	11:05:48 -	LMT	1912 Jan 13 # Nouméa
-			11:00	NC	NC%sT
+			11:00	NC	+11/+12
 
 
 ###############################################################################
@@ -514,8 +515,8 @@
 			11:30	NZ	NZ%sT	1946 Jan  1
 			12:00	NZ	NZ%sT
 Zone Pacific/Chatham	12:13:48 -	LMT	1868 Nov  2
-			12:15	-	CHAST	1946 Jan  1
-			12:45	Chatham	CHA%sT
+			12:15	-	+1215	1946 Jan  1
+			12:45	Chatham	+1245/+1345
 
 Link Pacific/Auckland Antarctica/McMurdo
 
@@ -537,8 +538,8 @@
 Rule	Cook	1979	1990	-	Oct	lastSun	0:00	0:30	HS
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Rarotonga	-10:39:04 -	LMT	1901        # Avarua
-			-10:30	-	CKT	1978 Nov 12 # Cook Is Time
-			-10:00	Cook	CK%sT
+			-10:30	-	-1030	1978 Nov 12
+			-10:00	Cook	-10/-0930
 
 ###############################################################################
 
@@ -546,29 +547,29 @@
 # Niue
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Niue	-11:19:40 -	LMT	1901        # Alofi
-			-11:20	-	NUT	1951        # Niue Time
-			-11:30	-	NUT	1978 Oct  1
-			-11:00	-	NUT
+			-11:20	-	-1120	1951
+			-11:30	-	-1130	1978 Oct  1
+			-11:00	-	-11
 
 # Norfolk
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Norfolk	11:11:52 -	LMT	1901 # Kingston
-			11:12	-	NMT	1951 # Norfolk Mean Time
-			11:30	-	NFT	1974 Oct 27 02:00 # Norfolk T.
-			11:30	1:00	NFST	1975 Mar  2 02:00
-			11:30	-	NFT	2015 Oct  4 02:00
-			11:00	-	NFT
+			11:12	-	+1112	1951
+			11:30	-	+1130	1974 Oct 27 02:00
+			11:30	1:00	+1230	1975 Mar  2 02:00
+			11:30	-	+1130	2015 Oct  4 02:00
+			11:00	-	+11
 
 # Palau (Belau)
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Palau	8:57:56 -	LMT	1901 # Koror
-			9:00	-	PWT	# Palau Time
+			9:00	-	+09
 
 # Papua New Guinea
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Port_Moresby 9:48:40 -	LMT	1880
 			9:48:32	-	PMMT	1895 # Port Moresby Mean Time
-			10:00	-	PGT	# Papua New Guinea Time
+			10:00	-	+10
 #
 # From Paul Eggert (2014-10-13):
 # Base the Bougainville entry on the Arawa-Kieta region, which appears to have
@@ -583,28 +584,26 @@
 # and seem to have controlled it until their 1945-08-21 surrender.
 #
 # The Autonomous Region of Bougainville switched from UT +10 to +11
-# on 2014-12-28 at 02:00.  They call +11 "Bougainville Standard Time";
-# abbreviate this as BST.  See:
+# on 2014-12-28 at 02:00.  They call +11 "Bougainville Standard Time".
+# See:
 # http://www.bougainville24.com/bougainville-issues/bougainville-gets-own-timezone/
 #
 Zone Pacific/Bougainville 10:22:16 -	LMT	1880
 			 9:48:32 -	PMMT	1895
-			10:00	-	PGT	1942 Jul
-			 9:00	-	JST	1945 Aug 21
-			10:00	-	PGT	2014 Dec 28  2:00
-			11:00	-	BST
+			10:00	-	+10	1942 Jul
+			 9:00	-	+09	1945 Aug 21
+			10:00	-	+10	2014 Dec 28  2:00
+			11:00	-	+11
 
 # Pitcairn
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Pitcairn	-8:40:20 -	LMT	1901        # Adamstown
-			-8:30	-	PNT	1998 Apr 27  0:00
-			-8:00	-	PST	# Pitcairn Standard Time
+			-8:30	-	-0830	1998 Apr 27  0:00
+			-8:00	-	-08
 
 # American Samoa
 Zone Pacific/Pago_Pago	 12:37:12 -	LMT	1879 Jul  5
 			-11:22:48 -	LMT	1911
-			-11:00	-	NST	1967 Apr    # N=Nome
-			-11:00	-	BST	1983 Nov 30 # B=Bering
 			-11:00	-	SST	            # S=Samoa
 Link Pacific/Pago_Pago Pacific/Midway # in US minor outlying islands
 
@@ -685,17 +684,17 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
-			-11:30	-	WSST	1950
-			-11:00	WS	S%sT	2011 Dec 29 24:00 # S=Samoa
-			 13:00	WS	WS%sT
+			-11:30	-	-1130	1950
+			-11:00	WS	-11/-10	2011 Dec 29 24:00
+			 13:00	WS	+13/+14
 
 # Solomon Is
 # excludes Bougainville, for which see Papua New Guinea
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Guadalcanal 10:39:48 -	LMT	1912 Oct # Honiara
-			11:00	-	SBT	# Solomon Is Time
+			11:00	-	+11
 
-# Tokelau Is
+# Tokelau
 #
 # From Gwillim Law (2011-12-29)
 # A correspondent informed me that Tokelau, like Samoa, will be skipping
@@ -716,8 +715,8 @@
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Fakaofo	-11:24:56 -	LMT	1901
-			-11:00	-	TKT	2011 Dec 30 # Tokelau Time
-			13:00	-	TKT
+			-11:00	-	-11	2011 Dec 30
+			13:00	-	+13
 
 # Tonga
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
@@ -736,7 +735,7 @@
 # Tuvalu
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Funafuti	11:56:52 -	LMT	1901
-			12:00	-	TVT	# Tuvalu Time
+			12:00	-	+12
 
 
 # US minor outlying islands
@@ -760,10 +759,11 @@
 
 # Johnston
 #
-# From Paul Eggert (2014-03-11):
+# From Paul Eggert (2017-02-10):
 # Sometimes Johnston kept Hawaii time, and sometimes it was an hour behind.
 # Details are uncertain.  We have no data for Johnston after 1970, so
-# treat it like Hawaii for now.
+# treat it like Hawaii for now.  Since Johnston is now uninhabited,
+# its link to Pacific/Honolulu is in the 'backward' file.
 #
 # In his memoirs of June 6th to October 4, 1945
 # <http://www.315bw.org/Herb_Bach.htm> (2005), Herbert C. Bach writes,
@@ -783,8 +783,6 @@
 # See the table on page 4 where he lists GMT and local times for the tests; a
 # footnote for the JI tests reads that local time is "JI time = Hawaii Time
 # Minus One Hour".
-#
-# See 'northamerica' for Pacific/Johnston.
 
 # Kingman
 # uninhabited
@@ -798,7 +796,7 @@
 # Wake
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Wake	11:06:28 -	LMT	1901
-			12:00	-	WAKT	# Wake Time
+			12:00	-	+12
 
 
 # Vanuatu
@@ -811,12 +809,12 @@
 Rule	Vanuatu	1992	only	-	Oct	Sun>=23	0:00	1:00	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Efate	11:13:16 -	LMT	1912 Jan 13 # Vila
-			11:00	Vanuatu	VU%sT	# Vanuatu Time
+			11:00	Vanuatu	+11/+12
 
 # Wallis and Futuna
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Wallis	12:15:20 -	LMT	1901
-			12:00	-	WFT	# Wallis & Futuna Time
+			12:00	-	+12
 
 ###############################################################################
 
@@ -827,15 +825,15 @@
 # tz@iana.org for general use in the future).  For more, please see
 # the file CONTRIBUTING in the tz distribution.
 
-# From Paul Eggert (2014-10-31):
+# From Paul Eggert (2017-02-10):
 #
 # Unless otherwise specified, the source for data through 1990 is:
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
 # San Diego: ACS Publications, Inc. (2003).
 # Unfortunately this book contains many errors and cites no sources.
 #
-# Gwillim Law writes that a good source
-# for recent time zone data is the International Air Transport
+# Many years ago Gwillim Law wrote that a good source
+# for time zone data was the International Air Transport
 # Association's Standard Schedules Information Manual (IATA SSIM),
 # published semiannually.  Law sent in several helpful summaries
 # of the IATA's data after 1990.  Except where otherwise noted,
@@ -852,28 +850,19 @@
 # A reliable and entertaining source about time zones is
 # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
 #
-# I invented the abbreviations marked '*' in the following table;
-# the rest are from earlier versions of this file, or from other sources.
+# The following abbreviations are from other sources.
 # Corrections are welcome!
 #		std	dst
 #		LMT		Local Mean Time
 #	  8:00	AWST	AWDT	Western Australia
-#	  8:45	ACWST	ACWDT	Central Western Australia*
-#	  9:00	JST		Japan
 #	  9:30	ACST	ACDT	Central Australia
 #	 10:00	AEST	AEDT	Eastern Australia
+#	 10:00	GST		Guam through 2000
 #	 10:00	ChST		Chamorro
-#	 10:30	LHST	LHDT	Lord Howe*
-#	 11:00	BST		Bougainville*
 #	 11:30	NZMT	NZST	New Zealand through 1945
 #	 12:00	NZST	NZDT	New Zealand 1946-present
-#	 12:15	CHAST		Chatham through 1945*
-#	 12:45	CHAST	CHADT	Chatham 1946-present*
-#	 13:00	WSST	WSDT	(western) Samoa 2011-present*
-#	-11:30	WSST		Western Samoa through 1950*
 #	-11:00	SST		Samoa
 #	-10:00	HST		Hawaii
-#	- 8:00	PST		Pitcairn*
 #
 # See the 'northamerica' file for Hawaii.
 # See the 'southamerica' file for Easter I and the Galápagos Is.
--- a/make/sun/javazic/tzdata/backward	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/backward	Sun May 28 23:44:03 2017 -0700
@@ -119,6 +119,7 @@
 Link	Pacific/Chatham		NZ-CHAT
 Link	America/Denver		Navajo
 Link	Asia/Shanghai		PRC
+Link	Pacific/Honolulu	Pacific/Johnston
 Link	Pacific/Pohnpei		Pacific/Ponape
 Link	Pacific/Pago_Pago	Pacific/Samoa
 Link	Pacific/Chuuk		Pacific/Truk
--- a/make/sun/javazic/tzdata/europe	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/europe	Sun May 28 23:44:03 2017 -0700
@@ -29,15 +29,15 @@
 # tz@iana.org for general use in the future).  For more, please see
 # the file CONTRIBUTING in the tz distribution.
 
-# From Paul Eggert (2014-10-31):
+# From Paul Eggert (2017-02-10):
 #
 # Unless otherwise specified, the source for data through 1990 is:
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
 # San Diego: ACS Publications, Inc. (2003).
 # Unfortunately this book contains many errors and cites no sources.
 #
-# Gwillim Law writes that a good source
-# for recent time zone data is the International Air Transport
+# Many years ago Gwillim Law wrote that a good source
+# for time zone data was the International Air Transport
 # Association's Standard Schedules Information Manual (IATA SSIM),
 # published semiannually.  Law sent in several helpful summaries
 # of the IATA's data after 1990.  Except where otherwise noted,
@@ -79,26 +79,23 @@
 #	History of Summer Time
 #	<http://pcdsh01.on.br/HISTHV.htm>
 #	(1998-09-21, in Portuguese)
-
 #
 # I invented the abbreviations marked '*' in the following table;
-# the rest are from earlier versions of this file, or from other sources.
-# Corrections are welcome!
-#                   std dst  2dst
-#                   LMT           Local Mean Time
-#       -4:00       AST ADT       Atlantic
-#       -3:00       WGT WGST      Western Greenland*
-#       -1:00       EGT EGST      Eastern Greenland*
-#        0:00       GMT BST  BDST Greenwich, British Summer
-#        0:00       GMT IST       Greenwich, Irish Summer
-#        0:00       WET WEST WEMT Western Europe
-#        0:19:32.13 AMT NST       Amsterdam, Netherlands Summer (1835-1937)*
-#        0:20       NET NEST      Netherlands (1937-1940)*
-#        1:00       BST           British Standard (1968-1971)
-#        1:00       CET CEST CEMT Central Europe
-#        1:00:14    SET           Swedish (1879-1899)*
-#        2:00       EET EEST      Eastern Europe
-#        3:00       MSK MSD       Moscow
+# the rest are variants of the "xMT" pattern for a city's mean time,
+# or are from other sources.  Corrections are welcome!
+#                   std  dst  2dst
+#                   LMT             Local Mean Time
+#       -4:00       AST  ADT        Atlantic
+#        0:00       GMT  BST  BDST  Greenwich, British Summer
+#        0:00       GMT  IST        Greenwich, Irish Summer
+#        0:00       WET  WEST WEMT  Western Europe
+#        0:19:32.13 AMT* NST*       Amsterdam, Netherlands Summer (1835-1937)
+#        1:00       BST             British Standard (1968-1971)
+#        1:00       CET  CEST CEMT  Central Europe
+#        1:00:14    SET             Swedish (1879-1899)
+#        1:36:34    RMT* LST*       Riga, Latvian Summer (1880-1926)*
+#        2:00       EET  EEST       Eastern Europe
+#        3:00       MSK  MSD  MDST* Moscow
 
 # From Peter Ilieve (1994-12-04),
 # The original six [EU members]: Belgium, France, (West) Germany, Italy,
@@ -498,7 +495,7 @@
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Europe/Dublin	-0:25:00 -	LMT	1880 Aug  2
-			-0:25:21 -	DMT	1916 May 21  2:00
+			-0:25:21 -	DMT	1916 May 21  2:00 # Dublin MT
 			-0:25:21 1:00	IST	1916 Oct  1  2:00s
 			 0:00	GB-Eire	%s	1921 Dec  6 # independence
 			 0:00	GB-Eire	GMT/IST	1940 Feb 25  2:00
@@ -924,7 +921,7 @@
 # Cyprus
 # Please see the 'asia' file for Asia/Nicosia.
 
-# Czech Republic
+# Czech Republic / Czechia
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Czech	1945	only	-	Apr	 8	2:00s	1:00	S
 Rule	Czech	1945	only	-	Nov	18	2:00s	0	-
@@ -1087,16 +1084,16 @@
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Danmarkshavn -1:14:40 -	LMT	1916 Jul 28
-			-3:00	-	WGT	1980 Apr  6  2:00
-			-3:00	EU	WG%sT	1996
+			-3:00	-	-03	1980 Apr  6  2:00
+			-3:00	EU	-03/-02	1996
 			0:00	-	GMT
 Zone America/Scoresbysund -1:27:52 -	LMT	1916 Jul 28 # Ittoqqortoormiit
-			-2:00	-	CGT	1980 Apr  6  2:00
-			-2:00	C-Eur	CG%sT	1981 Mar 29
-			-1:00	EU	EG%sT
+			-2:00	-	-02	1980 Apr  6  2:00
+			-2:00	C-Eur	-02/-01	1981 Mar 29
+			-1:00	EU	-01/+00
 Zone America/Godthab	-3:26:56 -	LMT	1916 Jul 28 # Nuuk
-			-3:00	-	WGT	1980 Apr  6  2:00
-			-3:00	EU	WG%sT
+			-3:00	-	-03	1980 Apr  6  2:00
+			-3:00	EU	-03/-02
 Zone America/Thule	-4:35:08 -	LMT	1916 Jul 28 # Pituffik air base
 			-4:00	Thule	A%sT
 
@@ -1511,7 +1508,7 @@
 Rule	Iceland	1967	only	-	Oct	29	 1:00s	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Atlantic/Reykjavik	-1:28	-	LMT	1908
-			-1:00	Iceland	IS%sT	1968 Apr  7  1:00s
+			-1:00	Iceland	-01/+00	1968 Apr  7  1:00s
 			 0:00	-	GMT
 
 # Italy
@@ -1975,7 +1972,7 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Europe/Amsterdam	0:19:32 -	LMT	1835
 			0:19:32	Neth	%s	1937 Jul  1
-			0:20	Neth	NE%sT	1940 May 16  0:00 # Dutch Time
+			0:20	Neth +0020/+0120 1940 May 16  0:00
 			1:00	C-Eur	CE%sT	1945 Apr  2  2:00
 			1:00	Neth	CE%sT	1977
 			1:00	EU	CE%sT
@@ -2192,16 +2189,34 @@
 			 0:00	W-Eur	WE%sT	1992 Sep 27  1:00s
 			 1:00	EU	CE%sT	1996 Mar 31  1:00u
 			 0:00	EU	WE%sT
+# This Zone can be simplified once we assume zic %z.
 Zone Atlantic/Azores	-1:42:40 -	LMT	1884        # Ponta Delgada
 			-1:54:32 -	HMT	1912 Jan  1 # Horta Mean Time
-			-2:00	Port	AZO%sT	1966 Apr  3  2:00  # Azores Time
-			-1:00	Port	AZO%sT	1983 Sep 25  1:00s
-			-1:00	W-Eur	AZO%sT	1992 Sep 27  1:00s
+			-2:00	Port	-02/-01	1942 Apr 25 22:00s
+			-2:00	Port	+00	1942 Aug 15 22:00s
+			-2:00	Port	-02/-01	1943 Apr 17 22:00s
+			-2:00	Port	+00	1943 Aug 28 22:00s
+			-2:00	Port	-02/-01	1944 Apr 22 22:00s
+			-2:00	Port	+00	1944 Aug 26 22:00s
+			-2:00	Port	-02/-01	1945 Apr 21 22:00s
+			-2:00	Port	+00	1945 Aug 25 22:00s
+			-2:00	Port	-02/-01	1966 Apr  3  2:00
+			-1:00	Port	-01/+00	1983 Sep 25  1:00s
+			-1:00	W-Eur	-01/+00	1992 Sep 27  1:00s
 			 0:00	EU	WE%sT	1993 Mar 28  1:00u
-			-1:00	EU	AZO%sT
+			-1:00	EU	-01/+00
+# This Zone can be simplified once we assume zic %z.
 Zone Atlantic/Madeira	-1:07:36 -	LMT	1884        # Funchal
 			-1:07:36 -	FMT	1912 Jan  1 # Funchal Mean Time
-			-1:00	Port	MAD%sT	1966 Apr  3  2:00 # Madeira Time
+			-1:00	Port	-01/+00	1942 Apr 25 22:00s
+			-1:00	Port	+01	1942 Aug 15 22:00s
+			-1:00	Port	-01/+00	1943 Apr 17 22:00s
+			-1:00	Port	+01	1943 Aug 28 22:00s
+			-1:00	Port	-01/+00	1944 Apr 22 22:00s
+			-1:00	Port	+01	1944 Aug 26 22:00s
+			-1:00	Port	-01/+00	1945 Apr 21 22:00s
+			-1:00	Port	+01	1945 Aug 25 22:00s
+			-1:00	Port	-01/+00	1966 Apr  3  2:00
 			 0:00	Port	WE%sT	1983 Sep 25  1:00s
 			 0:00	EU	WE%sT
 
@@ -2559,10 +2574,8 @@
 			 3:00	-	MSK
 
 
-# From Tim Parenti (2014-07-03):
-# Europe/Simferopol covers...
-# **	****	Crimea, Republic of
-# **	****	Sevastopol
+# From Paul Eggert (2016-12-06):
+# Europe/Simferopol covers Crimea.
 
 Zone Europe/Simferopol	 2:16:24 -	LMT	1880
 			 2:16	-	SMT	1924 May  2 # Simferopol Mean T
@@ -2624,10 +2637,9 @@
 			 3:00	-	+03	2016 Mar 27  2:00s
 			 4:00	-	+04
 
-# From Paul Eggert (2016-03-18):
+# From Paul Eggert (2016-11-11):
 # Europe/Volgograd covers:
 # 34	RU-VGG	Volgograd Oblast
-# 64	RU-SAR	Saratov Oblast
 # The 1988 transition is from USSR act No. 5 (1988-01-04).
 
 Zone Europe/Volgograd	 2:57:40 -	LMT	1920 Jan  3
@@ -2640,6 +2652,27 @@
 			 4:00	-	+04	2014 Oct 26  2:00s
 			 3:00	-	+03
 
+# From Paul Eggert (2016-11-11):
+# Europe/Saratov covers:
+# 64	RU-SAR	Saratov Oblast
+
+# From Yuri Konotopov (2016-11-11):
+# Dec 4, 2016 02:00 UTC+3....  Saratov Region's local time will be ... UTC+4.
+# From Stepan Golosunov (2016-11-11):
+# ... Byalokoz listed Saratov on 03:04:18.
+# From Stepan Golosunov (2016-11-22):
+# http://publication.pravo.gov.ru/Document/View/0001201611220031
+
+Zone Europe/Saratov	 3:04:18 -	LMT	1919 Jul  1  0:00u
+			 3:00	-	+03	1930 Jun 21
+			 4:00	Russia	+04/+05	1988 Mar 27  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 4:00	-	+04	1992 Mar 29  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04	2014 Oct 26  2:00s
+			 3:00	-	+03	2016 Dec  4  2:00s
+			 4:00	-	+04
+
 # From Paul Eggert (2016-03-18):
 # Europe/Kirov covers:
 # 43	RU-KIR	Kirov Oblast
@@ -3235,46 +3268,77 @@
 # See Europe/Belgrade.
 
 # Spain
+#
+# From Paul Eggert (2016-12-14):
+#
+# The source for Europe/Madrid before 2013 is:
+# Planesas P. La hora oficial en España y sus cambios.
+# Anuario del Observatorio Astronómico de Madrid (2013, in Spanish).
+# http://astronomia.ign.es/rknowsys-theme/images/webAstro/paginas/documentos/Anuario/lahoraoficialenespana.pdf
+# As this source says that historical time in the Canaries is obscure,
+# and it does not discuss Ceuta, stick with Shanks for now for that data.
+#
+# In the 1918 and 1919 fallback transitions in Spain, the clock for
+# the hour-longer day officially kept going after midnight, so that
+# the repeated instances of that day's 00:00 hour were 24 hours apart,
+# with a fallback transition from the second occurrence of 00:59... to
+# the next day's 00:00.  Our data format cannot represent this
+# directly, and instead repeats the first hour of the next day, with a
+# fallback transition from the next day's 00:59... to 00:00.
+
+# From Michael Deckers (2016-12-15):
+# The Royal Decree of 1900-06-26 quoted by Planesas, online at
+# https://www.boe.es/datos/pdfs/BOE//1900/209/A00383-00384.pdf
+# says in its article 5 (my translation):
+# These dispositions will enter into force beginning with the
+# instant at which, according to the time indicated in article 1,
+# the 1st day of January of 1901 will begin.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-# For 1917-1919 Whitman gives Apr Sat>=1 - Oct Sat>=1;
-# go with Shanks & Pottenger.
-Rule	Spain	1917	only	-	May	 5	23:00s	1:00	S
-Rule	Spain	1917	1919	-	Oct	 6	23:00s	0	-
-Rule	Spain	1918	only	-	Apr	15	23:00s	1:00	S
-Rule	Spain	1919	only	-	Apr	 5	23:00s	1:00	S
-# Whitman gives 1921 Feb 28 - Oct 14; go with Shanks & Pottenger.
-Rule	Spain	1924	only	-	Apr	16	23:00s	1:00	S
-# Whitman gives 1924 Oct 14; go with Shanks & Pottenger.
-Rule	Spain	1924	only	-	Oct	 4	23:00s	0	-
-Rule	Spain	1926	only	-	Apr	17	23:00s	1:00	S
-# Whitman says no DST in 1929; go with Shanks & Pottenger.
-Rule	Spain	1926	1929	-	Oct	Sat>=1	23:00s	0	-
-Rule	Spain	1927	only	-	Apr	 9	23:00s	1:00	S
-Rule	Spain	1928	only	-	Apr	14	23:00s	1:00	S
-Rule	Spain	1929	only	-	Apr	20	23:00s	1:00	S
-# Whitman gives 1937 Jun 16, 1938 Apr 16, 1940 Apr 13;
-# go with Shanks & Pottenger.
-Rule	Spain	1937	only	-	May	22	23:00s	1:00	S
-Rule	Spain	1937	1939	-	Oct	Sat>=1	23:00s	0	-
-Rule	Spain	1938	only	-	Mar	22	23:00s	1:00	S
-Rule	Spain	1939	only	-	Apr	15	23:00s	1:00	S
-Rule	Spain	1940	only	-	Mar	16	23:00s	1:00	S
-# Whitman says no DST 1942-1945; go with Shanks & Pottenger.
-Rule	Spain	1942	only	-	May	 2	22:00s	2:00	M # Midsummer
-Rule	Spain	1942	only	-	Sep	 1	22:00s	1:00	S
-Rule	Spain	1943	1946	-	Apr	Sat>=13	22:00s	2:00	M
-Rule	Spain	1943	only	-	Oct	 3	22:00s	1:00	S
-Rule	Spain	1944	only	-	Oct	10	22:00s	1:00	S
-Rule	Spain	1945	only	-	Sep	30	 1:00	1:00	S
-Rule	Spain	1946	only	-	Sep	30	 0:00	0	-
+Rule	Spain	1918	only	-	Apr	15	23:00	1:00	S
+Rule	Spain	1918	1919	-	Oct	 6	24:00s	0	-
+Rule	Spain	1919	only	-	Apr	 6	23:00	1:00	S
+Rule	Spain	1924	only	-	Apr	16	23:00	1:00	S
+Rule	Spain	1924	only	-	Oct	 4	24:00s	0	-
+Rule	Spain	1926	only	-	Apr	17	23:00	1:00	S
+Rule	Spain	1926	1929	-	Oct	Sat>=1	24:00s	0	-
+Rule	Spain	1927	only	-	Apr	 9	23:00	1:00	S
+Rule	Spain	1928	only	-	Apr	15	 0:00	1:00	S
+Rule	Spain	1929	only	-	Apr	20	23:00	1:00	S
+# Republican Spain during the civil war; it controlled Madrid until 1939-03-28.
+Rule	Spain	1937	only	-	Jun	16	23:00	1:00	S
+Rule	Spain	1937	only	-	Oct	 2	24:00s	0	-
+Rule	Spain	1938	only	-	Apr	 2	23:00	1:00	S
+Rule	Spain	1938	only	-	Apr	30	23:00	2:00	M
+Rule	Spain	1938	only	-	Oct	 2	24:00	1:00	S
+# The following rules are for unified Spain again.
+#
+# Planesas does not say what happened in Madrid between its fall on
+# 1939-03-28 and the Nationalist spring-forward transition on
+# 1939-04-15.  For lack of better info, assume Madrid's clocks did not
+# change during that period.
+#
+# The first rule is commented out, as it is redundant for Republican Spain.
+#Rule	Spain	1939	only	-	Apr	15	23:00	1:00	S
+Rule	Spain	1939	only	-	Oct	 7	24:00s	0	-
+Rule	Spain	1942	only	-	May	 2	23:00	1:00	S
+Rule	Spain	1942	only	-	Sep	 1	 1:00	0	-
+Rule	Spain	1943	1946	-	Apr	Sat>=13	23:00	1:00	S
+Rule	Spain	1943	1944	-	Oct	Sun>=1	 1:00	0	-
+Rule	Spain	1945	1946	-	Sep	lastSun	 1:00	0	-
 Rule	Spain	1949	only	-	Apr	30	23:00	1:00	S
-Rule	Spain	1949	only	-	Sep	30	 1:00	0	-
-Rule	Spain	1974	1975	-	Apr	Sat>=13	23:00	1:00	S
+Rule	Spain	1949	only	-	Oct	 2	 1:00	0	-
+Rule	Spain	1974	1975	-	Apr	Sat>=12	23:00	1:00	S
 Rule	Spain	1974	1975	-	Oct	Sun>=1	 1:00	0	-
 Rule	Spain	1976	only	-	Mar	27	23:00	1:00	S
 Rule	Spain	1976	1977	-	Sep	lastSun	 1:00	0	-
-Rule	Spain	1977	1978	-	Apr	 2	23:00	1:00	S
-Rule	Spain	1978	only	-	Oct	 1	 1:00	0	-
+Rule	Spain	1977	only	-	Apr	 2	23:00	1:00	S
+Rule	Spain	1978	only	-	Apr	 2	 2:00s	1:00	S
+Rule	Spain	1978	only	-	Oct	 1	 2:00s	0	-
+# Nationalist Spain during the civil war
+#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.
 Rule SpainAfrica 1967	only	-	Jun	 3	12:00	1:00	S
 Rule SpainAfrica 1967	only	-	Oct	 1	 0:00	0	-
@@ -3286,11 +3350,11 @@
 Rule SpainAfrica 1978	only	-	Jun	 1	 0:00	1:00	S
 Rule SpainAfrica 1978	only	-	Aug	 4	 0:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone	Europe/Madrid	-0:14:44 -	LMT	1901 Jan  1  0:00s
-			 0:00	Spain	WE%sT	1946 Sep 30
+Zone	Europe/Madrid	-0:14:44 -	LMT	1900 Dec 31 23:45:16
+			 0:00	Spain	WE%sT	1940 Mar 16 23:00
 			 1:00	Spain	CE%sT	1979
 			 1:00	EU	CE%sT
-Zone	Africa/Ceuta	-0:21:16 -	LMT	1901
+Zone	Africa/Ceuta	-0:21:16 -	LMT	1900 Dec 31 23:38:44
 			 0:00	-	WET	1918 May  6 23:00
 			 0:00	1:00	WEST	1918 Oct  7 23:00
 			 0:00	-	WET	1924
@@ -3299,7 +3363,7 @@
 			 1:00	-	CET	1986
 			 1:00	EU	CE%sT
 Zone	Atlantic/Canary	-1:01:36 -	LMT	1922 Mar # Las Palmas de Gran C.
-			-1:00	-	CANT	1946 Sep 30  1:00 # Canaries T
+			-1:00	-	-01	1946 Sep 30  1:00
 			 0:00	-	WET	1980 Apr  6  0:00s
 			 0:00	1:00	WEST	1980 Sep 28  1:00u
 			 0:00	EU	WE%sT
@@ -3712,7 +3776,7 @@
 # spelling, except omit the apostrophe as it is not allowed in
 # portable Posix file names.
 Zone Europe/Zaporozhye	2:20:40 -	LMT	1880
-			2:20	-	CUT	1924 May  2 # Central Ukraine T
+			2:20	-	+0220	1924 May  2
 			2:00	-	EET	1930 Jun 21
 			3:00	-	MSK	1941 Aug 25
 			1:00	C-Eur	CE%sT	1943 Oct 25
--- a/make/sun/javazic/tzdata/iso3166.tab	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/iso3166.tab	Sun May 28 23:44:03 2017 -0700
@@ -98,7 +98,7 @@
 CR	Costa Rica
 CU	Cuba
 CV	Cape Verde
-CW	Curacao
+CW	Curaçao
 CX	Christmas Island
 CY	Cyprus
 CZ	Czech Republic
--- a/make/sun/javazic/tzdata/leapseconds	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/leapseconds	Sun May 28 23:44:03 2017 -0700
@@ -81,5 +81,5 @@
 Leap	2015	Jun	30	23:59:60	+	S
 Leap	2016	Dec	31	23:59:60	+	S
 
-#	Updated through IERS Bulletin C52
-#	File expires on:  28 June 2017
+#	Updated through IERS Bulletin C53
+#	File expires on:  28 December 2017
--- a/make/sun/javazic/tzdata/northamerica	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/northamerica	Sun May 28 23:44:03 2017 -0700
@@ -201,22 +201,6 @@
 Zone	MST7MDT		 -7:00	US	M%sT
 Zone	PST8PDT		 -8:00	US	P%sT
 
-# From Bob Devine (1988-01-28):
-# ...Alaska (and Hawaii) had the timezone names changed in 1967.
-#    old			 new
-#    Pacific Standard Time(PST)  -same-
-#    Yukon Standard Time(YST)    -same-
-#    Central Alaska S.T. (CAT)   Alaska-Hawaii St[an]dard Time (AHST)
-#    Nome Standard Time (NT)     Bering Standard Time (BST)
-#
-# ...Alaska's timezone lines were redrawn in 1983 to give only 2 tz.
-#    The YST zone now covers nearly all of the state, AHST just part
-#    of the Aleutian islands.   No DST.
-
-# From Paul Eggert (1995-12-19):
-# The tables below use 'NST', not 'NT', for Nome Standard Time.
-# I invented 'CAWT' for Central Alaska War Time.
-
 # From U. S. Naval Observatory (1989-01-19):
 # USA  EASTERN       5 H  BEHIND UTC    NEW YORK, WASHINGTON
 # USA  EASTERN       4 H  BEHIND UTC    APR 3 - OCT 30
@@ -273,6 +257,21 @@
 #	Samoa standard time
 # The law doesn't give abbreviations.
 #
+# From Paul Eggert (2016-12-19):
+# Here are URLs for the 1918 and 1966 legislation:
+# http://uscode.house.gov/statviewer.htm?volume=40&page=451
+# http://uscode.house.gov/statviewer.htm?volume=80&page=108
+# Although the 1918 names were officially "United States Standard
+# Eastern Time" and similarly for "Central", "Mountain", "Pacific",
+# and "Alaska", in practice "Standard" was placed just before "Time",
+# as codified in 1966.  In practice, Alaska time was abbreviated "AST"
+# before 1968.  Summarizing the 1967 name changes:
+#	1918 names			1967 names
+#  -08	Standard Pacific Time (PST)	Pacific standard time (PST)
+#  -09	(unofficial) Yukon (YST)	Yukon standard time (YST)
+#  -10	Standard Alaska Time (AST)	Alaska-Hawaii standard time (AHST)
+#  -11	(unofficial) Nome (NST)		Bering standard time (BST)
+#
 # From Paul Eggert (2000-01-08), following a heads-up from Rives McDow:
 # Public law 106-564 (2000-12-23) introduced ... "Chamorro Standard Time"
 # for time in Guam and the Northern Marianas.  See the file "australasia".
@@ -328,6 +327,15 @@
 # Roberts, city administrator in Phenix City. as saying "We are in the Central
 # time zone, but we do go by the Eastern time zone because so many people work
 # in Columbus."
+#
+# From Paul Eggert (2017-02-22):
+# Four cities are involved.  The two not mentioned above are Smiths Station
+# and Valley.  Barbara Brooks, Valley's assistant treasurer, heard it started
+# because West Point Pepperell textile mills were in Alabama while the
+# corporate office was in Georgia, and residents voted to keep Eastern
+# time even after the mills closed.  See: Kazek K. Did you know which
+# Alabama towns are in a different time zone?  al.com 2017-02-06.
+# http://www.al.com/living/index.ssf/2017/02/do_you_know_which_alabama_town.html
 
 # From Paul Eggert (2014-09-06):
 # Monthly Notices of the Royal Astronomical Society 44, 4 (1884-02-08), 208
@@ -505,7 +513,7 @@
 			-8:00	US	P%sT
 
 # Alaska
-# AK%sT is the modern abbreviation for -9:00 per USNO.
+# AK%sT is the modern abbreviation for -09 per USNO.
 #
 # From Paul Eggert (2001-05-30):
 # Howse writes that Alaska switched from the Julian to the Gregorian calendar,
@@ -611,10 +619,8 @@
 			 -9:00	US	AK%sT
 Zone America/Anchorage	 14:00:24 -	LMT	1867 Oct 18
 			 -9:59:36 -	LMT	1900 Aug 20 12:00
-			-10:00	-	CAT	1942
-			-10:00	US	CAT/CAWT 1945 Aug 14 23:00u
-			-10:00	US	CAT/CAPT 1946 # Peace
-			-10:00	-	CAT	1967 Apr
+			-10:00	-	AST	1942
+			-10:00	US	A%sT	1967 Apr
 			-10:00	-	AHST	1969
 			-10:00	US	AH%sT	1983 Oct 30  2:00
 			 -9:00	US	Y%sT	1983 Nov 30
@@ -703,7 +709,6 @@
 			-10:30	1:00	HDT	1945 Sep 30  2:00
 			-10:30	-	HST	1947 Jun  8  2:00
 			-10:00	-	HST
-Link Pacific/Honolulu Pacific/Johnston
 
 # Now we turn to US areas that have diverged from the consensus since 1970.
 
@@ -1091,15 +1096,15 @@
 ################################################################################
 
 
-# From Paul Eggert (2014-10-31):
+# From Paul Eggert (2017-02-10):
 #
 # Unless otherwise specified, the source for data through 1990 is:
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
 # San Diego: ACS Publications, Inc. (2003).
 # Unfortunately this book contains many errors and cites no sources.
 #
-# Gwillim Law writes that a good source
-# for recent time zone data is the International Air Transport
+# Many years ago Gwillim Law wrote that a good source
+# for time zone data was the International Air Transport
 # Association's Standard Schedules Information Manual (IATA SSIM),
 # published semiannually.  Law sent in several helpful summaries
 # of the IATA's data after 1990.  Except where otherwise noted,
@@ -2757,15 +2762,15 @@
 # Belize
 # Whitman entirely disagrees with Shanks; go with Shanks & Pottenger.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Belize	1918	1942	-	Oct	Sun>=2	0:00	0:30	HD
-Rule	Belize	1919	1943	-	Feb	Sun>=9	0:00	0	S
-Rule	Belize	1973	only	-	Dec	 5	0:00	1:00	D
-Rule	Belize	1974	only	-	Feb	 9	0:00	0	S
-Rule	Belize	1982	only	-	Dec	18	0:00	1:00	D
-Rule	Belize	1983	only	-	Feb	12	0:00	0	S
+Rule	Belize	1918	1942	-	Oct	Sun>=2	0:00	0:30	-0530
+Rule	Belize	1919	1943	-	Feb	Sun>=9	0:00	0	CST
+Rule	Belize	1973	only	-	Dec	 5	0:00	1:00	CDT
+Rule	Belize	1974	only	-	Feb	 9	0:00	0	CST
+Rule	Belize	1982	only	-	Dec	18	0:00	1:00	CDT
+Rule	Belize	1983	only	-	Feb	12	0:00	0	CST
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Belize	-5:52:48 -	LMT	1912 Apr
-			-6:00	Belize	C%sT
+			-6:00	Belize	%s
 
 # Bermuda
 
@@ -3037,16 +3042,16 @@
 
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	DR	1966	only	-	Oct	30	0:00	1:00	D
-Rule	DR	1967	only	-	Feb	28	0:00	0	S
-Rule	DR	1969	1973	-	Oct	lastSun	0:00	0:30	HD
-Rule	DR	1970	only	-	Feb	21	0:00	0	S
-Rule	DR	1971	only	-	Jan	20	0:00	0	S
-Rule	DR	1972	1974	-	Jan	21	0:00	0	S
+Rule	DR	1966	only	-	Oct	30	0:00	1:00	EDT
+Rule	DR	1967	only	-	Feb	28	0:00	0	EST
+Rule	DR	1969	1973	-	Oct	lastSun	0:00	0:30	-0430
+Rule	DR	1970	only	-	Feb	21	0:00	0	EST
+Rule	DR	1971	only	-	Jan	20	0:00	0	EST
+Rule	DR	1972	1974	-	Jan	21	0:00	0	EST
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Santo_Domingo -4:39:36 -	LMT	1890
 			-4:40	-	SDMT	1933 Apr  1 12:00 # S. Dom. MT
-			-5:00	DR	E%sT	1974 Oct 27
+			-5:00	DR	%s	1974 Oct 27
 			-4:00	-	AST	2000 Oct 29  2:00
 			-5:00	US	E%sT	2000 Dec  3  1:00
 			-4:00	-	AST
@@ -3336,8 +3341,8 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Miquelon	-3:44:40 -	LMT	1911 May 15 # St Pierre
 			-4:00	-	AST	1980 May
-			-3:00	-	PMST	1987 # Pierre & Miquelon Time
-			-3:00	Canada	PM%sT
+			-3:00	-	-03	1987
+			-3:00	Canada	-03/-02
 
 # St Vincent and the Grenadines
 # See America/Port_of_Spain.
--- a/make/sun/javazic/tzdata/southamerica	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/southamerica	Sun May 28 23:44:03 2017 -0700
@@ -29,15 +29,15 @@
 # tz@iana.org for general use in the future).  For more, please see
 # the file CONTRIBUTING in the tz distribution.
 
-# From Paul Eggert (2014-10-31):
+# From Paul Eggert (2016-12-05):
 #
 # Unless otherwise specified, the source for data through 1990 is:
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
 # San Diego: ACS Publications, Inc. (2003).
 # Unfortunately this book contains many errors and cites no sources.
 #
-# Gwillim Law writes that a good source
-# for recent time zone data is the International Air Transport
+# Many years ago Gwillim Law wrote that a good source
+# for time zone data was the International Air Transport
 # Association's Standard Schedules Information Manual (IATA SSIM),
 # published semiannually.  Law sent in several helpful summaries
 # of the IATA's data after 1990.  Except where otherwise noted,
@@ -47,32 +47,10 @@
 # Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94.
 # http://www.jstor.org/stable/1774359
 #
-# Earlier editions of these tables used the North American style (e.g. ARST and
-# ARDT for Argentine Standard and Daylight Time), but the following quote
-# suggests that it's better to use European style (e.g. ART and ARST).
-#	I suggest the use of _Summer time_ instead of the more cumbersome
-#	_daylight-saving time_.  _Summer time_ seems to be in general use
-#	in Europe and South America.
-#	-- E O Cutler, _New York Times_ (1937-02-14), quoted in
-#	H L Mencken, _The American Language: Supplement I_ (1960), p 466
-#
-# Earlier editions of these tables also used the North American style
-# for time zones in Brazil, but this was incorrect, as Brazilians say
-# "summer time".  Reinaldo Goulart, a São Paulo businessman active in
-# the railroad sector, writes (1999-07-06):
-#	The subject of time zones is currently a matter of discussion/debate in
-#	Brazil.  Let's say that "the Brasília time" is considered the
-#	"official time" because Brasília is the capital city.
-#	The other three time zones are called "Brasília time "minus one" or
-#	"plus one" or "plus two".  As far as I know there is no such
-#	name/designation as "Eastern Time" or "Central Time".
-# So I invented the following (English-language) abbreviations for now.
-# Corrections are welcome!
-#		std	dst
-#	-2:00	FNT	FNST	Fernando de Noronha
-#	-3:00	BRT	BRST	Brasília
-#	-4:00	AMT	AMST	Amazon
-#	-5:00	ACT	ACST	Acre
+# These tables use numeric abbreviations like -03 and -0330 for
+# integer hour and minute UTC offsets.  Although earlier editions used
+# alphabetic time zone abbreviations, these abbreviations were
+# invented and did not reflect common practice.
 
 ###############################################################################
 
@@ -407,12 +385,6 @@
 #
 # So I guess a new set of rules, besides "Arg", must be made and the last
 # America/Argentina/San_Luis entries should change to use these...
-#
-# I'm enclosing a patch that does what I say... regretfully, the San Luis
-# timezone must be called "WART/WARST" even when most of the time (like,
-# right now) WARST == ART... that is, since last Sunday, all the country
-# is using UTC-3, but in my patch, San Luis calls it "WARST" and the rest
-# of the country calls it "ART".
 # ...
 
 # From Alexander Krivenyshev (2010-04-09):
@@ -451,11 +423,11 @@
 # Buenos Aires (BA), Capital Federal (CF),
 Zone America/Argentina/Buenos_Aires -3:53:48 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May    # Córdoba Mean Time
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	Arg	AR%sT
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	Arg	-03/-02
 #
 # Córdoba (CB), Santa Fe (SF), Entre Ríos (ER), Corrientes (CN), Misiones (MN),
 # Chaco (CC), Formosa (FM), Santiago del Estero (SE)
@@ -469,113 +441,113 @@
 #
 Zone America/Argentina/Cordoba -4:16:48 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1991 Mar  3
-			-4:00	-	WART	1991 Oct 20
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	Arg	AR%sT
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1991 Mar  3
+			-4:00	-	-04	1991 Oct 20
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	Arg	-03/-02
 #
 # Salta (SA), La Pampa (LP), Neuquén (NQ), Rio Negro (RN)
 Zone America/Argentina/Salta -4:21:40 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1991 Mar  3
-			-4:00	-	WART	1991 Oct 20
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	Arg	AR%sT	2008 Oct 18
-			-3:00	-	ART
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1991 Mar  3
+			-4:00	-	-04	1991 Oct 20
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	Arg	-03/-02	2008 Oct 18
+			-3:00	-	-03
 #
 # Tucumán (TM)
 Zone America/Argentina/Tucuman -4:20:52 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1991 Mar  3
-			-4:00	-	WART	1991 Oct 20
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	-	ART	2004 Jun  1
-			-4:00	-	WART	2004 Jun 13
-			-3:00	Arg	AR%sT
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1991 Mar  3
+			-4:00	-	-04	1991 Oct 20
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	-	-03	2004 Jun  1
+			-4:00	-	-04	2004 Jun 13
+			-3:00	Arg	-03/-02
 #
 # La Rioja (LR)
 Zone America/Argentina/La_Rioja -4:27:24 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1991 Mar  1
-			-4:00	-	WART	1991 May  7
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	-	ART	2004 Jun  1
-			-4:00	-	WART	2004 Jun 20
-			-3:00	Arg	AR%sT	2008 Oct 18
-			-3:00	-	ART
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1991 Mar  1
+			-4:00	-	-04	1991 May  7
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	-	-03	2004 Jun  1
+			-4:00	-	-04	2004 Jun 20
+			-3:00	Arg	-03/-02	2008 Oct 18
+			-3:00	-	-03
 #
 # San Juan (SJ)
 Zone America/Argentina/San_Juan -4:34:04 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1991 Mar  1
-			-4:00	-	WART	1991 May  7
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	-	ART	2004 May 31
-			-4:00	-	WART	2004 Jul 25
-			-3:00	Arg	AR%sT	2008 Oct 18
-			-3:00	-	ART
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1991 Mar  1
+			-4:00	-	-04	1991 May  7
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	-	-03	2004 May 31
+			-4:00	-	-04	2004 Jul 25
+			-3:00	Arg	-03/-02	2008 Oct 18
+			-3:00	-	-03
 #
 # Jujuy (JY)
 Zone America/Argentina/Jujuy -4:21:12 -	LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1990 Mar  4
-			-4:00	-	WART	1990 Oct 28
-			-4:00	1:00	WARST	1991 Mar 17
-			-4:00	-	WART	1991 Oct  6
-			-3:00	1:00	ARST	1992
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	Arg	AR%sT	2008 Oct 18
-			-3:00	-	ART
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1990 Mar  4
+			-4:00	-	-04	1990 Oct 28
+			-4:00	1:00	-03	1991 Mar 17
+			-4:00	-	-04	1991 Oct  6
+			-3:00	1:00	-02	1992
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	Arg	-03/-02	2008 Oct 18
+			-3:00	-	-03
 #
 # Catamarca (CT), Chubut (CH)
 Zone America/Argentina/Catamarca -4:23:08 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1991 Mar  3
-			-4:00	-	WART	1991 Oct 20
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	-	ART	2004 Jun  1
-			-4:00	-	WART	2004 Jun 20
-			-3:00	Arg	AR%sT	2008 Oct 18
-			-3:00	-	ART
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1991 Mar  3
+			-4:00	-	-04	1991 Oct 20
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	-	-03	2004 Jun  1
+			-4:00	-	-04	2004 Jun 20
+			-3:00	Arg	-03/-02	2008 Oct 18
+			-3:00	-	-03
 #
 # Mendoza (MZ)
 Zone America/Argentina/Mendoza -4:35:16 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1990 Mar  4
-			-4:00	-	WART	1990 Oct 15
-			-4:00	1:00	WARST	1991 Mar  1
-			-4:00	-	WART	1991 Oct 15
-			-4:00	1:00	WARST	1992 Mar  1
-			-4:00	-	WART	1992 Oct 18
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	-	ART	2004 May 23
-			-4:00	-	WART	2004 Sep 26
-			-3:00	Arg	AR%sT	2008 Oct 18
-			-3:00	-	ART
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1990 Mar  4
+			-4:00	-	-04	1990 Oct 15
+			-4:00	1:00	-03	1991 Mar  1
+			-4:00	-	-04	1991 Oct 15
+			-4:00	1:00	-03	1992 Mar  1
+			-4:00	-	-04	1992 Oct 18
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	-	-03	2004 May 23
+			-4:00	-	-04	2004 Sep 26
+			-3:00	Arg	-03/-02	2008 Oct 18
+			-3:00	-	-03
 #
 # San Luis (SL)
 
@@ -584,44 +556,44 @@
 
 Zone America/Argentina/San_Luis -4:25:24 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1990
-			-3:00	1:00	ARST	1990 Mar 14
-			-4:00	-	WART	1990 Oct 15
-			-4:00	1:00	WARST	1991 Mar  1
-			-4:00	-	WART	1991 Jun  1
-			-3:00	-	ART	1999 Oct  3
-			-4:00	1:00	WARST	2000 Mar  3
-			-3:00	-	ART	2004 May 31
-			-4:00	-	WART	2004 Jul 25
-			-3:00	Arg	AR%sT	2008 Jan 21
-			-4:00	SanLuis	WAR%sT	2009 Oct 11
-			-3:00	-	ART
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1990
+			-3:00	1:00	-02	1990 Mar 14
+			-4:00	-	-04	1990 Oct 15
+			-4:00	1:00	-03	1991 Mar  1
+			-4:00	-	-04	1991 Jun  1
+			-3:00	-	-03	1999 Oct  3
+			-4:00	1:00	-03	2000 Mar  3
+			-3:00	-	-03	2004 May 31
+			-4:00	-	-04	2004 Jul 25
+			-3:00	Arg	-03/-02	2008 Jan 21
+			-4:00	SanLuis	-04/-03	2009 Oct 11
+			-3:00	-	-03
 #
 # Santa Cruz (SC)
 Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT	1894 Oct 31
-			-4:16:48 -	CMT	1920 May    # Córdoba Mean Time
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	-	ART	2004 Jun  1
-			-4:00	-	WART	2004 Jun 20
-			-3:00	Arg	AR%sT	2008 Oct 18
-			-3:00	-	ART
+			-4:16:48 -	CMT	1920 May
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	-	-03	2004 Jun  1
+			-4:00	-	-04	2004 Jun 20
+			-3:00	Arg	-03/-02	2008 Oct 18
+			-3:00	-	-03
 #
 # Tierra del Fuego, Antártida e Islas del Atlántico Sur (TF)
 Zone America/Argentina/Ushuaia -4:33:12 - LMT	1894 Oct 31
-			-4:16:48 -	CMT	1920 May    # Córdoba Mean Time
-			-4:00	-	ART	1930 Dec
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1999 Oct  3
-			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	-	ART	2004 May 30
-			-4:00	-	WART	2004 Jun 20
-			-3:00	Arg	AR%sT	2008 Oct 18
-			-3:00	-	ART
+			-4:16:48 -	CMT	1920 May
+			-4:00	-	-04	1930 Dec
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1999 Oct  3
+			-4:00	Arg	-04/-03	2000 Mar  3
+			-3:00	-	-03	2004 May 30
+			-4:00	-	-04	2004 Jun 20
+			-3:00	Arg	-03/-02	2008 Oct 18
+			-3:00	-	-03
 
 # Aruba
 Link America/Curacao America/Aruba
@@ -631,7 +603,7 @@
 Zone	America/La_Paz	-4:32:36 -	LMT	1890
 			-4:32:36 -	CMT	1931 Oct 15 # Calamarca MT
 			-4:32:36 1:00	BOST	1932 Mar 21 # Bolivia ST
-			-4:00	-	BOT	# Bolivia Time
+			-4:00	-	-04
 
 # Brazil
 
@@ -983,12 +955,12 @@
 #
 # Fernando de Noronha (administratively part of PE)
 Zone America/Noronha	-2:09:40 -	LMT	1914
-			-2:00	Brazil	FN%sT	1990 Sep 17
-			-2:00	-	FNT	1999 Sep 30
-			-2:00	Brazil	FN%sT	2000 Oct 15
-			-2:00	-	FNT	2001 Sep 13
-			-2:00	Brazil	FN%sT	2002 Oct  1
-			-2:00	-	FNT
+			-2:00	Brazil	-02/-01	1990 Sep 17
+			-2:00	-	-02	1999 Sep 30
+			-2:00	Brazil	-02/-01	2000 Oct 15
+			-2:00	-	-02	2001 Sep 13
+			-2:00	Brazil	-02/-01	2002 Oct  1
+			-2:00	-	-02
 # Other Atlantic islands have no permanent settlement.
 # These include Trindade and Martim Vaz (administratively part of ES),
 # Rocas Atoll (RN), and the St Peter and St Paul Archipelago (PE).
@@ -1001,119 +973,119 @@
 # In the north a very small part from the river Javary (now Jari I guess,
 # the border with Amapá) to the Amazon, then to the Xingu.
 Zone America/Belem	-3:13:56 -	LMT	1914
-			-3:00	Brazil	BR%sT	1988 Sep 12
-			-3:00	-	BRT
+			-3:00	Brazil	-03/-02	1988 Sep 12
+			-3:00	-	-03
 #
 # west Pará (PA)
 # West Pará includes Altamira, Óbidos, Prainha, Oriximiná, and Santarém.
 Zone America/Santarem	-3:38:48 -	LMT	1914
-			-4:00	Brazil	AM%sT	1988 Sep 12
-			-4:00	-	AMT	2008 Jun 24  0:00
-			-3:00	-	BRT
+			-4:00	Brazil	-04/-03	1988 Sep 12
+			-4:00	-	-04	2008 Jun 24  0:00
+			-3:00	-	-03
 #
 # Maranhão (MA), Piauí (PI), Ceará (CE), Rio Grande do Norte (RN),
 # Paraíba (PB)
 Zone America/Fortaleza	-2:34:00 -	LMT	1914
-			-3:00	Brazil	BR%sT	1990 Sep 17
-			-3:00	-	BRT	1999 Sep 30
-			-3:00	Brazil	BR%sT	2000 Oct 22
-			-3:00	-	BRT	2001 Sep 13
-			-3:00	Brazil	BR%sT	2002 Oct  1
-			-3:00	-	BRT
+			-3:00	Brazil	-03/-02	1990 Sep 17
+			-3:00	-	-03	1999 Sep 30
+			-3:00	Brazil	-03/-02	2000 Oct 22
+			-3:00	-	-03	2001 Sep 13
+			-3:00	Brazil	-03/-02	2002 Oct  1
+			-3:00	-	-03
 #
 # Pernambuco (PE) (except Atlantic islands)
 Zone America/Recife	-2:19:36 -	LMT	1914
-			-3:00	Brazil	BR%sT	1990 Sep 17
-			-3:00	-	BRT	1999 Sep 30
-			-3:00	Brazil	BR%sT	2000 Oct 15
-			-3:00	-	BRT	2001 Sep 13
-			-3:00	Brazil	BR%sT	2002 Oct  1
-			-3:00	-	BRT
+			-3:00	Brazil	-03/-02	1990 Sep 17
+			-3:00	-	-03	1999 Sep 30
+			-3:00	Brazil	-03/-02	2000 Oct 15
+			-3:00	-	-03	2001 Sep 13
+			-3:00	Brazil	-03/-02	2002 Oct  1
+			-3:00	-	-03
 #
 # Tocantins (TO)
 Zone America/Araguaina	-3:12:48 -	LMT	1914
-			-3:00	Brazil	BR%sT	1990 Sep 17
-			-3:00	-	BRT	1995 Sep 14
-			-3:00	Brazil	BR%sT	2003 Sep 24
-			-3:00	-	BRT	2012 Oct 21
-			-3:00	Brazil	BR%sT	2013 Sep
-			-3:00	-	BRT
+			-3:00	Brazil	-03/-02	1990 Sep 17
+			-3:00	-	-03	1995 Sep 14
+			-3:00	Brazil	-03/-02	2003 Sep 24
+			-3:00	-	-03	2012 Oct 21
+			-3:00	Brazil	-03/-02	2013 Sep
+			-3:00	-	-03
 #
 # Alagoas (AL), Sergipe (SE)
 Zone America/Maceio	-2:22:52 -	LMT	1914
-			-3:00	Brazil	BR%sT	1990 Sep 17
-			-3:00	-	BRT	1995 Oct 13
-			-3:00	Brazil	BR%sT	1996 Sep  4
-			-3:00	-	BRT	1999 Sep 30
-			-3:00	Brazil	BR%sT	2000 Oct 22
-			-3:00	-	BRT	2001 Sep 13
-			-3:00	Brazil	BR%sT	2002 Oct  1
-			-3:00	-	BRT
+			-3:00	Brazil	-03/-02	1990 Sep 17
+			-3:00	-	-03	1995 Oct 13
+			-3:00	Brazil	-03/-02	1996 Sep  4
+			-3:00	-	-03	1999 Sep 30
+			-3:00	Brazil	-03/-02	2000 Oct 22
+			-3:00	-	-03	2001 Sep 13
+			-3:00	Brazil	-03/-02	2002 Oct  1
+			-3:00	-	-03
 #
 # Bahia (BA)
 # There are too many Salvadors elsewhere, so use America/Bahia instead
 # of America/Salvador.
 Zone America/Bahia	-2:34:04 -	LMT	1914
-			-3:00	Brazil	BR%sT	2003 Sep 24
-			-3:00	-	BRT	2011 Oct 16
-			-3:00	Brazil	BR%sT	2012 Oct 21
-			-3:00	-	BRT
+			-3:00	Brazil	-03/-02	2003 Sep 24
+			-3:00	-	-03	2011 Oct 16
+			-3:00	Brazil	-03/-02	2012 Oct 21
+			-3:00	-	-03
 #
 # Goiás (GO), Distrito Federal (DF), Minas Gerais (MG),
 # Espírito Santo (ES), Rio de Janeiro (RJ), São Paulo (SP), Paraná (PR),
 # Santa Catarina (SC), Rio Grande do Sul (RS)
 Zone America/Sao_Paulo	-3:06:28 -	LMT	1914
-			-3:00	Brazil	BR%sT	1963 Oct 23  0:00
-			-3:00	1:00	BRST	1964
-			-3:00	Brazil	BR%sT
+			-3:00	Brazil	-03/-02	1963 Oct 23  0:00
+			-3:00	1:00	-02	1964
+			-3:00	Brazil	-03/-02
 #
 # Mato Grosso do Sul (MS)
 Zone America/Campo_Grande -3:38:28 -	LMT	1914
-			-4:00	Brazil	AM%sT
+			-4:00	Brazil	-04/-03
 #
 # Mato Grosso (MT)
 Zone America/Cuiaba	-3:44:20 -	LMT	1914
-			-4:00	Brazil	AM%sT	2003 Sep 24
-			-4:00	-	AMT	2004 Oct  1
-			-4:00	Brazil	AM%sT
+			-4:00	Brazil	-04/-03	2003 Sep 24
+			-4:00	-	-04	2004 Oct  1
+			-4:00	Brazil	-04/-03
 #
 # Rondônia (RO)
 Zone America/Porto_Velho -4:15:36 -	LMT	1914
-			-4:00	Brazil	AM%sT	1988 Sep 12
-			-4:00	-	AMT
+			-4:00	Brazil	-04/-03	1988 Sep 12
+			-4:00	-	-04
 #
 # Roraima (RR)
 Zone America/Boa_Vista	-4:02:40 -	LMT	1914
-			-4:00	Brazil	AM%sT	1988 Sep 12
-			-4:00	-	AMT	1999 Sep 30
-			-4:00	Brazil	AM%sT	2000 Oct 15
-			-4:00	-	AMT
+			-4:00	Brazil	-04/-03	1988 Sep 12
+			-4:00	-	-04	1999 Sep 30
+			-4:00	Brazil	-04/-03	2000 Oct 15
+			-4:00	-	-04
 #
 # east Amazonas (AM): Boca do Acre, Jutaí, Manaus, Floriano Peixoto
 # The great circle line from Tabatinga to Porto Acre divides
 # east from west Amazonas.
 Zone America/Manaus	-4:00:04 -	LMT	1914
-			-4:00	Brazil	AM%sT	1988 Sep 12
-			-4:00	-	AMT	1993 Sep 28
-			-4:00	Brazil	AM%sT	1994 Sep 22
-			-4:00	-	AMT
+			-4:00	Brazil	-04/-03	1988 Sep 12
+			-4:00	-	-04	1993 Sep 28
+			-4:00	Brazil	-04/-03	1994 Sep 22
+			-4:00	-	-04
 #
 # west Amazonas (AM): Atalaia do Norte, Boca do Maoco, Benjamin Constant,
 #	Eirunepé, Envira, Ipixuna
 Zone America/Eirunepe	-4:39:28 -	LMT	1914
-			-5:00	Brazil	AC%sT	1988 Sep 12
-			-5:00	-	ACT	1993 Sep 28
-			-5:00	Brazil	AC%sT	1994 Sep 22
-			-5:00	-	ACT	2008 Jun 24  0:00
-			-4:00	-	AMT	2013 Nov 10
-			-5:00	-	ACT
+			-5:00	Brazil	-05/-04	1988 Sep 12
+			-5:00	-	-05	1993 Sep 28
+			-5:00	Brazil	-05/-04	1994 Sep 22
+			-5:00	-	-05	2008 Jun 24  0:00
+			-4:00	-	-04	2013 Nov 10
+			-5:00	-	-05
 #
 # Acre (AC)
 Zone America/Rio_Branco	-4:31:12 -	LMT	1914
-			-5:00	Brazil	AC%sT	1988 Sep 12
-			-5:00	-	ACT	2008 Jun 24  0:00
-			-4:00	-	AMT	2013 Nov 10
-			-5:00	-	ACT
+			-5:00	Brazil	-05/-04	1988 Sep 12
+			-5:00	-	-05	2008 Jun 24  0:00
+			-4:00	-	-04	2013 Nov 10
+			-5:00	-	-05
 
 # Chile
 
@@ -1258,6 +1230,18 @@
 # to mean 24:00 mainland time, not 24:00 local time, so that Easter
 # Island is always two hours behind the mainland.
 
+# From Juan Correa (2016-12-04):
+# Magallanes region ... will keep DST (UTC -3) all year round....
+# http://www.soychile.cl/Santiago/Sociedad/2016/12/04/433428/Bachelet-firmo-el-decreto-para-establecer-un-horario-unico-para-la-Region-de-Magallanes.aspx
+#
+# From Deborah Goldsmith (2017-01-19):
+# http://www.diariooficial.interior.gob.cl/publicaciones/2017/01/17/41660/01/1169626.pdf
+# From Paul Eggert (2017-01-19):
+# The above says the Magallanes change expires 2019-05-11 at 24:00,
+# so in theory, they will revert to -04/-03 after that, which means
+# they will switch from -03 to -04 one hour after Santiago does that day.
+# For now, assume that they will not revert.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Chile	1927	1931	-	Sep	 1	0:00	1:00	S
 Rule	Chile	1928	1932	-	Apr	 1	0:00	0	-
@@ -1298,22 +1282,35 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Santiago	-4:42:46 -	LMT	1890
 			-4:42:46 -	SMT	1910 Jan 10 # Santiago Mean Time
-			-5:00	-	CLT	1916 Jul  1 # Chile Time
+			-5:00	-	-05	1916 Jul  1
 			-4:42:46 -	SMT	1918 Sep 10
-			-4:00	-	CLT	1919 Jul  1
+			-4:00	-	-04	1919 Jul  1
 			-4:42:46 -	SMT	1927 Sep  1
-			-5:00	Chile	CL%sT	1932 Sep  1
-			-4:00	-	CLT	1942 Jun  1
-			-5:00	-	CLT	1942 Aug  1
-			-4:00	-	CLT	1946 Jul 15
-			-4:00	1:00	CLST	1946 Sep  1 # central Chile
-			-4:00	-	CLT	1947 Apr  1
-			-5:00	-	CLT	1947 May 21 23:00
-			-4:00	Chile	CL%sT
+			-5:00	Chile	-05/-04	1932 Sep  1
+			-4:00	-	-04	1942 Jun  1
+			-5:00	-	-05	1942 Aug  1
+			-4:00	-	-04	1946 Jul 15
+			-4:00	1:00	-03	1946 Sep  1 # central Chile
+			-4:00	-	-04	1947 Apr  1
+			-5:00	-	-05	1947 May 21 23:00
+			-4:00	Chile	-04/-03
+Zone America/Punta_Arenas -4:43:40 -	LMT	1890
+			-4:42:46 -	SMT	1910 Jan 10
+			-5:00	-	-05	1916 Jul  1
+			-4:42:46 -	SMT	1918 Sep 10
+			-4:00	-	-04	1919 Jul  1
+			-4:42:46 -	SMT	1927 Sep  1
+			-5:00	Chile	-05/-04	1932 Sep  1
+			-4:00	-	-04	1942 Jun  1
+			-5:00	-	-05	1942 Aug  1
+			-4:00	-	-04	1947 Apr  1
+			-5:00	-	-05	1947 May 21 23:00
+			-4:00	Chile	-04/-03	2016 Dec  4
+			-3:00	-	-03
 Zone Pacific/Easter	-7:17:28 -	LMT	1890
 			-7:17:28 -	EMT	1932 Sep    # Easter Mean Time
-			-7:00	Chile	EAS%sT	1982 Mar 14 3:00u # Easter Time
-			-6:00	Chile	EAS%sT
+			-7:00	Chile	-07/-06	1982 Mar 14 3:00u # Easter Time
+			-6:00	Chile	-06/-05
 #
 # Salas y Gómez Island is uninhabited.
 # Other Chilean locations, including Juan Fernández Is, Desventuradas Is,
@@ -1333,9 +1330,10 @@
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Palmer	0	-	-00	1965
-			-4:00	Arg	AR%sT	1969 Oct  5
-			-3:00	Arg	AR%sT	1982 May
-			-4:00	Chile	CL%sT
+			-4:00	Arg	-04/-03	1969 Oct  5
+			-3:00	Arg	-03/-02	1982 May
+			-4:00	Chile	-04/-03	2016 Dec  4
+			-3:00	-	-03
 
 # Colombia
 
@@ -1348,7 +1346,7 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Bogota	-4:56:16 -	LMT	1884 Mar 13
 			-4:56:16 -	BMT	1914 Nov 23 # Bogotá Mean Time
-			-5:00	CO	CO%sT	# Colombia Time
+			-5:00	CO	-05/-04
 # Malpelo, Providencia, San Andres
 # no information; probably like America/Bogota
 
@@ -1372,7 +1370,7 @@
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Curacao	-4:35:47 -	LMT	1912 Feb 12 # Willemstad
-			-4:30	-	ANT	1965 # Netherlands Antilles Time
+			-4:30	-	-0430	1965
 			-4:00	-	AST
 
 # From Arthur David Olson (2011-06-15):
@@ -1387,19 +1385,32 @@
 #
 # Milne says the Central and South American Telegraph Company used -5:24:15.
 #
-# From Paul Eggert (2007-03-04):
-# Apparently Ecuador had a failed experiment with DST in 1992.
-# <http://midena.gov.ec/content/view/1261/208/> (2007-02-27) and
-# <http://www.hoy.com.ec/NoticiaNue.asp?row_id=249856> (2006-11-06) both
-# talk about "hora Sixto".  Leave this alone for now, as we have no data.
+# From Alois Treindl (2016-12-15):
+# http://www.elcomercio.com/actualidad/hora-sixto-1993.html
+# ... Whether the law applied also to Galápagos, I do not know.
+# From Paul Eggert (2016-12-15):
+# http://www.elcomercio.com/afull/modificacion-husohorario-ecuador-presidentes-decreto.html
+# This says President Sixto Durán Ballén signed decree No. 285, which
+# established DST from 1992-11-28 to 1993-02-05; it does not give transition
+# times.  The people called it "hora de Sixto" ("Sixto hour").  The change did
+# not go over well; a popular song "Qué hora es" by Jaime Guevara had lyrics
+# that included "Amanecía en mitad de la noche, los guaguas iban a clase sin
+# sol" ("It was dawning in the middle of the night, the buses went to class
+# without sun").  Although Ballén's campaign slogan was "Ni un paso atrás"
+# (Not one step back), the clocks went back in 1993 and the experiment was not
+# repeated.  For now, assume transitions were at 00:00 local time country-wide.
+#
+# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	Ecuador	1992	only	-	Nov	28	0:00	1:00	S
+Rule	Ecuador	1993	only	-	Feb	 5	0:00	0	-
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Guayaquil	-5:19:20 -	LMT	1890
 			-5:14:00 -	QMT	1931 # Quito Mean Time
-			-5:00	-	ECT	# Ecuador Time
+			-5:00	Ecuador	-05/-04
 Zone Pacific/Galapagos	-5:58:24 -	LMT	1931 # Puerto Baquerizo Moreno
-			-5:00	-	ECT	1986
-			-6:00	-	GALT	# Galápagos Time
+			-5:00	-	-05	1986
+			-6:00	Ecuador	-06/-05
 
 # Falklands
 
@@ -1499,25 +1510,24 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Atlantic/Stanley	-3:51:24 -	LMT	1890
 			-3:51:24 -	SMT	1912 Mar 12 # Stanley Mean Time
-			-4:00	Falk	FK%sT	1983 May    # Falkland Is Time
-			-3:00	Falk	FK%sT	1985 Sep 15
-			-4:00	Falk	FK%sT	2010 Sep  5  2:00
-			-3:00	-	FKST
+			-4:00	Falk	-04/-03	1983 May
+			-3:00	Falk	-03/-02	1985 Sep 15
+			-4:00	Falk	-04/-03	2010 Sep  5  2:00
+			-3:00	-	-03
 
 # French Guiana
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Cayenne	-3:29:20 -	LMT	1911 Jul
-			-4:00	-	GFT	1967 Oct # French Guiana Time
-			-3:00	-	GFT
+			-4:00	-	-04	1967 Oct
+			-3:00	-	-03
 
 # Guyana
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Guyana	-3:52:40 -	LMT	1915 Mar    # Georgetown
-			-3:45	-	GBGT	1966 May 26 # Br Guiana Time
-			-3:45	-	GYT	1975 Jul 31 # Guyana Time
-			-3:00	-	GYT	1991
+			-3:45	-	-0345	1975 Jul 31
+			-3:00	-	-03	1991
 # IATA SSIM (1996-06) says -4:00.  Assume a 1991 switch.
-			-4:00	-	GYT
+			-4:00	-	-04
 
 # Paraguay
 #
@@ -1609,9 +1619,9 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Asuncion	-3:50:40 -	LMT	1890
 			-3:50:40 -	AMT	1931 Oct 10 # Asunción Mean Time
-			-4:00	-	PYT	1972 Oct    # Paraguay Time
-			-3:00	-	PYT	1974 Apr
-			-4:00	Para	PY%sT
+			-4:00	-	-04	1972 Oct
+			-3:00	-	-03	1974 Apr
+			-4:00	Para	-04/-03
 
 # Peru
 #
@@ -1638,12 +1648,12 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Lima	-5:08:12 -	LMT	1890
 			-5:08:36 -	LMT	1908 Jul 28 # Lima Mean Time?
-			-5:00	Peru	PE%sT	# Peru Time
+			-5:00	Peru	-05/-04
 
 # South Georgia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Atlantic/South_Georgia -2:26:08 -	LMT	1890 # Grytviken
-			-2:00	-	GST	# South Georgia Time
+			-2:00	-	-02
 
 # South Sandwich Is
 # uninhabited; scientific personnel have wintered
@@ -1653,9 +1663,8 @@
 Zone America/Paramaribo	-3:40:40 -	LMT	1911
 			-3:40:52 -	PMT	1935     # Paramaribo Mean Time
 			-3:40:36 -	PMT	1945 Oct    # The capital moved?
-			-3:30	-	NEGT	1975 Nov 20 # Dutch Guiana Time
-			-3:30	-	SRT	1984 Oct    # Suriname Time
-			-3:00	-	SRT
+			-3:30	-	-0330	1984 Oct
+			-3:00	-	-03
 
 # Trinidad and Tobago
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -1758,11 +1767,16 @@
 # [dated 2015-06-29; repeals Decree 311/006 dated 2006-09-04]
 Rule	Uruguay	2006	2014	-	Oct	Sun>=1	 2:00	1:00	S
 Rule	Uruguay	2007	2015	-	Mar	Sun>=8	 2:00	0	-
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
+
+# This Zone can be simplified once we assume zic %z.
 Zone America/Montevideo	-3:44:44 -	LMT	1898 Jun 28
 			-3:44:44 -	MMT	1920 May  1 # Montevideo MT
-			-3:30	Uruguay	UY%sT	1942 Dec 14 # Uruguay Time
-			-3:00	Uruguay	UY%sT
+			-3:30	Uruguay	-0330/-03 1942 Dec 14
+			-3:00	Uruguay	-03/-02	1968
+			-3:00	Uruguay	-03/-0230 1971
+			-3:00	Uruguay	-03/-02	1974
+			-3:00	Uruguay	-03/-0230 1974 Dec 22
+			-3:00	Uruguay	-03/-02
 
 # Venezuela
 #
@@ -1796,7 +1810,7 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Caracas	-4:27:44 -	LMT	1890
 			-4:27:40 -	CMT	1912 Feb 12 # Caracas Mean Time?
-			-4:30	-	VET	1965 Jan  1  0:00 # Venezuela T.
-			-4:00	-	VET	2007 Dec  9  3:00
-			-4:30	-	VET	2016 May  1  2:30
-			-4:00	-	VET
+			-4:30	-	-0430	1965 Jan  1  0:00
+			-4:00	-	-04	2007 Dec  9  3:00
+			-4:30	-	-0430	2016 May  1  2:30
+			-4:00	-	-04
--- a/make/sun/javazic/tzdata/zone.tab	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/javazic/tzdata/zone.tab	Sun May 28 23:44:03 2017 -0700
@@ -165,6 +165,7 @@
 CI	+0519-00402	Africa/Abidjan
 CK	-2114-15946	Pacific/Rarotonga
 CL	-3327-07040	America/Santiago	Chile (most areas)
+CL	-5309-07055	America/Punta_Arenas	Region of Magallanes
 CL	-2709-10926	Pacific/Easter	Easter Island
 CM	+0403+00942	Africa/Douala
 CN	+3114+12128	Asia/Shanghai	Beijing Time
@@ -262,7 +263,8 @@
 KZ	+4315+07657	Asia/Almaty	Kazakhstan (most areas)
 KZ	+4448+06528	Asia/Qyzylorda	Qyzylorda/Kyzylorda/Kzyl-Orda
 KZ	+5017+05710	Asia/Aqtobe	Aqtobe/Aktobe
-KZ	+4431+05016	Asia/Aqtau	Atyrau/Atirau/Gur'yev, Mangghystau/Mankistau
+KZ	+4431+05016	Asia/Aqtau	Mangghystau/Mankistau
+KZ	+4707+05156	Asia/Atyrau	Atyrau/Atirau/Gur'yev
 KZ	+5113+05121	Asia/Oral	West Kazakhstan
 LA	+1758+10236	Asia/Vientiane
 LB	+3353+03530	Asia/Beirut
@@ -353,14 +355,15 @@
 RU	+5443+02030	Europe/Kaliningrad	MSK-01 - Kaliningrad
 RU	+554521+0373704	Europe/Moscow	MSK+00 - Moscow area
 RU	+4457+03406	Europe/Simferopol	MSK+00 - Crimea
-RU	+4844+04425	Europe/Volgograd	MSK+00 - Volgograd, Saratov
+RU	+4844+04425	Europe/Volgograd	MSK+00 - Volgograd
 RU	+5836+04939	Europe/Kirov	MSK+00 - Kirov
 RU	+4621+04803	Europe/Astrakhan	MSK+01 - Astrakhan
+RU	+5134+04602	Europe/Saratov	MSK+01 - Saratov
+RU	+5420+04824	Europe/Ulyanovsk	MSK+01 - Ulyanovsk
 RU	+5312+05009	Europe/Samara	MSK+01 - Samara, Udmurtia
-RU	+5420+04824	Europe/Ulyanovsk	MSK+01 - Ulyanovsk
 RU	+5651+06036	Asia/Yekaterinburg	MSK+02 - Urals
 RU	+5500+07324	Asia/Omsk	MSK+03 - Omsk
-RU	+5502+08255	Asia/Novosibirsk	MSK+03 - Novosibirsk
+RU	+5502+08255	Asia/Novosibirsk	MSK+04 - Novosibirsk
 RU	+5322+08345	Asia/Barnaul	MSK+04 - Altai
 RU	+5630+08458	Asia/Tomsk	MSK+04 - Tomsk
 RU	+5345+08707	Asia/Novokuznetsk	MSK+04 - Kemerovo
@@ -418,7 +421,6 @@
 UA	+4837+02218	Europe/Uzhgorod	Ruthenia
 UA	+4750+03510	Europe/Zaporozhye	Zaporozh'ye/Zaporizhia; Lugansk/Luhansk (east)
 UG	+0019+03225	Africa/Kampala
-UM	+1645-16931	Pacific/Johnston	Johnston Atoll
 UM	+2813-17722	Pacific/Midway	Midway Islands
 UM	+1917+16637	Pacific/Wake	Wake Island
 US	+404251-0740023	America/New_York	Eastern (most areas)
--- a/make/sun/lwawt/FILES_export_macosx.gmk	Wed May 24 00:32:01 2017 -0700
+++ b/make/sun/lwawt/FILES_export_macosx.gmk	Sun May 28 23:44:03 2017 -0700
@@ -109,7 +109,6 @@
         sun/lwawt/LWToolkit.java \
         sun/lwawt/LWWindowPeer.java \
         sun/lwawt/PlatformWindow.java \
-        sun/lwawt/SelectionClearListener.java \
         sun/lwawt/macosx/CPrinterDevice.java \
         sun/lwawt/macosx/CPrinterDialog.java \
         sun/lwawt/macosx/CPrinterDialogPeer.java \
--- a/src/macosx/classes/com/apple/eawt/_AppDockIconHandler.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/com/apple/eawt/_AppDockIconHandler.java	Sun May 28 23:44:03 2017 -0700
@@ -72,8 +72,12 @@
     public void setDockIconImage(final Image image) {
         try {
             final CImage cImage = getCImageCreator().createFromImage(image);
-            final long nsImagePtr = getNSImagePtrFrom(cImage);
-            nativeSetDockIconImage(nsImagePtr);
+            cImage.execute(new CFRetainedResource.CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    _AppDockIconHandler.nativeSetDockIconImage(ptr);
+                }
+            });
         } catch (final Throwable e) {
             throw new RuntimeException(e);
         }
@@ -102,16 +106,4 @@
             throw new RuntimeException(e);
         }
     }
-
-    static long getNSImagePtrFrom(final CImage cImage) {
-        if (cImage == null) return 0;
-
-        try {
-            final Field cImagePtrField = CFRetainedResource.class.getDeclaredField("ptr");
-            cImagePtrField.setAccessible(true);
-            return cImagePtrField.getLong(cImage);
-        } catch (final Throwable e) {
-            throw new RuntimeException(e);
-        }
-    }
 }
--- a/src/macosx/classes/com/apple/laf/AquaIcon.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/com/apple/laf/AquaIcon.java	Sun May 28 23:44:03 2017 -0700
@@ -295,7 +295,14 @@
         }
 
         Image createImage() {
-            return AquaUtils.getCImageCreator().createSystemImageFromSelector(selector, getIconWidth(), getIconHeight());
+            int w = getIconWidth();
+            int h = getIconHeight();
+            return new AquaImageFactory.MultiResolutionIconImage(
+                    AquaUtils.getCImageCreator().createSystemImageFromSelector(
+                            selector, w, h),
+                    AquaUtils.getCImageCreator().createSystemImageFromSelector(
+                            selector, 2 * w, 2 * h)
+            );
         }
     }
 }
--- a/src/macosx/classes/com/apple/laf/AquaImageFactory.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/com/apple/laf/AquaImageFactory.java	Sun May 28 23:44:03 2017 -0700
@@ -46,6 +46,10 @@
 import com.apple.laf.AquaIcon.SystemIcon;
 import com.apple.laf.AquaUtils.RecyclableObject;
 import com.apple.laf.AquaUtils.RecyclableSingleton;
+import java.util.Arrays;
+import java.util.List;
+import sun.awt.image.MultiResolutionBufferedImage;
+import sun.awt.image.MultiResolutionImage;
 
 public class AquaImageFactory {
     public static IconUIResource getConfirmImageIcon() {
@@ -120,28 +124,48 @@
 
     private static final int kAlertIconSize = 64;
     static IconUIResource getAppIconCompositedOn(final Image background) {
-        final double scaleFactor = 1.0; // revise for HiDPI
 
-        final int kAlertSubIconSize = (int)(kAlertIconSize * 0.5 * scaleFactor);
-        final int kAlertSubIconInset = (int)(kAlertIconSize * scaleFactor) - kAlertSubIconSize;
-        final Icon smallAppIconScaled = new AquaIcon.CachingScalingIcon(kAlertSubIconSize, kAlertSubIconSize) {
-            Image createImage() {
-                return getThisApplicationsIcon(kAlertSubIconSize, kAlertSubIconSize);
-            }
-        };
+        final BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
 
-        final BufferedImage image = new BufferedImage(kAlertIconSize, kAlertIconSize, BufferedImage.TYPE_INT_ARGB);
+        if (background instanceof MultiResolutionIconImage) {
+            BufferedImage background2x
+                    = ((MultiResolutionIconImage) background).resolutionVariant;
+            BufferedImage icon2xImage = getAppIconImageCompositedOn(background2x, 2);
+
+            return new IconUIResource(new ImageIcon(
+                    new MultiResolutionIconImage(iconImage, icon2xImage)));
+        }
+        return new IconUIResource(new ImageIcon(iconImage));
+    }
+
+    static BufferedImage getAppIconImageCompositedOn(final Image background, int scaleFactor) {
+
+        final int scaledAlertIconSize = kAlertIconSize * scaleFactor;
+        final int kAlertSubIconSize = (int) (scaledAlertIconSize * 0.5);
+        final int kAlertSubIconInset = scaledAlertIconSize - kAlertSubIconSize;
+        final Icon smallAppIconScaled = new AquaIcon.CachingScalingIcon(
+                kAlertSubIconSize, kAlertSubIconSize) {
+                    Image createImage() {
+                        return getThisApplicationsIcon(kAlertSubIconSize, kAlertSubIconSize);
+                    }
+                };
+
+        final BufferedImage image = new BufferedImage(scaledAlertIconSize,
+                scaledAlertIconSize, BufferedImage.TYPE_INT_ARGB);
         final Graphics g = image.getGraphics();
-        g.drawImage(background, 0, 0, (int)(kAlertIconSize * scaleFactor), (int)(kAlertIconSize * scaleFactor), null);
+        g.drawImage(background, 0, 0,
+                scaledAlertIconSize, scaledAlertIconSize, null);
         if (g instanceof Graphics2D) {
             // improves icon rendering quality in Quartz
-            ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+            ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING,
+                    RenderingHints.VALUE_RENDER_QUALITY);
         }
 
-        smallAppIconScaled.paintIcon(null, g, kAlertSubIconInset, kAlertSubIconInset);
+        smallAppIconScaled.paintIcon(null, g,
+                kAlertSubIconInset, kAlertSubIconInset);
         g.dispose();
 
-        return new IconUIResource(new ImageIcon(image));
+        return image;
     }
 
     public static IconUIResource getTreeFolderIcon() {
@@ -207,7 +231,7 @@
 
         @Override
         protected Image getInstance() {
-            return Toolkit.getDefaultToolkit().getImage("NSImage://" + namedImage);
+            return getNSIcon(namedImage);
         }
     }
 
@@ -271,11 +295,27 @@
     }
 
     public static Icon getMenuItemCheckIcon() {
-        return new InvertableImageIcon(AquaUtils.generateLightenedImage(Toolkit.getDefaultToolkit().getImage("NSImage://NSMenuItemSelection"), 25));
+        return new InvertableImageIcon(AquaUtils.generateLightenedImage(
+                getNSIcon("NSMenuItemSelection"), 25));
     }
 
     public static Icon getMenuItemDashIcon() {
-        return new InvertableImageIcon(AquaUtils.generateLightenedImage(Toolkit.getDefaultToolkit().getImage("NSImage://NSMenuMixedState"), 25));
+        return new InvertableImageIcon(AquaUtils.generateLightenedImage(
+                getNSIcon("NSMenuMixedState"), 25));
+    }
+
+    private static Image getNSIcon(String imageName) {
+        Image icon = Toolkit.getDefaultToolkit()
+                .getImage("NSImage://" + imageName);
+
+        if (icon instanceof MultiResolutionImage) {
+            return icon;
+        }
+
+        Image icon2x = AquaUtils.getCImageCreator().createImageFromName(
+                imageName, 2 * icon.getWidth(null), 2 * icon.getHeight(null));
+        return new MultiResolutionBufferedImage(
+                BufferedImage.TYPE_INT_ARGB_PRE, 0, icon, icon2x);
     }
 
     public static class NineSliceMetrics {
@@ -484,4 +524,29 @@
     public static Color getSelectionInactiveForegroundColorUIResource() {
         return new SystemColorProxy(LWCToolkit.getAppleColor(LWCToolkit.INACTIVE_SELECTION_FOREGROUND_COLOR));
     }
+
+    static class MultiResolutionIconImage extends BufferedImage
+            implements MultiResolutionImage {
+
+        BufferedImage resolutionVariant;
+
+        public MultiResolutionIconImage(BufferedImage image, BufferedImage resolutionVariant) {
+            super(image.getWidth(), image.getHeight(), image.getType());
+            this.resolutionVariant = resolutionVariant;
+            Graphics g = getGraphics();
+            g.drawImage(image, 0, 0, null);
+            g.dispose();
+        }
+
+        @Override
+        public Image getResolutionVariant(int width, int height) {
+            return ((width <= getWidth() && height <= getHeight()))
+                    ? this : resolutionVariant;
+        }
+
+        @Override
+        public List<Image> getResolutionVariants() {
+            return Arrays.asList((Image) this, resolutionVariant);
+        }
+    }
 }
--- a/src/macosx/classes/com/apple/laf/AquaUtils.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/com/apple/laf/AquaUtils.java	Sun May 28 23:44:03 2017 -0700
@@ -48,6 +48,7 @@
 import sun.swing.SwingUtilities2;
 
 import com.apple.laf.AquaImageFactory.SlicedImageControl;
+import sun.awt.image.MultiResolutionBufferedImage;
 
 final class AquaUtils {
 
@@ -123,6 +124,17 @@
 
     static Image generateLightenedImage(final Image image, final int percent) {
         final GrayFilter filter = new GrayFilter(true, percent);
+        return (image instanceof MultiResolutionBufferedImage)
+                ? ((MultiResolutionBufferedImage) image).map(new MultiResolutionBufferedImage.ImageMapper() {
+                        @Override
+                        public Image mapImage(Image rv) {
+                            return generateLightenedImage(rv, filter);
+                        }
+                  })
+                : generateLightenedImage(image, filter);
+    }
+
+    static Image generateLightenedImage(Image image, ImageFilter filter) {
         final ImageProducer prod = new FilteredImageSource(image.getSource(), filter);
         return Toolkit.getDefaultToolkit().createImage(prod);
     }
@@ -452,4 +464,3 @@
         }
     }
 }
-
--- a/src/macosx/classes/com/apple/laf/resources/aqua_de.properties	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/com/apple/laf/resources/aqua_de.properties	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
 FileChooser.openButton.textAndMnemonic=\u00D6ffnen
 FileChooser.saveDialogTitle.textAndMnemonic=Speichern
 FileChooser.openDialogTitle.textAndMnemonic=\u00D6ffnen
-FileChooser.updateButton.textAndMnemonic=Updaten
+FileChooser.updateButton.textAndMnemonic=Aktualisieren
 FileChooser.helpButton.textAndMnemonic=Hilfe
 FileChooser.directoryOpenButton.textAndMnemonic=\u00D6ffnen
 
@@ -124,9 +124,9 @@
 
 # The following string will be formatted by a MessageFormat
 # and {0} will be replaced by page number being printed
-PrintingDialog.contentProgress.textAndMnemonic=Seite {0} wurde gedruckt ...
+PrintingDialog.contentProgress.textAndMnemonic=Seite {0} wurde gedruckt...
 
-PrintingDialog.contentAborting.textAndMnemonic=Druckvorgang wird abgebrochen ...
+PrintingDialog.contentAborting.textAndMnemonic=Druckvorgang wird abgebrochen...
 
 PrintingDialog.abortButton.textAndMnemonic=&Abbruch
 PrintingDialog.abortButtonToolTip.textAndMnemonic=Druckvorgang abbrechen
@@ -149,7 +149,7 @@
 # Used for html forms
 FormView.submitButton.textAndMnemonic=Abfrage weiterleiten
 FormView.resetButton.textAndMnemonic=Zur\u00FCcksetzen
-FormView.browseFileButton.textAndMnemonic=Durchsuchen ...
+FormView.browseFileButton.textAndMnemonic=Durchsuchen...
 
 ############ Abstract Document Strings ############
 AbstractDocument.styleChange.textAndMnemonic=Formatvorlagen\u00E4nderung
@@ -169,7 +169,7 @@
 ComboBox.togglePopup.textAndMnemonic=togglePopup
 
 ############ Progress Monitor Strings ############
-ProgressMonitor.progress.textAndMnemonic=Fortschritt ...
+ProgressMonitor.progress.textAndMnemonic=Fortschritt...
 
 ############ Split Pane Strings ############
 SplitPane.leftButton.textAndMnemonic=linke Schaltfl\u00E4che
--- a/src/macosx/classes/com/apple/laf/resources/aqua_sv.properties	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/com/apple/laf/resources/aqua_sv.properties	Sun May 28 23:44:03 2017 -0700
@@ -173,7 +173,7 @@
 
 ############ Split Pane Strings ############
 SplitPane.leftButton.textAndMnemonic=v\u00E4nsterknapp
-SplitPane.rightButton.textAndMnemonic=h\u00F6ger knapp
+SplitPane.rightButton.textAndMnemonic=h\u00F6gerknapp
 # Used for Isindex
 IsindexView.prompt=Detta \u00E4r ett s\u00F6kbart index. Ange s\u00F6kord:
 
--- a/src/macosx/classes/sun/awt/CGraphicsConfig.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/awt/CGraphicsConfig.java	Sun May 28 23:44:03 2017 -0700
@@ -31,13 +31,16 @@
 
 import sun.java2d.SurfaceData;
 import sun.java2d.opengl.CGLLayer;
+import sun.lwawt.LWGraphicsConfig;
 import sun.lwawt.macosx.CPlatformView;
 
-public class CGraphicsConfig extends GraphicsConfiguration {
+public abstract class CGraphicsConfig extends GraphicsConfiguration
+        implements LWGraphicsConfig {
+
     private final CGraphicsDevice device;
     private ColorModel colorModel;
 
-    public CGraphicsConfig(CGraphicsDevice device) {
+    protected CGraphicsConfig(CGraphicsDevice device) {
         this.device = device;
     }
 
@@ -84,88 +87,20 @@
         return new AffineTransform(xscale, 0.0, 0.0, yscale, 0.0, 0.0);
     }
 
-
-    /**
-     * The following methods are invoked from CToolkit.java and
-     * LWWindowPeer.java rather than having the native
-     * implementations hardcoded in those classes.  This way the appropriate
-     * actions are taken based on the peer's GraphicsConfig, whether it is
-     * an CGLGraphicsConfig or something else.
-     */
-
     /**
      * Creates a new SurfaceData that will be associated with the given
      * LWWindowPeer.
      */
-    public SurfaceData createSurfaceData(CPlatformView pView) {
-        throw new UnsupportedOperationException("not implemented");
-    }
+    public abstract SurfaceData createSurfaceData(CPlatformView pView);
 
     /**
      * Creates a new SurfaceData that will be associated with the given
      * CGLLayer.
      */
-    public SurfaceData createSurfaceData(CGLLayer layer) {
-        throw new UnsupportedOperationException("not implemented");
-    }
-
-    /**
-     * Creates a new hidden-acceleration image of the given width and height
-     * that is associated with the target Component.
-     */
-    public Image createAcceleratedImage(Component target,
-                                        int width, int height)
-    {
-        throw new UnsupportedOperationException("not implemented");
-    }
-
-    /**
-     * The following methods correspond to the multibuffering methods in
-     * LWWindowPeer.java...
-     */
-
-    /**
-     * Attempts to create a native backbuffer for the given peer.  If
-     * the requested configuration is not natively supported, an AWTException
-     * is thrown.  Otherwise, if the backbuffer creation is successful, a
-     * handle to the native backbuffer is returned.
-     */
-    public long createBackBuffer(CPlatformView pView,
-                                 int numBuffers, BufferCapabilities caps)
-        throws AWTException
-    {
-        throw new UnsupportedOperationException("not implemented");
-    }
-
-    public void destroyBackBuffer(long backBuffer)
-        throws AWTException
-    {
-        throw new UnsupportedOperationException("not implemented");
-    }
-
-    /**
-     * Creates a VolatileImage that essentially wraps the target Component's
-     * backbuffer, using the provided backbuffer handle.
-     */
-    public VolatileImage createBackBufferImage(Component target,
-                                               long backBuffer)
-    {
-        throw new UnsupportedOperationException("not implemented");
-    }
-
-    /**
-     * Performs the native flip operation for the given target Component.
-     */
-    public void flip(CPlatformView delegate,
-                     Component target, VolatileImage xBackBuffer,
-                     int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction)
-    {
-        throw new UnsupportedOperationException("not implemented");
-    }
+    public abstract SurfaceData createSurfaceData(CGLLayer layer);
 
     @Override
-    public boolean isTranslucencyCapable() {
+    public final boolean isTranslucencyCapable() {
         //we know for sure we have capable config :)
         return true;
     }
--- a/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java	Sun May 28 23:44:03 2017 -0700
@@ -27,7 +27,6 @@
 
 import java.awt.AWTException;
 import java.awt.BufferCapabilities;
-import java.awt.Color;
 import java.awt.Component;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
@@ -48,13 +47,10 @@
 
 import sun.awt.CGraphicsConfig;
 import sun.awt.CGraphicsDevice;
-import sun.awt.TextureSizeConstraining;
 import sun.awt.image.OffScreenImage;
 import sun.awt.image.SunVolatileImage;
-import sun.awt.image.SurfaceManager;
 import sun.java2d.Disposer;
 import sun.java2d.DisposerRecord;
-import sun.java2d.SunGraphics2D;
 import sun.java2d.Surface;
 import sun.java2d.SurfaceData;
 import sun.java2d.opengl.OGLContext.OGLContextCaps;
@@ -63,18 +59,19 @@
 import sun.java2d.pipe.hw.ContextCapabilities;
 import static sun.java2d.opengl.OGLSurfaceData.*;
 import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
-import sun.java2d.opengl.CGLSurfaceData.CGLVSyncOffScreenSurfaceData;
 import sun.java2d.pipe.hw.AccelDeviceEventListener;
 import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
 
+import sun.lwawt.LWComponentPeer;
 import sun.lwawt.macosx.CPlatformView;
 
-public class CGLGraphicsConfig extends CGraphicsConfig
-    implements OGLGraphicsConfig, TextureSizeConstraining
+public final class CGLGraphicsConfig extends CGraphicsConfig
+    implements OGLGraphicsConfig
 {
-    //private static final int kOpenGLSwapInterval = RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
+    //private static final int kOpenGLSwapInterval =
+    // RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
     private static final int kOpenGLSwapInterval = 0; // TODO
-    protected static boolean cglAvailable;
+    private static boolean cglAvailable;
     private static ImageCapabilities imageCaps = new CGLImageCaps();
 
     private int pixfmt;
@@ -82,7 +79,7 @@
     private long pConfigInfo;
     private ContextCapabilities oglCaps;
     private OGLContext context;
-    private Object disposerReferent = new Object();
+    private final Object disposerReferent = new Object();
 
     private final int cachedMaxTextureSize;
     private static native boolean initCGL();
@@ -95,7 +92,7 @@
         cglAvailable = initCGL();
     }
 
-    protected CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
+    private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                                 long configInfo, ContextCapabilities oglCaps)
     {
         super(device);
@@ -176,11 +173,13 @@
      * Returns true if the provided capability bit is present for this config.
      * See OGLContext.java for a list of supported capabilities.
      */
-    public final boolean isCapPresent(int cap) {
+    @Override
+    public boolean isCapPresent(int cap) {
         return ((oglCaps.getCaps() & cap) != 0);
     }
 
-    public final long getNativeConfigInfo() {
+    @Override
+    public long getNativeConfigInfo() {
         return pConfigInfo;
     }
 
@@ -189,7 +188,8 @@
      *
      * @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
      */
-    public final OGLContext getContext() {
+    @Override
+    public OGLContext getContext() {
         return context;
     }
 
@@ -263,145 +263,83 @@
         return ("CGLGraphicsConfig[dev="+displayID+",pixfmt="+pixfmt+"]");
     }
 
-
-    /**
-     * The following methods are invoked from ComponentModel.java rather
-     * than having the Mac OS X-dependent implementations hardcoded in that
-     * class.  This way the appropriate actions are taken based on the peer's
-     * GraphicsConfig, whether it is a CGraphicsConfig or a
-     * CGLGraphicsConfig.
-     */
-
-    /**
-     * Creates a new SurfaceData that will be associated with the given
-     * LWWindowPeer.
-     */
     @Override
     public SurfaceData createSurfaceData(CPlatformView pView) {
         return CGLSurfaceData.createData(pView);
     }
 
-    /**
-     * Creates a new SurfaceData that will be associated with the given
-     * CGLLayer.
-     */
     @Override
     public SurfaceData createSurfaceData(CGLLayer layer) {
         return CGLSurfaceData.createData(layer);
     }
 
-    /**
-     * Creates a new hidden-acceleration image of the given width and height
-     * that is associated with the target Component.
-     */
     @Override
     public Image createAcceleratedImage(Component target,
                                         int width, int height)
     {
         ColorModel model = getColorModel(Transparency.OPAQUE);
-        WritableRaster wr =
-            model.createCompatibleWritableRaster(width, height);
+        WritableRaster wr = model.createCompatibleWritableRaster(width, height);
         return new OffScreenImage(target, model, wr,
                                   model.isAlphaPremultiplied());
     }
 
-    /**
-     * The following methods correspond to the multibuffering methods in
-     * CWindowPeer.java...
-     */
-
-    /**
-     * Attempts to create a OGL-based backbuffer for the given peer.  If
-     * the requested configuration is not natively supported, an AWTException
-     * is thrown.  Otherwise, if the backbuffer creation is successful, a
-     * value of 1 is returned.
-     */
     @Override
-    public long createBackBuffer(CPlatformView pView,
-                                 int numBuffers, BufferCapabilities caps)
-        throws AWTException
-    {
-        if (numBuffers > 2) {
-            throw new AWTException(
-                "Only double or single buffering is supported");
+    public void assertOperationSupported(final int numBuffers,
+                                         final BufferCapabilities caps)
+            throws AWTException {
+        // Assume this method is never called with numBuffers != 2, as 0 is
+        // unsupported, and 1 corresponds to a SingleBufferStrategy which
+        // doesn't depend on the peer. Screen is considered as a separate
+        // "buffer".
+        if (numBuffers != 2) {
+            throw new AWTException("Only double buffering is supported");
         }
-        BufferCapabilities configCaps = getBufferCapabilities();
+        final BufferCapabilities configCaps = getBufferCapabilities();
         if (!configCaps.isPageFlipping()) {
             throw new AWTException("Page flipping is not supported");
         }
         if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
             throw new AWTException("FlipContents.PRIOR is not supported");
         }
-
-        // non-zero return value means backbuffer creation was successful
-        // (checked in CPlatformWindow.flip(), etc.)
-        return 1;
     }
 
-    /**
-     * Destroys the backbuffer object represented by the given handle value.
-     */
     @Override
-    public void destroyBackBuffer(long backBuffer) {
+    public Image createBackBuffer(final LWComponentPeer<?, ?> peer) {
+        final Rectangle r = peer.getBounds();
+        // It is possible for the component to have size 0x0, adjust it to
+        // be at least 1x1 to avoid IAE
+        final int w = Math.max(1, r.width);
+        final int h = Math.max(1, r.height);
+        final int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT
+                                                      : Transparency.OPAQUE;
+        return new SunVolatileImage(this, w, h, transparency, null);
     }
 
-    /**
-     * Creates a VolatileImage that essentially wraps the target Component's
-     * backbuffer (the provided backbuffer handle is essentially ignored).
-     */
     @Override
-    public VolatileImage createBackBufferImage(Component target,
-                                               long backBuffer)
-    {
-        return new SunVolatileImage(target,
-                                    target.getWidth(), target.getHeight(),
-                                    Boolean.TRUE);
+    public void destroyBackBuffer(final Image backBuffer) {
+        if (backBuffer != null) {
+            backBuffer.flush();
+        }
     }
 
-    /**
-     * Performs the native OGL flip operation for the given target Component.
-     */
     @Override
-    public void flip(CPlatformView pView,
-                     Component target, VolatileImage xBackBuffer,
-                     int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction)
-    {
-        if (flipAction == BufferCapabilities.FlipContents.COPIED) {
-            SurfaceManager vsm = SurfaceManager.getManager(xBackBuffer);
-            SurfaceData sd = vsm.getPrimarySurfaceData();
-
-            if (sd instanceof CGLVSyncOffScreenSurfaceData) {
-                CGLVSyncOffScreenSurfaceData vsd =
-                    (CGLVSyncOffScreenSurfaceData)sd;
-                SurfaceData bbsd = vsd.getFlipSurface();
-                Graphics2D bbg =
-                    new SunGraphics2D(bbsd, Color.black, Color.white, null);
-                try {
-                    bbg.drawImage(xBackBuffer, 0, 0, null);
-                } finally {
-                    bbg.dispose();
-                }
-            } else {
-                pView.drawImageOnPeer(xBackBuffer, x1, y1, x2, y2);
-                return;
-            }
-        } else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
-            // not supported by CGL...
-            return;
+    public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
+                     final int x1, final int y1, final int x2, final int y2,
+                     final BufferCapabilities.FlipContents flipAction) {
+        final Graphics g = peer.getGraphics();
+        try {
+            g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
+        } finally {
+            g.dispose();
         }
-
-        OGLSurfaceData.swapBuffers(pView.getAWTView());
-
         if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
-            Graphics g = xBackBuffer.getGraphics();
+            final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
             try {
-                g.setColor(target.getBackground());
-                g.fillRect(0, 0,
-                           xBackBuffer.getWidth(),
-                           xBackBuffer.getHeight());
+                bg.setBackground(peer.getBackground());
+                bg.clearRect(0, 0, backBuffer.getWidth(null),
+                             backBuffer.getHeight(null));
             } finally {
-                g.dispose();
+                bg.dispose();
             }
         }
     }
@@ -435,15 +373,10 @@
         return imageCaps;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage
-     */
-    public VolatileImage
-        createCompatibleVolatileImage(int width, int height,
-                                      int transparency, int type)
-    {
+    @Override
+    public VolatileImage createCompatibleVolatileImage(int width, int height,
+                                                       int transparency,
+                                                       int type) {
         if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED ||
             transparency == Transparency.BITMASK)
         {
@@ -479,15 +412,18 @@
      *
      * @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
      */
+    @Override
     public ContextCapabilities getContextCapabilities() {
         return oglCaps;
     }
 
+    @Override
     public void addDeviceEventListener(AccelDeviceEventListener l) {
         int displayID = getDevice().getCGDisplayID();
         AccelDeviceEventNotifier.addListener(l, displayID);
     }
 
+    @Override
     public void removeDeviceEventListener(AccelDeviceEventListener l) {
         AccelDeviceEventNotifier.removeListener(l);
     }
--- a/src/macosx/classes/sun/java2d/opengl/CGLLayer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/java2d/opengl/CGLLayer.java	Sun May 28 23:44:03 2017 -0700
@@ -108,7 +108,12 @@
         OGLRenderQueue rq = OGLRenderQueue.getInstance();
         rq.lock();
         try {
-            validate(getPointer(), cglsd);
+            execute(new CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    validate(ptr, cglsd);
+                }
+            });
         } finally {
             rq.unlock();
         }
@@ -124,7 +129,12 @@
     private void setScale(final int _scale) {
         if (scale != _scale) {
             scale = _scale;
-            nativeSetScale(getPointer(), scale);
+            execute(new CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    nativeSetScale(ptr, scale);
+                }
+            });
         }
     }
 
@@ -138,7 +148,12 @@
         OGLRenderQueue rq = OGLRenderQueue.getInstance();
         rq.lock();
         try {
-            blitTexture(getPointer());
+            execute(new CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    blitTexture(ptr);
+                }
+            });
         } finally {
             rq.unlock();
         }
--- a/src/macosx/classes/sun/lwawt/LWButtonPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWButtonPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,10 @@
 
 import javax.swing.JButton;
 
+/**
+ * Lightweight implementation of {@link ButtonPeer}. Delegates most of the work
+ * to the {@link JButton}.
+ */
 final class LWButtonPeer extends LWComponentPeer<Button, JButton>
         implements ButtonPeer, ActionListener {
 
@@ -42,7 +46,7 @@
     }
 
     @Override
-    protected JButton createDelegate() {
+    JButton createDelegate() {
         return new JButtonDelegate();
     }
 
@@ -74,6 +78,7 @@
         return true;
     }
 
+    @SuppressWarnings("serial")// Safe: outer class is non-serializable.
     private final class JButtonDelegate extends JButton {
 
         // Empty non private constructor was added because access to this
--- a/src/macosx/classes/sun/lwawt/LWCanvasPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWCanvasPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,94 +26,38 @@
 
 package sun.lwawt;
 
-import sun.awt.CGraphicsConfig;
-
-import java.awt.BufferCapabilities;
-import java.awt.BufferCapabilities.FlipContents;
-import java.awt.Canvas;
 import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
+import java.awt.Dimension;
 import java.awt.GraphicsConfiguration;
-import java.awt.Image;
-import java.awt.image.VolatileImage;
 import java.awt.peer.CanvasPeer;
 
 import javax.swing.JComponent;
 
-final class LWCanvasPeer extends LWComponentPeer<Component, JComponent>
-        implements CanvasPeer {
+/**
+ * Lightweight implementation of {@link CanvasPeer}. This peer is empty, because
+ * all the components in lwawt use graphic object from the top level window.
+ */
+class LWCanvasPeer<T extends Component, D extends JComponent>
+        extends LWComponentPeer<T, D> implements CanvasPeer {
 
-    /**
-     * The back buffer provide user with a BufferStrategy.
-     */
-    private VolatileImage backBuffer;
-
-    LWCanvasPeer(final Canvas target,
-                 final PlatformComponent platformComponent) {
+    LWCanvasPeer(final T target, final PlatformComponent platformComponent) {
         super(target, platformComponent);
     }
 
     @Override
-    public void createBuffers(final int numBuffers,
-                              final BufferCapabilities caps) {
-        //TODO parameters should be used.
-        final CGraphicsConfig gc = (CGraphicsConfig) getGraphicsConfiguration();
-        final VolatileImage buffer = gc.createBackBufferImage(getTarget(), 0);
-        synchronized (getStateLock()) {
-            backBuffer = buffer;
-        }
+    public final GraphicsConfiguration getAppropriateGraphicsConfiguration(
+            final GraphicsConfiguration gc) {
+        // TODO
+        return gc;
     }
 
     @Override
-    public Image getBackBuffer() {
-        synchronized (getStateLock()) {
-            return backBuffer;
-        }
+    public final Dimension getPreferredSize() {
+        return getMinimumSize();
     }
 
     @Override
-    public void flip(final int x1, final int y1, final int x2, final int y2,
-                     final FlipContents flipAction) {
-        final VolatileImage buffer = (VolatileImage) getBackBuffer();
-        if (buffer == null) {
-            throw new IllegalStateException("Buffers have not been created");
-        }
-        final Graphics g = getGraphics();
-        try {
-            g.drawImage(buffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
-        } finally {
-            g.dispose();
-        }
-        if (flipAction == FlipContents.BACKGROUND) {
-            final Graphics2D bg = (Graphics2D) buffer.getGraphics();
-            try {
-                bg.setBackground(getBackground());
-                bg.clearRect(0, 0, buffer.getWidth(), buffer.getHeight());
-            } finally {
-                bg.dispose();
-            }
-        }
-    }
-
-    @Override
-    public void destroyBuffers() {
-        final Image buffer = getBackBuffer();
-        if (buffer != null) {
-            synchronized (getStateLock()) {
-                if (buffer == backBuffer) {
-                    backBuffer = null;
-                }
-            }
-            buffer.flush();
-        }
-    }
-
-    @Override
-    public GraphicsConfiguration getAppropriateGraphicsConfiguration(
-            GraphicsConfiguration gc)
-    {
-        // TODO
-        return gc;
+    public final Dimension getMinimumSize() {
+        return getBounds().getSize();
     }
 }
--- a/src/macosx/classes/sun/lwawt/LWCheckboxPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWCheckboxPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,11 @@
 import javax.swing.JToggleButton;
 import javax.swing.SwingUtilities;
 
+/**
+ * Lightweight implementation of {@link CheckboxPeer}. Delegates most of the
+ * work to the {@link JCheckBox} and {@link JRadioButton}, which are placed
+ * inside an empty {@link JComponent}.
+ */
 final class LWCheckboxPeer
         extends LWComponentPeer<Checkbox, LWCheckboxPeer.CheckboxDelegate>
         implements CheckboxPeer, ItemListener {
@@ -51,12 +56,12 @@
     }
 
     @Override
-    protected CheckboxDelegate createDelegate() {
+    CheckboxDelegate createDelegate() {
         return new CheckboxDelegate();
     }
 
     @Override
-    protected Component getDelegateFocusOwner() {
+    Component getDelegateFocusOwner() {
         return getDelegate().getCurrentButton();
     }
 
@@ -137,6 +142,7 @@
         return true;
     }
 
+    @SuppressWarnings("serial")// Safe: outer class is non-serializable.
     final class CheckboxDelegate extends JComponent {
 
         private final JCheckBox cb;
@@ -186,6 +192,11 @@
         }
 
         @Override
+        public Dimension getPreferredSize() {
+            return getCurrentButton().getPreferredSize();
+        }
+
+        @Override
         @Transient
         public Dimension getMinimumSize() {
             return getCurrentButton().getMinimumSize();
--- a/src/macosx/classes/sun/lwawt/LWChoicePeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWChoicePeer.java	Sun May 28 23:44:03 2017 -0700
@@ -34,6 +34,10 @@
 import javax.accessibility.Accessible;
 import javax.swing.*;
 
+/**
+ * Lightweight implementation of {@link ChoicePeer}. Delegates most of the work
+ * to the {@link JComboBox}.
+ */
 final class LWChoicePeer extends LWComponentPeer<Choice, JComboBox<String>>
         implements ChoicePeer, ItemListener {
 
@@ -50,7 +54,7 @@
     }
 
     @Override
-    protected JComboBox<String> createDelegate() {
+    JComboBox<String> createDelegate() {
         return new JComboBoxDelegate();
     }
 
@@ -128,6 +132,7 @@
         return true;
     }
 
+    @SuppressWarnings("serial")// Safe: outer class is non-serializable.
     private final class JComboBoxDelegate extends JComboBox<String> {
 
         // Empty non private constructor was added because access to this
--- a/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,19 +72,23 @@
 {
     private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.lwawt.focus.LWComponentPeer");
 
-    // State lock is to be used for modifications to this
-    // peer's fields (e.g. bounds, background, font, etc.)
-    // It should be the last lock in the lock chain
-    private final Object stateLock =
-            new StringBuilder("LWComponentPeer.stateLock");
+    /**
+     * State lock is to be used for modifications to this peer's fields (e.g.
+     * bounds, background, font, etc.) It should be the last lock in the lock
+     * chain
+     */
+    private final Object stateLock = new Object();
 
-    // The lock to operate with the peers hierarchy. AWT tree
-    // lock is not used as there are many peers related ops
-    // to be done on the toolkit thread, and we don't want to
-    // depend on a public lock on this thread
-    private static final Object peerTreeLock =
-            new StringBuilder("LWComponentPeer.peerTreeLock");
+    /**
+     * The lock to operate with the peers hierarchy. AWT tree lock is not used
+     * as there are many peers related ops to be done on the toolkit thread, and
+     * we don't want to depend on a public lock on this thread
+     */
+    private static final Object peerTreeLock = new Object();
 
+    /**
+     * The associated AWT object.
+     */
     private final T target;
 
     // Container peer. It may not be the peer of the target's direct
@@ -93,7 +97,7 @@
     // the container peer is not null, which might also be false if
     // addNotify() is called for a component outside of the hierarchy.
     // The exception is LWWindowPeers: their parents are always null
-    private LWContainerPeer containerPeer;
+    private LWContainerPeer<?, ?> containerPeer;
 
     // Handy reference to the top-level window peer. Window peer is
     // borrowed from the containerPeer in constructor, and should also
@@ -123,7 +127,7 @@
     //   private volatile boolean paintPending;
     private volatile boolean isLayouting;
 
-    private D delegate = null;
+    private final D delegate;
     private Container delegateContainer;
     private Component delegateDropTarget;
     private final Object dropTargetLock = new Object();
@@ -133,11 +137,28 @@
 
     private final PlatformComponent platformComponent;
 
+    /**
+     * Character with reasonable value between the minimum width and maximum.
+     */
+    static final char WIDE_CHAR = '0';
+
+    /**
+     * The back buffer provide user with a BufferStrategy.
+     */
+    private Image backBuffer;
+
+    /**
+     * All Swing delegates use delegateContainer as a parent. This container
+     * intentionally do not use parent of the peer.
+     */
+    @SuppressWarnings("serial")// Safe: outer class is non-serializable.
     private final class DelegateContainer extends Container {
         {
             enableEvents(0xFFFFFFFF);
         }
 
+        // Empty non private constructor was added because access to this
+        // class shouldn't be emulated by a synthetic accessor method.
         DelegateContainer() {
             super();
         }
@@ -168,7 +189,7 @@
         }
     }
 
-    public LWComponentPeer(T target, PlatformComponent platformComponent) {
+    LWComponentPeer(final T target, final PlatformComponent platformComponent) {
         targetPaintArea = new LWRepaintArea();
         this.target = target;
         this.platformComponent = platformComponent;
@@ -262,17 +283,18 @@
      * This method is called under getDelegateLock().
      * Overridden in subclasses.
      */
-    protected D createDelegate() {
+    D createDelegate() {
         return null;
     }
 
-    protected final D getDelegate() {
-        synchronized (getStateLock()) {
-            return delegate;
-        }
+    final D getDelegate() {
+        return delegate;
     }
 
-    protected Component getDelegateFocusOwner() {
+    /**
+     * This method should be called under getDelegateLock().
+     */
+    Component getDelegateFocusOwner() {
         return getDelegate();
     }
 
@@ -293,6 +315,8 @@
      * subclasses to initialize specific peers properties.
      */
     void initializeImpl() {
+        // note that these methods can be overridden by the user and
+        // can return some strange values like null.
         setBackground(target.getBackground());
         setForeground(target.getForeground());
         setFont(target.getFont());
@@ -344,7 +368,7 @@
     }
 
     // Just a helper method
-    protected final LWContainerPeer getContainerPeer() {
+    protected final LWContainerPeer<?, ?> getContainerPeer() {
         return containerPeer;
     }
 
@@ -386,7 +410,8 @@
     }
 
     protected void disposeImpl() {
-        LWContainerPeer cp = getContainerPeer();
+        destroyBuffers();
+        LWContainerPeer<?, ?> cp = getContainerPeer();
         if (cp != null) {
             cp.removeChildPeer(this);
         }
@@ -412,6 +437,12 @@
         return getWindowPeer().getGraphicsConfiguration();
     }
 
+
+    // Just a helper method
+    public final LWGraphicsConfig getLWGC() {
+        return (LWGraphicsConfig) getGraphicsConfiguration();
+    }
+
     /*
      * Overridden in LWWindowPeer to replace its surface
      * data and back buffer.
@@ -452,12 +483,13 @@
         sg2d.constrain(size.x, size.y, size.width, size.height, getVisibleRegion());
     }
 
-    public Region getVisibleRegion() {
+    Region getVisibleRegion() {
         return computeVisibleRect(this, getRegion());
     }
 
-    static final Region computeVisibleRect(LWComponentPeer c, Region region) {
-        final LWContainerPeer p = c.getContainerPeer();
+    static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
+                                           Region region) {
+        final LWContainerPeer<?, ?> p = c.getContainerPeer();
         if (p != null) {
             final Rectangle r = c.getBounds();
             region = region.getTranslatedRegion(r.x, r.y);
@@ -476,31 +508,45 @@
         return getGraphicsConfiguration().getColorModel();
     }
 
-    @Override
-    public void createBuffers(int numBuffers, BufferCapabilities caps)
-            throws AWTException {
-        throw new AWTException("Back buffers are only supported for " +
-                "Window or Canvas components.");
-    }
-
-    /*
-     * To be overridden in LWWindowPeer and LWCanvasPeer.
-     */
-    @Override
-    public Image getBackBuffer() {
-        // Return null or throw AWTException?
-        return null;
+    public boolean isTranslucent() {
+        // Translucent windows of the top level are supported only
+        return false;
     }
 
     @Override
-    public void flip(int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction) {
-        // Skip silently or throw AWTException?
+    public final void createBuffers(int numBuffers, BufferCapabilities caps)
+            throws AWTException {
+        getLWGC().assertOperationSupported(numBuffers, caps);
+        final Image buffer = getLWGC().createBackBuffer(this);
+        synchronized (getStateLock()) {
+            backBuffer = buffer;
+        }
     }
 
     @Override
-    public void destroyBuffers() {
-        // Do nothing
+    public final Image getBackBuffer() {
+        synchronized (getStateLock()) {
+            if (backBuffer != null) {
+                return backBuffer;
+            }
+        }
+        throw new IllegalStateException("Buffers have not been created");
+    }
+
+    @Override
+    public final void flip(int x1, int y1, int x2, int y2,
+                     BufferCapabilities.FlipContents flipAction) {
+        getLWGC().flip(this, getBackBuffer(), x1, y1, x2, y2, flipAction);
+    }
+
+    @Override
+    public final void destroyBuffers() {
+        final Image oldBB;
+        synchronized (getStateLock()) {
+            oldBB = backBuffer;
+            backBuffer = null;
+        }
+        getLWGC().destroyBackBuffer(oldBB);
     }
 
     // Helper method
@@ -588,7 +634,7 @@
      * @param p Point relative to the peer.
      * @return Cursor of the peer or null if default cursor should be used.
      */
-    protected Cursor getCursor(final Point p) {
+    Cursor getCursor(final Point p) {
         return getTarget().getCursor();
     }
 
@@ -612,7 +658,7 @@
         }
     }
 
-    protected final Color getBackground() {
+    public final Color getBackground() {
         synchronized (getStateLock()) {
             return background;
         }
@@ -671,32 +717,29 @@
     }
 
     @Override
-    public FontMetrics getFontMetrics(Font f) {
+    public FontMetrics getFontMetrics(final Font f) {
         // Borrow the metrics from the top-level window
 //        return getWindowPeer().getFontMetrics(f);
         // Obtain the metrics from the offscreen window where this peer is
         // mostly drawn to.
         // TODO: check for "use platform metrics" settings
-        Graphics g = getWindowPeer().getGraphics();
-        try {
-            if (g != null) {
+        final Graphics g = getOnscreenGraphics();
+        if (g != null) {
+            try {
                 return g.getFontMetrics(f);
-            } else {
-                synchronized (getDelegateLock()) {
-                    return delegateContainer.getFontMetrics(f);
-                }
-            }
-        } finally {
-            if (g != null) {
+            } finally {
                 g.dispose();
             }
         }
+        synchronized (getDelegateLock()) {
+            return delegateContainer.getFontMetrics(f);
+        }
     }
 
     @Override
     public void setEnabled(final boolean e) {
         boolean status = e;
-        final LWComponentPeer cp = getContainerPeer();
+        final LWComponentPeer<?, ?> cp = getContainerPeer();
         if (cp != null) {
             status &= cp.isEnabled();
         }
@@ -781,12 +824,12 @@
     }
 
     @Override
-    public void setZOrder(ComponentPeer above) {
-        LWContainerPeer cp = getContainerPeer();
+    public void setZOrder(final ComponentPeer above) {
+        LWContainerPeer<?, ?> cp = getContainerPeer();
         // Don't check containerPeer for null as it can only happen
         // for windows, but this method is overridden in
         // LWWindowPeer and doesn't call super()
-        cp.setChildPeerZOrder(this, (LWComponentPeer) above);
+        cp.setChildPeerZOrder(this, (LWComponentPeer<?, ?>) above);
     }
 
     @Override
@@ -820,31 +863,46 @@
     }
 
     /**
-     * Should be overridden in subclasses to forward the request
-     * to the Swing helper component, if required.
+     * Determines the preferred size of the component. By default forwards the
+     * request to the Swing helper component. Should be overridden in subclasses
+     * if required.
      */
     @Override
     public Dimension getPreferredSize() {
-        // It looks like a default implementation for all toolkits
-        return getMinimumSize();
+        final Dimension size;
+        synchronized (getDelegateLock()) {
+            size = getDelegate().getPreferredSize();
+        }
+        return validateSize(size);
     }
 
-    /*
-     * Should be overridden in subclasses to forward the request
-     * to the Swing helper component.
+    /**
+     * Determines the minimum size of the component. By default forwards the
+     * request to the Swing helper component. Should be overridden in subclasses
+     * if required.
      */
     @Override
     public Dimension getMinimumSize() {
-        D delegate = getDelegate();
+        final Dimension size;
+        synchronized (getDelegateLock()) {
+            size = getDelegate().getMinimumSize();
+        }
+        return validateSize(size);
+    }
 
-        if (delegate == null) {
-            // Is it a correct default value?
-            return getBounds().getSize();
-        } else {
-            synchronized (getDelegateLock()) {
-                return delegate.getMinimumSize();
-            }
+    /**
+     * In some situations delegates can return empty minimum/preferred size.
+     * (For example: empty JLabel, etc), but awt components never should be
+     * empty. In the XPeers or WPeers we use some magic constants, but here we
+     * try to use something more useful,
+     */
+    private Dimension validateSize(final Dimension size) {
+        if (size.width == 0 || size.height == 0) {
+            final FontMetrics fm = getFontMetrics(getFont());
+            size.width = fm.charWidth(WIDE_CHAR);
+            size.height = fm.getHeight();
         }
+        return size;
     }
 
     @Override
@@ -887,7 +945,9 @@
                     LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
                     return false;
                 }
-                LWWindowPeer parentPeer = (LWWindowPeer) parentWindow.getPeer();
+                final LWWindowPeer parentPeer =
+                        (LWWindowPeer) AWTAccessor.getComponentAccessor()
+                                                  .getPeer(parentWindow);
                 if (parentPeer == null) {
                     focusLog.fine("request rejected, parentPeer is null");
                     LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
@@ -940,19 +1000,17 @@
     }
 
     @Override
-    public Image createImage(ImageProducer producer) {
+    public final Image createImage(final ImageProducer producer) {
         return new ToolkitImage(producer);
     }
 
     @Override
-    public Image createImage(int w, int h) {
-        CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration();
-        return gc.createAcceleratedImage(getTarget(), w, h);
+    public final Image createImage(final int width, final int height) {
+        return getLWGC().createAcceleratedImage(getTarget(), width, height);
     }
 
     @Override
-    public VolatileImage createVolatileImage(int w, int h) {
-        // TODO: is it a right/complete implementation?
+    public final VolatileImage createVolatileImage(final int w, final int h) {
         return new SunVolatileImage(getTarget(), w, h);
     }
 
@@ -1063,8 +1121,6 @@
      * of target.setLocation() or as a result of user actions (window is
      * dragged with mouse).
      *
-     * To be overridden in LWWindowPeer to update its GraphicsConfig.
-     *
      * This method could be called on the toolkit thread.
      */
     protected final void handleMove(final int x, final int y,
@@ -1080,13 +1136,19 @@
      * Called when this peer's size has been changed either as a result of
      * target.setSize() or as a result of user actions (window is resized).
      *
-     * To be overridden in LWWindowPeer to update its SurfaceData and
-     * GraphicsConfig.
-     *
      * This method could be called on the toolkit thread.
      */
     protected final void handleResize(final int w, final int h,
                                       final boolean updateTarget) {
+        Image oldBB = null;
+        synchronized (getStateLock()) {
+            if (backBuffer != null) {
+                oldBB = backBuffer;
+                backBuffer = getLWGC().createBackBuffer(this);
+            }
+        }
+        getLWGC().destroyBackBuffer(oldBB);
+
         if (updateTarget) {
             AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h);
         }
@@ -1100,7 +1162,7 @@
     }
 
     protected final void repaintParent(final Rectangle oldB) {
-        final LWContainerPeer cp = getContainerPeer();
+        final LWContainerPeer<?, ?> cp = getContainerPeer();
         if (cp != null) {
             // Repaint unobscured part of the parent
             cp.repaintPeer(cp.getContentSize().intersection(oldB));
@@ -1238,7 +1300,7 @@
     /**
      * Handler for FocusEvents.
      */
-    protected void handleJavaFocusEvent(FocusEvent e) {
+    void handleJavaFocusEvent(final FocusEvent e) {
         // Note that the peer receives all the FocusEvents from
         // its lightweight children as well
         KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
@@ -1274,7 +1336,7 @@
      * Finds a top-most visible component for the given point. The location is
      * specified relative to the peer's parent.
      */
-    public LWComponentPeer findPeerAt(final int x, final int y) {
+    LWComponentPeer<?, ?> findPeerAt(final int x, final int y) {
         final Rectangle r = getBounds();
         final Region sh = getRegion();
         final boolean found = isVisible() && sh.contains(x - r.x, y - r.y);
@@ -1291,7 +1353,7 @@
     }
 
     public Point windowToLocal(Point p, LWWindowPeer wp) {
-        LWComponentPeer cp = this;
+        LWComponentPeer<?, ?> cp = this;
         while (cp != wp) {
             Rectangle cpb = cp.getBounds();
             p.x -= cpb.x;
@@ -1312,7 +1374,7 @@
     }
 
     public Point localToWindow(Point p) {
-        LWComponentPeer cp = getContainerPeer();
+        LWComponentPeer<?, ?> cp = getContainerPeer();
         Rectangle r = getBounds();
         while (cp != null) {
             p.x += r.x;
@@ -1333,7 +1395,7 @@
         repaintPeer(getSize());
     }
 
-    public void repaintPeer(final Rectangle r) {
+    void repaintPeer(final Rectangle r) {
         final Rectangle toPaint = getSize().intersection(r);
         if (!isShowing() || toPaint.isEmpty()) {
             return;
@@ -1352,7 +1414,7 @@
     protected final boolean isShowing() {
         synchronized (getPeerTreeLock()) {
             if (isVisible()) {
-                final LWContainerPeer container = getContainerPeer();
+                final LWContainerPeer<?, ?> container = getContainerPeer();
                 return (container == null) || container.isShowing();
             }
         }
@@ -1360,8 +1422,7 @@
     }
 
     /**
-     * Paints the peer. Overridden in subclasses to delegate the actual painting
-     * to Swing components.
+     * Paints the peer. Delegate the actual painting to Swing components.
      */
     protected final void paintPeer(final Graphics g) {
         final D delegate = getDelegate();
--- a/src/macosx/classes/sun/lwawt/LWContainerPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWContainerPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,32 +41,25 @@
 import javax.swing.JComponent;
 
 abstract class LWContainerPeer<T extends Container, D extends JComponent>
-    extends LWComponentPeer<T, D>
-    implements ContainerPeer
-{
-    // List of child peers sorted by z-order from bottom-most
-    // to top-most
-    private List<LWComponentPeer> childPeers =
-        new LinkedList<LWComponentPeer>();
+        extends LWCanvasPeer<T, D> implements ContainerPeer {
 
-    LWContainerPeer(T target, PlatformComponent platformComponent) {
+    /**
+     * List of child peers sorted by z-order from bottom-most to top-most.
+     */
+    private final List<LWComponentPeer<?, ?>> childPeers = new LinkedList<>();
+
+    LWContainerPeer(final T target, final PlatformComponent platformComponent) {
         super(target, platformComponent);
     }
 
-    void addChildPeer(LWComponentPeer child) {
+    final void addChildPeer(final LWComponentPeer<?, ?> child) {
         synchronized (getPeerTreeLock()) {
-            addChildPeer(child, childPeers.size());
+            childPeers.add(childPeers.size(), child);
+            // TODO: repaint
         }
     }
 
-    void addChildPeer(LWComponentPeer child, int index) {
-        synchronized (getPeerTreeLock()) {
-            childPeers.add(index, child);
-        }
-        // TODO: repaint
-    }
-
-    void removeChildPeer(LWComponentPeer child) {
+    final void removeChildPeer(final LWComponentPeer<?, ?> child) {
         synchronized (getPeerTreeLock()) {
             childPeers.remove(child);
         }
@@ -74,7 +67,8 @@
     }
 
     // Used by LWComponentPeer.setZOrder()
-    void setChildPeerZOrder(LWComponentPeer peer, LWComponentPeer above) {
+    final void setChildPeerZOrder(final LWComponentPeer<?, ?> peer,
+                                  final LWComponentPeer<?, ?> above) {
         synchronized (getPeerTreeLock()) {
             childPeers.remove(peer);
             int index = (above != null) ? childPeers.indexOf(above) : childPeers.size();
@@ -98,25 +92,27 @@
     }
 
     @Override
-    public void beginValidate() {
-        // TODO: it seems that begin/endValidate() is only useful
-        // for heavyweight windows, when a batch movement for
-        // child windows  occurs. That's why no-op
-    }
-    @Override
-    public void endValidate() {
+    public final void beginValidate() {
         // TODO: it seems that begin/endValidate() is only useful
         // for heavyweight windows, when a batch movement for
         // child windows  occurs. That's why no-op
     }
 
     @Override
-    public void beginLayout() {
+    public final void endValidate() {
+        // TODO: it seems that begin/endValidate() is only useful
+        // for heavyweight windows, when a batch movement for
+        // child windows  occurs. That's why no-op
+    }
+
+    @Override
+    public final void beginLayout() {
         // Skip all painting till endLayout()
         setLayouting(true);
     }
+
     @Override
-    public void endLayout() {
+    public final void endLayout() {
         setLayouting(false);
 
         // Post an empty event to flush all the pending target paints
@@ -125,18 +121,19 @@
 
     // ---- PEER NOTIFICATIONS ---- //
 
-    /*
+    /**
      * Returns a copy of the childPeer collection.
      */
-    protected List<LWComponentPeer> getChildren() {
+    @SuppressWarnings("unchecked")
+    final List<LWComponentPeer<?, ?>> getChildren() {
         synchronized (getPeerTreeLock()) {
-            Object copy = ((LinkedList)childPeers).clone();
-            return (List<LWComponentPeer>)copy;
+            Object copy = ((LinkedList<?>) childPeers).clone();
+            return (List<LWComponentPeer<?, ?>>) copy;
         }
     }
 
     @Override
-    public final Region getVisibleRegion() {
+    final Region getVisibleRegion() {
         return cutChildren(super.getVisibleRegion(), null);
     }
 
@@ -144,9 +141,9 @@
      * Removes bounds of children above specific child from the region. If above
      * is null removes all bounds of children.
      */
-    protected final Region cutChildren(Region r, final LWComponentPeer above) {
+    final Region cutChildren(Region r, final LWComponentPeer<?, ?> above) {
         boolean aboveFound = above == null;
-        for (final LWComponentPeer child : getChildren()) {
+        for (final LWComponentPeer<?, ?> child : getChildren()) {
             if (!aboveFound && child == above) {
                 aboveFound = true;
                 continue;
@@ -170,8 +167,8 @@
      * specified relative to the peer's parent.
      */
     @Override
-    public final LWComponentPeer findPeerAt(int x, int y) {
-        LWComponentPeer peer = super.findPeerAt(x, y);
+    final LWComponentPeer<?, ?> findPeerAt(int x, int y) {
+        LWComponentPeer<?, ?> peer = super.findPeerAt(x, y);
         final Rectangle r = getBounds();
         // Translate to this container's coordinates to pass to children
         x -= r.x;
@@ -179,7 +176,7 @@
         if (peer != null && getContentSize().contains(x, y)) {
             synchronized (getPeerTreeLock()) {
                 for (int i = childPeers.size() - 1; i >= 0; --i) {
-                    LWComponentPeer p = childPeers.get(i).findPeerAt(x, y);
+                    LWComponentPeer<?, ?> p = childPeers.get(i).findPeerAt(x, y);
                     if (p != null) {
                         peer = p;
                         break;
@@ -195,7 +192,7 @@
     * peers should be repainted
     */
     @Override
-    public final void repaintPeer(final Rectangle r) {
+    final void repaintPeer(final Rectangle r) {
         final Rectangle toPaint = getSize().intersection(r);
         if (!isShowing() || toPaint.isEmpty()) {
             return;
@@ -208,13 +205,13 @@
         repaintChildren(toPaint);
     }
 
-    /*
-    * Paints all the child peers in the straight z-order, so the
-    * bottom-most ones are painted first.
-    */
+    /**
+     * Paints all the child peers in the straight z-order, so the
+     * bottom-most ones are painted first.
+     */
     private void repaintChildren(final Rectangle r) {
         final Rectangle content = getContentSize();
-        for (final LWComponentPeer child : getChildren()) {
+        for (final LWComponentPeer<?, ?> child : getChildren()) {
             final Rectangle childBounds = child.getBounds();
             Rectangle toPaint = r.intersection(childBounds);
             toPaint = toPaint.intersection(content);
@@ -223,21 +220,21 @@
         }
     }
 
-    protected Rectangle getContentSize() {
+    Rectangle getContentSize() {
         return getSize();
     }
 
     @Override
     public void setEnabled(final boolean e) {
         super.setEnabled(e);
-        for (final LWComponentPeer child : getChildren()) {
+        for (final LWComponentPeer<?, ?> child : getChildren()) {
             child.setEnabled(e && child.getTarget().isEnabled());
         }
     }
 
     @Override
     public void setBackground(final Color c) {
-        for (final LWComponentPeer child : getChildren()) {
+        for (final LWComponentPeer<?, ?> child : getChildren()) {
             if (!child.getTarget().isBackgroundSet()) {
                 child.setBackground(c);
             }
@@ -247,7 +244,7 @@
 
     @Override
     public void setForeground(final Color c) {
-        for (final LWComponentPeer child : getChildren()) {
+        for (final LWComponentPeer<?, ?> child : getChildren()) {
             if (!child.getTarget().isForegroundSet()) {
                 child.setForeground(c);
             }
@@ -257,7 +254,7 @@
 
     @Override
     public void setFont(final Font f) {
-        for (final LWComponentPeer child : getChildren()) {
+        for (final LWComponentPeer<?, ?> child : getChildren()) {
             if (!child.getTarget().isFontSet()) {
                 child.setFont(f);
             }
--- a/src/macosx/classes/sun/lwawt/LWCursorManager.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWCursorManager.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
 
 public abstract class LWCursorManager {
@@ -109,7 +110,8 @@
                                                     cursorPos.y - p.y);
             }
             while (c != null) {
-                if (c.isVisible() && c.isEnabled() && (c.getPeer() != null)) {
+                final Object p = AWTAccessor.getComponentAccessor().getPeer(c);
+                if (c.isVisible() && c.isEnabled() && p != null) {
                     break;
                 }
                 c = c.getParent();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/macosx/classes/sun/lwawt/LWGraphicsConfig.java	Sun May 28 23:44:03 2017 -0700
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.lwawt;
+
+import java.awt.AWTException;
+import java.awt.BufferCapabilities;
+import java.awt.Component;
+import java.awt.Image;
+
+/**
+ * As lwawt can be used on different platforms with different graphic
+ * configurations, the general set of methods is necessary. This interface
+ * collects the methods that should be provided by GraphicsConfiguration,
+ * simplifying use by the LWAWT.
+ *
+ * @author Sergey Bylokhov
+ */
+public interface LWGraphicsConfig {
+
+    /*
+     * A GraphicsConfiguration must implements following methods to indicate
+     * that it imposes certain limitations on the maximum size of supported
+     * textures.
+     */
+
+    /**
+     * Returns the maximum width of any texture image. By default return {@code
+     * Integer.MAX_VALUE}.
+     */
+    int getMaxTextureWidth();
+
+    /**
+     * Returns the maximum height of any texture image. By default return {@code
+     * Integer.MAX_VALUE}.
+     */
+    int getMaxTextureHeight();
+
+    /*
+     * The following methods correspond to the multi-buffering methods in
+     * LWComponentPeer.java.
+     */
+
+    /**
+     * Checks that the requested configuration is natively supported; if not, an
+     * AWTException is thrown.
+     */
+    void assertOperationSupported(int numBuffers, BufferCapabilities caps)
+            throws AWTException;
+
+    /**
+     * Creates a back buffer for the given peer and returns the image wrapper.
+     */
+    Image createBackBuffer(LWComponentPeer<?, ?> peer);
+
+    /**
+     * Destroys the back buffer object.
+     */
+    void destroyBackBuffer(Image backBuffer);
+
+    /**
+     * Performs the native flip operation for the given target Component. Our
+     * flip is implemented through normal drawImage() to the graphic object,
+     * because of our components uses a graphic object of the container(in this
+     * case we also apply necessary constrains)
+     */
+    void flip(LWComponentPeer<?, ?> peer, Image backBuffer, int x1, int y1,
+              int x2, int y2, BufferCapabilities.FlipContents flipAction);
+
+    /**
+     * Creates a new hidden-acceleration image of the given width and height
+     * that is associated with the target Component.
+     */
+    Image createAcceleratedImage(Component target, int width, int height);
+}
--- a/src/macosx/classes/sun/lwawt/LWLabelPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWLabelPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,6 @@
 
 package sun.lwawt;
 
-import java.awt.Dimension;
-import java.awt.FontMetrics;
 import java.awt.Label;
 import java.awt.peer.LabelPeer;
 
@@ -41,18 +39,13 @@
 final class LWLabelPeer extends LWComponentPeer<Label, JLabel>
         implements LabelPeer {
 
-    private static final int TEXT_XPAD = 5;
-    private static final int TEXT_YPAD = 1;
-
     LWLabelPeer(final Label target, final PlatformComponent platformComponent) {
         super(target, platformComponent);
     }
 
     @Override
-    protected JLabel createDelegate() {
-        final JLabel label = new JLabel();
-        label.setVerticalAlignment(SwingConstants.TOP);
-        return label;
+    JLabel createDelegate() {
+        return new JLabel();
     }
 
     @Override
@@ -76,24 +69,6 @@
         }
     }
 
-    @Override
-    public Dimension getMinimumSize() {
-        int w = TEXT_XPAD;
-        int h = TEXT_YPAD;
-        final FontMetrics fm = getFontMetrics(getFont());
-        if (fm != null) {
-            final String text;
-            synchronized (getDelegateLock()) {
-                text = getDelegate().getText();
-            }
-            if (text != null) {
-                w += fm.stringWidth(text);
-            }
-            h += fm.getHeight();
-        }
-        return new Dimension(w, h);
-    }
-
     /**
      * Converts {@code Label} alignment constant to the {@code JLabel} constant.
      * If wrong Label alignment provided returns default alignment.
--- a/src/macosx/classes/sun/lwawt/LWListPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWListPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,10 +32,23 @@
 import java.awt.peer.ListPeer;
 import java.util.Arrays;
 
-final class LWListPeer
-        extends LWComponentPeer<List, LWListPeer.ScrollableJList>
+/**
+ * Lightweight implementation of {@link ListPeer}. Delegates most of the work to
+ * the {@link JList}, which is placed inside {@link JScrollPane}.
+ */
+final class LWListPeer extends LWComponentPeer<List, LWListPeer.ScrollableJList>
         implements ListPeer {
 
+    /**
+     * The default number of visible rows.
+     */
+    private static final int DEFAULT_VISIBLE_ROWS = 4; // From java.awt.List,
+
+    /**
+     * This text is used for cell bounds calculation.
+     */
+    private static final String TEXT = "0123456789abcde";
+
     LWListPeer(final List target, final PlatformComponent platformComponent) {
         super(target, platformComponent);
         if (!getTarget().isBackgroundSet()) {
@@ -44,7 +57,7 @@
     }
 
     @Override
-    protected ScrollableJList createDelegate() {
+    ScrollableJList createDelegate() {
         return new ScrollableJList();
     }
 
@@ -66,7 +79,7 @@
     }
 
     @Override
-    protected Component getDelegateFocusOwner() {
+    Component getDelegateFocusOwner() {
         return getDelegate().getView();
     }
 
@@ -135,6 +148,16 @@
     }
 
     @Override
+    public Dimension getPreferredSize() {
+        return getMinimumSize();
+    }
+
+    @Override
+    public Dimension getMinimumSize() {
+        return getMinimumSize(DEFAULT_VISIBLE_ROWS);
+    }
+
+    @Override
     public Dimension getPreferredSize(final int rows) {
         return getMinimumSize(rows);
     }
@@ -142,16 +165,26 @@
     @Override
     public Dimension getMinimumSize(final int rows) {
         synchronized (getDelegateLock()) {
-            final int margin = 2;
-            final int space = 1;
+            final Dimension size = getCellSize();
+            size.height *= rows;
+            // Always take vertical scrollbar into account.
+            final JScrollBar vbar = getDelegate().getVerticalScrollBar();
+            size.width += vbar != null ? vbar.getMinimumSize().width : 0;
+            // JScrollPane and JList insets
+            final Insets pi = getDelegate().getInsets();
+            final Insets vi = getDelegate().getView().getInsets();
+            size.width += pi.left + pi.right + vi.left + vi.right;
+            size.height += pi.top + pi.bottom + vi.top + vi.bottom;
+            return size;
+        }
+    }
 
-            // TODO: count ScrollPane's scrolling elements if any.
-            final FontMetrics fm = getFontMetrics(getFont());
-            final int itemHeight = (fm.getHeight() - fm.getLeading()) + (2 * space);
-
-            return new Dimension(20 + (fm == null ? 10 * 15 : fm.stringWidth("0123456789abcde")),
-                    (fm == null ? 10 : itemHeight) * rows + (2 * margin));
-        }
+    private Dimension getCellSize() {
+        final JList<String> jList = getDelegate().getView();
+        final ListCellRenderer<? super String> cr = jList.getCellRenderer();
+        final Component cell = cr.getListCellRendererComponent(jList, TEXT, 0,
+                                                               false, false);
+        return cell.getPreferredSize();
     }
 
     private void revalidate() {
@@ -161,14 +194,15 @@
         }
     }
 
+    @SuppressWarnings("serial")// Safe: outer class is non-serializable.
     final class ScrollableJList extends JScrollPane implements ListSelectionListener {
 
         private boolean skipStateChangedEvent;
 
-        private DefaultListModel<Object> model =
-                new DefaultListModel<Object>() {
+        private final DefaultListModel<String> model =
+                new DefaultListModel<String>() {
                     @Override
-                    public void add(final int index, final Object element) {
+                    public void add(final int index, final String element) {
                         if (index == -1) {
                             addElement(element);
                         } else {
@@ -181,7 +215,7 @@
 
         ScrollableJList() {
             getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
-            final JList<Object> list = new JListDelegate();
+            final JList<String> list = new JListDelegate();
             list.addListSelectionListener(this);
 
             getViewport().setView(list);
@@ -202,9 +236,10 @@
         }
 
         @Override
+        @SuppressWarnings("unchecked")
         public void valueChanged(final ListSelectionEvent e) {
             if (!e.getValueIsAdjusting() && !isSkipStateChangedEvent()) {
-                final JList source = (JList) e.getSource();
+                final JList<?> source = (JList<?>) e.getSource();
                 for(int i = 0 ; i < source.getModel().getSize(); i++) {
 
                     final boolean wasSelected = Arrays.binarySearch(oldSelectedIndices, i) >= 0;
@@ -223,11 +258,12 @@
             }
         }
 
-        public JList getView() {
-            return (JList) getViewport().getView();
+        @SuppressWarnings("unchecked")
+        public JList<String> getView() {
+            return (JList<String>) getViewport().getView();
         }
 
-        public DefaultListModel<Object> getModel() {
+        public DefaultListModel<String> getModel() {
             return model;
         }
 
@@ -254,10 +290,10 @@
             }
         }
 
-        private final class JListDelegate extends JList<Object> {
+        private final class JListDelegate extends JList<String> {
 
             JListDelegate() {
-                super(ScrollableJList.this.model);
+                super(model);
             }
 
             @Override
@@ -272,7 +308,7 @@
                     final int index = locationToIndex(e.getPoint());
                     if (0 <= index && index < getModel().getSize()) {
                         LWListPeer.this.postEvent(new ActionEvent(getTarget(), ActionEvent.ACTION_PERFORMED,
-                            getModel().getElementAt(index).toString(), e.getWhen(), e.getModifiers()));
+                            getModel().getElementAt(index), e.getWhen(), e.getModifiers()));
                     }
                 }
             }
@@ -281,10 +317,10 @@
             protected void processKeyEvent(final KeyEvent e) {
                 super.processKeyEvent(e);
                 if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ENTER) {
-                    final Object selectedValue = getSelectedValue();
+                    final String selectedValue = getSelectedValue();
                     if(selectedValue != null){
                         LWListPeer.this.postEvent(new ActionEvent(getTarget(), ActionEvent.ACTION_PERFORMED,
-                            selectedValue.toString(), e.getWhen(), e.getModifiers()));
+                            selectedValue, e.getWhen(), e.getModifiers()));
                     }
                 }
             }
--- a/src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,10 @@
 
 import java.awt.peer.MouseInfoPeer;
 
+import sun.awt.AWTAccessor;
+
 public class LWMouseInfoPeer implements MouseInfoPeer {
 
-    public LWMouseInfoPeer() {
-    }
-
     @Override
     public int fillPointWithCoords(Point point) {
         LWCursorManager cursorManager =
@@ -52,8 +51,12 @@
             return false;
         }
 
-        LWWindowPeer windowPeer = (LWWindowPeer)w.getPeer();
-        return LWWindowPeer.getWindowUnderCursor() == windowPeer;
+        LWWindowPeer windowPeer = (LWWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);
+        if (windowPeer == null) {
+            return false;
+        }
+
+        return LWToolkit.getLWToolkit().getPlatformWindowUnderMouse() == windowPeer.getPlatformWindow();
     }
 
 }
--- a/src/macosx/classes/sun/lwawt/LWPanelPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWPanelPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,12 +26,15 @@
 
 package sun.lwawt;
 
-import java.awt.Dimension;
 import java.awt.Panel;
 import java.awt.peer.PanelPeer;
 
 import javax.swing.JPanel;
 
+/**
+ * Lightweight implementation of {@link PanelPeer}. Delegates most of the work
+ * to the {@link JPanel}.
+ */
 final class LWPanelPeer extends LWContainerPeer<Panel, JPanel>
         implements PanelPeer {
 
@@ -40,12 +43,7 @@
     }
 
     @Override
-    public JPanel createDelegate() {
+    JPanel createDelegate() {
         return new JPanel();
     }
-
-    @Override
-    public Dimension getMinimumSize() {
-        return getBounds().getSize();
-    }
 }
--- a/src/macosx/classes/sun/lwawt/LWRepaintArea.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWRepaintArea.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,39 +26,38 @@
 
 package sun.lwawt;
 
-import sun.awt.RepaintArea;
-
 import java.awt.Component;
 import java.awt.Graphics;
 
+import sun.awt.AWTAccessor;
+import sun.awt.RepaintArea;
+
 /**
+ * Emulates appearance of heavyweight components before call of the user code.
+ *
  * @author Sergey Bylokhov
  */
 final class LWRepaintArea extends RepaintArea {
 
     @Override
     protected void updateComponent(final Component comp, final Graphics g) {
+        // We shouldn't paint native component as a result of UPDATE events,
+        // just flush onscreen back-buffer.
         if (comp != null) {
             super.updateComponent(comp, g);
-            flushBuffers((LWComponentPeer) comp.getPeer());
+            LWComponentPeer.flushOnscreenGraphics();
         }
     }
 
     @Override
     protected void paintComponent(final Component comp, final Graphics g) {
         if (comp != null) {
-            final LWComponentPeer peer = (LWComponentPeer) comp.getPeer();
+            Object peer = AWTAccessor.getComponentAccessor().getPeer(comp);
             if (peer != null) {
-                peer.paintPeer(g);
+                ((LWComponentPeer<?, ?>) peer).paintPeer(g);
             }
             super.paintComponent(comp, g);
-            flushBuffers(peer);
-        }
-    }
-
-    private static void flushBuffers(final LWComponentPeer peer) {
-        if (peer != null) {
-            peer.flushOnscreenGraphics();
+            LWComponentPeer.flushOnscreenGraphics();
         }
     }
 }
--- a/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -27,7 +27,6 @@
 package sun.lwawt;
 
 import java.awt.Adjustable;
-import java.awt.Dimension;
 import java.awt.Scrollbar;
 import java.awt.event.AdjustmentEvent;
 import java.awt.event.AdjustmentListener;
@@ -35,10 +34,14 @@
 
 import javax.swing.JScrollBar;
 
+/**
+ * Lightweight implementation of {@link ScrollbarPeer}. Delegates most of the
+ * work to the {@link JScrollBar}.
+ */
 final class LWScrollBarPeer extends LWComponentPeer<Scrollbar, JScrollBar>
         implements ScrollbarPeer, AdjustmentListener {
 
-    //JScrollBar fires two changes with firePropertyChange (one for old value
+    // JScrollBar fires two changes with firePropertyChange (one for old value
     // and one for new one.
     // We save the last value and don't fire event if not changed.
     private int currentValue;
@@ -49,7 +52,7 @@
     }
 
     @Override
-    protected JScrollBar createDelegate() {
+    JScrollBar createDelegate() {
         return new JScrollBar();
     }
 
@@ -95,13 +98,6 @@
         }
     }
 
-    @Override
-    public Dimension getPreferredSize() {
-        synchronized (getDelegateLock()) {
-            return getDelegate().getPreferredSize();
-        }
-    }
-
     // Peer also registered as a listener for ComponentDelegate component
     @Override
     public void adjustmentValueChanged(final AdjustmentEvent e) {
--- a/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,10 @@
 import java.awt.peer.ScrollPanePeer;
 import java.util.List;
 
+/**
+ * Lightweight implementation of {@link ScrollPanePeer}. Delegates most of the
+ * work to the {@link JScrollPane}.
+ */
 final class LWScrollPanePeer extends LWContainerPeer<ScrollPane, JScrollPane>
         implements ScrollPanePeer, ChangeListener {
 
@@ -41,7 +45,8 @@
         super(target, platformComponent);
     }
 
-    protected JScrollPane createDelegate() {
+    @Override
+    JScrollPane createDelegate() {
         final JScrollPane sp = new JScrollPane();
         final JPanel panel = new JPanel();
         panel.setOpaque(false);
@@ -72,7 +77,7 @@
         SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
-                final LWComponentPeer viewPeer = getViewPeer();
+                final LWComponentPeer<?, ?> viewPeer = getViewPeer();
                 if (viewPeer != null) {
                     final Rectangle r;
                     synchronized (getDelegateLock()) {
@@ -96,14 +101,13 @@
         }
     }
 
-    LWComponentPeer getViewPeer() {
-        List<LWComponentPeer> peerList = getChildren();
+    LWComponentPeer<?, ?> getViewPeer() {
+        final List<LWComponentPeer<?, ?>> peerList = getChildren();
         return peerList.isEmpty() ? null : peerList.get(0);
     }
 
-
     @Override
-    protected Rectangle getContentSize() {
+    Rectangle getContentSize() {
         Rectangle viewRect = getDelegate().getViewport().getViewRect();
         return new Rectangle(viewRect.width, viewRect.height);
     }
@@ -112,7 +116,7 @@
     public void layout() {
         super.layout();
         synchronized (getDelegateLock()) {
-            LWComponentPeer viewPeer = getViewPeer();
+            final LWComponentPeer<?, ?> viewPeer = getViewPeer();
             if (viewPeer != null) {
                 Component view = getDelegate().getViewport().getView();
                 view.setBounds(viewPeer.getBounds());
--- a/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.Dimension;
+import java.awt.Insets;
 import java.awt.Point;
 import java.awt.TextArea;
 import java.awt.event.TextEvent;
@@ -41,11 +42,22 @@
 import javax.swing.text.Document;
 import javax.swing.text.JTextComponent;
 
+/**
+ * Lightweight implementation of {@link TextAreaPeer}. Delegates most of the
+ * work to the {@link JTextArea} inside {@link JScrollPane}.
+ */
 final class LWTextAreaPeer
         extends LWTextComponentPeer<TextArea, LWTextAreaPeer.ScrollableJTextArea>
         implements TextAreaPeer {
 
+    /**
+     * The default number of visible columns.
+     */
     private static final int DEFAULT_COLUMNS = 60;
+
+    /**
+     * The default number of visible rows.
+     */
     private static final int DEFAULT_ROWS = 10;
 
     LWTextAreaPeer(final TextArea target,
@@ -54,7 +66,7 @@
     }
 
     @Override
-    protected ScrollableJTextArea createDelegate() {
+    ScrollableJTextArea createDelegate() {
         return new ScrollableJTextArea();
     }
 
@@ -73,7 +85,7 @@
     }
 
     @Override
-    protected Cursor getCursor(final Point p) {
+    Cursor getCursor(final Point p) {
         final boolean isContains;
         synchronized (getDelegateLock()) {
             isContains = getDelegate().getViewport().getBounds().contains(p);
@@ -82,31 +94,46 @@
     }
 
     @Override
-    protected Component getDelegateFocusOwner() {
+    Component getDelegateFocusOwner() {
         return getTextComponent();
     }
 
     @Override
+    public Dimension getPreferredSize() {
+        return getMinimumSize();
+    }
+
+    @Override
     public Dimension getMinimumSize() {
         return getMinimumSize(DEFAULT_ROWS, DEFAULT_COLUMNS);
     }
 
     @Override
-    public Dimension getMinimumSize(final int rows, final int columns) {
-        return getPreferredSize(rows, columns);
+    public Dimension getPreferredSize(final int rows, final int columns) {
+        return getMinimumSize(rows, columns);
     }
 
     @Override
-    public Dimension getPreferredSize(final int rows, final int columns) {
-        final Dimension size = super.getPreferredSize(rows, columns);
+    public Dimension getMinimumSize(final int rows, final int columns) {
+        final Dimension size = super.getMinimumSize(rows, columns);
         synchronized (getDelegateLock()) {
-            final JScrollBar vbar = getDelegate().getVerticalScrollBar();
-            final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
-            final int scrollbarW = vbar != null ? vbar.getWidth() : 0;
-            final int scrollbarH = hbar != null ? hbar.getHeight() : 0;
-            return new Dimension(size.width + scrollbarW,
-                                 size.height + scrollbarH);
+            // JScrollPane insets
+            final Insets pi = getDelegate().getInsets();
+            size.width += pi.left + pi.right;
+            size.height += pi.top + pi.bottom;
+            // Take scrollbars into account.
+            final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
+            if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
+                final JScrollBar vbar = getDelegate().getVerticalScrollBar();
+                size.width += vbar != null ? vbar.getMinimumSize().width : 0;
+            }
+            final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
+            if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
+                final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
+                size.height += hbar != null ? hbar.getMinimumSize().height : 0;
+            }
         }
+        return size;
     }
 
     @Override
@@ -173,7 +200,7 @@
         }
     }
 
-    @SuppressWarnings("serial")
+    @SuppressWarnings("serial")// Safe: outer class is non-serializable.
     final class ScrollableJTextArea extends JScrollPane {
 
         ScrollableJTextArea() {
@@ -191,7 +218,6 @@
             super.setEnabled(enabled);
         }
 
-        @SuppressWarnings("serial")
         private final class JTextAreaDelegate extends JTextArea {
 
             // Empty non private constructor was added because access to this
--- a/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,14 +44,14 @@
 import javax.swing.text.Document;
 import javax.swing.text.JTextComponent;
 
+/**
+ * Lightweight implementation of {@link TextComponentPeer}. Provides useful
+ * methods for {@link LWTextAreaPeer} and {@link LWTextFieldPeer}
+ */
 abstract class LWTextComponentPeer<T extends TextComponent, D extends JComponent>
         extends LWComponentPeer<T, D>
         implements DocumentListener, TextComponentPeer, InputMethodListener {
 
-    /**
-     * Character with reasonable value between the minimum width and maximum.
-     */
-    protected static final char WIDE_CHAR = 'w';
     private volatile boolean firstChangeSkipped;
 
     LWTextComponentPeer(final T target,
@@ -95,18 +95,16 @@
      */
     abstract JTextComponent getTextComponent();
 
-    public Dimension getPreferredSize(final int rows, final int columns) {
+    public Dimension getMinimumSize(final int rows, final int columns) {
         final Insets insets;
         synchronized (getDelegateLock()) {
-            insets = getDelegate().getInsets();
+            insets = getTextComponent().getInsets();
         }
         final int borderHeight = insets.top + insets.bottom;
         final int borderWidth = insets.left + insets.right;
         final FontMetrics fm = getFontMetrics(getFont());
-        final int charWidth = (fm != null) ? fm.charWidth(WIDE_CHAR) : 10;
-        final int itemHeight = (fm != null) ? fm.getHeight() : 10;
-        return new Dimension(columns * charWidth + borderWidth,
-                             rows * itemHeight + borderHeight);
+        return new Dimension(fm.charWidth(WIDE_CHAR) * columns + borderWidth,
+                             fm.getHeight() * rows + borderHeight);
     }
 
     @Override
@@ -187,6 +185,7 @@
         }
     }
 
+    //TODO IN XAWT we just return true..
     @Override
     public final boolean isFocusable() {
         return getTarget().isFocusable();
@@ -222,14 +221,14 @@
     }
 
     @Override
-    public void inputMethodTextChanged(InputMethodEvent event) {
+    public void inputMethodTextChanged(final InputMethodEvent event) {
         synchronized (getDelegateLock()) {
             AWTAccessor.getComponentAccessor().processEvent(getTextComponent(), event);
         }
     }
 
     @Override
-    public void caretPositionChanged(InputMethodEvent event) {
+    public void caretPositionChanged(final InputMethodEvent event) {
         synchronized (getDelegateLock()) {
             AWTAccessor.getComponentAccessor().processEvent(getTextComponent(), event);
         }
--- a/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,19 +37,21 @@
 import javax.swing.*;
 import javax.swing.text.JTextComponent;
 
+/**
+ * Lightweight implementation of {@link TextFieldPeer}. Delegates most of the
+ * work to the {@link JPasswordField}.
+ */
 final class LWTextFieldPeer
         extends LWTextComponentPeer<TextField, JPasswordField>
         implements TextFieldPeer, ActionListener {
 
-    private static final int DEFAULT_COLUMNS = 1;
-
     LWTextFieldPeer(final TextField target,
                     final PlatformComponent platformComponent) {
         super(target, platformComponent);
     }
 
     @Override
-    protected JPasswordField createDelegate() {
+    JPasswordField createDelegate() {
         return new JPasswordFieldDelegate();
     }
 
@@ -88,17 +90,12 @@
 
     @Override
     public Dimension getPreferredSize(final int columns) {
-        return getPreferredSize(1, columns);
+        return getMinimumSize(columns);
     }
 
     @Override
     public Dimension getMinimumSize(final int columns) {
-        return getPreferredSize(columns);
-    }
-
-    @Override
-    public Dimension getMinimumSize() {
-        return getMinimumSize(DEFAULT_COLUMNS);
+        return getMinimumSize(1, columns);
     }
 
     @Override
@@ -114,7 +111,7 @@
      * @param e the focus event
      */
     @Override
-    protected void handleJavaFocusEvent(final FocusEvent e) {
+    void handleJavaFocusEvent(final FocusEvent e) {
         if (e.getID() == FocusEvent.FOCUS_LOST) {
             // In order to de-select the selection
             setCaretPosition(0);
@@ -122,6 +119,7 @@
         super.handleJavaFocusEvent(e);
     }
 
+    @SuppressWarnings("serial")// Safe: outer class is non-serializable.
     private final class JPasswordFieldDelegate extends JPasswordField {
 
         // Empty non private constructor was added because access to this
--- a/src/macosx/classes/sun/lwawt/LWToolkit.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWToolkit.java	Sun May 28 23:44:03 2017 -0700
@@ -313,7 +313,7 @@
     @Override
     public CanvasPeer createCanvas(Canvas target) {
         PlatformComponent platformComponent = createPlatformComponent();
-        LWCanvasPeer peer = new LWCanvasPeer(target, platformComponent);
+        LWCanvasPeer<?, ?> peer = new LWCanvasPeer<>(target, platformComponent);
         targetCreatedPeer(target, peer);
         peer.initialize();
         return peer;
@@ -384,6 +384,8 @@
         return peer;
     }
 
+    protected abstract PlatformWindow getPlatformWindowUnderMouse();
+
     @Override
     public TextFieldPeer createTextField(TextField target) {
         PlatformComponent platformComponent = createPlatformComponent();
@@ -528,16 +530,18 @@
     }
 
     @Override
-    public void grab(Window w) {
-        if (w.getPeer() != null) {
-            ((LWWindowPeer)w.getPeer()).grab();
+    public void grab(final Window w) {
+        final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
+        if (peer != null) {
+            ((LWWindowPeer) peer).grab();
         }
     }
 
     @Override
-    public void ungrab(Window w) {
-        if (w.getPeer() != null) {
-            ((LWWindowPeer)w.getPeer()).ungrab(false);
+    public void ungrab(final Window w) {
+        final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
+        if (peer != null) {
+            ((LWWindowPeer) peer).ungrab(false);
         }
     }
 }
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Sun May 28 23:44:03 2017 -0700
@@ -27,7 +27,6 @@
 
 import java.awt.*;
 import java.awt.event.*;
-import java.awt.image.BufferedImage;
 import java.awt.peer.*;
 import java.util.List;
 
@@ -44,7 +43,7 @@
     extends LWContainerPeer<Window, JComponent>
     implements FramePeer, DialogPeer, FullScreenCapable, DisplayChangedListener, PlatformEventNotifier
 {
-    public static enum PeerType {
+    public enum PeerType {
         SIMPLEWINDOW,
         FRAME,
         DIALOG,
@@ -76,32 +75,21 @@
     private SurfaceData surfaceData;
     private final Object surfaceDataLock = new Object();
 
-    private int backBufferCount;
-    private BufferCapabilities backBufferCaps;
-
-    // The back buffer is used for two purposes:
-    // 1. To render all the lightweight peers
-    // 2. To provide user with a BufferStrategy
-    // Need to check if a single back buffer can be used for both
-// TODO: VolatileImage
-//    private VolatileImage backBuffer;
-    private volatile BufferedImage backBuffer;
-
     private volatile int windowState = Frame.NORMAL;
 
     // check that the mouse is over the window
     private volatile boolean isMouseOver = false;
     // A peer where the last mouse event came to. Used by cursor manager to
     // find the component under cursor
-    private static volatile LWComponentPeer lastCommonMouseEventPeer = null;
+    private static volatile LWComponentPeer<?, ?> lastCommonMouseEventPeer;
 
     // A peer where the last mouse event came to. Used to generate
     // MOUSE_ENTERED/EXITED notifications
-    private volatile LWComponentPeer lastMouseEventPeer;
+    private volatile LWComponentPeer<?, ?> lastMouseEventPeer;
 
     // Peers where all dragged/released events should come to,
     // depending on what mouse button is being dragged according to Cocoa
-    private static LWComponentPeer mouseDownTarget[] = new LWComponentPeer[3];
+    private static final LWComponentPeer<?, ?>[] mouseDownTarget = new LWComponentPeer<?, ?>[3];
 
     // A bitmask that indicates what mouse buttons produce MOUSE_CLICKED events
     // on MOUSE_RELEASE. Click events are only generated if there were no drag
@@ -139,7 +127,8 @@
         this.peerType = peerType;
 
         Window owner = target.getOwner();
-        LWWindowPeer ownerPeer = (owner != null) ? (LWWindowPeer)owner.getPeer() : null;
+        LWWindowPeer ownerPeer = owner == null ? null :
+             (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner);
         PlatformWindow ownerDelegate = (ownerPeer != null) ? ownerPeer.getPlatformWindow() : null;
 
         // The delegate.initialize() needs a non-null GC on X11.
@@ -173,10 +162,10 @@
 
         // Init warning window(for applets)
         SecurityWarningWindow warn = null;
-        if (((Window)target).getWarningString() != null) {
+        if (target.getWarningString() != null) {
             // accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip
             // and TrayIcon balloon windows without a warning window.
-            if (!AWTAccessor.getWindowAccessor().isTrayIconWindow((Window)target)) {
+            if (!AWTAccessor.getWindowAccessor().isTrayIconWindow(target)) {
                 LWToolkit toolkit = (LWToolkit)Toolkit.getDefaultToolkit();
                 warn = toolkit.createSecurityWarning(target, this);
             }
@@ -218,6 +207,7 @@
     }
 
     // Just a helper method
+    @Override
     public PlatformWindow getPlatformWindow() {
         return platformWindow;
     }
@@ -250,7 +240,6 @@
         if (warningWindow != null) {
             warningWindow.dispose();
         }
-        destroyBuffers();
         platformWindow.dispose();
         super.disposeImpl();
     }
@@ -284,8 +273,10 @@
     }
 
     @Override
-    public GraphicsConfiguration getGraphicsConfiguration() {
-        return graphicsConfig;
+    public final GraphicsConfiguration getGraphicsConfiguration() {
+        synchronized (getStateLock()) {
+            return graphicsConfig;
+        }
     }
 
     @Override
@@ -311,66 +302,6 @@
     }
 
     @Override
-    public void createBuffers(int numBuffers, BufferCapabilities caps)
-        throws AWTException
-    {
-        try {
-            // Assume this method is never called with numBuffers <= 1, as 0 is
-            // unsupported, and 1 corresponds to a SingleBufferStrategy which
-            // doesn't depend on the peer. Screen is considered as a separate
-            // "buffer", that's why numBuffers - 1
-            assert numBuffers > 1;
-
-            replaceSurfaceData(numBuffers - 1, caps, false);
-        } catch (InvalidPipeException z) {
-            throw new AWTException(z.toString());
-        }
-    }
-
-    @Override
-    public final Image getBackBuffer() {
-        synchronized (getStateLock()) {
-            return backBuffer;
-        }
-    }
-
-    @Override
-    public void flip(int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction)
-    {
-        final BufferedImage buffer = (BufferedImage)getBackBuffer();
-        if (buffer == null) {
-            throw new IllegalStateException("Buffers have not been created");
-        }
-        final Graphics g = getGraphics();
-        try {
-            g.drawImage(buffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
-        } finally {
-            g.dispose();
-        }
-        if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
-            final Graphics2D bg = (Graphics2D) buffer.getGraphics();
-            try {
-                bg.setBackground(getBackground());
-                bg.clearRect(0, 0, buffer.getWidth(), buffer.getHeight());
-            } finally {
-                bg.dispose();
-            }
-        }
-    }
-
-    @Override
-    public final void destroyBuffers() {
-        final Image oldBB = getBackBuffer();
-        synchronized (getStateLock()) {
-            backBuffer = null;
-        }
-        if (oldBB != null) {
-            oldBB.flush();
-        }
-    }
-
-    @Override
     public void setBounds(int x, int y, int w, int h, int op) {
 
         if((op & NO_EMBEDDED_CHECK) == 0 && getPeerType() == PeerType.VIEW_EMBEDDED_FRAME) {
@@ -408,16 +339,14 @@
             h = MINIMUM_HEIGHT;
         }
 
-        if (graphicsConfig instanceof TextureSizeConstraining) {
-            final int maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
-            final int maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
+        final int maxW = getLWGC().getMaxTextureWidth();
+        final int maxH = getLWGC().getMaxTextureHeight();
 
-            if (w > maxW) {
-                w = maxW;
-            }
-            if (h > maxH) {
-                h = maxH;
-            }
+        if (w > maxW) {
+            w = maxW;
+        }
+        if (h > maxH) {
+            h = maxH;
         }
 
         return new Rectangle(x, y, w, h);
@@ -495,21 +424,14 @@
             min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
         }
 
-        final int maxW, maxH;
-        if (graphicsConfig instanceof TextureSizeConstraining) {
-            maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
-            maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
-        } else {
-            maxW = maxH = Integer.MAX_VALUE;
-        }
-
         final Dimension max;
         if (getTarget().isMaximumSizeSet()) {
             max = getTarget().getMaximumSize();
-            max.width = Math.min(max.width, maxW);
-            max.height = Math.min(max.height, maxH);
+            max.width = Math.min(max.width, getLWGC().getMaxTextureWidth());
+            max.height = Math.min(max.height, getLWGC().getMaxTextureHeight());
         } else {
-            max = new Dimension(maxW, maxH);
+            max = new Dimension(getLWGC().getMaxTextureWidth(),
+                                getLWGC().getMaxTextureHeight());
         }
 
         platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height);
@@ -521,6 +443,12 @@
     }
 
     @Override
+    public void setBackground(final Color c) {
+        super.setBackground(c);
+        updateOpaque();
+    }
+
+    @Override
     public void setOpacity(float opacity) {
         getPlatformWindow().setOpacity(opacity);
         repaintPeer();
@@ -631,7 +559,8 @@
     public void blockWindows(List<Window> windows) {
         //TODO: LWX will probably need some collectJavaToplevels to speed this up
         for (Window w : windows) {
-            WindowPeer wp = (WindowPeer)w.getPeer();
+            WindowPeer wp =
+                    (WindowPeer) AWTAccessor.getComponentAccessor().getPeer(w);
             if (wp != null) {
                 wp.setModalBlocked((Dialog)getTarget(), true);
             }
@@ -788,7 +717,7 @@
         // TODO: fill "bdata" member of AWTEvent
         Rectangle r = getBounds();
         // findPeerAt() expects parent coordinates
-        LWComponentPeer targetPeer = findPeerAt(r.x + x, r.y + y);
+        LWComponentPeer<?, ?> targetPeer = findPeerAt(r.x + x, r.y + y);
 
         if (id == MouseEvent.MOUSE_EXITED) {
             isMouseOver = false;
@@ -823,8 +752,7 @@
                 lastMouseEventPeer = targetPeer;
             }
         } else {
-            PlatformWindow topmostPlatformWindow =
-                    platformWindow.getTopmostPlatformWindowUnderMouse();
+            PlatformWindow topmostPlatformWindow = LWToolkit.getLWToolkit().getPlatformWindowUnderMouse();
 
             LWWindowPeer topmostWindowPeer =
                     topmostPlatformWindow != null ? topmostPlatformWindow.getPeer() : null;
@@ -838,8 +766,7 @@
                         screenX, screenY, modifiers, clickCount, popupTrigger,
                         targetPeer);
             } else {
-                LWComponentPeer topmostTargetPeer =
-                        topmostWindowPeer != null ? topmostWindowPeer.findPeerAt(r.x + x, r.y + y) : null;
+                LWComponentPeer<?, ?> topmostTargetPeer = topmostWindowPeer.findPeerAt(r.x + x, r.y + y);
                 topmostWindowPeer.generateMouseEnterExitEventsForComponents(when, button, x, y,
                         screenX, screenY, modifiers, clickCount, popupTrigger,
                         topmostTargetPeer);
@@ -934,7 +861,7 @@
     private void generateMouseEnterExitEventsForComponents(long when,
             int button, int x, int y, int screenX, int screenY,
             int modifiers, int clickCount, boolean popupTriger,
-            LWComponentPeer targetPeer) {
+            final LWComponentPeer<?, ?> targetPeer) {
         if (!isMouseOver || targetPeer == lastMouseEventPeer) {
             return;
         }
@@ -978,7 +905,7 @@
         // TODO: could we just use the last mouse event target here?
         Rectangle r = getBounds();
         // findPeerAt() expects parent coordinates
-        final LWComponentPeer targetPeer = findPeerAt(r.x + x, r.y + y);
+        final LWComponentPeer<?, ?> targetPeer = findPeerAt(r.x + x, r.y + y);
         if (targetPeer == null || !targetPeer.isEnabled()) {
             return;
         }
@@ -1132,21 +1059,10 @@
         replaceSurfaceData(true);
     }
 
-    private void replaceSurfaceData(boolean blit) {
-        replaceSurfaceData(backBufferCount, backBufferCaps, blit);
-    }
-
-    private void replaceSurfaceData(int newBackBufferCount,
-                                    BufferCapabilities newBackBufferCaps,
-                                    boolean blit) {
+    private void replaceSurfaceData(final boolean blit) {
         synchronized (surfaceDataLock) {
             final SurfaceData oldData = getSurfaceData();
             surfaceData = platformWindow.replaceSurfaceData();
-            // TODO: volatile image
-    //        VolatileImage oldBB = backBuffer;
-            BufferedImage oldBB = backBuffer;
-            backBufferCount = newBackBufferCount;
-            backBufferCaps = newBackBufferCaps;
             final Rectangle size = getSize();
             if (getSurfaceData() != null && oldData != getSurfaceData()) {
                 clearBackground(size.width, size.height);
@@ -1161,35 +1077,6 @@
                 // This can only happen when this peer is being created
                 oldData.flush();
             }
-
-            // TODO: volatile image
-    //        backBuffer = (VolatileImage)delegate.createBackBuffer();
-            backBuffer = (BufferedImage) platformWindow.createBackBuffer();
-            if (backBuffer != null) {
-                Graphics g = backBuffer.getGraphics();
-                try {
-                    Rectangle r = getBounds();
-                    if (g instanceof Graphics2D) {
-                        ((Graphics2D) g).setComposite(AlphaComposite.Src);
-                    }
-                    g.setColor(nonOpaqueBackground);
-                    g.fillRect(0, 0, r.width, r.height);
-                    if (g instanceof SunGraphics2D) {
-                       ((SunGraphics2D) g).constrain(0, 0, r.width, r.height, getRegion());
-                    }
-                    if (!isTextured()) {
-                        g.setColor(getBackground());
-                        g.fillRect(0, 0, r.width, r.height);
-                    }
-                    if (oldBB != null) {
-                        // Draw the old back buffer to the new one
-                        g.drawImage(oldBB, 0, 0, null);
-                        oldBB.flush();
-                    }
-                } finally {
-                    g.dispose();
-                }
-            }
         }
         flushOnscreenGraphics();
     }
@@ -1212,14 +1099,6 @@
         }
     }
 
-    public int getBackBufferCount() {
-        return backBufferCount;
-    }
-
-    public BufferCapabilities getBackBufferCaps() {
-        return backBufferCaps;
-    }
-
     /**
      * Request the window insets from the delegate and compares it with the
      * current one. This method is mostly called by the delegate, e.g. when the
@@ -1279,8 +1158,9 @@
                 if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
                     focusLog.fine("requesting native focus to the owner " + owner);
                 }
-                LWWindowPeer currentActivePeer = (currentActive != null ?
-                    (LWWindowPeer)currentActive.getPeer() : null);
+                LWWindowPeer currentActivePeer = currentActive == null ? null :
+                (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(
+                        currentActive);
 
                 // Ensure the opposite is natively active and suppress sending events.
                 if (currentActivePeer != null && currentActivePeer.platformWindow.isActive()) {
@@ -1403,7 +1283,8 @@
         while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) {
             owner = owner.getOwner();
         }
-        return owner != null ? (LWWindowPeer)owner.getPeer() : null;
+        return owner == null ? null :
+               (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner);
     }
 
     /**
@@ -1422,11 +1303,13 @@
         }
     }
 
+    @Override
     public void enterFullScreenMode() {
         platformWindow.enterFullScreenMode();
         updateSecurityWarningVisibility();
     }
 
+    @Override
     public void exitFullScreenMode() {
         platformWindow.exitFullScreenMode();
         updateSecurityWarningVisibility();
--- a/src/macosx/classes/sun/lwawt/PlatformWindow.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/PlatformWindow.java	Sun May 28 23:44:03 2017 -0700
@@ -97,17 +97,6 @@
      */
     public SurfaceData replaceSurfaceData();
 
-    /*
-     * Creates a new image to serve as a back buffer.
-     */
-    public Image createBackBuffer();
-
-    /*
-     * Move the given part of the back buffer to the front buffer.
-     */
-    public void flip(int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction);
-
     public void setModalBlocked(boolean blocked);
 
     public void toFront();
@@ -118,8 +107,6 @@
 
     public void setAlwaysOnTop(boolean value);
 
-    public PlatformWindow getTopmostPlatformWindowUnderMouse();
-
     public void updateFocusableWindowState();
 
     public boolean rejectFocusRequest(CausedFocusEvent.Cause cause);
--- a/src/macosx/classes/sun/lwawt/SelectionClearListener.java	Wed May 24 00:32:01 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.lwawt;
-
-/*
- * Every time the TextField (or TextArea) change selection, every other text components
- * must immediately clear their selections.
- */
-interface SelectionClearListener {
-   void clearSelection();
-}
--- a/src/macosx/classes/sun/lwawt/macosx/CCustomCursor.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CCustomCursor.java	Sun May 28 23:44:03 2017 -0700
@@ -38,6 +38,8 @@
 
     Image fImage;
     Point fHotspot;
+    int fWidth;
+    int fHeight;
 
     public CCustomCursor(final Image cursor, final Point hotSpot, final String name) throws IndexOutOfBoundsException, HeadlessException {
         super(name);
@@ -50,6 +52,7 @@
         // Make sure image is fully loaded.
         final Component c = new Canvas(); // for its imageUpdate method
         final MediaTracker tracker = new MediaTracker(c);
+        // MediaTracker loads resolution variants from MultiResolution Toolkit image
         tracker.addImage(fImage, 0);
         try {
             tracker.waitForAll();
@@ -67,15 +70,15 @@
             width = height = 1;
             fImage = createTransparentImage(width, height);
         } else {
-            // Scale image to nearest supported size
+            // Get the nearest supported cursor size
             final Dimension nativeSize = toolkit.getBestCursorSize(width, height);
-            if (nativeSize.width != width || nativeSize.height != height) {
-                fImage = fImage.getScaledInstance(nativeSize.width, nativeSize.height, Image.SCALE_DEFAULT);
-                width = nativeSize.width;
-                height = nativeSize.height;
-            }
+            width = nativeSize.width;
+            height = nativeSize.height;
         }
 
+        fWidth = width;
+        fHeight = height;
+
         // NOTE: this was removed for 3169146, but in 1.5 the JCK tests for an exception and fails if one isn't thrown.
         // See what JBuilder does.
         // Verify that the hotspot is within cursor bounds.
@@ -138,6 +141,7 @@
                 // failed to do its job. Return null to keep the cursor unchanged.
                 return 0L;
             } else {
+                fCImage.resizeRepresentations(fWidth, fHeight);
                 return fCImage.ptr;
             }
         } catch (IllegalArgumentException iae) {
--- a/src/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,10 @@
 
 package sun.lwawt.macosx;
 
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
 /**
  * Safely holds and disposes of native AppKit resources, using the
  * correct AppKit threading and Objective-C GC semantics.
@@ -36,6 +40,10 @@
     // TODO this pointer should be private and accessed via CFNativeAction class
     protected volatile long ptr;
 
+    private final ReadWriteLock lock = new ReentrantReadWriteLock();
+    private final Lock writeLock = lock.writeLock();
+    private final Lock readLock = lock.readLock();
+
     /**
      * @param ptr CFRetained native object pointer
      * @param disposeOnAppKitThread is the object needs to be CFReleased on the main thread
@@ -50,21 +58,31 @@
      * @param ptr CFRetained native object pointer
      */
     protected void setPtr(final long ptr) {
-        synchronized (this) {
-            if (this.ptr != 0) dispose();
+        writeLock.lock();
+        try {
+            if (this.ptr != 0) {
+                dispose();
+            }
             this.ptr = ptr;
+        } finally {
+            writeLock.unlock();
         }
     }
 
     /**
-     * Manually CFReleases the native resource
+     * Manually CFReleases the native resource.
      */
     protected void dispose() {
         long oldPtr = 0L;
-        synchronized (this) {
-            if (ptr == 0) return;
+        writeLock.lock();
+        try {
+            if (ptr == 0) {
+                return;
+            }
             oldPtr = ptr;
             ptr = 0;
+        } finally {
+            writeLock.unlock();
         }
 
         nativeCFRelease(oldPtr, disposeOnAppKitThread); // perform outside of the synchronized block
@@ -109,9 +127,14 @@
      *
      * @param  action The native operation
      */
-    public final synchronized void execute(final CFNativeAction action) {
-        if (ptr != 0) {
-            action.run(ptr);
+    public final void execute(final CFNativeAction action) {
+        readLock.lock();
+        try {
+            if (ptr != 0) {
+                action.run(ptr);
+            }
+        } finally {
+            readLock.unlock();
         }
     }
 
@@ -127,9 +150,14 @@
      * @return result of the native operation, usually the native pointer to
      *         some other data
      */
-    final synchronized long executeGet(final CFNativeActionGet action) {
-        if (ptr != 0) {
-            return action.run(ptr);
+    final long executeGet(final CFNativeActionGet action) {
+        readLock.lock();
+        try {
+            if (ptr != 0) {
+                return action.run(ptr);
+            }
+        } finally {
+            readLock.unlock();
         }
         return 0;
     }
--- a/src/macosx/classes/sun/lwawt/macosx/CImage.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CImage.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,17 +29,26 @@
 import java.awt.geom.Dimension2D;
 import java.awt.image.*;
 
+import java.util.Arrays;
+import java.util.List;
+import sun.awt.image.MultiResolutionImage;
+import sun.awt.image.MultiResolutionBufferedImage;
+import java.util.concurrent.atomic.AtomicReference;
+
 import sun.awt.image.SunWritableRaster;
 
 public class CImage extends CFRetainedResource {
     private static native long nativeCreateNSImageFromArray(int[] buffer, int w, int h);
+    private static native long nativeCreateNSImageFromArrays(int[][] buffers, int w[], int h[]);
     private static native long nativeCreateNSImageFromFileContents(String file);
     private static native long nativeCreateNSImageOfFileFromLaunchServices(String file);
     private static native long nativeCreateNSImageFromImageName(String name);
     private static native long nativeCreateNSImageFromIconSelector(int selector);
-    private static native void nativeCopyNSImageIntoArray(long image, int[] buffer, int w, int h);
+    private static native void nativeCopyNSImageIntoArray(long image, int[] buffer, int sw, int sh, int dw, int dh);
     private static native Dimension2D nativeGetNSImageSize(long image);
     private static native void nativeSetNSImageSize(long image, double w, double h);
+    private static native void nativeResizeNSImageRepresentations(long image, double w, double h);
+    private static native Dimension2D[] nativeGetNSImageRepresentationSizes(long image, double w, double h);
 
     static Creator creator = new Creator();
     static Creator getCreator() {
@@ -141,6 +150,12 @@
 
         // This is used to create a CImage from a Image
         public CImage createFromImage(final Image image) {
+            if (image instanceof MultiResolutionImage) {
+                List<Image> resolutionVariants
+                        = ((MultiResolutionImage) image).getResolutionVariants();
+                return createFromImages(resolutionVariants);
+            }
+
             int[] buffer = imageToArray(image, true);
             if (buffer == null) {
                 return null;
@@ -148,6 +163,40 @@
             return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
         }
 
+        public CImage createFromImages(List<Image> images) {
+            if (images == null || images.isEmpty()) {
+                return null;
+            }
+
+            int num = images.size();
+
+            int[][] buffers = new int[num][];
+            int[] w = new int[num];
+            int[] h = new int[num];
+
+            num = 0;
+
+            for (Image img : images) {
+                buffers[num] = imageToArray(img, true);
+                if (buffers[num] == null) {
+                    // Unable to process the image
+                    continue;
+                }
+                w[num] = img.getWidth(null);
+                h[num] = img.getHeight(null);
+                num++;
+            }
+
+            if (num == 0) {
+                return null;
+            }
+
+            return new CImage(nativeCreateNSImageFromArrays(
+                        Arrays.copyOf(buffers, num),
+                        Arrays.copyOf(w, num),
+                        Arrays.copyOf(h, num)));
+        }
+
         static int getSelectorAsInt(final String fromString) {
             final byte[] b = fromString.getBytes();
             final int len = Math.min(b.length, 4);
@@ -164,25 +213,86 @@
         super(nsImagePtr, true);
     }
 
-    /** @return A BufferedImage created from nsImagePtr, or null. */
-    public BufferedImage toImage() {
-        if (ptr == 0) return null;
+    /** @return A MultiResolution image created from nsImagePtr, or null. */
+    private BufferedImage toImage() {
+        if (ptr == 0) {
+            return null;
+        }
 
-        final Dimension2D size = nativeGetNSImageSize(ptr);
+        final AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                sizeRef.set(nativeGetNSImageSize(ptr));
+            }
+        });
+        final Dimension2D size = sizeRef.get();
+        if (size == null) {
+            return null;
+        }
         final int w = (int)size.getWidth();
         final int h = (int)size.getHeight();
+        final AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
+                                                               size.getHeight()));
+            }
+        });
+        Dimension2D[] sizes = repRef.get();
 
-        final BufferedImage bimg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
+        if (sizes == null || sizes.length < 2) {
+            return toImage(w, h, w, h);
+        }
+
+        BufferedImage[] images = new BufferedImage[sizes.length];
+        int currentImageIndex = 0;
+
+        for (int i = 0; i < sizes.length; i++) {
+            int imageRepWidth = (int) sizes[i].getWidth();
+            int imageRepHeight = (int) sizes[i].getHeight();
+
+            if(imageRepHeight <= w && imageRepHeight <= h){
+                currentImageIndex = i;
+            }
+            images[i] = toImage(w, h, imageRepWidth, imageRepHeight);
+        }
+        return new MultiResolutionBufferedImage(BufferedImage.TYPE_INT_ARGB_PRE,
+                currentImageIndex, images);
+    }
+
+    private BufferedImage toImage(final int srcWidth, final int srcHeight, final int dstWidth, final int dstHeight) {
+        final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE);
         final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();
         final int[] buffer = SunWritableRaster.stealData(dbi, 0);
-        nativeCopyNSImageIntoArray(ptr, buffer, w, h);
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight);
+            }
+        });
         SunWritableRaster.markDirty(dbi);
         return bimg;
     }
 
     /** If nsImagePtr != 0 then scale this NSImage. @return *this* */
     CImage resize(final double w, final double h) {
-        if (ptr != 0) nativeSetNSImageSize(ptr, w, h);
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeSetNSImageSize(ptr, w, h);
+            }
+        });
         return this;
     }
+
+    void resizeRepresentations(final double w, final double h) {
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeResizeNSImageRepresentations(ptr, w, h);
+            }
+        });
+    }
 }
--- a/src/macosx/classes/sun/lwawt/macosx/CMenuItem.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CMenuItem.java	Sun May 28 23:44:03 2017 -0700
@@ -124,11 +124,20 @@
     public final void setImage(final java.awt.Image img) {
         final CImage cimg = CImage.getCreator().createFromImage(img);
         execute(new CFNativeAction() {
-                @Override
-                public void run(long ptr) {
-                    nativeSetImage(ptr, cimg == null ? 0L : cimg.ptr);
+            @Override
+            public void run(final long ptr) {
+                if (cimg == null) {
+                    nativeSetImage(ptr, 0L);
+                } else {
+                    cimg.execute(new CFNativeAction() {
+                        @Override
+                        public void run(long imgPtr) {
+                            nativeSetImage(ptr, imgPtr);
+                        }
+                    });
                 }
-            });
+            }
+        });
     }
 
     /**
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,9 @@
         super(0, true);
     }
 
+    /**
+     * Used by JAWT.
+     */
     public long getPointer() {
         return ptr;
     }
@@ -61,7 +64,12 @@
         // translates values from the coordinate system of the top-level window
         // to the coordinate system of the content view
         final Insets insets = platformWindow.getPeer().getInsets();
-        nativeSetBounds(getPointer(), x - insets.left, y - insets.top, w, h);
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeSetBounds(ptr, x - insets.left, y - insets.top, w, h);
+            }
+        });
     }
 
     @Override
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	Sun May 28 23:44:03 2017 -0700
@@ -31,12 +31,9 @@
 import sun.java2d.opengl.CGLLayer;
 import sun.java2d.SurfaceData;
 
-import sun.awt.CGraphicsConfig;
-import sun.awt.CGraphicsDevice;
 import sun.awt.CausedFocusEvent;
 
 import java.awt.*;
-import java.awt.BufferCapabilities.FlipContents;
 
 import sun.util.logging.PlatformLogger;
 
@@ -113,22 +110,6 @@
     }
 
     @Override
-    public Image createBackBuffer() {
-        Rectangle r = peer.getBounds();
-        Image im = null;
-        if (!r.isEmpty()) {
-            int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
-            im = peer.getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency);
-        }
-        return im;
-    }
-
-    @Override
-    public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) {
-        throw new RuntimeException("Not implemented");
-    }
-
-    @Override
     public void setVisible(boolean visible) {}
 
     @Override
@@ -151,11 +132,6 @@
     @Override
     public void setAlwaysOnTop(boolean value) {}
 
-    // This method should be properly implemented for applets.
-    // It returns null just as a stub.
-    @Override
-    public PlatformWindow getTopmostPlatformWindowUnderMouse() { return null; }
-
     @Override
     public void updateFocusableWindowState() {}
 
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,9 @@
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.geom.Rectangle2D;
-import java.awt.image.VolatileImage;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 
 import sun.awt.CGraphicsConfig;
 import sun.awt.CGraphicsEnvironment;
@@ -80,8 +82,13 @@
      * All coordinates passed to the method should be based on the origin being in the bottom-left corner (standard
      * Cocoa coordinates).
      */
-    public void setBounds(int x, int y, int width, int height) {
-        CWrapper.NSView.setFrame(ptr, x, y, width, height);
+    public void setBounds(final int x, final int y, final int width, final int height) {
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CWrapper.NSView.setFrame(ptr, x, y, width, height);
+            }
+        });
     }
 
     // REMIND: CGLSurfaceData expects top-level's size
@@ -93,33 +100,18 @@
         return peer;
     }
 
-    public void setToolTip(String msg) {
-        CWrapper.NSView.setToolTip(ptr, msg);
+    public void setToolTip(final String msg) {
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CWrapper.NSView.setToolTip(ptr, msg);
+            }
+        });
     }
 
     // ----------------------------------------------------------------------
     // PAINTING METHODS
     // ----------------------------------------------------------------------
-
-    public void drawImageOnPeer(VolatileImage xBackBuffer, int x1, int y1, int x2, int y2) {
-        Graphics g = peer.getGraphics();
-        try {
-            g.drawImage(xBackBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
-        } finally {
-            g.dispose();
-        }
-    }
-
-    public Image createBackBuffer() {
-        Rectangle r = getBounds();
-        Image im = null;
-        if (!r.isEmpty()) {
-            int transparency = (isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT);
-            im = getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency);
-        }
-        return im;
-    }
-
     public SurfaceData replaceSurfaceData() {
         if (!LWCToolkit.getSunAwtDisableCALayers()) {
             surfaceData = windowLayer.replaceSurfaceData();
@@ -164,19 +156,37 @@
         }
     }
 
-    public void setAutoResizable(boolean toResize) {
-        nativeSetAutoResizable(this.getAWTView(), toResize);
+    public void setAutoResizable(final boolean toResize) {
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeSetAutoResizable(ptr, toResize);
+            }
+        });
     }
 
     public boolean isUnderMouse() {
-        return nativeIsViewUnderMouse(getAWTView());
+        final AtomicBoolean ref = new AtomicBoolean();
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                ref.set(nativeIsViewUnderMouse(ptr));
+            }
+        });
+        return ref.get();
     }
 
     public GraphicsDevice getGraphicsDevice() {
         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
         CGraphicsEnvironment cge = (CGraphicsEnvironment)ge;
-        int displayID = nativeGetNSViewDisplayID(getAWTView());
-        GraphicsDevice gd = cge.getScreenDevice(displayID);
+        final AtomicInteger ref = new AtomicInteger();
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                ref.set(nativeGetNSViewDisplayID(ptr));
+            }
+        });
+        GraphicsDevice gd = cge.getScreenDevice(ref.get());
         if (gd == null) {
             // this could possibly happen during device removal
             // use the default screen device in this case
@@ -186,8 +196,18 @@
     }
 
     public Point getLocationOnScreen() {
-        Rectangle r = nativeGetLocationOnScreen(this.getAWTView()).getBounds();
-        return new Point(r.x, r.y);
+        final AtomicReference<Rectangle> ref = new AtomicReference<>();
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                ref.set(nativeGetLocationOnScreen(ptr).getBounds());
+            }
+        });
+        Rectangle r = ref.get();
+        if (r != null) {
+            return new Point(r.x, r.y);
+        }
+        return new Point(0, 0);
     }
 
     // ----------------------------------------------------------------------
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Sun May 28 23:44:03 2017 -0700
@@ -25,19 +25,25 @@
 
 package sun.lwawt.macosx;
 
-import java.awt.BufferCapabilities.FlipContents;
 import java.awt.*;
 import java.awt.Dialog.ModalityType;
 import java.awt.event.*;
 import java.awt.peer.WindowPeer;
 import java.beans.*;
 import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.List;
 import java.util.Objects;
 
 import javax.swing.*;
 
 import sun.awt.*;
+import sun.awt.AWTAccessor.ComponentAccessor;
+import sun.awt.AWTAccessor.WindowAccessor;
 import sun.java2d.SurfaceData;
 import sun.java2d.opengl.CGLSurfaceData;
 import sun.lwawt.*;
@@ -63,9 +69,9 @@
     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
     private static native void nativeSynthesizeMouseEnteredExitedEvents();
     private static native void nativeDispose(long nsWindowPtr);
-    private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
     private static native void nativeEnterFullScreenMode(long nsWindowPtr);
     private static native void nativeExitFullScreenMode(long nsWindowPtr);
+    static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
 
     // Loger to report issues happened during execution but that do not affect functionality
     private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
@@ -179,16 +185,31 @@
             c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString()));
         }},
         new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
-            nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
+                c.execute(new CFNativeAction() {
+                    @Override
+                    public void run(long ptr) {
+                        nativeRevalidateNSWindowShadow(ptr);
+                    }
+                });
         }},
         new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
             if (value == null || !(value instanceof java.io.File)) {
-                nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null);
+                c.execute(new CFNativeAction() {
+                    @Override
+                    public void run(long ptr) {
+                        nativeSetNSWindowRepresentedFilename(ptr, null);
+                    }
+                });
                 return;
             }
 
             final String filename = ((java.io.File)value).getAbsolutePath();
-            nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
+            c.execute(new CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    nativeSetNSWindowRepresentedFilename(ptr, filename);
+                }
+            });
         }}
     }) {
         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
@@ -206,6 +227,8 @@
     private volatile boolean isFullScreenMode;
     private boolean isFullScreenAnimationOn;
 
+    private volatile boolean isIconifyAnimationActive;
+
     private Window target;
     private LWWindowPeer peer;
     protected CPlatformView contentView;
@@ -237,11 +260,35 @@
         contentView = createContentView();
         contentView.initialize(peer, responder);
 
-        final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L;
-        Rectangle bounds = _peer.constrainBounds(_target.getBounds());
-        final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(),
-                ownerPtr, styleBits, bounds.x, bounds.y, bounds.width, bounds.height);
-        setPtr(nativeWindowPtr);
+        final Rectangle bounds;
+        if (!IS(DECORATED, styleBits)) {
+            // For undecorated frames the move/resize event does not come if the frame is centered on the screen
+            // so we need to set a stub location to force an initial move/resize. Real bounds would be set later.
+            bounds = new Rectangle(0, 0, 1, 1);
+        } else {
+            bounds = _peer.constrainBounds(_target.getBounds());
+        }
+        final AtomicLong ref = new AtomicLong();
+        contentView.execute(new CFNativeAction() {
+            @Override
+            public void run(final long viewPtr) {
+                if (owner != null) {
+                    owner.execute(new CFNativeAction() {
+                        @Override
+                        public void run(long ownerPtr) {
+                            ref.set(nativeCreateNSWindow(viewPtr, ownerPtr, styleBits,
+                                                         bounds.x, bounds.y,
+                                                         bounds.width, bounds.height));
+                        }
+                    });
+                } else {
+                    ref.set(nativeCreateNSWindow(viewPtr, 0,
+                                                 styleBits, bounds.x, bounds.y,
+                                                 bounds.width, bounds.height));
+                }
+            }
+        });
+        setPtr(ref.get());
 
         // TODO: implement on top of JObjC bridged class
     //    NSWindow window = JObjC.getInstance().AppKit().NSWindow().getInstance(nativeWindowPtr, JObjCRuntime.getInstance());
@@ -398,53 +445,58 @@
 
     // this is the counter-point to -[CWindow _nativeSetStyleBit:]
     protected void setStyleBits(final int mask, final boolean value) {
-        nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0);
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeSetNSWindowStyleBits(ptr, mask, value ? mask : 0);
+            }
+        });
     }
 
     private native void _toggleFullScreenMode(final long model);
 
     public void toggleFullScreen() {
-        _toggleFullScreenMode(getNSWindowPtr());
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                _toggleFullScreenMode(ptr);
+            }
+        });
     }
 
     @Override // PlatformWindow
     public void setMenuBar(MenuBar mb) {
-        final long nsWindowPtr = getNSWindowPtr();
-        CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb);
-        if (mbPeer != null) {
-            mbPeer.execute(new CFNativeAction() {
-                    @Override
-                    public void run(long ptr) {
-                        nativeSetNSWindowMenuBar(nsWindowPtr, ptr);
-                    }
-                });
-        } else {
-            nativeSetNSWindowMenuBar(nsWindowPtr, 0);
-        }
-    }
-
-    @Override // PlatformWindow
-    public Image createBackBuffer() {
-        return contentView.createBackBuffer();
+        final CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb);
+        execute(new CFNativeAction() {
+            @Override
+            public void run(final long nsWindowPtr) {
+                if (mbPeer != null) {
+                    mbPeer.execute(new CFNativeAction() {
+                        @Override
+                        public void run(long ptr) {
+                            nativeSetNSWindowMenuBar(nsWindowPtr, ptr);
+                        }
+                    });
+                } else {
+                    nativeSetNSWindowMenuBar(nsWindowPtr, 0);
+                }
+            }
+        });
     }
 
     @Override // PlatformWindow
     public void dispose() {
-        if (owner != null) {
-            CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), getNSWindowPtr());
-        }
         contentView.dispose();
-        nativeDispose(getNSWindowPtr());
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CPlatformWindow.nativeDispose(ptr);
+            }
+        });
         CPlatformWindow.super.dispose();
     }
 
     @Override // PlatformWindow
-    public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) {
-        // TODO: not implemented
-        (new RuntimeException("unimplemented")).printStackTrace();
-    }
-
-    @Override // PlatformWindow
     public FontMetrics getFontMetrics(Font f) {
         // TODO: not implemented
         (new RuntimeException("unimplemented")).printStackTrace();
@@ -453,7 +505,14 @@
 
     @Override // PlatformWindow
     public Insets getInsets() {
-        return nativeGetNSWindowInsets(getNSWindowPtr());
+        final AtomicReference<Insets> ref = new AtomicReference<>();
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                ref.set(nativeGetNSWindowInsets(ptr));
+            }
+        });
+        return ref.get() != null ? ref.get() : new Insets(0, 0, 0, 0);
     }
 
     @Override // PlatformWindow
@@ -478,9 +537,14 @@
     }
 
     @Override // PlatformWindow
-    public void setBounds(int x, int y, int w, int h) {
+    public void setBounds(final int x, final int y, final int w, final int h) {
 //        assert CThreading.assertEventQueue();
-        nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h);
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeSetNSWindowBounds(ptr, x, y, w, h);
+            }
+        });
     }
 
     public boolean isVisible() {
@@ -488,8 +552,17 @@
     }
 
     private boolean isMaximized() {
-        return undecorated ? this.normalBounds != null
-                : CWrapper.NSWindow.isZoomed(getNSWindowPtr());
+        if (undecorated) {
+            return this.normalBounds != null;
+        }
+        final AtomicBoolean ref = new AtomicBoolean();
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                ref.set(CWrapper.NSWindow.isZoomed(ptr));
+            }
+        });
+        return ref.get();
     }
 
     private void maximize() {
@@ -497,7 +570,12 @@
             return;
         }
         if (!undecorated) {
-            CWrapper.NSWindow.zoom(getNSWindowPtr());
+            execute(new CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    CWrapper.NSWindow.zoom(ptr);
+                }
+            });
         } else {
             deliverZoom(true);
 
@@ -518,7 +596,12 @@
             return;
         }
         if (!undecorated) {
-            CWrapper.NSWindow.zoom(getNSWindowPtr());
+            execute(new CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    CWrapper.NSWindow.zoom(ptr);
+                }
+            });
         } else {
             deliverZoom(false);
 
@@ -530,27 +613,6 @@
 
     @Override // PlatformWindow
     public void setVisible(boolean visible) {
-        final long nsWindowPtr = getNSWindowPtr();
-
-        // Process parent-child relationship when hiding
-        if (!visible) {
-            // Unparent my children
-            for (Window w : target.getOwnedWindows()) {
-                WindowPeer p = (WindowPeer)w.getPeer();
-                if (p instanceof LWWindowPeer) {
-                    CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
-                    if (pw != null && pw.isVisible()) {
-                        CWrapper.NSWindow.removeChildWindow(nsWindowPtr, pw.getNSWindowPtr());
-                    }
-                }
-            }
-
-            // Unparent myself
-            if (owner != null && owner.isVisible()) {
-                CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), nsWindowPtr);
-            }
-        }
-
         // Configure stuff
         updateIconImages();
         updateFocusabilityForAutoRequestFocus(false);
@@ -560,27 +622,64 @@
         if (blocker == null || !visible) {
             // If it ain't blocked, or is being hidden, go regular way
             if (visible) {
-                CWrapper.NSWindow.makeFirstResponder(nsWindowPtr, contentView.getAWTView());
+                contentView.execute(new CFNativeAction() {
+                    @Override
+                    public void run(final long viewPtr) {
+                        execute(new CFNativeAction() {
+                            @Override
+                            public void run(long ptr) {
+                                CWrapper.NSWindow.makeFirstResponder(ptr,
+                                                                     viewPtr);
+                            }
+                        });
+                    }
+                });
 
-                boolean isPopup = (target.getType() == Window.Type.POPUP);
-                if (isPopup) {
-                    // Popups in applets don't activate applet's process
-                    CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
-                } else {
-                    CWrapper.NSWindow.orderFront(nsWindowPtr);
-                }
+                final boolean isPopup = (target.getType() == Window.Type.POPUP);
+                execute(new CFNativeAction() {
+                    @Override
+                    public void run(long ptr) {
+                        if (isPopup) {
+                            // Popups in applets don't activate applet's process
+                            CWrapper.NSWindow.orderFrontRegardless(ptr);
+                        } else {
+                            CWrapper.NSWindow.orderFront(ptr);
+                        }
 
-                boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(nsWindowPtr);
-                if (!isKeyWindow) {
-                    CWrapper.NSWindow.makeKeyWindow(nsWindowPtr);
-                }
+                        boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(ptr);
+                        if (!isKeyWindow) {
+                            CWrapper.NSWindow.makeKeyWindow(ptr);
+                        }
+                    }
+                });
             } else {
-                CWrapper.NSWindow.orderOut(nsWindowPtr);
+                execute(new CFNativeAction() {
+                    @Override
+                    public void run(long ptr) {
+                        // immediately hide the window
+                        CWrapper.NSWindow.orderOut(ptr);
+                        // process the close
+                        CWrapper.NSWindow.close(ptr);
+                    }
+                });
             }
         } else {
             // otherwise, put it in a proper z-order
-            CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowBelow,
-                    ((CPlatformWindow)blocker.getPlatformWindow()).getNSWindowPtr());
+            CPlatformWindow bw
+                    = (CPlatformWindow) blocker.getPlatformWindow();
+            bw.execute(new CFNativeAction() {
+                @Override
+                public void run(final long blockerPtr) {
+                    execute(new CFNativeAction() {
+                        @Override
+                        public void run(long ptr) {
+                            CWrapper.NSWindow.orderWindow(ptr,
+                                                          CWrapper.NSWindow.NSWindowBelow,
+                                                          blockerPtr);
+                        }
+                    });
+                }
+            });
         }
         this.visible = visible;
 
@@ -595,7 +694,12 @@
                 }
                 switch (frameState) {
                     case Frame.ICONIFIED:
-                        CWrapper.NSWindow.miniaturize(nsWindowPtr);
+                        execute(new CFNativeAction() {
+                            @Override
+                            public void run(long ptr) {
+                                CWrapper.NSWindow.miniaturize(ptr);
+                            }
+                        });
                         break;
                     case Frame.MAXIMIZED_BOTH:
                         maximize();
@@ -614,24 +718,40 @@
 
         // Manage parent-child relationship when showing
         if (visible) {
-            // Add myself as a child
+            // Order myself above my parent
             if (owner != null && owner.isVisible()) {
-                CWrapper.NSWindow.addChildWindow(owner.getNSWindowPtr(), nsWindowPtr, CWrapper.NSWindow.NSWindowAbove);
-                if (target.isAlwaysOnTop()) {
-                    CWrapper.NSWindow.setLevel(nsWindowPtr, CWrapper.NSWindow.NSFloatingWindowLevel);
-                }
+                owner.execute(new CFNativeAction() {
+                    @Override
+                    public void run(final long ownerPtr) {
+                        execute(new CFNativeAction() {
+                            @Override
+                            public void run(long ptr) {
+                                CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
+                            }
+                        });
+                    }
+                });
+                applyWindowLevel(target);
             }
 
-            // Add my own children to myself
+            // Order my own children above myself
             for (Window w : target.getOwnedWindows()) {
                 WindowPeer p = (WindowPeer)w.getPeer();
                 if (p instanceof LWWindowPeer) {
                     CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
                     if (pw != null && pw.isVisible()) {
-                        CWrapper.NSWindow.addChildWindow(nsWindowPtr, pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove);
-                        if (w.isAlwaysOnTop()) {
-                            CWrapper.NSWindow.setLevel(pw.getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel);
-                        }
+                        pw.execute(new CFNativeAction() {
+                            @Override
+                            public void run(final long childPtr) {
+                                execute(new CFNativeAction() {
+                                    @Override
+                                    public void run(long ptr) {
+                                        CWrapper.NSWindow.orderWindow(childPtr, CWrapper.NSWindow.NSWindowAbove, ptr);
+                                    }
+                                });
+                            }
+                        });
+                        pw.applyWindowLevel(w);
                     }
                 }
             }
@@ -645,26 +765,34 @@
     }
 
     @Override // PlatformWindow
-    public void setTitle(String title) {
-        nativeSetNSWindowTitle(getNSWindowPtr(), title);
+    public void setTitle(final String title) {
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeSetNSWindowTitle(ptr, title);
+            }
+        });
     }
 
     // Should be called on every window key property change.
     @Override // PlatformWindow
     public void updateIconImages() {
-        final long nsWindowPtr = getNSWindowPtr();
         final CImage cImage = getImageForTarget();
-        nativeSetNSWindowMinimizedIcon(nsWindowPtr, cImage == null ? 0L : cImage.ptr);
-    }
-
-    public long getNSWindowPtr() {
-        final long nsWindowPtr = ptr;
-        if (nsWindowPtr == 0L) {
-            if(logger.isLoggable(PlatformLogger.Level.FINE)) {
-                logger.fine("NSWindow already disposed?", new Exception("Pointer to native NSWindow is invalid."));
+        execute(new CFNativeAction() {
+            @Override
+            public void run(final long ptr) {
+                if (cImage == null) {
+                    nativeSetNSWindowMinimizedIcon(ptr, 0L);
+                } else {
+                    cImage.execute(new CFNativeAction() {
+                        @Override
+                        public void run(long imagePtr) {
+                            nativeSetNSWindowMinimizedIcon(ptr, imagePtr);
+                        }
+                    });
+                }
             }
-        }
-        return nsWindowPtr;
+        });
     }
 
     public SurfaceData getSurfaceData() {
@@ -673,13 +801,16 @@
 
     @Override  // PlatformWindow
     public void toBack() {
-        final long nsWindowPtr = getNSWindowPtr();
-        nativePushNSWindowToBack(nsWindowPtr);
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CPlatformWindow.nativePushNSWindowToBack(ptr);
+            }
+        });
     }
 
     @Override  // PlatformWindow
     public void toFront() {
-        final long nsWindowPtr = getNSWindowPtr();
         LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
         Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
         if( w != null && w.getPeer() != null
@@ -688,7 +819,12 @@
             lwcToolkit.activateApplicationIgnoringOtherApps();
         }
         updateFocusabilityForAutoRequestFocus(false);
-        nativePushNSWindowToFront(nsWindowPtr);
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CPlatformWindow.nativePushNSWindowToFront(ptr);
+            }
+        });
         updateFocusabilityForAutoRequestFocus(true);
     }
 
@@ -709,8 +845,13 @@
     }
 
     @Override
-    public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
-        nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH);
+    public void setSizeConstraints(final int minW, final int minH, final int maxW, final int maxH) {
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeSetNSWindowMinMax(ptr, minW, minH, maxW, maxH);
+            }
+        });
     }
 
     @Override
@@ -727,19 +868,28 @@
 
     @Override
     public boolean requestWindowFocus() {
-
-        long ptr = getNSWindowPtr();
-        if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) {
-            CWrapper.NSWindow.makeMainWindow(ptr);
-        }
-        CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) {
+                    CWrapper.NSWindow.makeMainWindow(ptr);
+                }
+                CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
+            }
+        });
         return true;
     }
 
     @Override
     public boolean isActive() {
-        long ptr = getNSWindowPtr();
-        return CWrapper.NSWindow.isKeyWindow(ptr);
+        final AtomicBoolean ref = new AtomicBoolean();
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                ref.set(CWrapper.NSWindow.isKeyWindow(ptr));
+            }
+        });
+        return ref.get();
     }
 
     @Override
@@ -759,21 +909,45 @@
         setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop);
     }
 
-    public PlatformWindow getTopmostPlatformWindowUnderMouse() {
-        return CPlatformWindow.nativeGetTopmostPlatformWindowUnderMouse();
-    }
     @Override
-    public void setOpacity(float opacity) {
-        CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity);
+    public void setOpacity(final float opacity) {
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CWrapper.NSWindow.setAlphaValue(ptr, opacity);
+            }
+        });
     }
 
     @Override
-    public void setOpaque(boolean isOpaque) {
-        CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque);
-        boolean isTextured = (peer == null)? false : peer.isTextured();
-        if (!isOpaque && !isTextured) {
-            long clearColor = CWrapper.NSColor.clearColor();
-            CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), clearColor);
+    public void setOpaque(final boolean isOpaque) {
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CWrapper.NSWindow.setOpaque(ptr, isOpaque);
+            }
+        });
+        boolean isTextured = (peer == null) ? false : peer.isTextured();
+        if (!isTextured) {
+            if (!isOpaque) {
+                execute(new CFNativeAction() {
+                    @Override
+                    public void run(long ptr) {
+                        CWrapper.NSWindow.setBackgroundColor(ptr, 0);
+                    }
+                });
+            } else if (peer != null) {
+                Color color = peer.getBackground();
+                if (color != null) {
+                    final int rgb = color.getRGB();
+                    execute(new CFNativeAction() {
+                        @Override
+                        public void run(long ptr) {
+                            CWrapper.NSWindow.setBackgroundColor(ptr, rgb);
+                        }
+                    });
+                }
+            }
         }
 
         //This is a temporary workaround. Looks like after 7124236 will be fixed
@@ -789,12 +963,22 @@
     @Override
     public void enterFullScreenMode() {
         isFullScreenMode = true;
-        nativeEnterFullScreenMode(getNSWindowPtr());
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CPlatformWindow.nativeEnterFullScreenMode(ptr);
+            }
+        });
     }
 
     @Override
     public void exitFullScreenMode() {
-        nativeExitFullScreenMode(getNSWindowPtr());
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CPlatformWindow.nativeExitFullScreenMode(ptr);
+            }
+        });
         isFullScreenMode = false;
     }
 
@@ -813,7 +997,6 @@
         int prevWindowState = peer.getState();
         if (prevWindowState == windowState) return;
 
-        final long nsWindowPtr = getNSWindowPtr();
         if ((windowState & Frame.ICONIFIED) != 0) {
             // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
             windowState = Frame.ICONIFIED;
@@ -825,18 +1008,33 @@
                     // the zoom call toggles between the normal and the max states
                     unmaximize();
                 }
-                CWrapper.NSWindow.miniaturize(nsWindowPtr);
+                execute(new CFNativeAction() {
+                    @Override
+                    public void run(long ptr) {
+                        CWrapper.NSWindow.miniaturize(ptr);
+                    }
+                });
                 break;
             case Frame.MAXIMIZED_BOTH:
                 if (prevWindowState == Frame.ICONIFIED) {
                     // let's return into the normal states first
-                    CWrapper.NSWindow.deminiaturize(nsWindowPtr);
+                    execute(new CFNativeAction() {
+                        @Override
+                        public void run(long ptr) {
+                            CWrapper.NSWindow.deminiaturize(ptr);
+                        }
+                    });
                 }
                 maximize();
                 break;
             case Frame.NORMAL:
                 if (prevWindowState == Frame.ICONIFIED) {
-                    CWrapper.NSWindow.deminiaturize(nsWindowPtr);
+                    execute(new CFNativeAction() {
+                        @Override
+                        public void run(long ptr) {
+                            CWrapper.NSWindow.deminiaturize(ptr);
+                        }
+                    });
                 } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {
                     // the zoom call toggles between the normal and the max states
                     unmaximize();
@@ -853,17 +1051,27 @@
     }
 
     @Override
-    public void setModalBlocked(boolean blocked) {
+    public void setModalBlocked(final boolean blocked) {
         if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
             return;
         }
 
-        nativeSetEnabled(getNSWindowPtr(), !blocked);
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeSetEnabled(ptr, !blocked);
+            }
+        });
     }
 
 
     public final void invalidateShadow(){
-        nativeRevalidateNSWindowShadow(getNSWindowPtr());
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeRevalidateNSWindowShadow(ptr);
+            }
+        });
     }
 
     // ----------------------------------------------------------------------
@@ -881,19 +1089,7 @@
         if (icons == null || icons.size() == 0) {
             return null;
         }
-
-        // Choose the best (largest) image
-        Image image = icons.get(0);
-        // Assume images are square, so check their widths only
-        int width = image.getWidth(null);
-        for (Image img : icons) {
-            final int w = img.getWidth(null);
-            if (w > width) {
-                image = img;
-                width = w;
-            }
-        }
-        return CImage.getCreator().createFromImage(image);
+        return CImage.getCreator().createFromImages(icons);
     }
 
     /*
@@ -991,6 +1187,9 @@
         if (peer != null) {
             peer.notifyIconify(iconify);
         }
+        if (iconify) {
+            isIconifyAnimationActive = false;
+        }
     }
 
     private void deliverZoom(final boolean isZoomed) {
@@ -1041,38 +1240,136 @@
 
         pWindow.orderAboveSiblings();
 
-        final long nsWindowPtr = pWindow.getNSWindowPtr();
-        CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
-        CWrapper.NSWindow.makeKeyAndOrderFront(nsWindowPtr);
-        CWrapper.NSWindow.makeMainWindow(nsWindowPtr);
-
+        pWindow.execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CWrapper.NSWindow.orderFrontRegardless(ptr);
+                CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
+                CWrapper.NSWindow.makeMainWindow(ptr);
+            }
+        });
         return true;
     }
 
+    private boolean isIconified() {
+        boolean isIconified = false;
+        if (target instanceof Frame) {
+            int state = ((Frame)target).getExtendedState();
+            if ((state & Frame.ICONIFIED) != 0) {
+                isIconified = true;
+            }
+        }
+        return isIconifyAnimationActive || isIconified;
+    }
+
+    private boolean isOneOfOwnersOrSelf(CPlatformWindow window) {
+        while (window != null) {
+            if (this == window) {
+                return true;
+            }
+            window = window.owner;
+        }
+        return false;
+    }
+
+    private CPlatformWindow getRootOwner() {
+        CPlatformWindow rootOwner = this;
+        while (rootOwner.owner != null) {
+            rootOwner = rootOwner.owner;
+        }
+        return rootOwner;
+    }
+
     private void orderAboveSiblings() {
-        if (owner == null) {
-            return;
+        // Recursively pop up the windows from the very bottom, (i.e. root owner) so that
+        // the windows are ordered above their nearest owner; ancestors of the window,
+        // which is going to become 'main window', are placed above their siblings.
+        CPlatformWindow rootOwner = getRootOwner();
+        if (rootOwner.isVisible() && !rootOwner.isIconified()) {
+            rootOwner.execute(new CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    CWrapper.NSWindow.orderFront(ptr);
+                }
+            });
         }
+        // Do not order child windows of iconified owner.
+        if (!rootOwner.isIconified()) {
+            final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();
+            orderAboveSiblingsImpl(windowAccessor.getOwnedWindows(rootOwner.target));
+        }
+    }
 
-        // NOTE: the logic will fail if we have a hierarchy like:
-        //       visible root owner
-        //          invisible owner
-        //              visible dialog
-        // However, this is an unlikely scenario for real life apps
-        if (owner.isVisible()) {
-            // Recursively pop up the windows from the very bottom so that only
-            // the very top-most one becomes the main window
-            owner.orderAboveSiblings();
+    private void orderAboveSiblingsImpl(Window[] windows) {
+        ArrayList<Window> childWindows = new ArrayList<Window>();
 
-            // Order the window to front of the stack of child windows
-            final long nsWindowSelfPtr = getNSWindowPtr();
-            final long nsWindowOwnerPtr = owner.getNSWindowPtr();
-            CWrapper.NSWindow.removeChildWindow(nsWindowOwnerPtr, nsWindowSelfPtr);
-            CWrapper.NSWindow.addChildWindow(nsWindowOwnerPtr, nsWindowSelfPtr, CWrapper.NSWindow.NSWindowAbove);
+        final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
+        final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();
+
+        // Go through the list of windows and perform ordering.
+        for (Window w : windows) {
+            boolean iconified = false;
+            final Object p = componentAccessor.getPeer(w);
+            if (p instanceof LWWindowPeer) {
+                final CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
+                iconified = isIconified();
+                if (pw != null && pw.isVisible() && !iconified) {
+                    // If the window is one of ancestors of 'main window' or is going to become main by itself,
+                    // the window should be ordered above its siblings; otherwise the window is just ordered
+                    // above its nearest parent.
+                    if (pw.isOneOfOwnersOrSelf(this)) {
+                        pw.execute(new CFNativeAction() {
+                            @Override
+                            public void run(long ptr) {
+                                CWrapper.NSWindow.orderFront(ptr);
+                            }
+                        });
+                    } else {
+                        pw.owner.execute(new CFNativeAction() {
+                            @Override
+                            public void run(final long ownerPtr) {
+                                pw.execute(new CFNativeAction() {
+                                    @Override
+                                    public void run(long ptr) {
+                                        CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
+                                    }
+                                });
+                            }
+                        });
+                    }
+                    pw.applyWindowLevel(w);
+                }
+            }
+            // Retrieve the child windows for each window from the list except iconified ones
+            // and store them for future use.
+            // Note: we collect data about child windows even for invisible owners, since they may have
+            // visible children.
+            if (!iconified) {
+                childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
+            }
         }
+        // If some windows, which have just been ordered, have any child windows, let's start new iteration
+        // and order these child windows.
+        if (!childWindows.isEmpty()) {
+            orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
+        }
+    }
 
-        if (target.isAlwaysOnTop()) {
-            CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel);
+    protected void applyWindowLevel(Window target) {
+        if (target.isAlwaysOnTop() && target.getType() != Window.Type.POPUP) {
+            execute(new CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSFloatingWindowLevel);
+                }
+            });
+        } else if (target.getType() == Window.Type.POPUP) {
+            execute(new CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSPopUpMenuWindowLevel);
+                }
+            });
         }
     }
 
@@ -1080,6 +1377,10 @@
     //                          NATIVE CALLBACKS
     // ----------------------------------------------------------------------
 
+    private void windowWillMiniaturize() {
+        isIconifyAnimationActive = true;
+    }
+
     private void windowDidBecomeMain() {
         assert CThreading.assertAppKit();
 
--- a/src/macosx/classes/sun/lwawt/macosx/CRobot.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CRobot.java	Sun May 28 23:44:03 2017 -0700
@@ -78,7 +78,7 @@
     @Override
     public void mousePress(int buttons) {
         mouseButtonsState |= buttons;
-
+        checkMousePos();
         mouseEvent(fDevice.getCGDisplayID(), mouseLastX, mouseLastY,
                    buttons, true, false);
     }
@@ -92,11 +92,40 @@
     @Override
     public void mouseRelease(int buttons) {
         mouseButtonsState &= ~buttons;
-
+        checkMousePos();
         mouseEvent(fDevice.getCGDisplayID(), mouseLastX, mouseLastY,
                    buttons, false, false);
     }
 
+    /**
+     * Set unknown mouse location, if needed.
+     */
+    private void checkMousePos() {
+        if (mouseLastX == MOUSE_LOCATION_UNKNOWN ||
+                mouseLastY == MOUSE_LOCATION_UNKNOWN) {
+
+            Rectangle deviceBounds = fDevice.getDefaultConfiguration().getBounds();
+            Point mousePos = CCursorManager.getInstance().getCursorPosition();
+
+            if (mousePos.x < deviceBounds.x) {
+                mousePos.x = deviceBounds.x;
+            }
+            else if (mousePos.x > deviceBounds.x + deviceBounds.width) {
+                mousePos.x = deviceBounds.x + deviceBounds.width;
+            }
+
+            if (mousePos.y < deviceBounds.y) {
+                mousePos.y = deviceBounds.y;
+            }
+            else if (mousePos.y > deviceBounds.y + deviceBounds.height) {
+                mousePos.y = deviceBounds.y + deviceBounds.height;
+            }
+
+            mouseLastX = mousePos.x;
+            mouseLastY = mousePos.y;
+        }
+    }
+
     @Override
     public native void mouseWheel(int wheelAmt);
 
--- a/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Sun May 28 23:44:03 2017 -0700
@@ -35,6 +35,7 @@
 import java.awt.peer.TrayIconPeer;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.util.concurrent.atomic.AtomicReference;
 
 public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
     private TrayIcon target;
@@ -86,10 +87,6 @@
         return nativeCreate();
     }
 
-    private long getModel() {
-        return ptr;
-    }
-
     private native long nativeCreate();
 
     //invocation from the AWTTrayIcon.m
@@ -142,8 +139,13 @@
     }
 
     @Override
-    public void setToolTip(String tooltip) {
-        nativeSetToolTip(getModel(), tooltip);
+    public void setToolTip(final String tooltip) {
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                nativeSetToolTip(ptr, tooltip);
+            }
+        });
     }
 
     //adds tooltip to the NSStatusBar's NSButton.
@@ -172,7 +174,18 @@
         }
 
         CImage cimage = CImage.getCreator().createFromImage(image);
-        setNativeImage(getModel(), cimage.ptr, target.isImageAutoSize());
+        final boolean imageAutoSize = target.isImageAutoSize();
+        cimage.execute(new CFNativeAction() {
+            @Override
+            public void run(final long imagePtr) {
+                execute(new CFNativeAction() {
+                    @Override
+                    public void run(long ptr) {
+                        setNativeImage(ptr, imagePtr, imageAutoSize);
+                    }
+                });
+            }
+        });
     }
 
     private native void setNativeImage(final long model, final long nsimage, final boolean autosize);
@@ -349,7 +362,17 @@
     private void showMessageDialog() {
 
         Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
-        Point2D iconLoc = nativeGetIconLocation(getModel());
+        final AtomicReference<Point2D> ref = new AtomicReference<>();
+        execute(new CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                ref.set(nativeGetIconLocation(ptr));
+            }
+        });
+        Point2D iconLoc = ref.get();
+        if (iconLoc == null) {
+            return;
+        }
 
         int dialogY = (int)iconLoc.getY();
         int dialogX = (int)iconLoc.getX();
--- a/src/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java	Sun May 28 23:44:03 2017 -0700
@@ -78,13 +78,23 @@
 
     @Override
     public void dispose() {
-        CWrapper.NSView.removeFromSuperview(view.getAWTView());
+        view.execute(new CFRetainedResource.CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CWrapper.NSView.removeFromSuperview(ptr);
+            }
+        });
         view.dispose();
     }
 
     @Override
-    public void setVisible(boolean visible) {
-        CWrapper.NSView.setHidden(view.getAWTView(), !visible);
+    public void setVisible(final boolean visible) {
+        view.execute(new CFRetainedResource.CFNativeAction() {
+            @Override
+            public void run(long ptr) {
+                CWrapper.NSView.setHidden(ptr, !visible);
+            }
+        });
     }
 
     @Override
@@ -148,11 +158,6 @@
     }
 
     @Override
-    public PlatformWindow getTopmostPlatformWindowUnderMouse() {
-        return null;
-    }
-
-    @Override
     public void updateFocusableWindowState() {
     }
 
@@ -217,14 +222,4 @@
     public boolean isUnderMouse() {
         return view.isUnderMouse();
     }
-
-    @Override
-    public Image createBackBuffer() {
-        return view.createBackBuffer();
-    }
-
-    @Override
-    public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) {
-        throw new RuntimeException("Not implemented");
-    }
 }
--- a/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java	Sun May 28 23:44:03 2017 -0700
@@ -119,7 +119,7 @@
         setBounds((int)point.getX(), (int)point.getY(), getWidth(), getHeight());
     }
 
-    public void setVisible(boolean visible, boolean doSchedule) {
+    public void setVisible(final boolean visible, boolean doSchedule) {
         synchronized (scheduler) {
             if (showingTaskHandle != null) {
                 showingTaskHandle.cancel(false);
@@ -217,40 +217,42 @@
     }
 
     @Override
-    public void setVisible(boolean visible) {
+    public void setVisible(final boolean visible) {
         synchronized (lock) {
-            final long nsWindowPtr = getNSWindowPtr();
-
-            // Process parent-child relationship when hiding
-            if (!visible) {
-                // Unparent myself
-                if (owner != null && owner.isVisible()) {
-                    CWrapper.NSWindow.removeChildWindow(
-                            owner.getNSWindowPtr(), nsWindowPtr);
+            execute(new CFNativeAction() {
+                @Override
+                public void run(long ptr) {
+                    // Actually show or hide the window
+                    if (visible) {
+                        CWrapper.NSWindow.orderFront(ptr);
+                    } else {
+                        CWrapper.NSWindow.orderOut(ptr);
+                    }
                 }
-            }
-
-            // Actually show or hide the window
-            if (visible) {
-                CWrapper.NSWindow.orderFront(nsWindowPtr);
-            } else {
-                CWrapper.NSWindow.orderOut(nsWindowPtr);
-            }
+            });
 
             this.visible = visible;
 
             // Manage parent-child relationship when showing
             if (visible) {
-                // Add myself as a child
+                // Order myself above my parent
                 if (owner != null && owner.isVisible()) {
-                    CWrapper.NSWindow.addChildWindow(owner.getNSWindowPtr(),
-                            nsWindowPtr, CWrapper.NSWindow.NSWindowAbove);
+                    owner.execute(new CFNativeAction() {
+                        @Override
+                        public void run(final long ownerPtr) {
+                            execute(new CFNativeAction() {
+                                @Override
+                                public void run(long ptr) {
+                                    CWrapper.NSWindow.orderWindow(ptr,
+                                                                  CWrapper.NSWindow.NSWindowAbove,
+                                                                  ownerPtr);
+                                }
+                            });
+                        }
+                    });
 
                     // do not allow security warning to be obscured by other windows
-                    if (ownerWindow.isAlwaysOnTop()) {
-                        CWrapper.NSWindow.setLevel(nsWindowPtr,
-                                CWrapper.NSWindow.NSFloatingWindowLevel);
-                    }
+                    applyWindowLevel(ownerWindow);
                 }
             }
         }
--- a/src/macosx/classes/sun/lwawt/macosx/CWrapper.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CWrapper.java	Sun May 28 23:44:03 2017 -0700
@@ -40,6 +40,7 @@
         // The levels: (these are NOT real constants, these are keys. See native code.)
         static final int NSNormalWindowLevel = 0;
         static final int NSFloatingWindowLevel = 1;
+        static final int NSPopUpMenuWindowLevel = 2;
 
         // 'level' is one of the keys defined above
         static native void setLevel(long window, int level);
@@ -53,14 +54,39 @@
         static native void orderFront(long window);
         static native void orderFrontRegardless(long window);
         static native void orderWindow(long window, int ordered, long relativeTo);
+
+        /**
+         * Removes the window from the screen.
+         *
+         * @param window the pointer of the NSWindow
+         */
         static native void orderOut(long window);
 
+        /**
+         * Removes the window from the screen and releases it. According to
+         * documentation this method should be similar to {@link #orderOut},
+         * because we use ReleasedWhenClosed:NO, so the window shouldn't be
+         * released. But the close method works differently, for example it
+         * close the space if the window was in the full screen via
+         * {@link CPlatformWindow#toggleFullScreen()}.
+         *
+         * @param window the pointer of the NSWindow
+         */
+        static native void close(long window);
+
         static native void addChildWindow(long parent, long child, int ordered);
         static native void removeChildWindow(long parent, long child);
 
         static native void setAlphaValue(long window, float alpha);
         static native void setOpaque(long window, boolean opaque);
-        static native void setBackgroundColor(long window, long color);
+
+        /**
+         * Sets background color of the NSWindow.
+         *
+         * @param window the pointer of the NSWindow
+         * @param color the color in argb format
+         */
+        static native void setBackgroundColor(long window, int color);
 
         static native void miniaturize(long window);
         static native void deminiaturize(long window);
@@ -81,8 +107,4 @@
 
         static native void setToolTip(long view, String msg);
     }
-
-    static final class NSColor {
-        static native long clearColor();
-    }
 }
--- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Sun May 28 23:44:03 2017 -0700
@@ -35,14 +35,17 @@
 import java.awt.im.InputMethodHighlight;
 import java.awt.peer.*;
 import java.lang.reflect.*;
+import java.net.URL;
 import java.security.*;
 import java.util.*;
 import java.util.concurrent.Callable;
+import java.net.MalformedURLException;
 
 import sun.awt.*;
 import sun.lwawt.*;
 import sun.lwawt.LWWindowPeer.PeerType;
 import sun.security.action.GetBooleanAction;
+import sun.awt.image.MultiResolutionImage;
 
 import sun.util.CoreResourceBundleControl;
 
@@ -470,9 +473,30 @@
     @Override
     public Image getImage(final String filename) {
         final Image nsImage = checkForNSImage(filename);
-        if (nsImage != null) return nsImage;
+        if (nsImage != null) {
+            return nsImage;
+        }
 
-        return super.getImage(filename);
+        if (imageCached(filename)) {
+            return super.getImage(filename);
+        }
+
+        String fileneame2x = getScaledImageName(filename);
+        return (imageExists(fileneame2x))
+                ? getImageWithResolutionVariant(filename, fileneame2x)
+                : super.getImage(filename);
+    }
+
+    @Override
+    public Image getImage(URL url) {
+
+        if (imageCached(url)) {
+            return super.getImage(url);
+        }
+
+        URL url2x = getScaledImageURL(url);
+        return (imageExists(url2x))
+                ? getImageWithResolutionVariant(url, url2x) : super.getImage(url);
     }
 
     static final String nsImagePrefix = "NSImage://";
@@ -763,8 +787,45 @@
         return true;
     }
 
+    private static URL getScaledImageURL(URL url) {
+        try {
+            String scaledImagePath = getScaledImageName(url.getPath());
+            return scaledImagePath == null ? null : new URL(url.getProtocol(),
+                    url.getHost(), url.getPort(), scaledImagePath);
+        } catch (MalformedURLException e) {
+            return null;
+        }
+    }
+
+    private static String getScaledImageName(String path) {
+        if (!isValidPath(path)) {
+            return null;
+        }
+
+        int slash = path.lastIndexOf('/');
+        String name = (slash < 0) ? path : path.substring(slash + 1);
+
+        if (name.contains("@2x")) {
+            return null;
+        }
+
+        int dot = name.lastIndexOf('.');
+        String name2x = (dot < 0) ? name + "@2x"
+                : name.substring(0, dot) + "@2x" + name.substring(dot);
+        return (slash < 0) ? name2x : path.substring(0, slash + 1) + name2x;
+    }
+
+    private static boolean isValidPath(String path) {
+        return !path.isEmpty() && !path.endsWith("/") && !path.endsWith(".");
+    }
+
     @Override
     public boolean enableInputMethodsForTextComponent() {
         return true;
     }
+
+    @Override
+    protected PlatformWindow getPlatformWindowUnderMouse() {
+        return CPlatformWindow.nativeGetTopmostPlatformWindowUnderMouse();
+    }
 }
--- a/src/macosx/native/sun/awt/AWTSurfaceLayers.h	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/native/sun/awt/AWTSurfaceLayers.h	Sun May 28 23:44:03 2017 -0700
@@ -41,6 +41,8 @@
     CALayer *windowLayer;
 }
 
+@property (retain) CALayer *windowLayer;
+
 - (id) initWithWindowLayer: (CALayer *)windowLayer;
 - (void) setBounds: (CGRect)rect;
 
--- a/src/macosx/native/sun/awt/AWTSurfaceLayers.m	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/native/sun/awt/AWTSurfaceLayers.m	Sun May 28 23:44:03 2017 -0700
@@ -37,11 +37,15 @@
     self = [super init];
     if (self == nil) return self;
 
-    windowLayer = aWindowLayer;
+    self.windowLayer = aWindowLayer;
 
     return self;
 }
 
+- (void) dealloc {
+    self.windowLayer = nil;
+    [super dealloc];
+}
 
 - (CALayer *) layer {
     return layer;
--- a/src/macosx/native/sun/awt/AWTWindow.h	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/native/sun/awt/AWTWindow.h	Sun May 28 23:44:03 2017 -0700
@@ -47,6 +47,7 @@
     NSWindow *nsWindow;
     AWTWindow *ownerWindow;
     jint preFullScreenLevel;
+    BOOL isMinimizing;
 }
 
 // An instance of either AWTWindow_Normal or AWTWindow_Panel
@@ -61,6 +62,7 @@
 @property (nonatomic) jint styleBits;
 @property (nonatomic) BOOL isEnabled;
 @property (nonatomic) jint preFullScreenLevel;
+@property (nonatomic) BOOL isMinimizing;
 
 - (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow
                   ownerWindow:owner
--- a/src/macosx/native/sun/awt/AWTWindow.m	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/native/sun/awt/AWTWindow.m	Sun May 28 23:44:03 2017 -0700
@@ -143,6 +143,7 @@
 @synthesize isEnabled;
 @synthesize ownerWindow;
 @synthesize preFullScreenLevel;
+@synthesize isMinimizing;
 
 - (void) updateMinMaxSize:(BOOL)resizable {
     if (resizable) {
@@ -281,6 +282,7 @@
     [self.nsWindow release]; // the property retains the object already
 
     self.isEnabled = YES;
+    self.isMinimizing = NO;
     self.javaPlatformWindow = platformWindow;
     self.styleBits = bits;
     self.ownerWindow = owner;
@@ -319,10 +321,44 @@
     return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]];
 }
 
+// Retrieves the list of possible window layers (levels)
++ (NSArray*) getWindowLayers {
+    static NSArray *windowLayers;
+    static dispatch_once_t token;
+
+    // Initialize the list of possible window layers
+    dispatch_once(&token, ^{
+        // The layers are ordered from front to back, (i.e. the toppest one is the first)
+        windowLayers = [NSArray arrayWithObjects:
+                            [NSNumber numberWithInt:CGWindowLevelForKey(kCGPopUpMenuWindowLevelKey)],
+                            [NSNumber numberWithInt:CGWindowLevelForKey(kCGFloatingWindowLevelKey)],
+                            [NSNumber numberWithInt:CGWindowLevelForKey(kCGNormalWindowLevelKey)],
+                            nil
+                       ];
+        [windowLayers retain];
+    });
+    return windowLayers;
+}
+
+
 // return id for the topmost window under mouse
 + (NSInteger) getTopmostWindowUnderMouseID {
     NSInteger result = -1;
-    
+
+    NSArray *windowLayers = [AWTWindow getWindowLayers];
+    // Looking for the window under mouse starting from the toppest layer
+    for (NSNumber *layer in windowLayers) {
+        result = [AWTWindow getTopmostWindowUnderMouseIDImpl:[layer integerValue]];
+        if (result != -1) {
+            break;
+        }
+    }
+    return result;
+}
+
++ (NSInteger) getTopmostWindowUnderMouseIDImpl:(NSInteger)windowLayer {
+    NSInteger result = -1;
+
     NSRect screenRect = [[NSScreen mainScreen] frame];
     NSPoint nsMouseLocation = [NSEvent mouseLocation];
     CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
@@ -332,7 +368,7 @@
 
     for (NSDictionary *window in windows) {
         NSInteger layer = [[window objectForKey:(id)kCGWindowLayer] integerValue];
-        if (layer == 0) {
+        if (layer == windowLayer) {
             CGRect rect;
             CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect);
             if (CGRectContainsPoint(rect, cgMouseLocation)) {
@@ -423,6 +459,68 @@
     [super dealloc];
 }
 
+// Tests wheather the corresponding Java paltform window is visible or not
++ (BOOL) isJavaPlatformWindowVisible:(NSWindow *)window {
+    BOOL isVisible = NO;
+    
+    if ([AWTWindow isAWTWindow:window] && [window delegate] != nil) {
+        AWTWindow *awtWindow = (AWTWindow *)[window delegate];
+        [AWTToolkit eventCountPlusPlus];
+        
+        JNIEnv *env = [ThreadUtilities getJNIEnv];
+        jobject platformWindow = [awtWindow.javaPlatformWindow jObjectWithEnv:env];
+        if (platformWindow != NULL) {
+            static JNF_MEMBER_CACHE(jm_isVisible, jc_CPlatformWindow, "isVisible", "()Z");
+            isVisible = JNFCallBooleanMethod(env, platformWindow, jm_isVisible) == JNI_TRUE ? YES : NO;
+            (*env)->DeleteLocalRef(env, platformWindow);
+            
+        }
+    }
+    return isVisible;
+}
+
+// Orders window's childs based on the current focus state
+- (void) orderChildWindows:(BOOL)focus {
+AWT_ASSERT_APPKIT_THREAD;
+
+    if (self.isMinimizing) {
+        // Do not perform any ordering, if iconify is in progress
+        return;
+    }
+
+    NSEnumerator *windowEnumerator = [[NSApp windows]objectEnumerator];
+    NSWindow *window;
+    while ((window = [windowEnumerator nextObject]) != nil) {
+        if ([AWTWindow isJavaPlatformWindowVisible:window]) {
+            AWTWindow *awtWindow = (AWTWindow *)[window delegate];
+            AWTWindow *owner = awtWindow.ownerWindow;
+            if (IS(awtWindow.styleBits, ALWAYS_ON_TOP)) {
+                // Do not order 'always on top' windows
+                continue;
+            }
+            while (awtWindow.ownerWindow != nil) {
+                if (awtWindow.ownerWindow == self) {
+                    if (focus) {
+                        // Move the childWindow to floating level
+                        // so it will appear in front of its
+                        // parent which owns the focus
+                        [window setLevel:NSFloatingWindowLevel];
+                    } else {
+                        // Focus owner has changed, move the childWindow
+                        // back to normal window level
+                        [window setLevel:NSNormalWindowLevel];
+                    }
+                    // The childWindow should be displayed in front of
+                    // its nearest parentWindow
+                    [window orderWindow:NSWindowAbove relativeTo:[owner.nsWindow windowNumber]];
+                    break;
+                }
+                awtWindow = awtWindow.ownerWindow;
+            }
+        }
+    }
+}
+
 // NSWindow overrides
 - (BOOL) canBecomeKeyWindow {
 AWT_ASSERT_APPKIT_THREAD;
@@ -572,6 +670,30 @@
     return YES;
 }
 
+// Hides/shows window's childs during iconify/de-iconify operation
+- (void) iconifyChildWindows:(BOOL)iconify {
+AWT_ASSERT_APPKIT_THREAD;
+
+    NSEnumerator *windowEnumerator = [[NSApp windows]objectEnumerator];
+    NSWindow *window;
+    while ((window = [windowEnumerator nextObject]) != nil) {
+        if ([AWTWindow isJavaPlatformWindowVisible:window]) {
+            AWTWindow *awtWindow = (AWTWindow *)[window delegate];
+            while (awtWindow.ownerWindow != nil) {
+                if (awtWindow.ownerWindow == self) {
+                    if (iconify) {
+                        [window orderOut:window];
+                    } else {
+                        [window orderFront:window];
+                    }
+                    break;
+                }
+                awtWindow = awtWindow.ownerWindow;
+            }
+        }
+    }
+}
+
 - (void) _deliverIconify:(BOOL)iconify {
 AWT_ASSERT_APPKIT_THREAD;
 
@@ -585,16 +707,36 @@
     }
 }
 
+- (void)windowWillMiniaturize:(NSNotification *)notification {
+AWT_ASSERT_APPKIT_THREAD;
+
+    self.isMinimizing = YES;
+
+    JNIEnv *env = [ThreadUtilities getJNIEnv];
+    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
+    if (platformWindow != NULL) {
+        static JNF_MEMBER_CACHE(jm_windowWillMiniaturize, jc_CPlatformWindow, "windowWillMiniaturize", "()V");
+        JNFCallVoidMethod(env, platformWindow, jm_windowWillMiniaturize);
+        (*env)->DeleteLocalRef(env, platformWindow);
+    }
+    // Excplicitly make myself a key window to avoid possible
+    // negative visual effects during iconify operation
+    [self.nsWindow makeKeyAndOrderFront:self.nsWindow];
+    [self iconifyChildWindows:YES];
+}
+
 - (void)windowDidMiniaturize:(NSNotification *)notification {
 AWT_ASSERT_APPKIT_THREAD;
 
     [self _deliverIconify:JNI_TRUE];
+    self.isMinimizing = NO;
 }
 
 - (void)windowDidDeminiaturize:(NSNotification *)notification {
 AWT_ASSERT_APPKIT_THREAD;
 
     [self _deliverIconify:JNI_FALSE];
+    [self iconifyChildWindows:NO];
 }
 
 - (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite {
@@ -640,6 +782,7 @@
     [AWTWindow setLastKeyWindow:nil];
 
     [self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
+    [self orderChildWindows:YES];
 }
 
 - (void) windowDidResignKey: (NSNotification *) notification {
@@ -667,6 +810,7 @@
     }
 
     [self _deliverWindowFocusEvent:NO oppositeWindow: opposite];
+    [self orderChildWindows:NO];
 }
 
 - (void) windowDidBecomeMain: (NSNotification *) notification {
@@ -1195,15 +1339,16 @@
 JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetTopmostPlatformWindowUnderMouse
 (JNIEnv *env, jclass clazz)
 {
-    jobject topmostWindowUnderMouse = nil;
+    __block jobject topmostWindowUnderMouse = nil;
 
     JNF_COCOA_ENTER(env);
-    AWT_ASSERT_APPKIT_THREAD;
 
-    AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse];
-    if (awtWindow != nil) {
-        topmostWindowUnderMouse = [awtWindow.javaPlatformWindow jObject];
-    }
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^{
+        AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse];
+        if (awtWindow != nil) {
+            topmostWindowUnderMouse = [awtWindow.javaPlatformWindow jObject];
+        }
+    }];
 
     JNF_COCOA_EXIT(env);
 
--- a/src/macosx/native/sun/awt/CCursorManager.m	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/native/sun/awt/CCursorManager.m	Sun May 28 23:44:03 2017 -0700
@@ -118,13 +118,11 @@
 
 JNF_COCOA_ENTER(env);
 
-    __block NSPoint pt = NSZeroPoint;
-    
-    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-            pt = ConvertNSScreenPoint(env, [NSEvent mouseLocation]);
-    }];
-    
-    jpt = NSToJavaPoint(env, pt);
+    CGEventRef event = CGEventCreate(NULL);
+    CGPoint globalPos = CGEventGetLocation(event);
+    CFRelease(event);
+
+    jpt = NSToJavaPoint(env, globalPos);
 
 JNF_COCOA_EXIT(env);
 
--- a/src/macosx/native/sun/awt/CImage.m	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/native/sun/awt/CImage.m	Sun May 28 23:44:03 2017 -0700
@@ -22,6 +22,7 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#import "jni_util.h"
 
 #import <Cocoa/Cocoa.h>
 #import <JavaNativeFoundation/JavaNativeFoundation.h>
@@ -52,36 +53,29 @@
 }
 
 static void CImage_CopyNSImageIntoArray
-(NSImage *srcImage, jint *dstPixels, int width, int height)
+(NSImage *srcImage, jint *dstPixels, NSRect fromRect, NSRect toRect)
 {
+    int width = toRect.size.width;
+    int height = toRect.size.height;
     CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
-    CGContextRef cgRef = CGBitmapContextCreate(dstPixels, width, height, 8, width * 4, colorspace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
+    CGContextRef cgRef = CGBitmapContextCreate(dstPixels, width, height,
+                                8, width * 4, colorspace,
+                                kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
     CGColorSpaceRelease(colorspace);
     NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithGraphicsPort:cgRef flipped:NO];
     CGContextRelease(cgRef);
     NSGraphicsContext *oldContext = [[NSGraphicsContext currentContext] retain];
     [NSGraphicsContext setCurrentContext:context];
-    NSRect rect = NSMakeRect(0, 0, width, height);
-    [srcImage drawInRect:rect
-                fromRect:rect
+    [srcImage drawInRect:toRect
+                fromRect:fromRect
                operation:NSCompositeSourceOver
                 fraction:1.0];
     [NSGraphicsContext setCurrentContext:oldContext];
     [oldContext release];
 }
 
-/*
- * Class:     sun_lwawt_macosx_CImage
- * Method:    nativeCreateNSImageFromArray
- * Signature: ([III)J
- */
-JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArray
-(JNIEnv *env, jclass klass, jintArray buffer, jint width, jint height)
+static NSBitmapImageRep* CImage_CreateImageRep(JNIEnv *env, jintArray buffer, jint width, jint height)
 {
-    jlong result = 0L;
-
-JNF_COCOA_ENTER(env);
-
     NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
                                                                          pixelsWide:width
                                                                          pixelsHigh:height
@@ -104,10 +98,70 @@
 
     (*env)->ReleasePrimitiveArrayCritical(env, buffer, src, JNI_ABORT);
 
-    NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(width, height)] retain];
-    [nsImage addRepresentation:imageRep];
-    [imageRep release];
-    result = ptr_to_jlong(nsImage);
+    return imageRep;
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CImage
+ * Method:    nativeCreateNSImageFromArray
+ * Signature: ([III)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArray
+(JNIEnv *env, jclass klass, jintArray buffer, jint width, jint height)
+{
+    jlong result = 0L;
+
+JNF_COCOA_ENTER(env);
+    
+    NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
+    if (imageRep) {
+        NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(width, height)] retain];
+        [nsImage addRepresentation:imageRep];
+        [imageRep release];
+        result = ptr_to_jlong(nsImage);
+    }
+
+JNF_COCOA_EXIT(env);
+
+    return result;
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CImage
+ * Method:    nativeCreateNSImageFromArrays
+ * Signature: ([[I[I[I)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArrays
+(JNIEnv *env, jclass klass, jobjectArray buffers, jintArray widths, jintArray heights)
+{
+    jlong result = 0L;
+
+JNF_COCOA_ENTER(env);
+
+    jsize num = (*env)->GetArrayLength(env, buffers);
+    NSMutableArray * reps = [NSMutableArray arrayWithCapacity: num];
+
+    jint * ws = (*env)->GetIntArrayElements(env, widths, NULL);
+    jint * hs = (*env)->GetIntArrayElements(env, heights, NULL);
+
+    jsize i;
+    for (i = 0; i < num; i++) {
+        jintArray buffer = (*env)->GetObjectArrayElement(env, buffers, i);
+
+        NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, ws[i], hs[i]);
+        if (imageRep) {
+            [reps addObject: imageRep];
+        }
+    }
+
+    (*env)->ReleaseIntArrayElements(env, heights, hs, JNI_ABORT);
+    (*env)->ReleaseIntArrayElements(env, widths, ws, JNI_ABORT);
+
+    if ([reps count]) {
+        NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(0, 0)] retain];
+        [nsImage addRepresentations: reps];
+        result = ptr_to_jlong(nsImage);
+    }
 
 JNF_COCOA_EXIT(env);
 
@@ -202,17 +256,20 @@
 /*
  * Class:     sun_lwawt_macosx_CImage
  * Method:    nativeCopyNSImageIntoArray
- * Signature: (J[III)V
+ * Signature: (J[IIIII)V
  */
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CImage_nativeCopyNSImageIntoArray
-(JNIEnv *env, jclass klass, jlong nsImgPtr, jintArray buffer, jint w, jint h)
+(JNIEnv *env, jclass klass, jlong nsImgPtr, jintArray buffer, jint sw, jint sh,
+                 jint dw, jint dh)
 {
 JNF_COCOA_ENTER(env);
 
     NSImage *img = (NSImage *)jlong_to_ptr(nsImgPtr);
     jint *dst = (*env)->GetPrimitiveArrayCritical(env, buffer, NULL);
     if (dst) {
-        CImage_CopyNSImageIntoArray(img, dst, w, h);
+        NSRect fromRect = NSMakeRect(0, 0, sw, sh);
+        NSRect toRect = NSMakeRect(0, 0, dw, dh);
+        CImage_CopyNSImageIntoArray(img, dst, fromRect, toRect);
         (*env)->ReleasePrimitiveArrayCritical(env, buffer, dst, JNI_ABORT);
     }
 
@@ -256,3 +313,110 @@
 
 JNF_COCOA_EXIT(env);
 }
+
+/*
+ * Class:     sun_lwawt_macosx_CImage
+ * Method:    nativeResizeNSImageRepresentations
+ * Signature: (JDD)V
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CImage_nativeResizeNSImageRepresentations
+(JNIEnv *env, jclass clazz, jlong image, jdouble w, jdouble h)
+{
+    if (!image) return;
+    NSImage *i = (NSImage *)jlong_to_ptr(image);
+    
+JNF_COCOA_ENTER(env);
+    
+    NSImageRep *imageRep = nil;
+    NSArray *imageRepresentations = [i representations];
+    NSEnumerator *imageEnumerator = [imageRepresentations objectEnumerator];
+    while ((imageRep = [imageEnumerator nextObject]) != nil) {
+        [imageRep setSize:NSMakeSize(w, h)];
+    }
+    
+JNF_COCOA_EXIT(env);
+}
+
+NSComparisonResult getOrder(BOOL order){
+    return (NSComparisonResult) (order ? NSOrderedAscending : NSOrderedDescending);
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CImage
+ * Method:    nativeGetNSImageRepresentationsCount
+ * Signature: (JDD)[Ljava/awt/geom/Dimension2D;
+ */
+JNIEXPORT jobjectArray JNICALL
+                  Java_sun_lwawt_macosx_CImage_nativeGetNSImageRepresentationSizes
+(JNIEnv *env, jclass clazz, jlong image, jdouble w, jdouble h)
+{
+    if (!image) return NULL;
+    jobjectArray jreturnArray = NULL;
+    NSImage *img = (NSImage *)jlong_to_ptr(image);
+
+JNF_COCOA_ENTER(env);
+        
+    NSArray *imageRepresentations = [img representations];
+    if([imageRepresentations count] == 0){
+        return NULL;
+    }
+    
+    NSArray *sortedImageRepresentations = [imageRepresentations
+                    sortedArrayUsingComparator: ^(id obj1, id obj2) {
+        
+        NSImageRep *imageRep1 = (NSImageRep *) obj1;
+        NSImageRep *imageRep2 = (NSImageRep *) obj2;
+        NSSize size1 = [imageRep1 size];
+        NSSize size2 = [imageRep2 size];
+        
+        if (NSEqualSizes(size1, size2)) {
+            return getOrder([imageRep1 pixelsWide] <= [imageRep2 pixelsWide] &&
+                            [imageRep1 pixelsHigh] <= [imageRep2 pixelsHigh]);
+        }
+
+        return getOrder(size1.width <= size2.width && size1.height <= size2.height);
+    }];
+
+    NSMutableArray *sortedPixelSizes = [[NSMutableArray alloc] init];
+    NSSize lastSize = [[sortedImageRepresentations lastObject] size];
+    
+    NSUInteger i = [sortedImageRepresentations indexOfObjectPassingTest:
+               ^BOOL(id obj, NSUInteger idx, BOOL *stop) {
+        NSSize imageRepSize = [obj size];
+        return (w <= imageRepSize.width && h <= imageRepSize.height)
+                   || NSEqualSizes(imageRepSize, lastSize);
+    }];
+
+    NSUInteger count = [sortedImageRepresentations count];
+    i = (i == NSNotFound) ? count - 1 : i;
+    NSSize bestFitSize = [[sortedImageRepresentations objectAtIndex: i] size];
+
+    for(; i < count; i++){
+        NSImageRep *imageRep = [sortedImageRepresentations objectAtIndex: i];
+
+        if (!NSEqualSizes([imageRep size], bestFitSize)) {
+            break;
+        }
+
+        NSSize pixelSize = NSMakeSize(
+                                [imageRep pixelsWide], [imageRep pixelsHigh]);
+        [sortedPixelSizes addObject: [NSValue valueWithSize: pixelSize]];
+    }
+
+    count = [sortedPixelSizes count];
+    static JNF_CLASS_CACHE(jc_Dimension, "java/awt/Dimension");
+    jreturnArray = JNFNewObjectArray(env, &jc_Dimension, count);
+    CHECK_NULL_RETURN(jreturnArray, NULL);
+
+    for(i = 0; i < count; i++){
+        NSSize pixelSize = [[sortedPixelSizes objectAtIndex: i] sizeValue];
+
+        (*env)->SetObjectArrayElement(env, jreturnArray, i,
+                                      NSToJavaSize(env, pixelSize));
+        JNU_CHECK_EXCEPTION_RETURN(env, NULL);
+    }
+
+JNF_COCOA_EXIT(env);
+
+    return jreturnArray;
+}
\ No newline at end of file
--- a/src/macosx/native/sun/awt/CRobot.m	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/native/sun/awt/CRobot.m	Sun May 28 23:44:03 2017 -0700
@@ -143,47 +143,10 @@
 
     // This is the native method called when Robot mouse events occur.
     // The CRobot tracks the mouse position, and which button was
-    // pressed. If the mouse position is unknown it is obtained from
-    // CGEvents. The peer also tracks the mouse button desired state,
+    // pressed. The peer also tracks the mouse button desired state,
     // the appropriate key modifier state, and whether the mouse action
     // is simply a mouse move with no mouse button state changes.
 
-    CGError err = kCGErrorSuccess;
-
-    CGRect globalDeviceBounds = CGDisplayBounds(displayID);
-
-    // Set unknown mouse location, if needed.
-    if ((mouseLastX == sun_lwawt_macosx_CRobot_MOUSE_LOCATION_UNKNOWN) ||
-        (mouseLastY == sun_lwawt_macosx_CRobot_MOUSE_LOCATION_UNKNOWN))
-    {
-        CGEventRef event = CGEventCreate(NULL);
-        if (event == NULL) {
-            return;
-        }
-
-        CGPoint globalPos = CGEventGetLocation(event);
-        CFRelease(event);
-
-        // Normalize the coords within this display device, as
-        // per Robot rules.
-        if (globalPos.x < CGRectGetMinX(globalDeviceBounds)) {
-            globalPos.x = CGRectGetMinX(globalDeviceBounds);
-        }
-        else if (globalPos.x > CGRectGetMaxX(globalDeviceBounds)) {
-            globalPos.x = CGRectGetMaxX(globalDeviceBounds);
-        }
-
-        if (globalPos.y < CGRectGetMinY(globalDeviceBounds)) {
-            globalPos.y = CGRectGetMinY(globalDeviceBounds);
-        }
-        else if (globalPos.y > CGRectGetMaxY(globalDeviceBounds)) {
-            globalPos.y = CGRectGetMaxY(globalDeviceBounds);
-        }
-
-        mouseLastX = (jint)globalPos.x;
-        mouseLastY = (jint)globalPos.y;
-    }
-
     // volatile, otherwise it warns that it might be clobbered by 'longjmp'
     volatile CGPoint point;
 
--- a/src/macosx/native/sun/awt/CWrapper.m	Wed May 24 00:32:01 2017 -0700
+++ b/src/macosx/native/sun/awt/CWrapper.m	Sun May 28 23:44:03 2017 -0700
@@ -175,6 +175,23 @@
 
 /*
  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
+ * Method:    close
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_lwawt_macosx_CWrapper_00024NSWindow_close
+        (JNIEnv *env, jclass cls, jlong windowPtr)
+{
+JNF_COCOA_ENTER(env);
+    NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
+        [window close];
+    }];
+JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CWrapper$NSWindow
  * Method:    orderFrontRegardless
  * Signature: (J)V
  */
@@ -222,6 +239,7 @@
     dispatch_once(&pred, ^{
         LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSNormalWindowLevel] = NSNormalWindowLevel;
         LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSFloatingWindowLevel] = NSFloatingWindowLevel;
+        LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSPopUpMenuWindowLevel] = NSPopUpMenuWindowLevel;
     });
 }
 
@@ -336,12 +354,17 @@
  */
 JNIEXPORT void JNICALL
 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setBackgroundColor
-(JNIEnv *env, jclass cls, jlong windowPtr, jlong colorPtr)
+(JNIEnv *env, jclass cls, jlong windowPtr, jint rgb)
 {
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    NSColor *color = (NSColor *)jlong_to_ptr(colorPtr);
+    CGFloat alpha = (((rgb >> 24) & 0xff) / 255.0);
+    CGFloat red   = (((rgb >> 16) & 0xff) / 255.0);
+    CGFloat green = (((rgb >>  8) & 0xff) / 255.0);
+    CGFloat blue  = (((rgb >>  0) & 0xff) / 255.0);
+    NSColor *color = [NSColor colorWithCalibratedRed:red green:green blue:blue
+                                               alpha:alpha];
     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [window setBackgroundColor:color];
     }];
@@ -574,26 +597,3 @@
     
     JNF_COCOA_EXIT(env);
 }
-
-/*
- * Class:     sun_lwawt_macosx_CWrapper$NSColor
- * Method:    clearColor
- * Signature: ()J
- */
-JNIEXPORT jlong JNICALL
-Java_sun_lwawt_macosx_CWrapper_00024NSColor_clearColor
-(JNIEnv *env, jclass cls)
-{
-    __block jlong clearColorPtr = 0L;
-
-JNF_COCOA_ENTER(env);
-
-    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-        clearColorPtr = ptr_to_jlong([NSColor clearColor]);
-    }];
-
-JNF_COCOA_EXIT(env);
-
-    return clearColorPtr;
-}
-
--- a/src/share/classes/com/sun/java/swing/plaf/windows/resources/windows_ko.properties	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/resources/windows_ko.properties	Sun May 28 23:44:03 2017 -0700
@@ -38,7 +38,7 @@
 FileChooser.viewMenuButtonToolTipText = \uBCF4\uAE30 \uBA54\uB274
 FileChooser.viewMenuButtonAccessibleName = \uBCF4\uAE30 \uBA54\uB274
 FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
-FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C \uACE0\uCE68
+FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
 FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
 FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
 FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
--- a/src/share/classes/com/sun/jndi/ldap/pool/Connections.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/jndi/ldap/pool/Connections.java	Sun May 28 23:44:03 2017 -0700
@@ -27,7 +27,6 @@
 
 import java.util.ArrayList; // JDK 1.2
 import java.util.List;
-import java.util.Iterator;
 
 import java.lang.ref.Reference;
 import java.lang.ref.SoftReference;
@@ -290,23 +289,28 @@
      * @param threshold an entry idle since this time has expired.
      * @return true if no more connections in list
      */
-    synchronized boolean expire(long threshold) {
-        Iterator<ConnectionDesc> iter = conns.iterator();
-        ConnectionDesc entry;
-        while (iter.hasNext()) {
-            entry = iter.next();
+    boolean expire(long threshold) {
+        List<ConnectionDesc> clonedConns;
+        synchronized(this) {
+            clonedConns = new ArrayList<>(conns);
+        }
+        List<ConnectionDesc> expired = new ArrayList<>();
+
+        for (ConnectionDesc entry : clonedConns) {
+            d("expire(): ", entry);
             if (entry.expire(threshold)) {
-                d("expire(): removing ", entry);
-                td("Expired ", entry);
-
-                iter.remove();  // remove from pool
-
-                // Don't need to call notify() because we're
-                // removing only idle connections. If there were
-                // idle connections, then there should be no waiters.
+                expired.add(entry);
+                td("expire(): Expired ", entry);
             }
         }
-        return conns.isEmpty();  // whether whole list has 'expired'
+
+        synchronized (this) {
+            conns.removeAll(expired);
+            // Don't need to call notify() because we're
+            // removing only idle connections. If there were
+            // idle connections, then there should be no waiters.
+            return conns.isEmpty();  // whether whole list has 'expired'
+        }
     }
 
     /**
--- a/src/share/classes/com/sun/jndi/ldap/pool/Pool.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/jndi/ldap/pool/Pool.java	Sun May 28 23:44:03 2017 -0700
@@ -25,11 +25,11 @@
 
 package com.sun.jndi.ldap.pool;
 
+import java.util.ArrayList;
 import java.util.Map;
 import java.util.WeakHashMap;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.LinkedList;
 
 import java.io.PrintStream;
@@ -163,17 +163,25 @@
      *          and removed.
      */
     public void expire(long threshold) {
+        Collection<ConnectionsRef> copy;
         synchronized (map) {
-            Iterator<ConnectionsRef> iter = map.values().iterator();
-            Connections conns;
-            while (iter.hasNext()) {
-                conns = iter.next().getConnections();
-                if (conns.expire(threshold)) {
-                    d("expire(): removing ", conns);
-                    iter.remove();
-                }
+            copy = new ArrayList<>(map.values());
+        }
+
+        ArrayList<ConnectionsRef> removed = new ArrayList<>();
+        Connections conns;
+        for (ConnectionsRef ref : copy) {
+            conns = ref.getConnections();
+            if (conns.expire(threshold)) {
+                d("expire(): removing ", conns);
+                removed.add(ref);
             }
         }
+
+        synchronized (map) {
+            map.values().removeAll(removed);
+        }
+
         expungeStaleConnections();
     }
 
--- a/src/share/classes/com/sun/rowset/RowSetResourceBundle_sv.properties	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/rowset/RowSetResourceBundle_sv.properties	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
 cachedrowsetimpl.longfail = getLong utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}
 cachedrowsetimpl.floatfail = getFloat utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}
 cachedrowsetimpl.doublefail = getDouble utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}
-cachedrowsetimpl.dtypemismt = Inkompatibel datatyp 
+cachedrowsetimpl.dtypemismt = Felmatchad datatyp 
 cachedrowsetimpl.datefail = getDate utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}, ingen konvertering tillg\u00E4nglig
 cachedrowsetimpl.timefail = getTime utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}, ingen konvertering tillg\u00E4nglig
 cachedrowsetimpl.posupdate = Det finns inte st\u00F6d f\u00F6r positionerad uppdatering
--- a/src/share/classes/com/sun/security/ntlm/Client.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/security/ntlm/Client.java	Sun May 28 23:44:03 2017 -0700
@@ -46,7 +46,7 @@
     final private String hostname;
     final private String username;
 
-    private String domain;    // might be updated by Type 2 msg
+    private String domain;
     private byte[] pw1, pw2;
 
     /**
@@ -82,7 +82,7 @@
         }
         this.hostname = hostname;
         this.username = username;
-        this.domain = domain;
+        this.domain = domain == null ? "" : domain;
         this.pw1 = getP1(password);
         this.pw2 = getP2(password);
         debug("NTLM Client: (h,u,t,version(v)) = (%s,%s,%s,%s(%s))\n",
@@ -95,19 +95,13 @@
      */
     public byte[] type1() {
         Writer p = new Writer(1, 32);
-        int flags = 0x8203;
-        if (hostname != null) {
-            flags |= 0x2000;
-        }
-        if (domain != null) {
-            flags |= 0x1000;
-        }
+        // Negotiate always sign, Negotiate NTLM,
+        // Request Target, Negotiate OEM, Negotiate unicode
+        int flags = 0x8207;
         if (v != Version.NTLM) {
             flags |= 0x80000;
         }
         p.writeInt(12, flags);
-        p.writeSecurityBuffer(24, hostname, false);
-        p.writeSecurityBuffer(16, domain, false);
         debug("NTLM Client: Type 1 created\n");
         debug(p.getBytes());
         return p.getBytes();
@@ -133,13 +127,10 @@
         byte[] challenge = r.readBytes(24, 8);
         int inputFlags = r.readInt(20);
         boolean unicode = (inputFlags & 1) == 1;
-        String domainFromServer = r.readSecurityBuffer(12, unicode);
-        if (domainFromServer != null) {
-            domain = domainFromServer;
-        }
-        if (domain == null) {
-            domain = "";
-        }
+
+        // IE uses domainFromServer to generate an alist if server has not
+        // provided one. Firefox/WebKit do not. Neither do we.
+        //String domainFromServer = r.readSecurityBuffer(12, unicode);
 
         int flags = 0x88200 | (inputFlags & 3);
         Writer p = new Writer(3, 64);
@@ -163,7 +154,9 @@
             if (writeLM) lm = calcV2(nthash,
                     username.toUpperCase(Locale.US)+domain, nonce, challenge);
             if (writeNTLM) {
-                byte[] alist = type2.length > 48 ?
+                // Some client create a alist even if server does not send
+                // one: (i16)2 (i16)len target_in_unicode (i16)0 (i16) 0
+                byte[] alist = ((inputFlags & 0x800000) != 0) ?
                     r.readSecurityBuffer(40) : new byte[0];
                 byte[] blob = new byte[32+alist.length];
                 System.arraycopy(new byte[]{1,1,0,0,0,0,0,0}, 0, blob, 0, 8);
--- a/src/share/classes/com/sun/security/ntlm/Server.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/security/ntlm/Server.java	Sun May 28 23:44:03 2017 -0700
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -92,7 +93,9 @@
         debug("NTLM Server: Type 1 received\n");
         if (type1 != null) debug(type1);
         Writer p = new Writer(2, 32);
-        int flags = 0x80205;
+        // Negotiate NTLM2 Key, Target Type Domain,
+        // Negotiate NTLM, Request Target, Negotiate unicode
+        int flags = 0x90205;
         p.writeSecurityBuffer(12, domain, true);
         p.writeInt(20, flags);
         p.writeBytes(24, nonce);
@@ -127,8 +130,9 @@
                     "Wrong domain: " + incomingDomain +
                     " vs " + domain); // Needed?
         }*/
+
         boolean verified = false;
-        char[] password = getPassword(domain, username);
+        char[] password = getPassword(incomingDomain, username);
         if (password == null) {
             throw new NTLMException(NTLMException.USER_UNKNOWN,
                     "Unknown user");
@@ -179,6 +183,8 @@
                 }
             }
             if (incomingNTLM.length > 0) {
+                // We didn't sent alist in type2(), so there
+                // is nothing to check here.
                 byte[] clientBlob = Arrays.copyOfRange(
                         incomingNTLM, 16, incomingNTLM.length);
                 byte[] ntlmresponse = calcV2(nthash,
--- a/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java	Sun May 28 23:44:03 2017 -0700
@@ -160,9 +160,17 @@
             }
         }
         try {
+            String name = ncb.getName();
+            if (name == null) {
+                name = authzid;
+            }
+            String domain = dcb.getText();
+            if (domain == null) {
+                domain = serverName;
+            }
             client = new Client(version, hostname,
-                    ncb.getName(),
-                    dcb.getText(),
+                    name,
+                    domain,
                     pcb.getPassword());
         } catch (NTLMException ne) {
             throw new SaslException(
--- a/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java	Sun May 28 23:44:03 2017 -0700
@@ -140,8 +140,10 @@
             server = new Server(version, domain) {
                 public char[] getPassword(String ntdomain, String username) {
                     try {
-                        RealmCallback rcb = new RealmCallback(
-                                "Domain: ", ntdomain);
+                        RealmCallback rcb =
+                                (ntdomain == null || ntdomain.isEmpty())
+                                    ? new RealmCallback("Domain: ")
+                                    : new RealmCallback("Domain: ", ntdomain);
                         NameCallback ncb = new NameCallback(
                                 "Name: ", username);
                         PasswordCallback pcb = new PasswordCallback(
--- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_sv.properties	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_sv.properties	Sun May 28 23:44:03 2017 -0700
@@ -33,7 +33,7 @@
 ############ FILE CHOOSER STRINGS #############
 FileChooser.fileDescription.textAndMnemonic=Generisk fil
 FileChooser.directoryDescription.textAndMnemonic=Katalog
-FileChooser.newFolderError.textAndMnemonic=Fel uppstod n\u00E4r ny mapp skapades
+FileChooser.newFolderError.textAndMnemonic=Kan inte skapa ny mapp
 FileChooser.newFolderErrorSeparator= :
 FileChooser.newFolderParentDoesntExistTitle.textAndMnemonic=Kan inte skapa mappen
 FileChooser.newFolderParentDoesntExist.textAndMnemonic=Kan inte skapa mappen.\n\nSystemet kan inte hitta angiven s\u00F6kv\u00E4g.
@@ -59,15 +59,15 @@
 FileChooser.win32.newFolder=Ny mapp
 FileChooser.win32.newFolder.subsequent=Ny mapp ({0})
 FileChooser.other.newFolder=Ny mapp
-FileChooser.other.newFolder.subsequent=Ny mapp.{0}
+FileChooser.other.newFolder.subsequent=Ny mapp {0}
 
 
 ## file chooser tooltips ###
-FileChooser.cancelButtonToolTip.textAndMnemonic=Avbryt filvalsdialogruta
+FileChooser.cancelButtonToolTip.textAndMnemonic=Avbryt dialogrutan f\u00F6r filval
 FileChooser.saveButtonToolTip.textAndMnemonic=Spara vald fil
 FileChooser.openButtonToolTip.textAndMnemonic=\u00D6ppna vald fil
 FileChooser.updateButtonToolTip.textAndMnemonic=Uppdatera kataloglistan
-FileChooser.helpButtonToolTip.textAndMnemonic=Hj\u00E4lp - Filv\u00E4ljare
+FileChooser.helpButtonToolTip.textAndMnemonic=Hj\u00E4lp f\u00F6r val av fil
 FileChooser.directoryOpenButtonToolTip.textAndMnemonic=\u00D6ppna vald katalog
 
 FileChooser.filesListAccessibleName=Fillista
@@ -129,7 +129,7 @@
 
 # The following string will be formatted by a MessageFormat
 # and {0} will be replaced by page number being printed
-PrintingDialog.contentProgress.textAndMnemonic=Utskriven sida {0}...
+PrintingDialog.contentProgress.textAndMnemonic=Skriver ut sida {0}...
 
 PrintingDialog.contentAborting.textAndMnemonic=Utskriften avbryts...
 
@@ -177,8 +177,8 @@
 ProgressMonitor.progress.textAndMnemonic=P\u00E5g\u00E5r...
 
 ############ Split Pane Strings ############
-SplitPane.leftButton.textAndMnemonic=v\u00E4nster knapp
-SplitPane.rightButton.textAndMnemonic=h\u00F6ger knapp
+SplitPane.leftButton.textAndMnemonic=v\u00E4nsterknapp
+SplitPane.rightButton.textAndMnemonic=h\u00F6gerknapp
 # Used for Isindex
 IsindexView.prompt=Detta \u00E4r ett s\u00F6kbart index. Ange s\u00F6kord:
 
--- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_ko.properties	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_ko.properties	Sun May 28 23:44:03 2017 -0700
@@ -36,7 +36,7 @@
 FileChooser.detailsViewButtonToolTip.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
 FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4
 FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
-FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C \uACE0\uCE68
+FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
 FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
 FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
 FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
--- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_sv.properties	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_sv.properties	Sun May 28 23:44:03 2017 -0700
@@ -20,7 +20,7 @@
 
 FileChooser.lookInLabel.textAndMnemonic=Leta &i:
 FileChooser.saveInLabel.textAndMnemonic=Spara i:
-FileChooser.fileNameLabel.textAndMnemonic=&Fil:
+FileChooser.fileNameLabel.textAndMnemonic=Fil&namn:
 FileChooser.folderNameLabel.textAndMnemonic=&Mapp:
 FileChooser.filesOfTypeLabel.textAndMnemonic=Filer av &typen:
 FileChooser.upFolderToolTip.textAndMnemonic=Upp en niv\u00E5
--- a/src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ko.properties	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ko.properties	Sun May 28 23:44:03 2017 -0700
@@ -36,7 +36,7 @@
 FileChooser.detailsViewButtonToolTip.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
 FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4
 FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
-FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C \uACE0\uCE68
+FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
 FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
 FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
 FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
--- a/src/share/classes/java/awt/CheckboxMenuItem.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/CheckboxMenuItem.java	Sun May 28 23:44:03 2017 -0700
@@ -277,7 +277,7 @@
      * @since 1.4
      */
     public synchronized ItemListener[] getItemListeners() {
-        return (ItemListener[])(getListeners(ItemListener.class));
+        return getListeners(ItemListener.class);
     }
 
     /**
--- a/src/share/classes/java/awt/Cursor.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/Cursor.java	Sun May 28 23:44:03 2017 -0700
@@ -163,11 +163,11 @@
      * hashtable, filesystem dir prefix, filename, and properties for custom cursors support
      */
 
-    private static final Hashtable  systemCustomCursors         = new Hashtable(1);
+    private static final Hashtable<String,Cursor> systemCustomCursors = new Hashtable<>(1);
     private static final String systemCustomCursorDirPrefix = initCursorDir();
 
     private static String initCursorDir() {
-        String jhome =  (String) java.security.AccessController.doPrivileged(
+        String jhome = java.security.AccessController.doPrivileged(
                new sun.security.action.GetPropertyAction("java.home"));
         return jhome +
             File.separator + "lib" + File.separator + "images" +
@@ -298,7 +298,7 @@
     static public Cursor getSystemCustomCursor(final String name)
         throws AWTException, HeadlessException {
         GraphicsEnvironment.checkHeadless();
-        Cursor cursor = (Cursor)systemCustomCursors.get(name);
+        Cursor cursor = systemCustomCursors.get(name);
 
         if (cursor == null) {
             synchronized(systemCustomCursors) {
@@ -319,11 +319,11 @@
             final String fileName =
                 systemCustomCursorProperties.getProperty(key);
 
-            String localized = (String)systemCustomCursorProperties.getProperty(prefix + DotNameSuffix);
+            String localized = systemCustomCursorProperties.getProperty(prefix + DotNameSuffix);
 
             if (localized == null) localized = name;
 
-            String hotspot = (String)systemCustomCursorProperties.getProperty(prefix + DotHotspotSuffix);
+            String hotspot = systemCustomCursorProperties.getProperty(prefix + DotHotspotSuffix);
 
             if (hotspot == null)
                 throw new AWTException("no hotspot property defined for cursor: " + name);
@@ -348,9 +348,9 @@
                 final int fy = y;
                 final String flocalized = localized;
 
-                cursor = (Cursor) java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedExceptionAction() {
-                    public Object run() throws Exception {
+                cursor = java.security.AccessController.<Cursor>doPrivileged(
+                    new java.security.PrivilegedExceptionAction<Cursor>() {
+                    public Cursor run() throws Exception {
                         Toolkit toolkit = Toolkit.getDefaultToolkit();
                         Image image = toolkit.getImage(
                            systemCustomCursorDirPrefix + fileName);
@@ -447,8 +447,8 @@
             systemCustomCursorProperties = new Properties();
 
             try {
-                AccessController.doPrivileged(
-                      new java.security.PrivilegedExceptionAction() {
+                AccessController.<Object>doPrivileged(
+                      new java.security.PrivilegedExceptionAction<Object>() {
                     public Object run() throws Exception {
                         FileInputStream fis = null;
                         try {
--- a/src/share/classes/java/awt/EventQueue.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/EventQueue.java	Sun May 28 23:44:03 2017 -0700
@@ -166,7 +166,7 @@
      * The modifiers field of the current event, if the current event is an
      * InputEvent or ActionEvent.
      */
-    private WeakReference currentEvent;
+    private WeakReference<AWTEvent> currentEvent;
 
     /*
      * Non-zero if a thread is waiting in getNextEvent(int) for an event of
@@ -834,7 +834,7 @@
         pushPopLock.lock();
         try {
                 return (Thread.currentThread() == dispatchThread)
-                ? ((AWTEvent)currentEvent.get())
+                ? currentEvent.get()
                 : null;
         } finally {
             pushPopLock.unlock();
@@ -1183,7 +1183,7 @@
                 return;
             }
 
-            currentEvent = new WeakReference(e);
+            currentEvent = new WeakReference<>(e);
 
             // This series of 'instanceof' checks should be replaced with a
             // polymorphic type (for example, an interface which declares a
--- a/src/share/classes/java/awt/MediaTracker.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/MediaTracker.java	Sun May 28 23:44:03 2017 -0700
@@ -28,6 +28,7 @@
 import java.awt.Component;
 import java.awt.Image;
 import java.awt.image.ImageObserver;
+import sun.awt.image.MultiResolutionToolkitImage;
 
 /**
  * The <code>MediaTracker</code> class is a utility class to track
@@ -222,10 +223,17 @@
      * @param     h    the height at which the image is rendered
      */
     public synchronized void addImage(Image image, int id, int w, int h) {
+        addImageImpl(image, id, w, h);
+        Image rvImage = getResolutionVariant(image);
+        if (rvImage != null) {
+            addImageImpl(rvImage, id, 2 * w, 2 * h);
+        }
+    }
+
+    private void addImageImpl(Image image, int id, int w, int h) {
         head = MediaEntry.insert(head,
                                  new ImageMediaEntry(this, image, id, w, h));
     }
-
     /**
      * Flag indicating that media is currently being loaded.
      * @see         java.awt.MediaTracker#statusAll
@@ -719,6 +727,15 @@
      * @since   JDK1.1
      */
     public synchronized void removeImage(Image image) {
+        removeImageImpl(image);
+        Image rvImage = getResolutionVariant(image);
+        if (rvImage != null) {
+            removeImageImpl(rvImage);
+        }
+        notifyAll();    // Notify in case remaining images are "done".
+    }
+
+    private void removeImageImpl(Image image) {
         MediaEntry cur = head;
         MediaEntry prev = null;
         while (cur != null) {
@@ -735,7 +752,6 @@
             }
             cur = next;
         }
-        notifyAll();    // Notify in case remaining images are "done".
     }
 
     /**
@@ -750,6 +766,15 @@
      * @since      JDK1.1
      */
     public synchronized void removeImage(Image image, int id) {
+        removeImageImpl(image, id);
+        Image rvImage = getResolutionVariant(image);
+        if (rvImage != null) {
+            removeImageImpl(rvImage, id);
+        }
+        notifyAll();    // Notify in case remaining images are "done".
+    }
+
+    private void removeImageImpl(Image image, int id) {
         MediaEntry cur = head;
         MediaEntry prev = null;
         while (cur != null) {
@@ -766,7 +791,6 @@
             }
             cur = next;
         }
-        notifyAll();    // Notify in case remaining images are "done".
     }
 
     /**
@@ -783,6 +807,16 @@
      */
     public synchronized void removeImage(Image image, int id,
                                          int width, int height) {
+        removeImageImpl(image, id, width, height);
+        Image rvImage = getResolutionVariant(image);
+        if (rvImage != null) {
+            removeImageImpl(rvImage, id, 2 * width, 2 * height);
+
+        }
+        notifyAll();    // Notify in case remaining images are "done".
+    }
+
+    private void removeImageImpl(Image image, int id, int width, int height) {
         MediaEntry cur = head;
         MediaEntry prev = null;
         while (cur != null) {
@@ -801,12 +835,18 @@
             }
             cur = next;
         }
-        notifyAll();    // Notify in case remaining images are "done".
     }
 
     synchronized void setDone() {
         notifyAll();
     }
+
+    private static Image getResolutionVariant(Image image) {
+        if (image instanceof MultiResolutionToolkitImage) {
+            return ((MultiResolutionToolkitImage) image).getResolutionVariant();
+        }
+        return null;
+    }
 }
 
 abstract class MediaEntry {
--- a/src/share/classes/java/awt/Menu.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/Menu.java	Sun May 28 23:44:03 2017 -0700
@@ -66,7 +66,7 @@
 
         AWTAccessor.setMenuAccessor(
             new AWTAccessor.MenuAccessor() {
-                public Vector getItems(Menu menu) {
+                public Vector<MenuComponent> getItems(Menu menu) {
                     return menu.items;
                 }
             });
@@ -78,7 +78,7 @@
      * @serial
      * @see #countItems()
      */
-    Vector              items = new Vector();
+    Vector<MenuComponent> items = new Vector<>();
 
     /**
      * This field indicates whether the menu has the
@@ -313,7 +313,7 @@
             }
 
             int nitems = getItemCount();
-            Vector tempItems = new Vector();
+            Vector<MenuItem> tempItems = new Vector<>();
 
             /* Remove the item at index, nitems-index times
                storing them in a temporary vector in the
@@ -330,7 +330,7 @@
                already in the correct order in the temp vector.
             */
             for (int i = 0; i < tempItems.size()  ; i++) {
-                add((MenuItem)tempItems.elementAt(i));
+                add(tempItems.elementAt(i));
             }
         }
     }
@@ -379,7 +379,7 @@
             }
 
             int nitems = getItemCount();
-            Vector tempItems = new Vector();
+            Vector<MenuItem> tempItems = new Vector<>();
 
             /* Remove the item at index, nitems-index times
                storing them in a temporary vector in the
@@ -396,7 +396,7 @@
                already in the correct order in the temp vector.
             */
             for (int i = 0; i < tempItems.size()  ; i++) {
-                add((MenuItem)tempItems.elementAt(i));
+                add(tempItems.elementAt(i));
             }
         }
     }
@@ -411,9 +411,9 @@
             items.removeElementAt(index);
             MenuPeer peer = (MenuPeer)this.peer;
             if (peer != null) {
+                peer.delItem(index);
                 mi.removeNotify();
                 mi.parent = null;
-                peer.delItem(index);
             }
         }
     }
@@ -475,13 +475,13 @@
         return null;
     }
 
-    synchronized Enumeration shortcuts() {
-        Vector shortcuts = new Vector();
+    synchronized Enumeration<MenuShortcut> shortcuts() {
+        Vector<MenuShortcut> shortcuts = new Vector<>();
         int nitems = getItemCount();
         for (int i = 0 ; i < nitems ; i++) {
             MenuItem mi = getItem(i);
             if (mi instanceof Menu) {
-                Enumeration e = ((Menu)mi).shortcuts();
+                Enumeration<MenuShortcut> e = ((Menu)mi).shortcuts();
                 while (e.hasMoreElements()) {
                     shortcuts.addElement(e.nextElement());
                 }
--- a/src/share/classes/java/awt/MenuBar.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/MenuBar.java	Sun May 28 23:44:03 2017 -0700
@@ -81,7 +81,7 @@
                     return menuBar.helpMenu;
                 }
 
-                public Vector getMenus(MenuBar menuBar) {
+                public Vector<Menu> getMenus(MenuBar menuBar) {
                     return menuBar.menus;
                 }
             });
@@ -94,7 +94,7 @@
      * @serial
      * @see #countMenus()
      */
-    Vector menus = new Vector();
+    Vector<Menu> menus = new Vector<>();
 
     /**
      * This menu is a special menu dedicated to
@@ -222,7 +222,6 @@
             if (m.parent != null) {
                 m.parent.remove(m);
             }
-            menus.addElement(m);
             m.parent = this;
 
             MenuBarPeer peer = (MenuBarPeer)this.peer;
@@ -230,7 +229,10 @@
                 if (m.peer == null) {
                     m.addNotify();
                 }
+                menus.addElement(m);
                 peer.addMenu(m);
+            } else {
+                menus.addElement(m);
             }
             return m;
         }
@@ -248,9 +250,9 @@
             menus.removeElementAt(index);
             MenuBarPeer peer = (MenuBarPeer)this.peer;
             if (peer != null) {
+                peer.delMenu(index);
                 m.removeNotify();
                 m.parent = null;
-                peer.delMenu(index);
             }
         }
     }
@@ -309,7 +311,7 @@
      * be called on the toolkit thread.
      */
     final Menu getMenuImpl(int i) {
-        return (Menu)menus.elementAt(i);
+        return menus.elementAt(i);
     }
 
     /**
@@ -321,10 +323,10 @@
      * @since       JDK1.1
      */
     public synchronized Enumeration<MenuShortcut> shortcuts() {
-        Vector shortcuts = new Vector();
+        Vector<MenuShortcut> shortcuts = new Vector<>();
         int nmenus = getMenuCount();
         for (int i = 0 ; i < nmenus ; i++) {
-            Enumeration e = getMenu(i).shortcuts();
+            Enumeration<MenuShortcut> e = getMenu(i).shortcuts();
             while (e.hasMoreElements()) {
                 shortcuts.addElement(e.nextElement());
             }
@@ -438,7 +440,7 @@
       // HeadlessException will be thrown from MenuComponent's readObject
       s.defaultReadObject();
       for (int i = 0; i < menus.size(); i++) {
-        Menu m = (Menu)menus.elementAt(i);
+        Menu m = menus.elementAt(i);
         m.parent = this;
       }
     }
--- a/src/share/classes/java/awt/MenuComponent.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/MenuComponent.java	Sun May 28 23:44:03 2017 -0700
@@ -75,7 +75,7 @@
      * @see #setFont(Font)
      * @see #getFont()
      */
-    Font font;
+    volatile Font font;
 
     /**
      * The menu component's name, which defaults to <code>null</code>.
@@ -292,11 +292,13 @@
      * @see       java.awt.font.TextAttribute
      */
     public void setFont(Font f) {
-        font = f;
-        //Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
-        MenuComponentPeer peer = (MenuComponentPeer)this.peer;
-        if (peer != null) {
-            peer.setFont(f);
+        synchronized (getTreeLock()) {
+            font = f;
+            //Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
+            MenuComponentPeer peer = this.peer;
+            if (peer != null) {
+                peer.setFont(f);
+            }
         }
     }
 
@@ -307,7 +309,7 @@
      */
     public void removeNotify() {
         synchronized (getTreeLock()) {
-            MenuComponentPeer p = (MenuComponentPeer)this.peer;
+            MenuComponentPeer p = this.peer;
             if (p != null) {
                 Toolkit.getEventQueue().removeSourceEvents(this, true);
                 this.peer = null;
--- a/src/share/classes/java/awt/MenuItem.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/MenuItem.java	Sun May 28 23:44:03 2017 -0700
@@ -564,7 +564,7 @@
      * @since 1.4
      */
     public synchronized ActionListener[] getActionListeners() {
-        return (ActionListener[])(getListeners(ActionListener.class));
+        return getListeners(ActionListener.class);
     }
 
     /**
--- a/src/share/classes/java/awt/RenderingHints.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/RenderingHints.java	Sun May 28 23:44:03 2017 -0700
@@ -92,7 +92,7 @@
      * {@code equals()} method.
      */
     public abstract static class Key {
-        private static HashMap identitymap = new HashMap(17);
+        private static HashMap<Object,Object> identitymap = new HashMap<>(17);
 
         private String getIdentity() {
             // Note that the identity string is dependent on 3 variables:
@@ -138,7 +138,7 @@
             }
             // Note: Use a weak reference to avoid holding on to extra
             // objects and classes after they should be unloaded.
-            identitymap.put(identity, new WeakReference(k));
+            identitymap.put(identity, new WeakReference<Key>(k));
         }
 
         private int privatekey;
@@ -195,7 +195,7 @@
         }
     }
 
-    HashMap hintmap = new HashMap(7);
+    HashMap<Object,Object> hintmap = new HashMap<>(7);
 
     /**
      * Antialiasing hint key.
@@ -1267,12 +1267,13 @@
      * object.
      * @return a clone of this instance.
      */
+    @SuppressWarnings("unchecked")
     public Object clone() {
         RenderingHints rh;
         try {
             rh = (RenderingHints) super.clone();
             if (hintmap != null) {
-                rh.hintmap = (HashMap) hintmap.clone();
+                rh.hintmap = (HashMap<Object,Object>) hintmap.clone();
             }
         } catch (CloneNotSupportedException e) {
             // this shouldn't happen, since we are Cloneable
--- a/src/share/classes/java/awt/Window.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/Window.java	Sun May 28 23:44:03 2017 -0700
@@ -4072,6 +4072,10 @@
             public void setTrayIconWindow(Window w, boolean isTrayIconWindow) {
                 w.isTrayIconWindow = isTrayIconWindow;
             }
+
+            public Window[] getOwnedWindows(Window w) {
+                return w.getOwnedWindows_NoClientCode();
+            }
         }); // WindowAccessor
     } // static
 
--- a/src/share/classes/java/awt/datatransfer/Clipboard.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/datatransfer/Clipboard.java	Sun May 28 23:44:03 2017 -0700
@@ -72,7 +72,7 @@
      *
      * @since 1.5
      */
-    private Set currentDataFlavors;
+    private Set<DataFlavor> currentDataFlavors;
 
     /**
      * Creates a clipboard object.
@@ -314,7 +314,7 @@
         if (flavorListeners == null) {
             return;
         }
-        Set prevDataFlavors = currentDataFlavors;
+        Set<DataFlavor> prevDataFlavors = currentDataFlavors;
         currentDataFlavors = getAvailableDataFlavorSet();
         if (prevDataFlavors.equals(currentDataFlavors)) {
             return;
@@ -340,8 +340,8 @@
      *
      * @since 1.5
      */
-    private Set getAvailableDataFlavorSet() {
-        Set set = new HashSet();
+    private Set<DataFlavor> getAvailableDataFlavorSet() {
+        Set<DataFlavor> set = new HashSet<>();
         Transferable contents = getContents(null);
         if (contents != null) {
             DataFlavor[] flavors = contents.getTransferDataFlavors();
--- a/src/share/classes/java/awt/dnd/DragGestureEvent.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/dnd/DragGestureEvent.java	Sun May 28 23:44:03 2017 -0700
@@ -165,7 +165,7 @@
      * <P>
      * @return an Iterator for the events comprising the gesture
      */
-
+    @SuppressWarnings("unchecked")
     public Iterator<InputEvent> iterator() { return events.iterator(); }
 
     /**
@@ -184,7 +184,7 @@
      * <P>
      * @return an array of the events comprising the gesture
      */
-
+    @SuppressWarnings("unchecked")
     public Object[] toArray(Object[] array) { return events.toArray(array); }
 
     /**
@@ -333,7 +333,6 @@
         component = (Component)f.get("component", null);
         origin = (Point)f.get("origin", null);
         action = f.get("action", 0);
-
         // Pre-1.4 support. 'events' was previously non-transient
         try {
             events = (List)f.get("events", null);
@@ -351,7 +350,7 @@
     /*
      * fields
      */
-
+    @SuppressWarnings("rawtypes")
     private transient List events;
 
     /**
--- a/src/share/classes/java/awt/dnd/DragGestureRecognizer.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/dnd/DragGestureRecognizer.java	Sun May 28 23:44:03 2017 -0700
@@ -297,7 +297,7 @@
      * @return the initial event that triggered the drag gesture
      */
 
-    public InputEvent getTriggerEvent() { return events.isEmpty() ? null : (InputEvent)events.get(0); }
+    public InputEvent getTriggerEvent() { return events.isEmpty() ? null : events.get(0); }
 
     /**
      * Reset the Recognizer, if its currently recognizing a gesture, ignore
--- a/src/share/classes/java/awt/dnd/DragSource.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/dnd/DragSource.java	Sun May 28 23:44:03 2017 -0700
@@ -600,7 +600,7 @@
      * @since    1.4
      */
     public DragSourceListener[] getDragSourceListeners() {
-        return (DragSourceListener[])getListeners(DragSourceListener.class);
+        return getListeners(DragSourceListener.class);
     }
 
     /**
@@ -660,8 +660,7 @@
      * @since    1.4
      */
     public DragSourceMotionListener[] getDragSourceMotionListeners() {
-        return (DragSourceMotionListener[])
-            getListeners(DragSourceMotionListener.class);
+        return getListeners(DragSourceMotionListener.class);
     }
 
     /**
@@ -896,8 +895,8 @@
      * @since 1.5
      */
     public static int getDragThreshold() {
-        int ts = ((Integer)AccessController.doPrivileged(
-                new GetIntegerAction("awt.dnd.drag.threshold", 0))).intValue();
+        int ts = AccessController.doPrivileged(
+                new GetIntegerAction("awt.dnd.drag.threshold", 0)).intValue();
         if (ts > 0) {
             return ts;
         } else {
--- a/src/share/classes/java/awt/dnd/InvalidDnDOperationException.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/dnd/InvalidDnDOperationException.java	Sun May 28 23:44:03 2017 -0700
@@ -36,6 +36,8 @@
 
 public class InvalidDnDOperationException extends IllegalStateException {
 
+    private static final long serialVersionUID = -6062568741193956678L;
+
     static private String dft_msg = "The operation requested cannot be performed by the DnD system since it is not in the appropriate state";
 
     /**
--- a/src/share/classes/java/awt/geom/AffineTransform.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/awt/geom/AffineTransform.java	Sun May 28 23:44:03 2017 -0700
@@ -876,6 +876,7 @@
      * they have not been cached.
      * @see #getType
      */
+    @SuppressWarnings("fallthrough")
     private void calculateType() {
         int ret = TYPE_IDENTITY;
         boolean sgn0, sgn1;
@@ -1038,6 +1039,7 @@
      * @see #TYPE_UNIFORM_SCALE
      * @since 1.2
      */
+    @SuppressWarnings("fallthrough")
     public double getDeterminant() {
         switch (state) {
         default:
@@ -1250,6 +1252,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
             m02 = tx * m00 + ty * m01 + m02;
             m12 = tx * m10 + ty * m11 + m12;
@@ -1631,6 +1634,7 @@
      * Y axis direction
      * @since 1.2
      */
+    @SuppressWarnings("fallthrough")
     public void scale(double sx, double sy) {
         int state = this.state;
         switch (state) {
@@ -1705,6 +1709,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
         case (APPLY_SHEAR | APPLY_SCALE):
             double M0, M1;
@@ -2224,6 +2229,7 @@
      * @see #preConcatenate
      * @since 1.2
      */
+    @SuppressWarnings("fallthrough")
     public void concatenate(AffineTransform Tx) {
         double M0, M1;
         double T00, T01, T10, T11;
@@ -2432,6 +2438,7 @@
      * @see #concatenate
      * @since 1.2
      */
+    @SuppressWarnings("fallthrough")
     public void preConcatenate(AffineTransform Tx) {
         double M0, M1;
         double T00, T01, T10, T11;
@@ -2655,6 +2662,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return null;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
             det = m00 * m11 - m01 * m10;
             if (Math.abs(det) <= Double.MIN_VALUE) {
@@ -2751,6 +2759,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
             M00 = m00; M01 = m01; M02 = m02;
             M10 = m10; M11 = m11; M12 = m12;
@@ -2885,6 +2894,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return null;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
             ptDst.setLocation(x * m00 + y * m01 + m02,
                               x * m10 + y * m11 + m12);
@@ -2968,6 +2978,7 @@
             default:
                 stateError();
                 /* NOTREACHED */
+                return;
             case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
                 dst.setLocation(x * m00 + y * m01 + m02,
                                 x * m10 + y * m11 + m12);
@@ -3043,6 +3054,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
             M00 = m00; M01 = m01; M02 = m02;
             M10 = m10; M11 = m11; M12 = m12;
@@ -3157,6 +3169,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
             M00 = m00; M01 = m01; M02 = m02;
             M10 = m10; M11 = m11; M12 = m12;
@@ -3252,6 +3265,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
             M00 = m00; M01 = m01; M02 = m02;
             M10 = m10; M11 = m11; M12 = m12;
@@ -3347,6 +3361,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
             M00 = m00; M01 = m01; M02 = m02;
             M10 = m10; M11 = m11; M12 = m12;
@@ -3436,6 +3451,7 @@
      *                                         inverted.
      * @since 1.2
      */
+    @SuppressWarnings("fallthrough")
     public Point2D inverseTransform(Point2D ptSrc, Point2D ptDst)
         throws NoninvertibleTransformException
     {
@@ -3547,6 +3563,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
             M00 = m00; M01 = m01; M02 = m02;
             M10 = m10; M11 = m11; M12 = m12;
@@ -3679,6 +3696,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return null;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
         case (APPLY_SHEAR | APPLY_SCALE):
             ptDst.setLocation(x * m00 + y * m01, x * m10 + y * m11);
@@ -3754,6 +3772,7 @@
         default:
             stateError();
             /* NOTREACHED */
+            return;
         case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
         case (APPLY_SHEAR | APPLY_SCALE):
             M00 = m00; M01 = m01;
--- a/src/share/classes/java/io/ObjectInputStream.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/io/ObjectInputStream.java	Sun May 28 23:44:03 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1772,12 +1772,19 @@
         } catch (ClassNotFoundException ex) {
             resolveEx = ex;
         }
+
+        // Call filterCheck on the class before reading anything else
+        filterCheck(cl, -1);
+
         skipCustomData();
 
-        desc.initProxy(cl, resolveEx, readClassDesc(false));
-
-        // Call filterCheck on the definition
-        filterCheck(desc.forClass(), -1);
+        try {
+            totalObjectRefs++;
+            depth++;
+            desc.initProxy(cl, resolveEx, readClassDesc(false));
+        } finally {
+            depth--;
+        }
 
         handles.finish(descHandle);
         passHandle = descHandle;
@@ -1822,12 +1829,19 @@
         } catch (ClassNotFoundException ex) {
             resolveEx = ex;
         }
+
+        // Call filterCheck on the class before reading anything else
+        filterCheck(cl, -1);
+
         skipCustomData();
 
-        desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));
-
-        // Call filterCheck on the definition
-        filterCheck(desc.forClass(), -1);
+        try {
+            totalObjectRefs++;
+            depth++;
+            desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));
+        } finally {
+            depth--;
+        }
 
         handles.finish(descHandle);
         passHandle = descHandle;
--- a/src/share/classes/java/lang/Thread.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/java/lang/Thread.java	Sun May 28 23:44:03 2017 -0700
@@ -342,11 +342,11 @@
 
     /**
      * Initializes a Thread with the current AccessControlContext.
-     * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext)
+     * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext,boolean)
      */
     private void init(ThreadGroup g, Runnable target, String name,
                       long stackSize) {
-        init(g, target, name, stackSize, null);
+        init(g, target, name, stackSize, null, true);
     }
 
     /**
@@ -359,9 +359,12 @@
      *        zero to indicate that this parameter is to be ignored.
      * @param acc the AccessControlContext to inherit, or
      *            AccessController.getContext() if null
+     * @param inheritThreadLocals if {@code true}, inherit initial values for
+     *            inheritable thread-locals from the constructing thread
      */
     private void init(ThreadGroup g, Runnable target, String name,
-                      long stackSize, AccessControlContext acc) {
+                      long stackSize, AccessControlContext acc,
+                      boolean inheritThreadLocals) {
         if (name == null) {
             throw new NullPointerException("name cannot be null");
         }
@@ -412,7 +415,7 @@
                 acc != null ? acc : AccessController.getContext();
         this.target = target;
         setPriority(priority);
-        if (parent.inheritableThreadLocals != null)
+        if (inheritThreadLocals && parent.inheritableThreadLocals != null)
             this.inheritableThreadLocals =
                 ThreadLocal.createInheritedMap(parent.inheritableThreadLocals);
         /* Stash the specified stack size in case the VM cares */
@@ -466,7 +469,7 @@
      * This is not a public constructor.
      */
     Thread(Runnable target, AccessControlContext acc) {
-        init(null, target, "Thread-" + nextThreadNum(), 0, acc);
+        init(null, target, "Thread-" + nextThreadNum(), 0, acc, false);
     }
 
     /**
--- a/src/share/classes/javax/swing/JDialog.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/javax/swing/JDialog.java	Sun May 28 23:44:03 2017 -0700
@@ -645,6 +645,7 @@
         enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
         setLocale( JComponent.getDefaultLocale() );
         setRootPane(createRootPane());
+        setBackground(UIManager.getColor("control"));
         setRootPaneCheckingEnabled(true);
         if (JDialog.isDefaultLookAndFeelDecorated()) {
             boolean supportsWindowDecorations =
--- a/src/share/classes/sun/awt/AWTAccessor.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/sun/awt/AWTAccessor.java	Sun May 28 23:44:03 2017 -0700
@@ -326,6 +326,12 @@
          * Marks the specified window as an utility window for TrayIcon.
          */
         void setTrayIconWindow(Window w, boolean isTrayIconWindow);
+
+        /**
+         * Return an array containing all the windows this
+         * window currently owns.
+         */
+        Window[] getOwnedWindows(Window w);
     }
 
     /**
--- a/src/share/classes/sun/awt/SunHints.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/sun/awt/SunHints.java	Sun May 28 23:44:03 2017 -0700
@@ -171,7 +171,7 @@
         }
     }
 
-    private static final int NUM_KEYS = 9;
+    private static final int NUM_KEYS = 10;
     private static final int VALS_PER_KEY = 8;
 
     /**
@@ -252,6 +252,13 @@
     public static final int INTVAL_STROKE_PURE = 2;
 
     /**
+     * Image scaling hint key and values
+     */
+    public static final int INTKEY_RESOLUTION_VARIANT = 9;
+    public static final int INTVAL_RESOLUTION_VARIANT_DEFAULT = 0;
+    public static final int INTVAL_RESOLUTION_VARIANT_OFF = 1;
+    public static final int INTVAL_RESOLUTION_VARIANT_ON = 2;
+    /**
      * LCD text contrast control hint key.
      * Value is "100" to make discontiguous with the others which
      * are all enumerative and are of a different class.
@@ -449,6 +456,24 @@
                            SunHints.INTVAL_STROKE_PURE,
                            "Pure stroke conversion for accurate paths");
 
+    /**
+     * Image resolution variant hint key and value objects
+     */
+    public static final Key KEY_RESOLUTION_VARIANT =
+        new SunHints.Key(SunHints.INTKEY_RESOLUTION_VARIANT,
+                         "Global image resolution variant key");
+    public static final Object VALUE_RESOLUTION_VARIANT_DEFAULT =
+        new SunHints.Value(KEY_RESOLUTION_VARIANT,
+                           SunHints.INTVAL_RESOLUTION_VARIANT_DEFAULT,
+                           "Choose image resolutions based on a default heuristic");
+    public static final Object VALUE_RESOLUTION_VARIANT_OFF =
+        new SunHints.Value(KEY_RESOLUTION_VARIANT,
+                           SunHints.INTVAL_RESOLUTION_VARIANT_OFF,
+                           "Use only the standard resolution of an image");
+    public static final Object VALUE_RESOLUTION_VARIANT_ON =
+        new SunHints.Value(KEY_RESOLUTION_VARIANT,
+                           SunHints.INTVAL_RESOLUTION_VARIANT_ON,
+                           "Always use resolution-specific variants of images");
 
     public static class LCDContrastKey extends Key {
 
--- a/src/share/classes/sun/awt/SunToolkit.java	Wed May 24 00:32:01 2017 -0700
+++ b/src/share/classes/sun/awt/SunToolkit.java	Sun May 28 23:44:03 2017 -0700
@@ -36,6 +36,9 @@
 import java.awt.TrayIcon;
 import java.awt.SystemTray;
 import java.awt.event.InputEvent;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 import java.security.PrivilegedAction;
 import java.util.*;
@@ -725,6 +728,194 @@
     static final SoftCache imgCache = new SoftCache();
 
     static Image getImageFromHash(Toolkit tk, URL url) {
+        checkPermissions(url);
+        synchronized (imgCache) {
+            Image img = (Image)imgCache.get(url);
+            if (img == null) {
+                try {
+                    img = tk.createImage(new URLImageSource(url));
+                    imgCache.put(url, img);
+                } catch (Exception e) {
+                }
+            }
+            return img;
+        }
+    }
+
+    static Image getImageFromHash(Toolkit tk,
+                                               String filename) {
+        checkPermissions(filename);
+        synchronized (imgCache) {
+            Image img = (Image)imgCache.get(filename);
+            if (img == null) {
+                try {
+                    img = tk.createImage(new FileImageSource(filename));
+                    imgCache.put(filename, img);
+                } catch (Exception e) {
+                }
+            }
+            return img;
+        }
+    }
+
+    public Image getImage(String filename) {
+        return getImageFromHash(this, filename);
+    }
+
+    public Image getImage(URL url) {
+        return getImageFromHash(this, url);
+    }
+
+    protected Image getImageWithResolutionVariant(String fileName,
+            String resolutionVariantName) {
+        synchronized (imgCache) {
+            Image image = getImageFromHash(this, fileName);
+            if (image instanceof MultiResolutionImage) {
+                return image;
+            }
+            Image resolutionVariant = getImageFromHash(this, resolutionVariantName);
+            image = createImageWithResolutionVariant(image, resolutionVariant);