Merge
diff --git a/make/CopyFiles.gmk b/make/CopyFiles.gmk
index 0ac509c..e2ff9c9 100644
--- a/make/CopyFiles.gmk
+++ b/make/CopyFiles.gmk
@@ -183,9 +183,9 @@
##########################################################################################
-ifeq ($(OPENJDK_TARGET_OS), windows)
+ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),)
- TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib
+ TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS)/lib
$(LIBDIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings
$(call install-file)
diff --git a/make/data/tzdata/VERSION b/make/data/tzdata/VERSION
index 1c96650..c735be5 100644
--- a/make/data/tzdata/VERSION
+++ b/make/data/tzdata/VERSION
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2014b
+tzdata2014c
diff --git a/make/data/tzdata/africa b/make/data/tzdata/africa
index 3198e1c..6f1a147 100644
--- a/make/data/tzdata/africa
+++ b/make/data/tzdata/africa
@@ -358,11 +358,54 @@
# http://www.worldtimezone.com/dst_news/dst_news_egypt02.html
# </a>
+# From Ahmad El-Dardiry (2014-05-07):
+# Egypt is to change back to Daylight system on May 15
+# http://english.ahram.org.eg/NewsContent/1/64/100735/Egypt/Politics-/Egypts-government-to-reapply-daylight-saving-time-.aspx
+
+# From Gunther Vermier (2015-05-13):
+# our Egypt office confirms that the change will be at 15 May "midnight" (24:00)
+
+# From Paul Eggert (2014-05-13):
+# Sarah El Deeb and Lee Keath of AP report that the Egyptian government says
+# the change is because of blackouts in Cairo, even though Ahram Online (cited
+# above) says DST had no affect on electricity consumption. The AP story says
+# DST will not be observed during Ramadan. There is no information about when
+# DST will end. See:
+# http://abcnews.go.com/International/wireStory/el-sissi-pushes-egyptians-line-23614833
+#
+# For now, guess that later transitions will use 2010's rules, and that
+# Egypt will agree with Morocco (see below) about the date Ramadan starts and
+# ends, though (unlike Morocco) it will switch at 00:00 standard time. In
+# Egypt the spring-forward transitions are removed for 2020-2022, when the
+# guessed spring-forward date falls during the estimated Ramadan, and all
+# transitions removed for 2023-2038, where the estimated Ramadan falls entirely
+# outside the guessed daylight-saving time. Ramadan intrudes on the guessed
+# DST starting in 2039, but that's beyond our somewhat-arbitrary cutoff.
+
Rule Egypt 2008 only - Aug lastThu 23:00s 0 -
Rule Egypt 2009 only - Aug 20 23:00s 0 -
Rule Egypt 2010 only - Aug 11 0:00 0 -
Rule Egypt 2010 only - Sep 10 0:00 1:00 S
Rule Egypt 2010 only - Sep lastThu 23:00s 0 -
+Rule Egypt 2014 only - May 15 24:00 1:00 S
+Rule Egypt 2014 only - Jun 29 0:00s 0 -
+Rule Egypt 2014 only - Jul 29 0:00s 1:00 S
+Rule Egypt 2014 max - Sep lastThu 23:00s 0 -
+Rule Egypt 2015 2019 - Apr lastFri 0:00s 1:00 S
+Rule Egypt 2015 only - Jun 18 0:00s 0 -
+Rule Egypt 2015 only - Jul 18 0:00s 1:00 S
+Rule Egypt 2016 only - Jun 7 0:00s 0 -
+Rule Egypt 2016 only - Jul 7 0:00s 1:00 S
+Rule Egypt 2017 only - May 27 0:00s 0 -
+Rule Egypt 2017 only - Jun 26 0:00s 1:00 S
+Rule Egypt 2018 only - May 16 0:00s 0 -
+Rule Egypt 2018 only - Jun 15 0:00s 1:00 S
+Rule Egypt 2019 only - May 6 0:00s 0 -
+Rule Egypt 2019 only - Jun 5 0:00s 1:00 S
+Rule Egypt 2020 only - May 24 0:00s 1:00 S
+Rule Egypt 2021 only - May 13 0:00s 1:00 S
+Rule Egypt 2022 only - May 3 0:00s 1:00 S
+Rule Egypt 2023 max - Apr lastFri 0:00s 1:00 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Cairo 2:05:09 - LMT 1900 Oct
diff --git a/make/data/tzdata/asia b/make/data/tzdata/asia
index dc3c94b..595c8ed 100644
--- a/make/data/tzdata/asia
+++ b/make/data/tzdata/asia
@@ -1370,22 +1370,6 @@
# "Jordan will switch to winter time on Friday, October 27".
#
-# From Phil Pizzey (2009-04-02):
-# ...I think I may have spotted an error in the timezone data for
-# Jordan.
-# The current (2009d) asia file shows Jordan going to daylight
-# saving
-# time on the last Thursday in March.
-#
-# Rule Jordan 2000 max - Mar lastThu 0:00s 1:00 S
-#
-# However timeanddate.com, which I usually find reliable, shows Jordan
-# going to daylight saving time on the last Friday in March since 2002.
-# Please see
-# <a href="http://www.timeanddate.com/worldclock/timezone.html?n=11">
-# http://www.timeanddate.com/worldclock/timezone.html?n=11
-# </a>
-
# From Steffen Thorsen (2009-04-02):
# This single one might be good enough, (2009-03-24, Arabic):
# <a href="http://petra.gov.jo/Artical.aspx?Lng=2&Section=8&Artical=95279">
diff --git a/make/data/tzdata/europe b/make/data/tzdata/europe
index 2b0c561..226c393 100644
--- a/make/data/tzdata/europe
+++ b/make/data/tzdata/europe
@@ -2989,6 +2989,10 @@
# From Alexander Krivenyshev (2014-03-17):
# time change at 2:00 (2am) on March 30, 2014
# http://vz.ru/news/2014/3/17/677464.html
+# From Paul Eggert (2014-03-30):
+# Simferopol and Sevastopol reportedly changed their central town clocks
+# late the previous day, but this appears to have been ceremonial
+# and the discrepancies are small enough to not worry about.
2:00 EU EE%sT 2014 Mar 30 2:00
4:00 - MSK
diff --git a/src/aix/lib/tzmappings b/src/aix/lib/tzmappings
new file mode 100644
index 0000000..079d2c9
--- /dev/null
+++ b/src/aix/lib/tzmappings
@@ -0,0 +1,586 @@
+#
+#
+# Copyright (c) 1994, 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# Portions Copyright (c) 2014 IBM Corporation
+#
+
+# This table describes mappings between AIX time zone IDs and Java time zone
+# IDs. Fields are separated by a single TAB ('\t'). Lines must be in the ascending
+# order in ASCII. (non-ASCII characters can't be used.)
+# NOTE
+# This table format is not a public interface of any Java
+# platforms. No applications should depend on this file in any form.
+# This file has been generated using programs. Do not edit this file manually.
+#
+# Solaris Java
+
+ACST-9:30ACDT Australia/Adelaide
+AST4 America/Curacao
+AST4ADT America/Halifax
+AST9 Pacific/Gambier
+AST9ADT America/Anchorage
+AZOREST1 Atlantic/Cape_Verde
+AZOREST1AZOREDT Atlantic/Azores
+Africa/Abidjan Africa/Abidjan
+Africa/Accra Africa/Accra
+Africa/Addis_Ababa Africa/Addis_Ababa
+Africa/Algiers Africa/Algiers
+Africa/Asmera Africa/Asmera
+Africa/Bamako GMT
+Africa/Bangui Africa/Bangui
+Africa/Banjul Africa/Banjul
+Africa/Bissau Africa/Bissau
+Africa/Blantyre Africa/Blantyre
+Africa/Brazzaville Africa/Luanda
+Africa/Bujumbura Africa/Bujumbura
+Africa/Cairo Africa/Cairo
+Africa/Casablanca Africa/Casablanca
+Africa/Ceuta Europe/Paris
+Africa/Conakry Africa/Conakry
+Africa/Dakar Africa/Dakar
+Africa/Dar_es_Salaam Africa/Dar_es_Salaam
+Africa/Djibouti Africa/Djibouti
+Africa/Douala Africa/Douala
+Africa/El_Aaiun Africa/Casablanca
+Africa/Freetown Africa/Freetown
+Africa/Gaborone Africa/Gaborone
+Africa/Harare Africa/Harare
+Africa/Johannesburg Africa/Johannesburg
+Africa/Kampala Africa/Kampala
+Africa/Khartoum Africa/Khartoum
+Africa/Kigali Africa/Kigali
+Africa/Kinshasa Africa/Kinshasa
+Africa/Lagos Africa/Lagos
+Africa/Libreville Africa/Libreville
+Africa/Lome Africa/Lome
+Africa/Luanda Africa/Luanda
+Africa/Lubumbashi Africa/Lubumbashi
+Africa/Lusaka Africa/Lusaka
+Africa/Malabo Africa/Malabo
+Africa/Maputo Africa/Maputo
+Africa/Maseru Africa/Maseru
+Africa/Mbabane Africa/Mbabane
+Africa/Mogadishu Africa/Mogadishu
+Africa/Monrovia Africa/Monrovia
+Africa/Nairobi Africa/Nairobi
+Africa/Ndjamena Africa/Ndjamena
+Africa/Niamey Africa/Niamey
+Africa/Nouakchott Africa/Nouakchott
+Africa/Ouagadougou Africa/Ouagadougou
+Africa/Porto-Novo Africa/Porto-Novo
+Africa/Sao_Tome Africa/Sao_Tome
+Africa/Timbuktu Africa/Timbuktu
+Africa/Tripoli Africa/Tripoli
+Africa/Tunis Africa/Tunis
+Africa/Windhoek Africa/Windhoek
+America/Adak America/Adak
+America/Anchorage America/Anchorage
+America/Anguilla America/Anguilla
+America/Antigua America/Antigua
+America/Araguaina America/Sao_Paulo
+America/Argentina/Buenos_Aires America/Argentina/Buenos_Aires
+America/Argentina/Catamarca America/Argentina/Catamarca
+America/Argentina/ComodRivadavia America/Argentina/Catamarca
+America/Argentina/Cordoba America/Argentina/Cordoba
+America/Argentina/Jujuy America/Argentina/Jujuy
+America/Argentina/La_Rioja America/Argentina/La_Rioja
+America/Argentina/Mendoza America/Argentina/Mendoza
+America/Argentina/Rio_Gallegos America/Argentina/Rio_Gallegos
+America/Argentina/Salta America/Argentina/Salta
+America/Argentina/San_Juan America/Argentina/San_Juan
+America/Argentina/San_Luis America/Argentina/San_Luis
+America/Argentina/Tucuman America/Argentina/Tucuman
+America/Argentina/Ushuaia America/Argentina/Ushuaia
+America/Aruba America/Aruba
+America/Asuncion America/Asuncion
+America/Atka America/Adak
+America/Barbados America/Barbados
+America/Belize America/Belize
+America/Bogota America/Bogota
+America/Boise America/Denver
+America/Buenos_Aires America/Argentina/Buenos_Aires
+America/Cancun America/Chicago
+America/Caracas America/Caracas
+America/Catamarca America/Argentina/Catamarca
+America/Cayenne America/Cayenne
+America/Cayman America/Cayman
+America/Chicago America/Chicago
+America/Chihuahua America/Denver
+America/Coral_Harbour America/Atikokan
+America/Cordoba America/Argentina/Cordoba
+America/Costa_Rica America/Costa_Rica
+America/Cuiaba America/Cuiaba
+America/Curacao America/Curacao
+America/Dawson America/Los_Angeles
+America/Dawson_Creek America/Dawson_Creek
+America/Denver America/Denver
+America/Detroit America/New_York
+America/Dominica America/Dominica
+America/Edmonton America/Edmonton
+America/El_Salvador America/El_Salvador
+America/Ensenada America/Los_Angeles
+America/Fort_Wayne America/Indiana/Indianapolis
+America/Fortaleza America/Fortaleza
+America/Glace_Bay America/Halifax
+America/Godthab America/Godthab
+America/Goose_Bay America/Thule
+America/Grand_Turk America/Grand_Turk
+America/Grenada America/Grenada
+America/Guadeloupe America/Guadeloupe
+America/Guatemala America/Guatemala
+America/Guayaquil America/Guayaquil
+America/Guyana America/Guyana
+America/Halifax America/Halifax
+America/Havana America/Havana
+America/Indiana/Indianapolis America/Indianapolis
+America/Indianapolis America/Indiana/Indianapolis
+America/Inuvik America/Denver
+America/Iqaluit America/New_York
+America/Jamaica America/Jamaica
+America/Jujuy America/Argentina/Jujuy
+America/Juneau America/Anchorage
+America/Knox_IN America/Indiana/Knox
+America/La_Paz America/La_Paz
+America/Lima America/Lima
+America/Los_Angeles America/Los_Angeles
+America/Louisville America/Kentucky/Louisville
+America/Managua America/Managua
+America/Manaus America/Manaus
+America/Marigot America/Guadeloupe
+America/Martinique America/Martinique
+America/Mazatlan America/Mazatlan
+America/Mendoza America/Argentina/Mendoza
+America/Menominee America/Winnipeg
+America/Mexico_City America/Mexico_City
+America/Miquelon America/Miquelon
+America/Moncton America/Moncton
+America/Montevideo America/Montevideo
+America/Montreal America/Montreal
+America/Montserrat America/Montserrat
+America/Nassau America/Nassau
+America/New_York America/New_York
+America/Nipigon America/New_York
+America/Nome America/Anchorage
+America/Noronha America/Noronha
+America/Panama America/Panama
+America/Pangnirtung America/Thule
+America/Paramaribo America/Paramaribo
+America/Phoenix America/Phoenix
+America/Port-au-Prince America/Port-au-Prince
+America/Port_of_Spain America/Port_of_Spain
+America/Porto_Acre America/Rio_Branco
+America/Puerto_Rico America/Puerto_Rico
+America/Rainy_River America/Chicago
+America/Rankin_Inlet America/Chicago
+America/Regina America/Regina
+America/Rio_Branco America/Rio_Branco
+America/Rosario America/Argentina/Cordoba
+America/Santiago America/Santiago
+America/Santo_Domingo America/Santo_Domingo
+America/Sao_Paulo America/Sao_Paulo
+America/Scoresbysund America/Scoresbysund
+America/Shiprock America/Denver
+America/St_Barthelemy America/Guadeloupe
+America/St_Johns America/St_Johns
+America/St_Kitts America/St_Kitts
+America/St_Lucia America/St_Lucia
+America/St_Thomas America/St_Thomas
+America/St_Vincent America/St_Vincent
+America/Tegucigalpa America/Tegucigalpa
+America/Thule America/Thule
+America/Thunder_Bay America/New_York
+America/Tijuana America/Tijuana
+America/Toronto America/Toronto
+America/Tortola America/Tortola
+America/Vancouver America/Vancouver
+America/Virgin America/St_Thomas
+America/Whitehorse America/Los_Angeles
+America/Winnipeg America/Winnipeg
+America/Yakutat America/Anchorage
+America/Yellowknife America/Denver
+Antarctica/Casey Antarctica/Casey
+Antarctica/DumontDUrville Antarctica/DumontDUrville
+Antarctica/Mawson Antarctica/Mawson
+Antarctica/McMurdo Antarctica/McMurdo
+Antarctica/Palmer Antarctica/Palmer
+Antarctica/South_Pole Antarctica/McMurdo
+Arctic/Longyearbyen Europe/Oslo
+Asia/Aden Asia/Aden
+Asia/Almaty Asia/Almaty
+Asia/Amman Asia/Amman
+Asia/Anadyr Asia/Anadyr
+Asia/Aqtau Asia/Aqtau
+Asia/Aqtobe Asia/Aqtobe
+Asia/Ashkhabad Asia/Ashkhabad
+Asia/Baghdad Asia/Baghdad
+Asia/Bahrain Asia/Bahrain
+Asia/Baku Asia/Baku
+Asia/Bangkok Asia/Bangkok
+Asia/Beirut Asia/Beirut
+Asia/Bishkek Asia/Bishkek
+Asia/Brunei Asia/Brunei
+Asia/Calcutta Asia/Calcutta
+Asia/Chungking Asia/Shanghai
+Asia/Colombo Asia/Colombo
+Asia/Dacca Asia/Dacca
+Asia/Damascus Asia/Damascus
+Asia/Dhaka Asia/Dhaka
+Asia/Dubai Asia/Dubai
+Asia/Dushanbe Asia/Dushanbe
+Asia/Gaza Asia/Amman
+Asia/Harbin Asia/Shanghai
+Asia/Hong_Kong Asia/Hong_Kong
+Asia/Irkutsk Asia/Irkutsk
+Asia/Istanbul Europe/Istanbul
+Asia/Jakarta Asia/Jakarta
+Asia/Jayapura Asia/Jayapura
+Asia/Jerusalem Asia/Jerusalem
+Asia/Kabul Asia/Kabul
+Asia/Kamchatka Asia/Kamchatka
+Asia/Karachi Asia/Karachi
+Asia/Kashgar Asia/Shanghai
+Asia/Katmandu Asia/Katmandu
+Asia/Kolkata Asia/Kolkata
+Asia/Krasnoyarsk Asia/Krasnoyarsk
+Asia/Kuala_Lumpur Asia/Kuala_Lumpur
+Asia/Kuwait Asia/Kuwait
+Asia/Macao Asia/Macao
+Asia/Magadan Asia/Magadan
+Asia/Manila Asia/Manila
+Asia/Muscat Asia/Muscat
+Asia/Nicosia Asia/Nicosia
+Asia/Novosibirsk Asia/Novosibirsk
+Asia/Omsk Asia/Novosibirsk
+Asia/Phnom_Penh Asia/Phnom_Penh
+Asia/Pyongyang Asia/Pyongyang
+Asia/Qatar Asia/Qatar
+Asia/Rangoon Asia/Rangoon
+Asia/Riyadh Asia/Riyadh
+Asia/Saigon Asia/Ho_Chi_Minh
+Asia/Seoul Asia/Seoul
+Asia/Shanghai Asia/Shanghai
+Asia/Singapore Asia/Singapore
+Asia/Taipei Asia/Taipei
+Asia/Tashkent Asia/Tashkent
+Asia/Tbilisi Asia/Tbilisi
+Asia/Tehran Asia/Tehran
+Asia/Tel_Aviv Asia/Jerusalem
+Asia/Thimbu Asia/Thimbu
+Asia/Tokyo Asia/Tokyo
+Asia/Ujung_Pandang Asia/Ujung_Pandang
+Asia/Ulan_Bator Asia/Ulaanbaatar
+Asia/Urumqi Asia/Shanghai
+Asia/Vientiane Asia/Vientiane
+Asia/Vladivostok Asia/Vladivostok
+Asia/Yakutsk Asia/Yakutsk
+Asia/Yekaterinburg Asia/Yekaterinburg
+Asia/Yerevan Asia/Yerevan
+Atlantic/Azores Atlantic/Azores
+Atlantic/Bermuda Atlantic/Bermuda
+Atlantic/Canary Atlantic/Canary
+Atlantic/Cape_Verde Atlantic/Cape_Verde
+Atlantic/Faeroe Atlantic/Faeroe
+Atlantic/Jan_Mayen Atlantic/Jan_Mayen
+Atlantic/Madeira Europe/London
+Atlantic/Reykjavik Atlantic/Reykjavik
+Atlantic/South_Georgia Atlantic/South_Georgia
+Atlantic/St_Helena Atlantic/St_Helena
+Atlantic/Stanley Atlantic/Stanley
+Australia/ACT Australia/Sydney
+Australia/Adelaide Australia/Adelaide
+Australia/Brisbane Australia/Brisbane
+Australia/Broken_Hill Australia/Broken_Hill
+Australia/Canberra Australia/Sydney
+Australia/Darwin Australia/Darwin
+Australia/Hobart Australia/Hobart
+Australia/LHI Australia/Lord_Howe
+Australia/Lord_Howe Australia/Lord_Howe
+Australia/Melbourne Australia/Sydney
+Australia/NSW Australia/Sydney
+Australia/North Australia/Darwin
+Australia/Perth Australia/Perth
+Australia/Queensland Australia/Brisbane
+Australia/South Australia/Adelaide
+Australia/Sydney Australia/Sydney
+Australia/Tasmania Australia/Hobart
+Australia/Victoria Australia/Melbourne
+Australia/West Australia/Perth
+Australia/Yancowinna Australia/Broken_Hill
+BRT3BRST America/Sao_Paulo
+BST11 Pacific/Apia
+BST11BDT Pacific/Apia
+Brazil/Acre America/Rio_Branco
+Brazil/DeNoronha America/Noronha
+Brazil/East America/Sao_Paulo
+Brazil/West America/Manaus
+CET Europe/Paris
+CET-1CEST Europe/Paris
+CET-1CEST-2 Europe/Berlin
+CET-1CET-2 Europe/Paris
+CST6 America/Costa_Rica
+CST6CDT America/Chicago
+CUT0 UTC
+CUT0GDT Europe/London
+Canada/Atlantic America/Halifax
+Canada/Central America/Winnipeg
+Canada/East-Saskatchewan America/Regina
+Canada/Eastern America/Montreal
+Canada/Mountain America/Edmonton
+Canada/Newfoundland America/St_Johns
+Canada/Pacific America/Vancouver
+Canada/Saskatchewan America/Regina
+Canada/Yukon America/Whitehorse
+Chile/Continental America/Santiago
+Chile/EasterIsland Pacific/Easter
+Cuba America/Havana
+EET Europe/Istanbul
+EET-10 Australia/Brisbane
+EET-10EETDT Australia/Sydney
+EST America/Indianapolis
+EST5 America/Indianapolis
+EST5EDT America/New_York
+Egypt Africa/Cairo
+Eire Europe/Dublin
+Etc/GMT GMT
+Etc/GMT0 GMT
+Etc/Greenwich GMT
+Etc/UCT UTC
+Etc/UTC UTC
+Etc/Universal UTC
+Etc/Zulu UTC
+Europe/Amsterdam Europe/Amsterdam
+Europe/Andorra Europe/Andorra
+Europe/Athens Europe/Athens
+Europe/Belfast Europe/London
+Europe/Belgrade Europe/Belgrade
+Europe/Berlin Europe/Berlin
+Europe/Bratislava Europe/Prague
+Europe/Brussels Europe/Brussels
+Europe/Bucharest Europe/Bucharest
+Europe/Budapest Europe/Budapest
+Europe/Chisinau Europe/Chisinau
+Europe/Copenhagen Europe/Copenhagen
+Europe/Dublin Europe/Dublin
+Europe/Gibraltar Europe/Gibraltar
+Europe/Guernsey Europe/London
+Europe/Helsinki Europe/Helsinki
+Europe/Isle_of_Man Europe/London
+Europe/Istanbul Europe/Istanbul
+Europe/Jersey Europe/London
+Europe/Kaliningrad Europe/Kaliningrad
+Europe/Kiev Europe/Kiev
+Europe/Lisbon Europe/Lisbon
+Europe/Ljubljana Europe/Belgrade
+Europe/London Europe/London
+Europe/Luxembourg Europe/Luxembourg
+Europe/Madrid Europe/Madrid
+Europe/Malta Europe/Malta
+Europe/Mariehamn Europe/Helsinki
+Europe/Minsk Europe/Minsk
+Europe/Monaco Europe/Monaco
+Europe/Moscow Europe/Moscow
+Europe/Nicosia Asia/Nicosia
+Europe/Oslo Europe/Oslo
+Europe/Paris Europe/Paris
+Europe/Podgorica Europe/Belgrade
+Europe/Prague Europe/Prague
+Europe/Riga Europe/Riga
+Europe/Rome Europe/Rome
+Europe/Samara Europe/Samara
+Europe/San_Marino Europe/Rome
+Europe/Sarajevo Europe/Belgrade
+Europe/Simferopol Europe/Simferopol
+Europe/Skopje Europe/Belgrade
+Europe/Sofia Europe/Sofia
+Europe/Stockholm Europe/Stockholm
+Europe/Tallinn Europe/Tallinn
+Europe/Tirane Europe/Tirane
+Europe/Vaduz Europe/Vaduz
+Europe/Vatican Europe/Rome
+Europe/Vienna Europe/Vienna
+Europe/Vilnius Europe/Vilnius
+Europe/Warsaw Europe/Warsaw
+Europe/Zagreb Europe/Belgrade
+Europe/Zurich Europe/Zurich
+FALKST2 Atlantic/South_Georgia
+FALKST2FALKDT Atlantic/South_Georgia
+Factory GMT
+GB Europe/London
+GB-Eire Europe/London
+GMT GMT
+GMT0 GMT
+GMT0BST Europe/London
+GMT0BST-1 Europe/London
+GMT0WET Europe/Lisbon
+GRNLNDST3 America/Buenos_Aires
+GRNLNDST3GRNLNDDT America/Godthab
+Greenwich GMT
+HST Pacific/Honolulu
+HST10 Pacific/Honolulu
+HST10HDT America/Adak
+Hongkong Asia/Hong_Kong
+Iceland Atlantic/Reykjavik
+Indian/Antananarivo Indian/Antananarivo
+Indian/Chagos Indian/Chagos
+Indian/Christmas Indian/Christmas
+Indian/Cocos Indian/Cocos
+Indian/Comoro Indian/Comoro
+Indian/Kerguelen Indian/Kerguelen
+Indian/Mahe Indian/Mahe
+Indian/Maldives Indian/Maldives
+Indian/Mauritius Indian/Mauritius
+Indian/Mayotte Indian/Mayotte
+Indian/Reunion Indian/Reunion
+Iran Asia/Tehran
+Israel Asia/Jerusalem
+JST-9 Asia/Tokyo
+JST-9JSTDT Asia/Tokyo
+Jamaica America/Jamaica
+Japan Asia/Tokyo
+KORST-9 Asia/Seoul
+KORST-9KORDT Asia/Seoul
+Kwajalein Pacific/Kwajalein
+Libya Africa/Tripoli
+MEST-2 Europe/Istanbul
+MEST-2MEDT Europe/Istanbul
+MEST-3 Asia/Riyadh
+MEST-3MEDT Europe/Moscow
+MET Europe/Paris
+MET-11 Pacific/Guadalcanal
+MET-11METDT Asia/Magadan
+MET-1MEST Europe/Paris
+MET-1MST-2 Europe/Berlin
+MEZ-1MESZ Europe/Berlin
+MEZ-1MESZ-2 Europe/Berlin
+MSK-3MSD Europe/Moscow
+MST America/Phoenix
+MST7 America/Phoenix
+MST7MDT America/Denver
+Mexico/BajaNorte America/Tijuana
+Mexico/BajaSur America/Mazatlan
+Mexico/General America/Mexico_City
+Mideast/Riyadh87 Asia/Riyadh87
+Mideast/Riyadh88 Asia/Riyadh88
+Mideast/Riyadh89 Asia/Riyadh89
+NFT-1 Africa/Algiers
+NFT-1DFT Europe/Paris
+NFT-1DST Europe/Paris
+NZ Pacific/Auckland
+NZ-CHAT Pacific/Chatham
+NZST-12 Pacific/Fiji
+NZST-12NZDT Pacific/Auckland
+Navajo America/Denver
+PAKST-5 Asia/Karachi
+PAKST-5PAKDT Asia/Yekaterinburg
+PRC Asia/Shanghai
+PST8 Pacific/Pitcairn
+PST8PDT America/Los_Angeles
+PST8PDT7 America/Tijuana
+Pacific/Apia Pacific/Apia
+Pacific/Auckland Pacific/Auckland
+Pacific/Chatham Pacific/Chatham
+Pacific/Easter Pacific/Easter
+Pacific/Efate Pacific/Efate
+Pacific/Enderbury Pacific/Enderbury
+Pacific/Fakaofo Pacific/Fakaofo
+Pacific/Fiji Pacific/Fiji
+Pacific/Funafuti Pacific/Funafuti
+Pacific/Galapagos Pacific/Galapagos
+Pacific/Gambier Pacific/Gambier
+Pacific/Guadalcanal Pacific/Guadalcanal
+Pacific/Guam Pacific/Guam
+Pacific/Honolulu Pacific/Honolulu
+Pacific/Kiritimati Pacific/Kiritimati
+Pacific/Kosrae Pacific/Kosrae
+Pacific/Majuro Pacific/Majuro
+Pacific/Marquesas Pacific/Marquesas
+Pacific/Nauru Pacific/Nauru
+Pacific/Niue Pacific/Niue
+Pacific/Norfolk Pacific/Norfolk
+Pacific/Noumea Pacific/Noumea
+Pacific/Pago_Pago Pacific/Pago_Pago
+Pacific/Palau Pacific/Palau
+Pacific/Pitcairn Pacific/Pitcairn
+Pacific/Ponape Pacific/Ponape
+Pacific/Port_Moresby Pacific/Port_Moresby
+Pacific/Rarotonga Pacific/Rarotonga
+Pacific/Saipan Pacific/Saipan
+Pacific/Samoa Pacific/Pago_Pago
+Pacific/Tahiti Pacific/Tahiti
+Pacific/Tarawa Pacific/Tarawa
+Pacific/Tongatapu Pacific/Tongatapu
+Pacific/Truk Pacific/Truk
+Pacific/Wake Pacific/Wake
+Pacific/Wallis Pacific/Wallis
+Poland Europe/Warsaw
+Portugal Europe/Lisbon
+ROC Asia/Taipei
+ROK Asia/Seoul
+SAUST-3 Asia/Riyadh
+SAUST-3SAUDT Europe/Moscow
+Singapore Asia/Singapore
+SystemV/AST4ADT America/Thule
+SystemV/CST6CDT America/Chicago
+SystemV/EST5EDT America/New_York
+SystemV/MST7MDT America/Denver
+SystemV/PST8PDT America/Los_Angeles
+SystemV/YST9YDT America/Anchorage
+TAIST-8 Asia/Taipei
+TAIST-8TAIDT Asia/Irkutsk
+TASHST-6 Asia/Dacca
+TASHST-6TASHDT Asia/Novosibirsk
+THAIST-7 Asia/Bangkok
+THAIST-7THAIDT Asia/Krasnoyarsk
+Turkey Europe/Istanbul
+UCT UTC
+US/Alaska America/Anchorage
+US/Aleutian America/Adak
+US/Arizona America/Phoenix
+US/Central America/Chicago
+US/East-Indiana America/Indiana/Indianapolis
+US/Eastern America/New_York
+US/Hawaii Pacific/Honolulu
+US/Indiana-Starke America/Indiana/Knox
+US/Michigan America/New_York
+US/Mountain America/Denver
+US/Pacific America/Los_Angeles
+US/Pacific-New America/Los_Angeles
+US/Samoa Pacific/Pago_Pago
+USAST-2 Africa/Johannesburg
+USAST-2USADT Europe/Istanbul
+UTC UTC
+UYT3UYST America/Montevideo
+Universal UTC
+W-SU Europe/Moscow
+WAUST-8 Australia/Perth
+WAUST-8WAUDT Australia/Perth
+WET WET
+WET-2 Africa/Johannesburg
+WET-2WET Europe/Helsinki
+WST-4 Asia/Dubai
+WST-4WDT Europe/Samara
+Zulu UTC
diff --git a/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java b/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java
index 4b9c78b..c9a86b8 100644
--- a/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java
+++ b/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java
@@ -510,15 +510,17 @@
}
};
- private static Action hideAction = new AbstractAction() {
+ private final Action hideAction = new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent e) {
final JComboBox comboBox = (JComboBox)e.getSource();
+ comboBox.firePopupMenuCanceled();
+ comboBox.setPopupVisible(false);
+ }
- if (comboBox.isPopupVisible()) {
- comboBox.firePopupMenuCanceled();
- comboBox.setPopupVisible(false);
- }
+ @Override
+ public boolean isEnabled() {
+ return comboBox.isPopupVisible() && super.isEnabled();
}
};
diff --git a/src/macosx/lib/Info-privileged.plist b/src/macosx/lib/Info-privileged.plist
index 776967a..1d5ef39 100644
--- a/src/macosx/lib/Info-privileged.plist
+++ b/src/macosx/lib/Info-privileged.plist
@@ -7,7 +7,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
- <string>OpenJDK 7 Command</string>
+ <string>OpenJDK 8 Command</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
diff --git a/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m b/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
index 44b28f0..40f380b 100644
--- a/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
+++ b/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
@@ -142,10 +142,9 @@
splash->screenFormat.byteOrder = 1 ? BYTE_ORDER_LSBFIRST : BYTE_ORDER_MSBFIRST;
splash->screenFormat.depthBytes = 4;
- dispatch_async(dispatch_get_main_queue(), ^(void) {
- NSApplication * app = [NSApplicationAWT sharedApplication];
- [NSApplicationAWT runAWTLoopWithApp: app];
- });
+ [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
+ [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
+ }];
}
void
diff --git a/src/share/bin/java.c b/src/share/bin/java.c
index 73c5326..ed45f08 100644
--- a/src/share/bin/java.c
+++ b/src/share/bin/java.c
@@ -732,6 +732,9 @@
if (s == NULL)
return;
s = JLI_WildcardExpandClasspath(s);
+ if (sizeof(format) - 2 + JLI_StrLen(s) < JLI_StrLen(s))
+ // s is corrupted after wildcard expansion
+ return;
def = JLI_MemAlloc(sizeof(format)
- 2 /* strlen("%s") */
+ JLI_StrLen(s));
@@ -1351,9 +1354,11 @@
if (s) {
s = (char *) JLI_WildcardExpandClasspath(s);
/* 40 for -Denv.class.path= */
- envcp = (char *)JLI_MemAlloc(JLI_StrLen(s) + 40);
- sprintf(envcp, "-Denv.class.path=%s", s);
- AddOption(envcp, NULL);
+ if (JLI_StrLen(s) + 40 > JLI_StrLen(s)) { // Safeguard from overflow
+ envcp = (char *)JLI_MemAlloc(JLI_StrLen(s) + 40);
+ sprintf(envcp, "-Denv.class.path=%s", s);
+ AddOption(envcp, NULL);
+ }
}
}
diff --git a/src/share/classes/java/awt/MediaTracker.java b/src/share/classes/java/awt/MediaTracker.java
index 91e074a..a96dda6 100644
--- a/src/share/classes/java/awt/MediaTracker.java
+++ b/src/share/classes/java/awt/MediaTracker.java
@@ -226,7 +226,9 @@
addImageImpl(image, id, w, h);
Image rvImage = getResolutionVariant(image);
if (rvImage != null) {
- addImageImpl(rvImage, id, 2 * w, 2 * h);
+ addImageImpl(rvImage, id,
+ w == -1 ? -1 : 2 * w,
+ h == -1 ? -1 : 2 * h);
}
}
@@ -810,8 +812,9 @@
removeImageImpl(image, id, width, height);
Image rvImage = getResolutionVariant(image);
if (rvImage != null) {
- removeImageImpl(rvImage, id, 2 * width, 2 * height);
-
+ removeImageImpl(rvImage, id,
+ width == -1 ? -1 : 2 * width,
+ height == -1 ? -1 : 2 * height);
}
notifyAll(); // Notify in case remaining images are "done".
}
diff --git a/src/share/classes/java/awt/datatransfer/DataFlavor.java b/src/share/classes/java/awt/datatransfer/DataFlavor.java
index 9ca61a3..2df8e5a 100644
--- a/src/share/classes/java/awt/datatransfer/DataFlavor.java
+++ b/src/share/classes/java/awt/datatransfer/DataFlavor.java
@@ -25,13 +25,28 @@
package java.awt.datatransfer;
-import java.io.*;
-import java.nio.*;
-import java.util.*;
-
import sun.awt.datatransfer.DataTransferer;
import sun.reflect.misc.ReflectUtil;
+import java.io.ByteArrayInputStream;
+import java.io.CharArrayReader;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.OptionalDataException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Objects;
+
import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
/**
@@ -501,7 +516,7 @@
* @throws ClassNotFoundException
* @throws NullPointerException if <code>mimeType</code> is null
*
- * @see tryToLoadClass
+ * @see #tryToLoadClass
*/
private void initialize(String mimeType, String humanPresentableName, ClassLoader classLoader) throws MimeTypeParseException, ClassNotFoundException {
if (mimeType == null) {
@@ -990,14 +1005,8 @@
return true;
}
- if (representationClass == null) {
- if (that.getRepresentationClass() != null) {
- return false;
- }
- } else {
- if (!representationClass.equals(that.getRepresentationClass())) {
- return false;
- }
+ if (!Objects.equals(this.getRepresentationClass(), that.getRepresentationClass())) {
+ return false;
}
if (mimeType == null) {
@@ -1010,34 +1019,22 @@
}
if ("text".equals(getPrimaryType())) {
- if (DataTransferer.doesSubtypeSupportCharset(this) &&
- representationClass != null &&
- !(isRepresentationClassReader() ||
- String.class.equals(representationClass) ||
- isRepresentationClassCharBuffer() ||
- char[].class.equals(representationClass)))
- {
+ if (DataTransferer.doesSubtypeSupportCharset(this)
+ && representationClass != null
+ && !isStandardTextRepresentationClass()) {
String thisCharset =
- DataTransferer.canonicalName(getParameter("charset"));
+ DataTransferer.canonicalName(this.getParameter("charset"));
String thatCharset =
- DataTransferer.canonicalName(that.getParameter("charset"));
- if (thisCharset == null) {
- if (thatCharset != null) {
- return false;
- }
- } else {
- if (!thisCharset.equals(thatCharset)) {
- return false;
- }
+ DataTransferer.canonicalName(that.getParameter("charset"));
+ if (!Objects.equals(thisCharset, thatCharset)) {
+ return false;
}
}
- if ("html".equals(getSubType()) &&
- this.getParameter("document") != null )
- {
- if (!this.getParameter("document").
- equals(that.getParameter("document")))
- {
+ if ("html".equals(getSubType())) {
+ String thisDocument = this.getParameter("document");
+ String thatDocument = that.getParameter("document");
+ if (!Objects.equals(thisDocument, thatDocument)) {
return false;
}
}
@@ -1094,18 +1091,21 @@
// MimeType.match which reports a match if one or both of the
// subTypes is '*', regardless of the other subType.
- if ("text".equals(primaryType) &&
- DataTransferer.doesSubtypeSupportCharset(this) &&
- representationClass != null &&
- !(isRepresentationClassReader() ||
- String.class.equals(representationClass) ||
- isRepresentationClassCharBuffer() ||
- char[].class.equals(representationClass)))
- {
- String charset =
- DataTransferer.canonicalName(getParameter("charset"));
- if (charset != null) {
- total += charset.hashCode();
+ if ("text".equals(primaryType)) {
+ if (DataTransferer.doesSubtypeSupportCharset(this)
+ && representationClass != null
+ && !isStandardTextRepresentationClass()) {
+ String charset = DataTransferer.canonicalName(getParameter("charset"));
+ if (charset != null) {
+ total += charset.hashCode();
+ }
+ }
+
+ if ("html".equals(getSubType())) {
+ String document = this.getParameter("document");
+ if (document != null) {
+ total += document.hashCode();
+ }
}
}
}
@@ -1181,6 +1181,20 @@
return mimeType.match(mtype);
}
+ /**
+ * Checks if the representation class is one of the standard text
+ * representation classes.
+ *
+ * @return true if the representation class is one of the standard text
+ * representation classes, otherwise false
+ */
+ private boolean isStandardTextRepresentationClass() {
+ return isRepresentationClassReader()
+ || String.class.equals(representationClass)
+ || isRepresentationClassCharBuffer()
+ || char[].class.equals(representationClass);
+ }
+
/**
* Does the <code>DataFlavor</code> represent a serialized object?
*/
diff --git a/src/share/classes/java/awt/dnd/DragSourceContext.java b/src/share/classes/java/awt/dnd/DragSourceContext.java
index cbc4c83..3397f81 100644
--- a/src/share/classes/java/awt/dnd/DragSourceContext.java
+++ b/src/share/classes/java/awt/dnd/DragSourceContext.java
@@ -576,9 +576,9 @@
throw new InvalidObjectException("Null trigger component");
}
- int DGRActions = newTrigger.getSourceAsDragGestureRecognizer().getSourceActions()
+ int newSourceActions = f.get("sourceActions", 0)
& (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
- if (DGRActions == DnDConstants.ACTION_NONE) {
+ if (newSourceActions == DnDConstants.ACTION_NONE) {
throw new InvalidObjectException("Invalid source actions");
}
int triggerActions = newTrigger.getDragAction();
@@ -591,8 +591,7 @@
cursor = (Cursor)f.get("cursor", null);
useCustomCursor = f.get("useCustomCursor", false);
- sourceActions = f.get("sourceActions", 0)
- & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
+ sourceActions = newSourceActions;
transferable = (Transferable)s.readObject();
listener = (DragSourceListener)s.readObject();
diff --git a/src/share/classes/java/lang/ConditionalSpecialCasing.java b/src/share/classes/java/lang/ConditionalSpecialCasing.java
index fd84954..79fda55 100644
--- a/src/share/classes/java/lang/ConditionalSpecialCasing.java
+++ b/src/share/classes/java/lang/ConditionalSpecialCasing.java
@@ -62,6 +62,7 @@
//# Conditional mappings
//# ================================================================================
new Entry(0x03A3, new char[]{0x03C2}, new char[]{0x03A3}, null, FINAL_CASED), // # GREEK CAPITAL LETTER SIGMA
+ new Entry(0x0130, new char[]{0x0069, 0x0307}, new char[]{0x0130}, null, 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
//# ================================================================================
//# Locale-sensitive mappings
@@ -77,8 +78,8 @@
//# ================================================================================
//# Turkish and Azeri
-// new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "tr", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
-// new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "az", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
+ new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "tr", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
+ new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "az", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
new Entry(0x0307, new char[]{}, new char[]{0x0307}, "tr", AFTER_I), // # COMBINING DOT ABOVE
new Entry(0x0307, new char[]{}, new char[]{0x0307}, "az", AFTER_I), // # COMBINING DOT ABOVE
new Entry(0x0049, new char[]{0x0131}, new char[]{0x0049}, "tr", NOT_BEFORE_DOT), // # LATIN CAPITAL LETTER I
@@ -148,21 +149,25 @@
private static char[] lookUpTable(String src, int index, Locale locale, boolean bLowerCasing) {
HashSet<Entry> set = entryTable.get(new Integer(src.codePointAt(index)));
+ char[] ret = null;
if (set != null) {
Iterator<Entry> iter = set.iterator();
String currentLang = locale.getLanguage();
while (iter.hasNext()) {
Entry entry = iter.next();
- String conditionLang= entry.getLanguage();
+ String conditionLang = entry.getLanguage();
if (((conditionLang == null) || (conditionLang.equals(currentLang))) &&
isConditionMet(src, index, locale, entry.getCondition())) {
- return (bLowerCasing ? entry.getLowerCase() : entry.getUpperCase());
+ ret = bLowerCasing ? entry.getLowerCase() : entry.getUpperCase();
+ if (conditionLang != null) {
+ break;
+ }
}
}
}
- return null;
+ return ret;
}
private static boolean isConditionMet(String src, int index, Locale locale, int condition) {
diff --git a/src/share/classes/java/lang/String.java b/src/share/classes/java/lang/String.java
index 6565f64..ce7d8f7 100644
--- a/src/share/classes/java/lang/String.java
+++ b/src/share/classes/java/lang/String.java
@@ -2597,7 +2597,9 @@
} else {
srcCount = 1;
}
- if (localeDependent || srcChar == '\u03A3') { // GREEK CAPITAL LETTER SIGMA
+ if (localeDependent ||
+ srcChar == '\u03A3' || // GREEK CAPITAL LETTER SIGMA
+ srcChar == '\u0130') { // LATIN CAPITAL LETTER I WITH DOT ABOVE
lowerChar = ConditionalSpecialCasing.toLowerCaseEx(this, i, locale);
} else {
lowerChar = Character.toLowerCase(srcChar);
diff --git a/src/share/classes/java/util/Random.java b/src/share/classes/java/util/Random.java
index 069242c..1061b59 100644
--- a/src/share/classes/java/util/Random.java
+++ b/src/share/classes/java/util/Random.java
@@ -874,7 +874,7 @@
* (inclusive) and one (exclusive).
*
* <p>A pseudorandom {@code double} value is generated as if it's the result
- * of calling the method {@link #nextDouble()}}.
+ * of calling the method {@link #nextDouble()}.
*
* @param streamSize the number of values to generate
* @return a stream of {@code double} values
@@ -897,7 +897,7 @@
* (exclusive).
*
* <p>A pseudorandom {@code double} value is generated as if it's the result
- * of calling the method {@link #nextDouble()}}.
+ * of calling the method {@link #nextDouble()}.
*
* @implNote This method is implemented to be equivalent to {@code
* doubles(Long.MAX_VALUE)}.
diff --git a/src/share/classes/javax/crypto/JceSecurity.java b/src/share/classes/javax/crypto/JceSecurity.java
index 7e06246..fb7052d 100644
--- a/src/share/classes/javax/crypto/JceSecurity.java
+++ b/src/share/classes/javax/crypto/JceSecurity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -216,26 +216,28 @@
new WeakHashMap<>();
/*
- * Retuns the CodeBase for the given class.
+ * Returns the CodeBase for the given class.
*/
static URL getCodeBase(final Class<?> clazz) {
- URL url = codeBaseCacheRef.get(clazz);
- if (url == null) {
- url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
- public URL run() {
- ProtectionDomain pd = clazz.getProtectionDomain();
- if (pd != null) {
- CodeSource cs = pd.getCodeSource();
- if (cs != null) {
- return cs.getLocation();
+ synchronized (codeBaseCacheRef) {
+ URL url = codeBaseCacheRef.get(clazz);
+ if (url == null) {
+ url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
+ ProtectionDomain pd = clazz.getProtectionDomain();
+ if (pd != null) {
+ CodeSource cs = pd.getCodeSource();
+ if (cs != null) {
+ return cs.getLocation();
+ }
}
+ return NULL_URL;
}
- return NULL_URL;
- }
- });
- codeBaseCacheRef.put(clazz, url);
+ });
+ codeBaseCacheRef.put(clazz, url);
+ }
+ return (url == NULL_URL) ? null : url;
}
- return (url == NULL_URL) ? null : url;
}
private static void setupJurisdictionPolicies() throws Exception {
diff --git a/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
index 28494fe..82be7d0 100644
--- a/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+++ b/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
@@ -379,15 +379,11 @@
InternalFrameEvent e = new InternalFrameEvent(
frame, InternalFrameEvent.INTERNAL_FRAME_CLOSING);
// Try posting event, unless there's a SecurityManager.
- if (JInternalFrame.class.getClassLoader() == null) {
- try {
- Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e);
- return;
- } catch (SecurityException se) {
- // Use dispatchEvent instead.
- }
+ try {
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e);
+ } catch (SecurityException se) {
+ frame.dispatchEvent(e);
}
- frame.dispatchEvent(e);
}
diff --git a/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java b/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java
index ff3eab8..01aa45f 100644
--- a/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java
+++ b/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java
@@ -31,6 +31,7 @@
import javax.swing.plaf.UIResource;
import javax.swing.Painter;
import java.awt.print.PrinterGraphics;
+import sun.reflect.misc.MethodUtil;
/**
* Convenient base class for defining Painter instances for rendering a
@@ -445,8 +446,8 @@
} else {
String s = "get" + Character.toUpperCase(property.charAt(0)) + property.substring(1);
try {
- Method method = c.getClass().getMethod(s);
- color = (Color) method.invoke(c);
+ Method method = MethodUtil.getMethod(c.getClass(), s, null);
+ color = (Color) MethodUtil.invoke(method, c, null);
} catch (Exception e) {
//don't do anything, it just didn't work, that's all.
//This could be a normal occurance if you use a property
diff --git a/src/share/classes/javax/swing/plaf/nimbus/skin.laf b/src/share/classes/javax/swing/plaf/nimbus/skin.laf
index 3901004..394721e 100644
--- a/src/share/classes/javax/swing/plaf/nimbus/skin.laf
+++ b/src/share/classes/javax/swing/plaf/nimbus/skin.laf
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -13424,10 +13424,10 @@
<state stateKeys="Selected">
<style>
<textForeground>
- <matte red="255" green="255" blue="255" alpha="255" uiDefaultParentName="nimbusLightBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
+ <matte red="255" green="255" blue="255" alpha="255" uiDefaultParentName="nimbusLightBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textForeground>
<textBackground>
- <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
+ <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textBackground>
<background/>
<inherit-textForeground>false</inherit-textForeground>
@@ -13453,7 +13453,7 @@
<style>
<textForeground/>
<textBackground>
- <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
+ <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textBackground>
<background/>
<inherit-textBackground>false</inherit-textBackground>
@@ -13477,7 +13477,7 @@
<state stateKeys="Disabled">
<style>
<textForeground>
- <matte red="142" green="143" blue="145" alpha="255" uiDefaultParentName="nimbusDisabledText" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
+ <matte red="142" green="143" blue="145" alpha="255" uiDefaultParentName="nimbusDisabledText" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textForeground>
<textBackground/>
<background/>
@@ -13520,7 +13520,7 @@
</textForeground>
<textBackground/>
<background>
- <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
+ <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</background>
<inherit-textForeground>false</inherit-textForeground>
<inherit-background>false</inherit-background>
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java b/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
index 74e13aa..38900d0 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
@@ -138,9 +138,7 @@
}
SynthContext getContext(JComponent c, int state) {
- Region region = SynthLookAndFeel.getRegion(c);
- return SynthContext.getContext(SynthContext.class, c, region,
- style, state);
+ return SynthContext.getContext(c, style, state);
}
/**
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java b/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
index 9256684..72ab2b0 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
@@ -128,8 +128,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java b/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
index 754484d..d56a5a6 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
@@ -208,8 +208,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthContext.java b/src/share/classes/javax/swing/plaf/synth/SynthContext.java
index 6d89a4a..64b6e53 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthContext.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthContext.java
@@ -24,8 +24,9 @@
*/
package javax.swing.plaf.synth;
-import javax.swing.*;
-import java.util.*;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import javax.swing.JComponent;
/**
* An immutable transient object containing contextual information about
@@ -39,59 +40,32 @@
* @author Scott Violet
*/
public class SynthContext {
- private static final Map<Class, List<SynthContext>> contextMap;
+ private static final Queue<SynthContext> queue = new ConcurrentLinkedQueue<>();
private JComponent component;
private Region region;
private SynthStyle style;
private int state;
-
- static {
- contextMap = new HashMap<Class, List<SynthContext>>();
+ static SynthContext getContext(JComponent c, SynthStyle style, int state) {
+ return getContext(c, SynthLookAndFeel.getRegion(c), style, state);
}
-
- static SynthContext getContext(Class type, JComponent component,
+ static SynthContext getContext(JComponent component,
Region region, SynthStyle style,
int state) {
- SynthContext context = null;
-
- synchronized(contextMap) {
- List<SynthContext> instances = contextMap.get(type);
-
- if (instances != null) {
- int size = instances.size();
-
- if (size > 0) {
- context = instances.remove(size - 1);
- }
- }
- }
+ SynthContext context = queue.poll();
if (context == null) {
- try {
- context = (SynthContext)type.newInstance();
- } catch (IllegalAccessException iae) {
- } catch (InstantiationException ie) {
- }
+ context = new SynthContext();
}
context.reset(component, region, style, state);
return context;
}
static void releaseContext(SynthContext context) {
- synchronized(contextMap) {
- List<SynthContext> instances = contextMap.get(context.getClass());
-
- if (instances == null) {
- instances = new ArrayList<SynthContext>(5);
- contextMap.put(context.getClass(), instances);
- }
- instances.add(context);
- }
+ queue.offer(context);
}
-
SynthContext() {
}
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java b/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
index cde0f05..ff66896 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
@@ -142,9 +142,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- Region region = SynthLookAndFeel.getRegion(c);
- return SynthContext.getContext(SynthContext.class, c, region,
- style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java b/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
index c109908..3620bda 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
@@ -430,8 +430,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java b/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
index 2ccf592..6948919 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
@@ -139,8 +139,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java b/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
index f0f7b60..a538457 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
@@ -67,8 +67,7 @@
}
public SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private Region getRegion(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java b/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
index 34c94cd..c5c1ef7 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
@@ -141,8 +141,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java b/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
index 45031e9..22e57e5 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
@@ -91,8 +91,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthListUI.java b/src/share/classes/javax/swing/plaf/synth/SynthListUI.java
index 5f19a19..249bc0a 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthListUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthListUI.java
@@ -188,8 +188,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java b/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
index 9c1f9cb..1f09664 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
@@ -116,8 +116,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java b/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
index 19ac0a7..956f76f 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
@@ -170,8 +170,7 @@
}
SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
SynthContext getContext(JComponent c, Region region) {
@@ -179,8 +178,7 @@
}
private SynthContext getContext(JComponent c, Region region, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- region, accStyle, state);
+ return SynthContext.getContext(c, region, accStyle, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java b/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
index 3f53f46..7bb66a2 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
@@ -170,9 +170,7 @@
}
SynthContext getContext(JComponent c, int state) {
- Region region = SynthLookAndFeel.getRegion(c);
- return SynthContext.getContext(SynthContext.class, c, region,
- style, state);
+ return SynthContext.getContext(c, style, state);
}
SynthContext getContext(JComponent c, Region region) {
@@ -180,8 +178,7 @@
}
private SynthContext getContext(JComponent c, Region region, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- region, accStyle, state);
+ return SynthContext.getContext(c, region, accStyle, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java b/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
index 42d454c..de6f2a7 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
@@ -140,8 +140,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java b/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
index ddfff5c..73f37ff 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
@@ -127,8 +127,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthParser.java b/src/share/classes/javax/swing/plaf/synth/SynthParser.java
index a03e752..c27b104 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthParser.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthParser.java
@@ -67,6 +67,7 @@
import org.xml.sax.helpers.DefaultHandler;
import com.sun.beans.decoder.DocumentHandler;
+import sun.reflect.misc.ReflectUtil;
class SynthParser extends DefaultHandler {
//
@@ -648,7 +649,7 @@
}
else {
try {
- typeClass = Class.forName(typeName.substring(
+ typeClass = ReflectUtil.forName(typeName.substring(
0, classIndex));
} catch (ClassNotFoundException cnfe) {
throw new SAXException("Unknown class: " +
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java b/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
index d228aba..cbb09f2 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
@@ -123,8 +123,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java b/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
index 1afc81b..c37ce49 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
@@ -138,8 +138,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java b/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
index 0d437de..1115fe3 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
@@ -80,8 +80,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java b/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
index 21b0a52..04b89bb 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
@@ -185,8 +185,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private SynthContext getContext(JComponent c, Region region) {
@@ -199,8 +198,7 @@
if (region == Region.SCROLL_BAR_THUMB) {
style = thumbStyle;
}
- return SynthContext.getContext(SynthContext.class, c, region, style,
- state);
+ return SynthContext.getContext(c, region, style, state);
}
private int getComponentState(JComponent c, Region region) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java b/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
index 82d0b5e..b8b13c7 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
@@ -211,8 +211,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java b/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
index 7e759d4..158e16b 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
@@ -248,8 +248,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
public void propertyChange(PropertyChangeEvent evt) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java b/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
index 65d4612..5cc7cd4 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
@@ -722,8 +722,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private SynthContext getContext(JComponent c, Region subregion) {
@@ -732,14 +731,13 @@
private SynthContext getContext(JComponent c, Region subregion, int state) {
SynthStyle style = null;
- Class klass = SynthContext.class;
if (subregion == Region.SLIDER_TRACK) {
style = sliderTrackStyle;
} else if (subregion == Region.SLIDER_THUMB) {
style = sliderThumbStyle;
}
- return SynthContext.getContext(klass, c, subregion, style, state);
+ return SynthContext.getContext(c, subregion, style, state);
}
private int getComponentState(JComponent c, Region region) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java b/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
index d8bc4fe..a1293df 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
@@ -278,8 +278,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
/**
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java b/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
index 665286c..225c41f 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
@@ -209,8 +209,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
SynthContext getContext(JComponent c, Region region) {
@@ -219,11 +218,9 @@
private SynthContext getContext(JComponent c, Region region, int state) {
if (region == Region.SPLIT_PANE_DIVIDER) {
- return SynthContext.getContext(SynthContext.class, c, region,
- dividerStyle, state);
+ return SynthContext.getContext(c, region, dividerStyle, state);
}
- return SynthContext.getContext(SynthContext.class, c, region,
- style, state);
+ return SynthContext.getContext(c, region, style, state);
}
private int getComponentState(JComponent c, Region subregion) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java b/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
index 95aa6dc..6d9dee0 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
@@ -235,13 +235,11 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c),style, state);
+ return SynthContext.getContext(c, style, state);
}
private SynthContext getContext(JComponent c, Region subregion, int state){
SynthStyle style = null;
- Class klass = SynthContext.class;
if (subregion == Region.TABBED_PANE_TAB) {
style = tabStyle;
@@ -252,7 +250,7 @@
else if (subregion == Region.TABBED_PANE_CONTENT) {
style = tabContentStyle;
}
- return SynthContext.getContext(klass, c, subregion, style, state);
+ return SynthContext.getContext(c, subregion, style, state);
}
/**
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java b/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
index ec358aa..c95469c 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
@@ -193,8 +193,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
/**
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java b/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java
index 49dfe4b..d39a47d 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java
@@ -246,8 +246,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
//
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java b/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
index e39f144..fa84eeb 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
@@ -118,8 +118,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
/**
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java b/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
index f033e97..3831da9 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
@@ -156,8 +156,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
/**
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java b/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
index f65fdd1..51d2fef 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
@@ -178,19 +178,17 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private SynthContext getContext(JComponent c, Region region, SynthStyle style) {
- return SynthContext.getContext(SynthContext.class, c, region,
+ return SynthContext.getContext(c, region,
style, getComponentState(c, region));
}
private SynthContext getContext(JComponent c, Region region,
SynthStyle style, int state) {
- return SynthContext.getContext(SynthContext.class, c, region,
- style, state);
+ return SynthContext.getContext(c, region, style, state);
}
private int getComponentState(JComponent c, Region region) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java b/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
index afd49f4..dc42deb 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
@@ -107,8 +107,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private int getComponentState(JComponent c) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java b/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
index 70f7f64..721c322 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
@@ -173,8 +173,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- SynthLookAndFeel.getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private SynthContext getContext(JComponent c, Region region) {
@@ -182,8 +181,7 @@
}
private SynthContext getContext(JComponent c, Region region, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- region, cellStyle, state);
+ return SynthContext.getContext(c, region, cellStyle, state);
}
private int getComponentState(JComponent c, Region region) {
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java b/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
index 4c5a9b0..dc3e6c6 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
@@ -141,8 +141,7 @@
}
private SynthContext getContext(JComponent c, int state) {
- return SynthContext.getContext(SynthContext.class, c,
- getRegion(c), style, state);
+ return SynthContext.getContext(c, style, state);
}
private Region getRegion(JComponent c) {
diff --git a/src/share/classes/sun/awt/SunToolkit.java b/src/share/classes/sun/awt/SunToolkit.java
index c45938c..08c3615 100644
--- a/src/share/classes/sun/awt/SunToolkit.java
+++ b/src/share/classes/sun/awt/SunToolkit.java
@@ -851,22 +851,30 @@
private int checkResolutionVariant(Image img, int w, int h, ImageObserver o) {
ToolkitImage rvImage = getResolutionVariant(img);
+ int rvw = getRVSize(w);
+ int rvh = getRVSize(h);
// Ignore the resolution variant in case of error
return (rvImage == null || rvImage.hasError()) ? 0xFFFF :
- checkImage(rvImage, 2 * w, 2 * h, MultiResolutionToolkitImage.
+ checkImage(rvImage, rvw, rvh, MultiResolutionToolkitImage.
getResolutionVariantObserver(
- img, o, w, h, 2 * w, 2 * h));
+ img, o, w, h, rvw, rvh, true));
}
private boolean prepareResolutionVariant(Image img, int w, int h,
ImageObserver o) {
ToolkitImage rvImage = getResolutionVariant(img);
+ int rvw = getRVSize(w);
+ int rvh = getRVSize(h);
// Ignore the resolution variant in case of error
return rvImage == null || rvImage.hasError() || prepareImage(
- rvImage, 2 * w, 2 * h,
+ rvImage, rvw, rvh,
MultiResolutionToolkitImage.getResolutionVariantObserver(
- img, o, w, h, 2 * w, 2 * h));
+ img, o, w, h, rvw, rvh, true));
+ }
+
+ private static int getRVSize(int size){
+ return size == -1 ? -1 : 2 * size;
}
private static ToolkitImage getResolutionVariant(Image image) {
diff --git a/src/share/classes/sun/awt/image/ByteBandedRaster.java b/src/share/classes/sun/awt/image/ByteBandedRaster.java
index 164324f..62dbcc6 100644
--- a/src/share/classes/sun/awt/image/ByteBandedRaster.java
+++ b/src/share/classes/sun/awt/image/ByteBandedRaster.java
@@ -755,10 +755,22 @@
+ scanlineStride);
}
- for (int i = 0; i < data.length; i++) {
- if (scanlineStride > data[i].length) {
- throw new RasterFormatException("Incorrect scanline stride: "
- + scanlineStride);
+ if ((long)minX - sampleModelTranslateX < 0 ||
+ (long)minY - sampleModelTranslateY < 0) {
+
+ throw new RasterFormatException("Incorrect origin/translate: (" +
+ minX + ", " + minY + ") / (" +
+ sampleModelTranslateX + ", " + sampleModelTranslateY + ")");
+ }
+
+
+ if (height > 1 || minY - sampleModelTranslateY > 0) {
+ // buffer should contain at least one scanline
+ for (int i = 0; i < data.length; i++) {
+ if (scanlineStride > data[i].length) {
+ throw new RasterFormatException("Incorrect scanline stride: "
+ + scanlineStride);
+ }
}
}
diff --git a/src/share/classes/sun/awt/image/ByteComponentRaster.java b/src/share/classes/sun/awt/image/ByteComponentRaster.java
index 6587f77..c43ab2c 100644
--- a/src/share/classes/sun/awt/image/ByteComponentRaster.java
+++ b/src/share/classes/sun/awt/image/ByteComponentRaster.java
@@ -885,15 +885,31 @@
}
}
+ if ((long)minX - sampleModelTranslateX < 0 ||
+ (long)minY - sampleModelTranslateY < 0) {
+
+ throw new RasterFormatException("Incorrect origin/translate: (" +
+ minX + ", " + minY + ") / (" +
+ sampleModelTranslateX + ", " + sampleModelTranslateY + ")");
+ }
+
// we can be sure that width and height are greater than 0
if (scanlineStride < 0 ||
- scanlineStride > (Integer.MAX_VALUE / height) ||
- scanlineStride > data.length)
+ scanlineStride > (Integer.MAX_VALUE / height))
{
// integer overflow
throw new RasterFormatException("Incorrect scanline stride: "
+ scanlineStride);
}
+
+ if (height > 1 || minY - sampleModelTranslateY > 0) {
+ // buffer should contain at least one scanline
+ if (scanlineStride > data.length) {
+ throw new RasterFormatException("Incorrect scanline stride: "
+ + scanlineStride);
+ }
+ }
+
int lastScanOffset = (height - 1) * scanlineStride;
if (pixelStride < 0 ||
diff --git a/src/share/classes/sun/awt/image/BytePackedRaster.java b/src/share/classes/sun/awt/image/BytePackedRaster.java
index da370a3..bd3835d 100644
--- a/src/share/classes/sun/awt/image/BytePackedRaster.java
+++ b/src/share/classes/sun/awt/image/BytePackedRaster.java
@@ -1386,13 +1386,28 @@
throw new RasterFormatException("Invalid raster dimension");
}
+ if ((long)minX - sampleModelTranslateX < 0 ||
+ (long)minY - sampleModelTranslateY < 0) {
+
+ throw new RasterFormatException("Incorrect origin/translate: (" +
+ minX + ", " + minY + ") / (" +
+ sampleModelTranslateX + ", " + sampleModelTranslateY + ")");
+ }
+
if (scanlineStride < 0 ||
- scanlineStride > (Integer.MAX_VALUE / height) ||
- scanlineStride > data.length)
+ scanlineStride > (Integer.MAX_VALUE / height))
{
throw new RasterFormatException("Invalid scanline stride");
}
+ if (height > 1 || minY - sampleModelTranslateY > 0) {
+ // buffer should contain at least one scanline
+ if (scanlineStride > data.length) {
+ throw new RasterFormatException("Incorrect scanline stride: "
+ + scanlineStride);
+ }
+ }
+
int lastbit = (dataBitOffset
+ (height-1) * scanlineStride * 8
+ (width-1) * pixelBitStride
diff --git a/src/share/classes/sun/awt/image/IntegerComponentRaster.java b/src/share/classes/sun/awt/image/IntegerComponentRaster.java
index f36b108..b3456e0 100644
--- a/src/share/classes/sun/awt/image/IntegerComponentRaster.java
+++ b/src/share/classes/sun/awt/image/IntegerComponentRaster.java
@@ -654,15 +654,31 @@
") must be >= 0");
}
+ if ((long)minX - sampleModelTranslateX < 0 ||
+ (long)minY - sampleModelTranslateY < 0) {
+
+ throw new RasterFormatException("Incorrect origin/translate: (" +
+ minX + ", " + minY + ") / (" +
+ sampleModelTranslateX + ", " + sampleModelTranslateY + ")");
+ }
+
// we can be sure that width and height are greater than 0
if (scanlineStride < 0 ||
- scanlineStride > (Integer.MAX_VALUE / height) ||
- scanlineStride > data.length)
+ scanlineStride > (Integer.MAX_VALUE / height))
{
// integer overflow
throw new RasterFormatException("Incorrect scanline stride: "
+ scanlineStride);
}
+
+ if (height > 1 || minY - sampleModelTranslateY > 0) {
+ // buffer should contain at least one scanline
+ if (scanlineStride > data.length) {
+ throw new RasterFormatException("Incorrect scanline stride: "
+ + scanlineStride);
+ }
+ }
+
int lastScanOffset = (height - 1) * scanlineStride;
if (pixelStride < 0 ||
diff --git a/src/share/classes/sun/awt/image/MultiResolutionToolkitImage.java b/src/share/classes/sun/awt/image/MultiResolutionToolkitImage.java
index a49c8a7..bde59ab 100644
--- a/src/share/classes/sun/awt/image/MultiResolutionToolkitImage.java
+++ b/src/share/classes/sun/awt/image/MultiResolutionToolkitImage.java
@@ -66,6 +66,14 @@
final Image image, final ImageObserver observer,
final int imgWidth, final int imgHeight,
final int rvWidth, final int rvHeight) {
+ return getResolutionVariantObserver(image, observer,
+ imgWidth, imgHeight, rvWidth, rvHeight, false);
+ }
+
+ public static ImageObserver getResolutionVariantObserver(
+ final Image image, final ImageObserver observer,
+ final int imgWidth, final int imgHeight,
+ final int rvWidth, final int rvHeight, boolean concatenateInfo) {
if (observer == null) {
return null;
@@ -92,6 +100,11 @@
y /= 2;
}
+ if(concatenateInfo){
+ flags &= ((ToolkitImage) image).
+ getImageRep().check(null);
+ }
+
return observer.imageUpdate(
image, flags, x, y, width, height);
};
diff --git a/src/share/classes/sun/awt/image/ShortBandedRaster.java b/src/share/classes/sun/awt/image/ShortBandedRaster.java
index b6e955b..c73e7a7 100644
--- a/src/share/classes/sun/awt/image/ShortBandedRaster.java
+++ b/src/share/classes/sun/awt/image/ShortBandedRaster.java
@@ -754,10 +754,21 @@
+ scanlineStride);
}
- for (int i = 0; i < data.length; i++) {
- if (scanlineStride > data[i].length) {
- throw new RasterFormatException("Incorrect scanline stride: "
- + scanlineStride);
+ if ((long)minX - sampleModelTranslateX < 0 ||
+ (long)minY - sampleModelTranslateY < 0) {
+
+ throw new RasterFormatException("Incorrect origin/translate: (" +
+ minX + ", " + minY + ") / (" +
+ sampleModelTranslateX + ", " + sampleModelTranslateY + ")");
+ }
+
+ if (height > 1 || minY - sampleModelTranslateY > 0) {
+ // buffer should contain at least one scanline
+ for (int i = 0; i < data.length; i++) {
+ if (scanlineStride > data[i].length) {
+ throw new RasterFormatException("Incorrect scanline stride: "
+ + scanlineStride);
+ }
}
}
diff --git a/src/share/classes/sun/awt/image/ShortComponentRaster.java b/src/share/classes/sun/awt/image/ShortComponentRaster.java
index e6a5bc0..cdbc93c 100644
--- a/src/share/classes/sun/awt/image/ShortComponentRaster.java
+++ b/src/share/classes/sun/awt/image/ShortComponentRaster.java
@@ -819,15 +819,31 @@
}
}
+ if ((long)minX - sampleModelTranslateX < 0 ||
+ (long)minY - sampleModelTranslateY < 0) {
+
+ throw new RasterFormatException("Incorrect origin/translate: (" +
+ minX + ", " + minY + ") / (" +
+ sampleModelTranslateX + ", " + sampleModelTranslateY + ")");
+ }
+
// we can be sure that width and height are greater than 0
if (scanlineStride < 0 ||
- scanlineStride > (Integer.MAX_VALUE / height) ||
- scanlineStride > data.length)
+ scanlineStride > (Integer.MAX_VALUE / height))
{
// integer overflow
throw new RasterFormatException("Incorrect scanline stride: "
+ scanlineStride);
}
+
+ if (height > 1 || minY - sampleModelTranslateY > 0) {
+ // buffer should contain at least one scanline
+ if (scanlineStride > data.length) {
+ throw new RasterFormatException("Incorrect scanline stride: "
+ + scanlineStride);
+ }
+ }
+
int lastScanOffset = (height - 1) * scanlineStride;
if (pixelStride < 0 ||
diff --git a/src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java b/src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java
index 8701a77..f031407 100644
--- a/src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java
+++ b/src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java
@@ -34,8 +34,11 @@
import java.util.Random;
import sun.net.www.HeaderParser;
+import sun.net.NetProperties;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.security.PrivilegedAction;
+import java.security.AccessController;
import static sun.net.www.protocol.http.HttpURLConnection.HTTP_CONNECT;
/**
@@ -51,6 +54,23 @@
private String authMethod;
+ private final static String compatPropName = "http.auth.digest." +
+ "quoteParameters";
+
+ // true if http.auth.digest.quoteParameters Net property is true
+ private static final boolean delimCompatFlag;
+
+ static {
+ Boolean b = AccessController.doPrivileged(
+ new PrivilegedAction<Boolean>() {
+ public Boolean run() {
+ return NetProperties.getBoolean(compatPropName);
+ }
+ }
+ );
+ delimCompatFlag = (b == null) ? false : b.booleanValue();
+ }
+
// Authentication parameters defined in RFC2617.
// One instance of these may be shared among several DigestAuthentication
// instances as a result of a single authorization (for multiple domains)
@@ -357,24 +377,34 @@
ncfield = "\", nc=" + ncstring;
}
+ String algoS, qopS;
+
+ if (delimCompatFlag) {
+ // Put quotes around these String value parameters
+ algoS = ", algorithm=\"" + algorithm + "\"";
+ qopS = ", qop=\"auth\"";
+ } else {
+ // Don't put quotes around them, per the RFC
+ algoS = ", algorithm=" + algorithm;
+ qopS = ", qop=auth";
+ }
+
String value = authMethod
+ " username=\"" + pw.getUserName()
+ "\", realm=\"" + realm
+ "\", nonce=\"" + nonce
+ ncfield
+ ", uri=\"" + uri
- + "\", response=\"" + response
- + "\", algorithm=" + algorithm;
+ + "\", response=\"" + response + "\""
+ + algoS;
if (opaque != null) {
- value = value + ", opaque=\"" + opaque;
- value = value + "\"";
+ value += ", opaque=\"" + opaque + "\"";
}
if (cnonce != null) {
- value = value + ", cnonce=\"" + cnonce;
- value = value + "\"";
+ value += ", cnonce=\"" + cnonce + "\"";
}
if (qop) {
- value = value + ", qop=auth";
+ value += qopS;
}
return value;
}
diff --git a/src/share/classes/sun/nio/cs/UTF_8.java b/src/share/classes/sun/nio/cs/UTF_8.java
index bfb7b7a..3ee2341 100644
--- a/src/share/classes/sun/nio/cs/UTF_8.java
+++ b/src/share/classes/sun/nio/cs/UTF_8.java
@@ -111,12 +111,18 @@
(b4 & 0xc0) != 0x80;
}
- // only used when there is less than 4 bytes left in src buffer
+ // only used when there is less than 4 bytes left in src buffer.
+ // both b1 and b2 should be "& 0xff" before passed in.
private static boolean isMalformed4_2(int b1, int b2) {
- return (b1 == 0xf0 && b2 == 0x90) ||
+ return (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) ||
+ (b1 == 0xf4 && (b2 & 0xf0) != 0x80) ||
(b2 & 0xc0) != 0x80;
}
+ // tests if b1 and b2 are malformed as the first 2 bytes of a
+ // legal`4-byte utf-8 byte sequence.
+ // only used when there is less than 4 bytes left in src buffer,
+ // after isMalformed4_2 has been invoked.
private static boolean isMalformed4_3(int b3) {
return (b3 & 0xc0) != 0x80;
}
@@ -280,7 +286,9 @@
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
int srcRemaining = sl - sp;
if (srcRemaining < 4 || dl - dp < 2) {
- if (srcRemaining > 1 && isMalformed4_2(b1, sa[sp + 1]))
+ b1 &= 0xff;
+ if (b1 > 0xf4 ||
+ srcRemaining > 1 && isMalformed4_2(b1, sa[sp + 1] & 0xff))
return malformedForLength(src, sp, dst, dp, 1);
if (srcRemaining > 2 && isMalformed4_3(sa[sp + 2]))
return malformedForLength(src, sp, dst, dp, 2);
@@ -363,7 +371,9 @@
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
int srcRemaining = limit - mark;
if (srcRemaining < 4 || dst.remaining() < 2) {
- if (srcRemaining > 1 && isMalformed4_2(b1, src.get()))
+ b1 &= 0xff;
+ if (b1 > 0xf4 ||
+ srcRemaining > 1 && isMalformed4_2(b1, src.get() & 0xff))
return malformedForLength(src, mark, 1);
if (srcRemaining > 2 && isMalformed4_3(src.get()))
return malformedForLength(src, mark, 2);
@@ -518,8 +528,9 @@
}
if (malformedInputAction() != CodingErrorAction.REPLACE)
return -1;
-
- if (sp < sl && isMalformed4_2(b1, sa[sp])) {
+ b1 &= 0xff;
+ if (b1 > 0xf4 ||
+ sp < sl && isMalformed4_2(b1, sa[sp] & 0xff)) {
da[dp++] = replacement().charAt(0);
continue;
}
diff --git a/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java b/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java
index 9bd4b6c..8eab556 100644
--- a/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java
+++ b/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java
@@ -75,7 +75,7 @@
if (ti.getTarget() == filter)
l.add(t);
}
- TypeAnnotation[] typeAnnotations = l.toArray(new TypeAnnotation[0]);
+ TypeAnnotation[] typeAnnotations = l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY);
return AnnotatedTypeFactory.buildAnnotatedType(type,
LocationInfo.BASE_LOCATION,
typeAnnotations,
@@ -245,7 +245,6 @@
if (bounds != null) {
int startIndex = 0;
AnnotatedType[] res = new AnnotatedType[bounds.length];
- Arrays.fill(res, AnnotatedTypeFactory.EMPTY_ANNOTATED_TYPE);
// Adjust bounds index
//
@@ -276,12 +275,12 @@
tInfo.getCount() == typeVarIndex) {
l.add(t);
}
- res[i] = AnnotatedTypeFactory.buildAnnotatedType(bounds[i],
- loc,
- l.toArray(new TypeAnnotation[0]),
- candidates.toArray(new TypeAnnotation[0]),
- (AnnotatedElement)decl);
}
+ res[i] = AnnotatedTypeFactory.buildAnnotatedType(bounds[i],
+ loc,
+ l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
+ candidates.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
+ (AnnotatedElement)decl);
}
return res;
}
diff --git a/src/share/native/sun/font/layout/IndicLayoutEngine.cpp b/src/share/native/sun/font/layout/IndicLayoutEngine.cpp
index d45ebb6..c50fbae 100644
--- a/src/share/native/sun/font/layout/IndicLayoutEngine.cpp
+++ b/src/share/native/sun/font/layout/IndicLayoutEngine.cpp
@@ -151,7 +151,7 @@
le_int32 outCharCount;
if (fVersion2) {
_LETRACE("v2process");
- outCharCount = IndicReordering::v2process(&chars[offset], count, fScriptCode, outChars, glyphStorage);
+ outCharCount = IndicReordering::v2process(&chars[offset], count, fScriptCode, outChars, glyphStorage, success);
} else {
_LETRACE("reorder");
outCharCount = IndicReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage, &fMPreFixups, success);
diff --git a/src/share/native/sun/font/layout/IndicReordering.cpp b/src/share/native/sun/font/layout/IndicReordering.cpp
index 7753e24..22bbb7c 100644
--- a/src/share/native/sun/font/layout/IndicReordering.cpp
+++ b/src/share/native/sun/font/layout/IndicReordering.cpp
@@ -1096,9 +1096,13 @@
le_int32 IndicReordering::v2process(const LEUnicode *chars, le_int32 charCount, le_int32 scriptCode,
- LEUnicode *outChars, LEGlyphStorage &glyphStorage)
+ LEUnicode *outChars, LEGlyphStorage &glyphStorage, LEErrorCode& success)
{
const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
+ if (classTable == NULL) {
+ success = LE_MEMORY_ALLOCATION_ERROR;
+ return 0;
+ }
DynamicProperties dynProps[INDIC_BLOCK_SIZE];
IndicReordering::getDynamicProperties(dynProps,classTable);
diff --git a/src/share/native/sun/font/layout/IndicReordering.h b/src/share/native/sun/font/layout/IndicReordering.h
index f90bf1b..ca77fe0 100644
--- a/src/share/native/sun/font/layout/IndicReordering.h
+++ b/src/share/native/sun/font/layout/IndicReordering.h
@@ -181,7 +181,7 @@
static void adjustMPres(MPreFixups *mpreFixups, LEGlyphStorage &glyphStorage, LEErrorCode& success);
static le_int32 v2process(const LEUnicode *theChars, le_int32 charCount, le_int32 scriptCode,
- LEUnicode *outChars, LEGlyphStorage &glyphStorage);
+ LEUnicode *outChars, LEGlyphStorage &glyphStorage, LEErrorCode& success);
static const FeatureMap *getFeatureMap(le_int32 &count);
diff --git a/src/share/native/sun/font/layout/LEScripts.h b/src/share/native/sun/font/layout/LEScripts.h
index 5524ef3..bb1b07e 100644
--- a/src/share/native/sun/font/layout/LEScripts.h
+++ b/src/share/native/sun/font/layout/LEScripts.h
@@ -263,12 +263,6 @@
tirhScriptCode = 158,
/**
- * @stable ICU 52
- */
- aghbScriptCode = 159,
- mahjScriptCode = 160,
-
-/**
* @stable ICU 2.2
*/
scriptCodeCount
diff --git a/src/solaris/native/java/util/TimeZone_md.c b/src/solaris/native/java/util/TimeZone_md.c
index e1af8f9..c90fcee 100644
--- a/src/solaris/native/java/util/TimeZone_md.c
+++ b/src/solaris/native/java/util/TimeZone_md.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,6 +56,9 @@
static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime";
#else
+#ifdef _AIX
+static const char *ETC_ENVIRONMENT_FILE = "/etc/environment";
+#endif
static const char *SYS_INIT_FILE = "/etc/default/init";
static const char *ZONEINFO_DIR = "/usr/share/lib/zoneinfo";
static const char *DEFAULT_ZONEINFO_FILE = "/usr/share/lib/zoneinfo/localtime";
@@ -619,8 +622,29 @@
static char *
getPlatformTimeZoneID()
{
- return NULL;
+ FILE *fp;
+ char *tz = NULL;
+ char *tz_key = "TZ=";
+ char line[256];
+ size_t tz_key_len = strlen(tz_key);
+
+ if ((fp = fopen(ETC_ENVIRONMENT_FILE, "r")) != NULL) {
+ while (fgets(line, sizeof(line), fp) != NULL) {
+ char *p = strchr(line, '\n');
+ if (p != NULL) {
+ *p = '\0';
+ }
+ if (0 == strncmp(line, tz_key, tz_key_len)) {
+ tz = strdup(line + tz_key_len);
+ break;
+ }
+ }
+ (void) fclose(fp);
+ }
+
+ return tz;
}
+static char *mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz);
#endif
/*
@@ -678,9 +702,19 @@
if (freetz != NULL) {
free((void *) freetz);
}
+
+#ifdef _AIX
+ freetz = mapPlatformToJavaTimezone(java_home_dir, javatz);
+ if (javatz != NULL) {
+ free((void *) javatz);
+ }
+ javatz = freetz;
+#endif
}
+
return javatz;
}
+
/**
* Returns a GMT-offset-based zone ID. (e.g., "GMT-08:00")
*/
@@ -747,3 +781,101 @@
return strdup(buf);
}
#endif /* MACOSX */
+
+#ifdef _AIX
+static char *
+mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz) {
+ FILE *tzmapf;
+ char mapfilename[PATH_MAX+1];
+ char line[256];
+ int linecount = 0;
+ char temp[100], *temp_tz;
+ char *javatz = NULL;
+ char *str_tmp = NULL;
+ size_t temp_tz_len = 0;
+
+ /* On AIX, the TZ environment variable may end with a comma
+ * followed by modifier fields. These are ignored here.
+ */
+ strncpy(temp, tz, 100);
+ temp_tz = strtok_r(temp, ",", &str_tmp);
+
+ if(temp_tz == NULL)
+ goto tzerr;
+
+ temp_tz_len = strlen(temp_tz);
+
+ if (strlen(java_home_dir) >= (PATH_MAX - 15)) {
+ jio_fprintf(stderr, "java.home longer than maximum path length \n");
+ goto tzerr;
+ }
+
+ strncpy(mapfilename, java_home_dir, PATH_MAX);
+ strcat(mapfilename, "/lib/tzmappings");
+
+ if ((tzmapf = fopen(mapfilename, "r")) == NULL) {
+ jio_fprintf(stderr, "can't open %s\n", mapfilename);
+ goto tzerr;
+ }
+
+ while (fgets(line, sizeof(line), tzmapf) != NULL) {
+ char *p = line;
+ char *sol = line;
+ char *java;
+ int result;
+
+ linecount++;
+ /*
+ * Skip comments and blank lines
+ */
+ if (*p == '#' || *p == '\n') {
+ continue;
+ }
+
+ /*
+ * Get the first field, platform zone ID
+ */
+ while (*p != '\0' && *p != '\t') {
+ p++;
+ }
+ if (*p == '\0') {
+ /* mapping table is broken! */
+ jio_fprintf(stderr, "tzmappings: Illegal format at near line %d.\n", linecount);
+ break;
+ }
+
+ *p++ = '\0';
+ if ((result = strncmp(temp_tz, sol, temp_tz_len)) == 0) {
+ /*
+ * If this is the current platform zone ID,
+ * take the Java time zone ID (2nd field).
+ */
+ java = p;
+ while (*p != '\0' && *p != '\n') {
+ p++;
+ }
+
+ if (*p == '\0') {
+ /* mapping table is broken! */
+ jio_fprintf(stderr, "tzmappings: Illegal format at line %d.\n", linecount);
+ break;
+ }
+
+ *p = '\0';
+ javatz = strdup(java);
+ break;
+ } else if (result < 0) {
+ break;
+ }
+ }
+ (void) fclose(tzmapf);
+
+tzerr:
+ if (javatz == NULL) {
+ return getGMTOffsetID();
+ }
+
+ return javatz;
+}
+#endif
+
diff --git a/src/windows/native/sun/windows/awt_TextField.cpp b/src/windows/native/sun/windows/awt_TextField.cpp
index c6d3f21..b37b5c7 100644
--- a/src/windows/native/sun/windows/awt_TextField.cpp
+++ b/src/windows/native/sun/windows/awt_TextField.cpp
@@ -200,7 +200,10 @@
si.cbSize = sizeof(si);
si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
+ SendMessage(EM_SHOWSCROLLBAR, SB_HORZ, TRUE);
VERIFY(::GetScrollInfo(GetHWnd(), SB_HORZ, &si));
+ SendMessage(EM_SHOWSCROLLBAR, SB_HORZ, FALSE);
+
if (bScrollLeft == TRUE) {
si.nPos = si.nPos - si.nPage / 2;
si.nPos = max(si.nMin, si.nPos);
diff --git a/test/com/sun/jdi/BadHandshakeTest.java b/test/com/sun/jdi/BadHandshakeTest.java
index 35afb33..7e35ce3 100644
--- a/test/com/sun/jdi/BadHandshakeTest.java
+++ b/test/com/sun/jdi/BadHandshakeTest.java
@@ -26,7 +26,7 @@
* @summary Check that a bad handshake doesn't cause a debuggee to abort
* @library /lib/testlibrary
*
- * @build VMConnection BadHandshakeTest Exit0
+ * @build jdk.testlibrary.* VMConnection BadHandshakeTest Exit0
* @run main BadHandshakeTest
*
*/
diff --git a/test/com/sun/jdi/ExclusiveBind.java b/test/com/sun/jdi/ExclusiveBind.java
index d53efd8..b5ca807 100644
--- a/test/com/sun/jdi/ExclusiveBind.java
+++ b/test/com/sun/jdi/ExclusiveBind.java
@@ -27,8 +27,7 @@
* at the same time.
* @library /lib/testlibrary
*
- * @build jdk.testlibrary.ProcessTools jdk.testlibrary.JDKToolLauncher jdk.testlibrary.Utils
- * @build VMConnection ExclusiveBind HelloWorld
+ * @build jdk.testlibrary.* VMConnection ExclusiveBind HelloWorld
* @run main ExclusiveBind
*/
import java.net.ServerSocket;
diff --git a/test/com/sun/tools/attach/BasicTests.java b/test/com/sun/tools/attach/BasicTests.java
index 51f202b..e8cf947 100644
--- a/test/com/sun/tools/attach/BasicTests.java
+++ b/test/com/sun/tools/attach/BasicTests.java
@@ -38,7 +38,7 @@
* @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
* @summary Basic unit tests for the VM attach mechanism.
* @library /lib/testlibrary
- * @run build Agent BadAgent RedefineAgent Application Shutdown RedefineDummy
+ * @build jdk.testlibrary.* Agent BadAgent RedefineAgent Application Shutdown RedefineDummy
* @run main BasicTests
*
* This test will perform a number of basic attach tests.
diff --git a/test/com/sun/tools/attach/PermissionTest.java b/test/com/sun/tools/attach/PermissionTest.java
index 933ec2c..4fbf49a 100644
--- a/test/com/sun/tools/attach/PermissionTest.java
+++ b/test/com/sun/tools/attach/PermissionTest.java
@@ -34,7 +34,7 @@
* @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
* @summary Basic unit tests for the VM attach mechanism.
* @library /lib/testlibrary
- * @run build Application Shutdown
+ * @build jdk.testlibrary.* Application Shutdown
* @run main PermissionTest
*
* Unit test for Attach API -
diff --git a/test/com/sun/tools/attach/ProviderTest.java b/test/com/sun/tools/attach/ProviderTest.java
index 58ea6d5..ea30b5b 100644
--- a/test/com/sun/tools/attach/ProviderTest.java
+++ b/test/com/sun/tools/attach/ProviderTest.java
@@ -33,7 +33,7 @@
* @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
* @summary Basic unit tests for the VM attach mechanism.
* @library /lib/testlibrary
- * @run build SimpleProvider
+ * @build jdk.testlibrary.* SimpleProvider
* @run main ProviderTest
*
* The test will attach and detach to/from the running Application.
diff --git a/test/java/awt/SplashScreen/FullscreenAfterSplash/FullScreenAfterSplash.java b/test/java/awt/SplashScreen/FullscreenAfterSplash/FullScreenAfterSplash.java
new file mode 100644
index 0000000..b5e019e
--- /dev/null
+++ b/test/java/awt/SplashScreen/FullscreenAfterSplash/FullScreenAfterSplash.java
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* This code is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License version 2 only, as
+* published by the Free Software Foundation.
+*
+* This code is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* version 2 for more details (a copy is included in the LICENSE file that
+* accompanied this code).
+*
+* You should have received a copy of the GNU General Public License version
+* 2 along with this work; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+*
+* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+* or visit www.oracle.com if you need additional information or have any
+* questions.
+*/
+
+import sun.awt.OSInfo;
+
+import java.awt.*;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.lang.InterruptedException;
+import java.lang.System;
+import java.lang.Thread;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import javax.swing.*;
+
+/*
+ * @test
+ * @bug 8024185
+ * @summary Native Mac OS X full screen does not work after showing the splash
+ * @library ../
+ * @build GenerateTestImage
+ * @run main GenerateTestImage
+ * @author Petr Pchelko area=awt.event
+ * @run main/othervm -splash:test.png FullScreenAfterSplash
+ */
+public class FullScreenAfterSplash {
+
+ private static JFrame frame;
+
+ private static volatile boolean windowEnteringFullScreen = false;
+ private static volatile boolean windowEnteredFullScreen = false;
+
+ public static void main(String[] args) throws Exception {
+
+ if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+ System.out.println("The test is applicable only to Mac OS X. Passed");
+ return;
+ }
+ try {
+ //Move the mouse out, because it could interfere with the test.
+ Robot r = new Robot();
+ r.mouseMove(0, 0);
+ sleep();
+
+ SwingUtilities.invokeAndWait(FullScreenAfterSplash::createAndShowGUI);
+ sleep();
+
+ Point fullScreenButtonPos = frame.getLocation();
+ fullScreenButtonPos.translate(frame.getWidth() - 10, 10);
+ r.mouseMove(fullScreenButtonPos.x, fullScreenButtonPos.y);
+
+ //Cant use waitForIdle for full screen transition.
+ int waitCount = 0;
+ while (!windowEnteringFullScreen) {
+ r.mousePress(InputEvent.BUTTON1_MASK);
+ r.mouseRelease(InputEvent.BUTTON1_MASK);
+ Thread.sleep(100);
+ if (waitCount++ > 10) {
+ System.err.println("Can't enter full screen mode. Failed.");
+ System.exit(1);
+ }
+ }
+
+ waitCount = 0;
+ while (!windowEnteredFullScreen) {
+ Thread.sleep(100);
+ if (waitCount++ > 10) {
+ System.err.println("Can't enter full screen mode. Failed.");
+ System.exit(1);
+ }
+ }
+ } finally {
+ if (frame != null) {
+ frame.dispose();
+ }
+ }
+ }
+
+ private static void createAndShowGUI() {
+ frame = new JFrame(" Fullscreen OSX Bug ");
+ frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ enableFullScreen(frame);
+ frame.setBounds(100, 100, 100, 100);
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+ /*
+ * Use reflection to make a test compilable on not Mac OS X
+ */
+ private static void enableFullScreen(Window window) {
+ try {
+ Class<?> fullScreenUtilities = Class.forName("com.apple.eawt.FullScreenUtilities");
+ Method setWindowCanFullScreen = fullScreenUtilities.getMethod("setWindowCanFullScreen", Window.class, boolean.class);
+ setWindowCanFullScreen.invoke(fullScreenUtilities, window, true);
+ Class fullScreenListener = Class.forName("com.apple.eawt.FullScreenListener");
+ Object listenerObject = Proxy.newProxyInstance(fullScreenListener.getClassLoader(), new Class[]{fullScreenListener}, (proxy, method, args) -> {
+ switch (method.getName()) {
+ case "windowEnteringFullScreen":
+ windowEnteringFullScreen = true;
+ break;
+ case "windowEnteredFullScreen":
+ windowEnteredFullScreen = true;
+ break;
+ }
+ return null;
+ });
+ Method addFullScreenListener = fullScreenUtilities.getMethod("addFullScreenListenerTo", Window.class, fullScreenListener);
+ addFullScreenListener.invoke(fullScreenUtilities, window, listenerObject);
+ } catch (Exception e) {
+ throw new RuntimeException("FullScreen utilities not available", e);
+ }
+ }
+
+ private static void sleep() {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ignored) { }
+ }
+}
diff --git a/test/java/awt/SplashScreen/GenerateTestImage.java b/test/java/awt/SplashScreen/GenerateTestImage.java
new file mode 100644
index 0000000..9c06133
--- /dev/null
+++ b/test/java/awt/SplashScreen/GenerateTestImage.java
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* This code is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License version 2 only, as
+* published by the Free Software Foundation.
+*
+* This code is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* version 2 for more details (a copy is included in the LICENSE file that
+* accompanied this code).
+*
+* You should have received a copy of the GNU General Public License version
+* 2 along with this work; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+*
+* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+* or visit www.oracle.com if you need additional information or have any
+* questions.
+*/
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileOutputStream;
+
+/**
+ * A utility to generate a test image for the SplashScreen test
+ */
+public class GenerateTestImage {
+ private static final int IMAGE_SIZE = 20;
+
+ public static void main(String[] args) throws Exception {
+ String path = System.getProperty("test.classes") + File.separator + "test.png";
+
+ BufferedImage image = new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D graphics2D = image.createGraphics();
+ graphics2D.setColor(Color.red);
+ graphics2D.fillOval(0, 0, IMAGE_SIZE, IMAGE_SIZE);
+ graphics2D.dispose();;
+
+ try(FileOutputStream fos = new FileOutputStream(path)) {
+ ImageIO.write(image, "png", fos);
+ }
+ }
+}
diff --git a/test/java/awt/TextField/SelectionInvisibleTest/SelectionInvisibleTest.java b/test/java/awt/TextField/SelectionInvisibleTest/SelectionInvisibleTest.java
new file mode 100644
index 0000000..be45128
--- /dev/null
+++ b/test/java/awt/TextField/SelectionInvisibleTest/SelectionInvisibleTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.TextField;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+import sun.awt.SunToolkit;
+
+/**
+ * @test
+ * @bug 8036110
+ * @author Alexander Scherbatiy
+ * @summary In TextField can only select text visible or to the left
+ * @run main SelectionInvisibleTest
+ */
+
+public class SelectionInvisibleTest {
+
+ private static final String TEXT = "One Two Three Four Five Six Seven Eight Nine ";
+ private static final String LAST_WORD = "Ten";
+
+ public static void main(String[] args) throws Exception {
+
+ Frame frame = new Frame();
+ frame.setSize(300, 200);
+ TextField textField = new TextField(TEXT + LAST_WORD, 30);
+ Panel panel = new Panel(new FlowLayout());
+ panel.add(textField);
+ frame.add(panel);
+ frame.setVisible(true);
+
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ toolkit.realSync();
+
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+
+ Point point = textField.getLocationOnScreen();
+ int x = point.x + textField.getWidth() / 2;
+ int y = point.y + textField.getHeight() / 2;
+ robot.mouseMove(x, y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ toolkit.realSync();
+
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ int N = 10;
+ int dx = textField.getWidth() / N;
+ for (int i = 0; i < N; i++) {
+ x += dx;
+ robot.mouseMove(x, y);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ toolkit.realSync();
+
+ if (!textField.getSelectedText().endsWith(LAST_WORD)) {
+ throw new RuntimeException("Last word is not selected!");
+ }
+ }
+}
diff --git a/test/java/awt/Window/AlwaysOnTop/TestAlwaysOnTopBeforeShow.java b/test/java/awt/Window/AlwaysOnTop/TestAlwaysOnTopBeforeShow.java
new file mode 100644
index 0000000..21ddb23
--- /dev/null
+++ b/test/java/awt/Window/AlwaysOnTop/TestAlwaysOnTopBeforeShow.java
@@ -0,0 +1,472 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+@test
+@bug 6236247
+@summary Test that setting of always-on-top flags before showing window works
+@author dom@sparc.spb.su: area=awt.toplevel
+@run main TestAlwaysOnTopBeforeShow
+*/
+
+/**
+ * TestAlwaysOnTopBeforeShow.java
+ *
+ * summary: Test that always-on-top works in the following situations:
+ * - when set on a window before showing
+ * - when set on a child dialog
+ * - that it doesn't generate focus event when set on an invisible window
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+import sun.awt.SunToolkit;
+
+
+//*** global search and replace TestAlwaysOnTopBeforeShow with name of the test ***
+
+public class TestAlwaysOnTopBeforeShow
+{
+
+ //*** test-writer defined static variables go here ***
+
+ private static AtomicBoolean focused = new AtomicBoolean();
+ private static AtomicBoolean pressed = new AtomicBoolean();
+ private static volatile Object pressedTarget;
+ private static void init()
+ {
+ //*** Create instructions for the user here ***
+
+ Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+ public void eventDispatched(AWTEvent e) {
+ if (e.getID() == MouseEvent.MOUSE_PRESSED) {
+ synchronized(pressed) {
+ pressed.set(true);
+ pressedTarget = e.getSource();
+ pressed.notifyAll();
+ }
+ }
+ }
+ }, AWTEvent.MOUSE_EVENT_MASK);
+
+ Frame f = new Frame("always-on-top");
+ f.setBounds(0, 0, 200, 200);
+ f.addFocusListener(new FocusAdapter() {
+ public void focusGained(FocusEvent e) {
+ synchronized(focused) {
+ focused.set(true);
+ focused.notifyAll();
+ }
+ }
+ });
+
+ f.setAlwaysOnTop(true);
+
+ waitForIdle(1000);
+ if (focused.get()) {
+ throw new RuntimeException("Always-on-top generated focus event");
+ }
+
+ f.setVisible(true);
+
+ waitFocused(f, focused);
+ focused.set(false);
+
+ Frame f2 = new Frame("auxilary");
+ f2.setBounds(100, 0, 200, 100);
+ f2.setVisible(true);
+ f2.toFront();
+ waitForIdle(1000);
+
+ Point location = f.getLocationOnScreen();
+ Dimension size = f.getSize();
+ checkOnTop(f, f2, location.x + size.width / 2, location.y + size.height / 2);
+
+ Dialog d = new Dialog(f, "Always-on-top");
+ d.pack();
+ d.setBounds(0, 0, 100, 100);
+
+ waitForIdle(1000);
+ checkOnTop(f, f2, location.x + size.width / 2, location.y + size.height / 2);
+ waitForIdle(1000);
+
+ focused.set(false);
+ f.setVisible(false);
+ f.setAlwaysOnTop(false);
+ waitForIdle(1000);
+ if (focused.get()) {
+ throw new RuntimeException("Always-on-top generated focus event");
+ }
+
+ TestAlwaysOnTopBeforeShow.pass();
+
+ }//End init()
+
+ private static void waitForIdle(int mls) {
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ try {
+ Thread.sleep(mls);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ static void waitFocused(Window w, AtomicBoolean b) {
+ try {
+ synchronized(b) {
+ if (w.isFocusOwner()) {
+ return;
+ }
+ b.wait(3000);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ if (!w.isFocusOwner()) {
+ throw new RuntimeException("Can't make " + w + " focus owner");
+ }
+ }
+
+ static void checkOnTop(Window ontop, Window under, int x, int y) {
+ under.toFront();
+ try {
+ Robot robot = new Robot();
+ robot.mouseMove(x, y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ synchronized(pressed) {
+ if (pressed.get()) {
+ if (pressedTarget != ontop) {
+ throw new RuntimeException("Pressed at wrong location: " + pressedTarget);
+ }
+ } else {
+ pressed.wait(5000);
+ }
+ }
+ if (!pressed.get() || pressedTarget != ontop) {
+ throw new RuntimeException("Pressed at wrong location: " + pressedTarget);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+
+ private static Thread mainThread = null;
+
+ private static int sleepTime = 300000;
+
+ // Not sure about what happens if multiple of this test are
+ // instantiated in the same VM. Being static (and using
+ // static vars), it aint gonna work. Not worrying about
+ // it for now.
+ public static void main( String args[] ) throws InterruptedException
+ {
+ mainThread = Thread.currentThread();
+ try
+ {
+ init();
+ }
+ catch( TestPassedException e )
+ {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test pass nor test fail has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try
+ {
+ Thread.sleep( sleepTime );
+ //Timed out, so fail the test
+ throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+ }
+ catch (InterruptedException e)
+ {
+ //The test harness may have interrupted the test. If so, rethrow the exception
+ // so that the harness gets it and deals with it.
+ if( ! testGeneratedInterrupt ) throw e;
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+
+ if ( theTestPassed == false )
+ {
+ throw new RuntimeException( failureMessage );
+ }
+ }
+
+ }//main
+
+ public static synchronized void setTimeoutTo( int seconds )
+ {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass()
+ {
+ Sysout.println( "The test passed." );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //first check if this is executing in main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }//pass()
+
+ public static synchronized void fail()
+ {
+ //test writer didn't specify why test failed, so give generic
+ fail( "it just plain failed! :-)" );
+ }
+
+ public static synchronized void fail( String whyFailed )
+ {
+ Sysout.println( "The test failed: " + whyFailed );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //check if this called from main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException( whyFailed );
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }//fail()
+
+}// class TestAlwaysOnTopBeforeShow
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// if want to make listeners, here is the recommended place for them, then instantiate
+// them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+ static int newVar = 0;
+
+ public void eventDispatched(AWTEvent e)
+ {
+ //Counting events to see if we get enough
+ eventCount++;
+
+ if( eventCount == 20 )
+ {
+ //got enough events, so pass
+
+ TestAlwaysOnTopBeforeShow.pass();
+ }
+ else if( tries == 20 )
+ {
+ //tried too many times without getting enough events so fail
+
+ TestAlwaysOnTopBeforeShow.fail();
+ }
+
+ }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ System.out.println(messageIn);
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
diff --git a/test/java/awt/datatransfer/DataFlavor/EqualsHashCodeSymmetryTest/EqualsHashCodeSymmetryTest.java b/test/java/awt/datatransfer/DataFlavor/EqualsHashCodeSymmetryTest/EqualsHashCodeSymmetryTest.java
new file mode 100644
index 0000000..bfe820f
--- /dev/null
+++ b/test/java/awt/datatransfer/DataFlavor/EqualsHashCodeSymmetryTest/EqualsHashCodeSymmetryTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.datatransfer.DataFlavor;
+
+/**
+ * @test
+ * @bug 8038999
+ * @summary DataFlavor.equals is not symmetric
+ * @author Petr Pchelko <petr.pchelko@oracle.com>
+ */
+public class EqualsHashCodeSymmetryTest {
+
+ private static final DataFlavor[] dataFlavors = {
+ DataFlavor.stringFlavor,
+ DataFlavor.imageFlavor,
+ DataFlavor.javaFileListFlavor,
+ DataFlavor.allHtmlFlavor,
+ DataFlavor.selectionHtmlFlavor,
+ DataFlavor.fragmentHtmlFlavor,
+ createFlavor("text/html; class=java.lang.String"),
+ new DataFlavor(String.class, "My test flavor number 1"),
+ new DataFlavor(String.class, "My test flavor number 2"),
+ new DataFlavor(StringBuilder.class, "My test flavor number 1")
+ };
+
+ public static void main(String[] args) {
+ testEqualsSymmetry();
+ testEqualsHashCodeConsistency();
+ testSimpleCollision();
+ }
+
+ private static void testEqualsSymmetry() {
+ for (DataFlavor flavor1 : dataFlavors) {
+ for (DataFlavor flavor2 : dataFlavors) {
+ if (flavor1.equals(flavor2) != flavor2.equals(flavor1)) {
+ throw new RuntimeException(
+ String.format("Equals is not symmetric for %s and %s", flavor1, flavor2));
+ }
+ }
+ }
+ }
+
+ private static void testEqualsHashCodeConsistency() {
+ for (DataFlavor flavor1 : dataFlavors) {
+ for (DataFlavor flavor2 : dataFlavors) {
+ if ((flavor1.equals(flavor2) && flavor1.hashCode() != flavor2.hashCode())) {
+ throw new RuntimeException(
+ String.format("Equals and hash code not consistent for %s and %s", flavor1, flavor2));
+ }
+ }
+ }
+ }
+
+ private static void testSimpleCollision() {
+ if (createFlavor("text/html; class=java.lang.String").hashCode() == DataFlavor.allHtmlFlavor.hashCode()) {
+ throw new RuntimeException("HashCode collision because the document parameter is not used");
+ }
+ }
+
+ private static DataFlavor createFlavor(String mime) {
+ try {
+ return new DataFlavor(mime);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorAppletTest.html b/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorAppletTest.html
new file mode 100644
index 0000000..7d4a3a5
--- /dev/null
+++ b/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorAppletTest.html
@@ -0,0 +1,48 @@
+<!--
+ Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6887703
+ @summary Unsigned applet can retrieve the dragged information before drop action occurs
+ @author : area=dnd
+ @library ../../regtesthelpers
+ @library ../../regtesthelpers/process
+ @build Util
+ @build ProcessResults ProcessCommunicator
+ @run applet/othervm DragInterceptorAppletTest.html
+
+-->
+<head>
+<title> Unsigned applet can retrieve the dragged information before drop action occurs </title>
+</head>
+<body>
+
+<h1>DragInterceptorAppletTest<br>Bug ID: 6887703</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="DragInterceptorAppletTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
diff --git a/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorAppletTest.java b/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorAppletTest.java
new file mode 100644
index 0000000..5f70e2d
--- /dev/null
+++ b/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorAppletTest.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ test
+ @bug 6887703
+ @summary Unsigned applet can retrieve the dragged information before drop action occurs
+ @author : area=dnd
+ @run applet DragInterceptorAppletTest.html
+*/
+
+/**
+ * DragInterceptorAppletTest.java
+ *
+ * summary: Unsigned applet can retrieve the dragged information before drop action occurs
+ */
+
+import static java.lang.Thread.sleep;
+
+import test.java.awt.regtesthelpers.process.ProcessCommunicator;
+import test.java.awt.regtesthelpers.process.ProcessResults;
+import test.java.awt.regtesthelpers.Util;
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.InputEvent;
+
+public class DragInterceptorAppletTest extends Applet {
+
+ public void init() {
+ setLayout(new BorderLayout());
+ }//End init()
+
+ public void start() {
+
+ SourceFrame sourceFrame = new SourceFrame();
+
+ Util.waitForIdle(null);
+
+ String [] args = new String [] {
+ String.valueOf(sourceFrame.getNextLocationX()),
+ String.valueOf(sourceFrame.getNextLocationY()),
+ String.valueOf(sourceFrame.getDragSourcePointX()),
+ String.valueOf(sourceFrame.getDragSourcePointY()),
+ };
+ String classpath = System.getProperty("java.class.path");
+ ProcessResults processResults =
+ ProcessCommunicator.executeChildProcess(this.getClass(),classpath,args);
+
+ verifyTestResults(processResults);
+
+ }// start()
+
+ private static void verifyTestResults(ProcessResults processResults) {
+
+ switch (processResults.getExitValue()) {
+ case InterprocessMessages.DATA_WAS_INTERCEPTED_AND_EXCEPTION_HANDLER_WAS_NOT_TRIGGERED:
+ processResults.printProcessErrorOutput(System.err);
+ throw new RuntimeException("TEST IS FAILED: Target applet can intercept data " +
+ "without a clipboard permission and an exception handler was not triggered.");
+ //Unreachable...
+
+ case InterprocessMessages.DATA_WAS_INTERCEPTED:
+ processResults.printProcessErrorOutput(System.err);
+ throw new RuntimeException("TEST IS FAILED: Target applet can intercept data " +
+ "without a clipboard permission");
+ //Unreachable...
+
+ case InterprocessMessages.EXCEPTION_HANDLER_WAS_NOT_TRIGGERED:
+ processResults.printProcessErrorOutput(System.err);
+ throw new RuntimeException("TEST IS FAILED: An exception handler was not triggered.");
+ //Unreachable...
+
+ }
+
+ // The child process throws an exception. do not look at the stderr.
+ processResults.verifyStdErr(System.err);
+ processResults.verifyProcessExitValue(System.err);
+ processResults.printProcessStandartOutput(System.out);
+ }
+
+ //We cannot make an instance of the applet without the default constructor
+ public DragInterceptorAppletTest() {
+ super();
+ }
+
+ //We need in this constructor to pass frame position between JVMs
+ public DragInterceptorAppletTest(Point targetFrameLocation, Point dragSourcePoint)
+ throws InterruptedException
+ {
+ DragInterceptorFrame targetFrame = new DragInterceptorFrame(targetFrameLocation);
+
+ Util.waitForIdle(null);
+
+ final Robot robot = Util.createRobot();
+
+ robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY());
+ sleep(100);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ sleep(100);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ sleep(100);
+
+ Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(),
+ InputEvent.BUTTON1_MASK);
+
+ sleep(2000);
+ ProcessCommunicator.destroyProcess();
+ }
+
+ enum InterprocessArguments {
+ TARGET_FRAME_X_POSITION_ARGUMENT,
+ TARGET_FRAME_Y_POSITION_ARGUMENT,
+ DRAG_SOURCE_POINT_X_ARGUMENT,
+ DRAG_SOURCE_POINT_Y_ARGUMENT;
+
+ int extract (String [] args) {
+ return Integer.parseInt(args[this.ordinal()]);
+ }
+ }
+
+ public static void main (String [] args) {
+ Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args),
+ InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args));
+ Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args),
+ InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args));
+ try {
+ new DragInterceptorAppletTest(targetFrameLocation, dragSourcePoint);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+}// class DragInterceptorAppletTest
diff --git a/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorFrame.java b/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorFrame.java
new file mode 100644
index 0000000..69d4a01
--- /dev/null
+++ b/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorFrame.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.dnd.*;
+import java.io.IOException;
+import java.security.Permission;
+import java.security.AccessControlException;
+
+class DragInterceptorFrame extends Frame implements DropTargetListener {
+
+ private static int exitMessage = InterprocessMessages.TEST_PASSED;
+ private static boolean dataIsAccessible = false;
+ private static boolean exceptionHasBeenThrown = false;
+
+ DragInterceptorFrame(Point location) {
+ System.setSecurityManager(new ClipboardDefender());
+ initGUI(location);
+ setDropTarget(new DropTarget(this, DnDConstants.ACTION_COPY,
+ this));
+ }
+
+ private void initGUI(Point location) {
+ this.setLocation(location);
+ this.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ DragInterceptorFrame.this.dispose();
+ }
+ });
+ setSize (200, 200);
+ this.setVisible(true);
+ }
+
+ public void dragEnter(DropTargetDragEvent dtde) {
+ // We want to set the exception handler on EDT
+ Thread.currentThread().setUncaughtExceptionHandler (
+ new Thread.UncaughtExceptionHandler() {
+ public void uncaughtException(Thread t, Throwable e) {
+ exceptionHasBeenThrown = true;
+ }
+ }
+ );
+ examineTransferable(dtde);
+ }
+
+ public void dragOver(DropTargetDragEvent dtde) {
+ examineTransferable(dtde);
+ }
+
+ public void dropActionChanged(DropTargetDragEvent dtde) {
+ examineTransferable(dtde);
+ }
+
+ public void dragExit(DropTargetEvent dte) {}
+
+ public void drop(DropTargetDropEvent dtde) {
+
+ if (dataIsAccessible && !exceptionHasBeenThrown) {
+ exitMessage = InterprocessMessages.DATA_WAS_INTERCEPTED_AND_EXCEPTION_HANDLER_WAS_NOT_TRIGGERED;
+ } else if (dataIsAccessible) {
+ exitMessage = InterprocessMessages.DATA_WAS_INTERCEPTED;
+ } else if (!exceptionHasBeenThrown) {
+ exitMessage = InterprocessMessages.EXCEPTION_HANDLER_WAS_NOT_TRIGGERED;
+ }
+
+ // This returns the diagnostic code from the child VM
+ System.exit(exitMessage);
+ }
+
+ Point getDropTargetPoint() {
+ return new Point((int)getLocationOnScreen().getX()+(getWidth()/2),
+ (int)getLocationOnScreen().getY()+(getHeight()/2));
+ }
+
+ private void examineTransferable(DropTargetDragEvent dtde) {
+ if (dtde.getCurrentDataFlavorsAsList().contains(DataFlavor.stringFlavor)) {
+ dtde.acceptDrag(DnDConstants.ACTION_COPY);
+ try{
+ if (null != dtde.getTransferable().getTransferData(DataFlavor.stringFlavor)) {
+ dataIsAccessible = true;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ exitMessage = InterprocessMessages.UNEXPECTED_IO_EXCEPTION;
+ } catch (UnsupportedFlavorException e) {
+ e.printStackTrace();
+ exitMessage = InterprocessMessages.UNEXPECTED_UNSUPPORTED_FLAVOR_EXCEPTION;
+ }
+ }
+ }
+
+ static class ClipboardDefender extends SecurityManager {
+ public void checkPermission(Permission p) {
+ if (p instanceof java.awt.AWTPermission &&
+ p.getName().equals("accessClipboard")) {
+ throw new AccessControlException("access denied ");
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ new DragInterceptorFrame(new Point(200,200));
+ }
+}
diff --git a/test/java/awt/dnd/DragInterceptorAppletTest/InterprocessMessages.java b/test/java/awt/dnd/DragInterceptorAppletTest/InterprocessMessages.java
new file mode 100644
index 0000000..6506565
--- /dev/null
+++ b/test/java/awt/dnd/DragInterceptorAppletTest/InterprocessMessages.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public interface InterprocessMessages {
+ final static int TEST_PASSED = 0;
+ final static int DATA_WAS_INTERCEPTED = 212;
+ final static int EXCEPTION_HANDLER_WAS_NOT_TRIGGERED = 213;
+ final static int DATA_WAS_INTERCEPTED_AND_EXCEPTION_HANDLER_WAS_NOT_TRIGGERED = 214;
+
+ final static int UNEXPECTED_IO_EXCEPTION = 400;
+ final static int UNEXPECTED_UNSUPPORTED_FLAVOR_EXCEPTION = 401;
+}
diff --git a/test/java/awt/dnd/DragInterceptorAppletTest/SourceFrame.java b/test/java/awt/dnd/DragInterceptorAppletTest/SourceFrame.java
new file mode 100644
index 0000000..7a7c833
--- /dev/null
+++ b/test/java/awt/dnd/DragInterceptorAppletTest/SourceFrame.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import test.java.awt.regtesthelpers.Util;
+
+import java.awt.*;
+import java.awt.datatransfer.StringSelection;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+
+class SourceFrame extends Frame implements DragGestureListener {
+
+ SourceFrame() {
+ super("Source File List Frame");
+ initGUI();
+ new DragSource().createDefaultDragGestureRecognizer(this,
+ DnDConstants.ACTION_COPY,this);
+ }
+
+ private void initGUI() {
+ this.addWindowListener(Util.getClosingWindowAdapter());
+ this.setLocation(300,250);
+ this.setSize(200,200);
+ this.setVisible(true);
+ }
+
+ int getNextLocationX() {
+ return getX()+getWidth();
+ }
+
+ int getNextLocationY() {
+ return getY();
+ }
+
+ int getDragSourcePointX() {
+ return (int)getLocationOnScreen().getX()+(getWidth()/2);
+ }
+
+ int getDragSourcePointY() {
+ return (int)getLocationOnScreen().getY()+ (getHeight()/2);
+ }
+
+ public void dragGestureRecognized(DragGestureEvent dge) {
+ dge.startDrag(null, new StringSelection("A TEXT"));
+ }
+}
diff --git a/test/java/awt/dnd/DragSourceListenerSerializationTest/DragSourceListenerSerializationTest.java b/test/java/awt/dnd/DragSourceListenerSerializationTest/DragSourceListenerSerializationTest.java
new file mode 100644
index 0000000..2087c60
--- /dev/null
+++ b/test/java/awt/dnd/DragSourceListenerSerializationTest/DragSourceListenerSerializationTest.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ @test
+ @bug 4422345 8039083
+ @summary tests serialization of DragSourceListeners
+ @author das@sparc.spb.su area=dnd
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.Asserts
+ @run main/othervm DragSourceListenerSerializationTest
+*/
+
+import java.awt.Button;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.awt.datatransfer.StringSelection;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceAdapter;
+import java.awt.dnd.DragSourceContext;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DragSourceMotionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseEvent;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.TooManyListenersException;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static jdk.testlibrary.Asserts.assertEquals;
+
+public class DragSourceListenerSerializationTest {
+ public static void main(String[] args) throws Exception {
+ DragSource ds = new DragSource();
+ TestDragSourceAdapter dsa1 = new TestDragSourceAdapter(1);
+ TestDragSourceAdapter dsa2 = new TestDragSourceAdapter(2);
+ Component c = new Button();
+ DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(c,
+ DnDConstants.ACTION_COPY,
+ e -> e.startDrag(null, null));
+ MouseEvent me = new MouseEvent(c, MouseEvent.MOUSE_PRESSED, 0,
+ InputEvent.CTRL_MASK, 100, 100, 0, false);
+ DragGestureEvent dge = new DragGestureEvent(dgr, DnDConstants.ACTION_COPY,
+ new Point(100, 100),
+ Arrays.asList(me));
+ DragSourceContext dsc = new DragSourceContext(
+ Toolkit.getDefaultToolkit().createDragSourceContextPeer(dge),
+ dge,
+ new Cursor(Cursor.HAND_CURSOR),
+ null, null, new StringSelection("TEXT"), null);
+
+ ds.addDragSourceListener(dsa1);
+ ds.addDragSourceListener(dsa2);
+ ds.addDragSourceListener(dsa2);
+ ds.addDragSourceMotionListener(dsa1);
+ ds.addDragSourceMotionListener(dsa1);
+ ds.addDragSourceMotionListener(dsa2);
+ dsc.addDragSourceListener(dsa2);
+
+ byte[] serialized;
+ try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos)) {
+ oos.writeObject(dsc);
+ serialized = bos.toByteArray();
+ }
+
+ DragSourceContext dsc_copy;
+ try (ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
+ ObjectInputStream ois = new ObjectInputStream(bis)) {
+ dsc_copy = (DragSourceContext) ois.readObject();
+ }
+
+ try {
+ dsc_copy.addDragSourceListener(dsa1);
+ throw new RuntimeException("Test failed. Listener addition succeeded");
+ } catch (TooManyListenersException ignored) {
+ }
+
+ try {
+ dsc_copy.addDragSourceListener(dsa2);
+ throw new RuntimeException("Test failed. Listener addition succeeded");
+ } catch (TooManyListenersException ignored) {
+ }
+
+ try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos)) {
+ oos.writeObject(ds);
+ serialized = bos.toByteArray();
+ }
+
+ DragSource ds_copy;
+ try (ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
+ ObjectInputStream ois = new ObjectInputStream(bis)) {
+ ds_copy = (DragSource) ois.readObject();
+ }
+
+ DragSourceListener[] dsls = ds_copy.getDragSourceListeners();
+ assertEquals(3, dsls.length, "DragSourceListeners number");
+ assertEquals(1, Stream.of(dsls).filter(dsa1::equals).collect(Collectors.counting()).intValue());
+ assertEquals(2, Stream.of(dsls).filter(dsa2::equals).collect(Collectors.counting()).intValue());
+
+ DragSourceMotionListener[] dsmls = ds_copy.getDragSourceMotionListeners();
+ assertEquals(3, dsmls.length, "DragSourceMotionListeners number");
+ assertEquals(2, Stream.of(dsmls).filter(dsa1::equals).collect(Collectors.counting()).intValue());
+ assertEquals(1, Stream.of(dsmls).filter(dsa2::equals).collect(Collectors.counting()).intValue());
+ }
+}
+
+class TestDragSourceAdapter extends DragSourceAdapter implements Serializable {
+ final int id;
+
+ TestDragSourceAdapter(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof TestDragSourceAdapter) {
+ TestDragSourceAdapter tdsa = (TestDragSourceAdapter) obj;
+ return tdsa.getId() == getId();
+ }
+ return false;
+ }
+}
diff --git a/test/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.html b/test/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.html
new file mode 100644
index 0000000..2b3aa7a
--- /dev/null
+++ b/test/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.html
@@ -0,0 +1,43 @@
+<!--
+ Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<!--
+ @test
+ @bug 4658741
+ @summary verifies that getDropSuccess() returns correct value for inter-JVM DnD
+ @author das@sparc.spb.su area=dnd
+ @run applet InterJVMGetDropSuccessTest.html
+ -->
+<head>
+<title> </title>
+</head>
+<body>
+
+<h1>InterJVMGetDropSuccessTest<br>Bug ID: 4658741</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="InterJVMGetDropSuccessTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
diff --git a/test/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java b/test/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java
new file mode 100644
index 0000000..9307fa2
--- /dev/null
+++ b/test/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java
@@ -0,0 +1,499 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ test
+ @bug 4658741
+ @summary verifies that getDropSuccess() returns correct value for inter-JVM DnD
+ @author das@sparc.spb.su area=dnd
+ @run applet InterJVMGetDropSuccessTest.html
+*/
+
+// Note there is no @ in front of test above. This is so that the
+// harness will not mistake this file as a test file. It should
+// only see the html file as a test file. (the harness runs all
+// valid test files, so it would run this test twice if this file
+// were valid as well as the html file.)
+// Also, note the area= after Your Name in the author tag. Here, you
+// should put which functional area the test falls in. See the
+// AWT-core home page -> test areas and/or -> AWT team for a list of
+// areas.
+// Note also the 'InterJVMGetDropSuccessTest.html' in the run tag. This should
+// be changed to the name of the test.
+
+
+/**
+ * InterJVMGetDropSuccessTest.java
+ *
+ * summary: verifies that getDropSuccess() returns correct value for inter-JVM DnD
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.datatransfer.*;
+import java.awt.dnd.*;
+import java.awt.event.*;
+import java.io.*;
+import javax.swing.*;
+
+
+//Automated tests should run as applet tests if possible because they
+// get their environments cleaned up, including AWT threads, any
+// test created threads, and any system resources used by the test
+// such as file descriptors. (This is normally not a problem as
+// main tests usually run in a separate VM, however on some platforms
+// such as the Mac, separate VMs are not possible and non-applet
+// tests will cause problems). Also, you don't have to worry about
+// synchronisation stuff in Applet tests they way you do in main
+// tests...
+
+
+public class InterJVMGetDropSuccessTest extends Applet {
+
+ private int returnCode = Util.CODE_NOT_RETURNED;
+ private boolean successCodes[] = { true, false };
+ private int dropCount = 0;
+
+ final Frame frame = new Frame("Target Frame");
+
+ final DropTargetListener dropTargetListener = new DropTargetAdapter() {
+ public void drop(DropTargetDropEvent dtde) {
+ dtde.acceptDrop(DnDConstants.ACTION_COPY);
+ dtde.dropComplete(successCodes[dropCount]);
+ dropCount++;
+ }
+ };
+ final DropTarget dropTarget = new DropTarget(frame, dropTargetListener);
+
+ public void init() {
+ //Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test",
+ "simply wait until it is done"
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ frame.setTitle("Test frame");
+ frame.setBounds(100, 100, 150, 150);
+ } // init()
+
+ public void start() {
+
+ frame.setVisible(true);
+
+ try {
+ Thread.sleep(Util.FRAME_ACTIVATION_TIMEOUT);
+
+ Point p = frame.getLocationOnScreen();
+ Dimension d = frame.getSize();
+
+ String javaPath = System.getProperty("java.home", "");
+ String command = javaPath + File.separator + "bin" +
+ File.separator + "java -cp " + System.getProperty("test.classes", ".") +
+ " Child " +
+ p.x + " " + p.y + " " + d.width + " " + d.height;
+
+ Process process = Runtime.getRuntime().exec(command);
+ returnCode = process.waitFor();
+
+ InputStream errorStream = process.getErrorStream();
+ int count = errorStream.available();
+ if (count > 0) {
+ byte[] b = new byte[count];
+ errorStream.read(b);
+ System.err.println("========= Child VM System.err ========");
+ System.err.print(new String(b));
+ System.err.println("======================================");
+ }
+
+ InputStream outputStream = process.getInputStream();
+ count = outputStream.available();
+ if (count > 0) {
+ byte[] b = new byte[count];
+ outputStream.read(b);
+ System.err.println("========= Child VM System.out ========");
+ System.err.print(new String(b));
+ System.err.println("======================================");
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ switch (returnCode) {
+ case Util.CODE_NOT_RETURNED:
+ throw new RuntimeException("Child VM: failed to start");
+ case Util.CODE_FAILURE:
+ throw new RuntimeException("Child VM: abnormal termination");
+ default:
+ if (dropCount == 2) {
+ int expectedRetCode = 0;
+ if (successCodes[0]) {
+ expectedRetCode |= Util.CODE_FIRST_SUCCESS;
+ }
+ if (successCodes[1]) {
+ expectedRetCode |= Util.CODE_SECOND_SUCCESS;
+ }
+ if (expectedRetCode != returnCode) {
+ throw new RuntimeException("The test failed. Expected:" +
+ expectedRetCode + ". Returned:" +
+ returnCode);
+ }
+ }
+ break;
+ }
+ } // start()
+} // class InterJVMGetDropSuccessTest
+
+final class Util implements AWTEventListener {
+ public static final int CODE_NOT_RETURNED = -1;
+ public static final int CODE_FIRST_SUCCESS = 0x2;
+ public static final int CODE_SECOND_SUCCESS = 0x2;
+ public static final int CODE_FAILURE = 0x1;
+
+ public static final int FRAME_ACTIVATION_TIMEOUT = 3000;
+
+ static final Object SYNC_LOCK = new Object();
+ static final int MOUSE_RELEASE_TIMEOUT = 1000;
+
+ static final Util theInstance = new Util();
+
+ static {
+ Toolkit.getDefaultToolkit().addAWTEventListener(theInstance, AWTEvent.MOUSE_EVENT_MASK);
+ }
+
+ public static Point getCenterLocationOnScreen(Component c) {
+ Point p = c.getLocationOnScreen();
+ Dimension d = c.getSize();
+ p.translate(d.width / 2, d.height / 2);
+ return p;
+ }
+
+ public static int sign(int n) {
+ return n < 0 ? -1 : n == 0 ? 0 : 1;
+ }
+
+ private Component clickedComponent = null;
+
+ private void reset() {
+ clickedComponent = null;
+ }
+
+ public void eventDispatched(AWTEvent e) {
+ if (e.getID() == MouseEvent.MOUSE_RELEASED) {
+ clickedComponent = (Component)e.getSource();
+ synchronized (SYNC_LOCK) {
+ SYNC_LOCK.notifyAll();
+ }
+ }
+ }
+
+ public static boolean pointInComponent(Robot robot, Point p, Component comp)
+ throws InterruptedException {
+ return theInstance.pointInComponentImpl(robot, p, comp);
+ }
+
+ private boolean pointInComponentImpl(Robot robot, Point p, Component comp)
+ throws InterruptedException {
+ robot.waitForIdle();
+ reset();
+ robot.mouseMove(p.x, p.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ synchronized (SYNC_LOCK) {
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ SYNC_LOCK.wait(MOUSE_RELEASE_TIMEOUT);
+ }
+
+ Component c = clickedComponent;
+
+ while (c != null && c != comp) {
+ c = c.getParent();
+ }
+
+ return c == comp;
+ }
+}
+
+class Child {
+ static class DragSourceDropListener extends DragSourceAdapter {
+ private boolean finished = false;
+ private boolean dropSuccess = false;
+
+ public void reset() {
+ finished = false;
+ dropSuccess = false;
+ }
+
+ public boolean isDropFinished() {
+ return finished;
+ }
+
+ public boolean getDropSuccess() {
+ return dropSuccess;
+ }
+
+ public void dragDropEnd(DragSourceDropEvent dsde) {
+ finished = true;
+ dropSuccess = dsde.getDropSuccess();
+ synchronized (Util.SYNC_LOCK) {
+ Util.SYNC_LOCK.notifyAll();
+ }
+ }
+ }
+
+ final Frame frame = new Frame("Source Frame");
+ final DragSource dragSource = DragSource.getDefaultDragSource();
+ final DragSourceDropListener dragSourceListener = new DragSourceDropListener();
+ final Transferable transferable = new StringSelection("TEXT");
+ final DragGestureListener dragGestureListener = new DragGestureListener() {
+ public void dragGestureRecognized(DragGestureEvent dge) {
+ dge.startDrag(null, transferable, dragSourceListener);
+ }
+ };
+ final DragGestureRecognizer dragGestureRecognizer =
+ dragSource.createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY,
+ dragGestureListener);
+
+ public static void main(String[] args) {
+ Child child = new Child();
+ child.run(args);
+ }
+
+ public void run(String[] args) {
+ try {
+ if (args.length != 4) {
+ throw new RuntimeException("Incorrect command line arguments.");
+ }
+
+ int x = Integer.parseInt(args[0]);
+ int y = Integer.parseInt(args[1]);
+ int w = Integer.parseInt(args[2]);
+ int h = Integer.parseInt(args[3]);
+
+ frame.setBounds(300, 200, 150, 150);
+ frame.setVisible(true);
+
+ Thread.sleep(Util.FRAME_ACTIVATION_TIMEOUT);
+
+ Point sourcePoint = Util.getCenterLocationOnScreen(frame);
+
+ Point targetPoint = new Point(x + w / 2, y + h / 2);
+
+ Robot robot = new Robot();
+ robot.mouseMove(sourcePoint.x, sourcePoint.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (Point p = new Point(sourcePoint); !p.equals(targetPoint);
+ p.translate(Util.sign(targetPoint.x - p.x),
+ Util.sign(targetPoint.y - p.y))) {
+ robot.mouseMove(p.x, p.y);
+ Thread.sleep(50);
+ }
+
+ synchronized (Util.SYNC_LOCK) {
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.SYNC_LOCK.wait(Util.FRAME_ACTIVATION_TIMEOUT);
+ }
+
+ if (!dragSourceListener.isDropFinished()) {
+ throw new RuntimeException("Drop not finished");
+ }
+
+ boolean success1 = dragSourceListener.getDropSuccess();
+
+ dragSourceListener.reset();
+ robot.mouseMove(sourcePoint.x, sourcePoint.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (Point p = new Point(sourcePoint); !p.equals(targetPoint);
+ p.translate(Util.sign(targetPoint.x - p.x),
+ Util.sign(targetPoint.y - p.y))) {
+ robot.mouseMove(p.x, p.y);
+ Thread.sleep(50);
+ }
+
+ synchronized (Util.SYNC_LOCK) {
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.SYNC_LOCK.wait(Util.FRAME_ACTIVATION_TIMEOUT);
+ }
+
+ if (!dragSourceListener.isDropFinished()) {
+ throw new RuntimeException("Drop not finished");
+ }
+
+ boolean success2 = dragSourceListener.getDropSuccess();
+ int retCode = 0;
+
+ if (success1) {
+ retCode |= Util.CODE_FIRST_SUCCESS;
+ }
+ if (success2) {
+ retCode |= Util.CODE_SECOND_SUCCESS;
+ }
+ // This returns the diagnostic code from the child VM
+ System.exit(retCode);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ // This returns the diagnostic code from the child VM
+ System.exit(Util.CODE_FAILURE);
+ }
+ } // run()
+} // class child
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+ {
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.show();
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.show();
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+ }// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+ {
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("South", messageText);
+
+ pack();
+
+ show();
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ }
+
+ }// TestDialog class
diff --git a/test/java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.html b/test/java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.html
new file mode 100644
index 0000000..c19a0a0
--- /dev/null
+++ b/test/java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.html
@@ -0,0 +1,45 @@
+<!--
+ Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<!--
+ @test
+ @bug 4870762
+ @summary tests that a drop target JVM doesn't crash if the source doesn't export
+ data in native formats.
+ @author das@sparc.spb.su area=dnd
+ @run applet NoFormatsCrashTest.html
+ -->
+<head>
+<title> </title>
+</head>
+<body>
+
+<h1>NoFormatsCrashTest<br>Bug ID: 4870762</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="NoFormatsCrashTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
diff --git a/test/java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.java b/test/java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.java
new file mode 100644
index 0000000..3be0adc
--- /dev/null
+++ b/test/java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.java
@@ -0,0 +1,488 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ test
+ @bug 4870762
+ @summary tests that a drop target JVM doesn't crash if the source doesn't export
+ data in native formats.
+ @author das@sparc.spb.su area=dnd
+ @compile NoFormatsCrashTest.java
+ @run applet NoFormatsCrashTest.html
+*/
+
+// Note there is no @ in front of test above. This is so that the
+// harness will not mistake this file as a test file. It should
+// only see the html file as a test file. (the harness runs all
+// valid test files, so it would run this test twice if this file
+// were valid as well as the html file.)
+// Also, note the area= after Your Name in the author tag. Here, you
+// should put which functional area the test falls in. See the
+// AWT-core home page -> test areas and/or -> AWT team for a list of
+// areas.
+// Note also the 'NoFormatsCrashTest.html' in the run tag. This should
+// be changed to the name of the test.
+
+
+/**
+ * NoFormatsCrashTest.java
+ *
+ * summary: tests that a drop target JVM doesn't crash if the source doesn't export
+ * data in native formats.
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.datatransfer.*;
+import java.awt.dnd.*;
+import java.awt.event.*;
+import java.io.*;
+
+
+//Automated tests should run as applet tests if possible because they
+// get their environments cleaned up, including AWT threads, any
+// test created threads, and any system resources used by the test
+// such as file descriptors. (This is normally not a problem as
+// main tests usually run in a separate VM, however on some platforms
+// such as the Mac, separate VMs are not possible and non-applet
+// tests will cause problems). Also, you don't have to worry about
+// synchronisation stuff in Applet tests they way you do in main
+// tests...
+
+
+public class NoFormatsCrashTest extends Applet {
+
+ final Frame frame = new Frame();
+ private volatile Process process;
+
+ static final int FRAME_ACTIVATION_TIMEOUT = 2000;
+
+ public static void main(String[] args) {
+ NoFormatsCrashTest test = new NoFormatsCrashTest();
+ test.run(args);
+ }
+
+ public void run(String[] args) {
+ try {
+ if (args.length != 4) {
+ throw new RuntimeException("Incorrect command line arguments.");
+ }
+
+ int x = Integer.parseInt(args[0]);
+ int y = Integer.parseInt(args[1]);
+ int w = Integer.parseInt(args[2]);
+ int h = Integer.parseInt(args[3]);
+
+ Panel panel = new DragSourcePanel();
+
+ frame.setTitle("Drag source frame");
+ frame.setLocation(500, 200);
+ frame.add(panel);
+ frame.pack();
+ frame.setVisible(true);
+
+ Thread.sleep(FRAME_ACTIVATION_TIMEOUT);
+
+ Point sourcePoint = panel.getLocationOnScreen();
+ Dimension d = panel.getSize();
+ sourcePoint.translate(d.width / 2, d.height / 2);
+
+ Point targetPoint = new Point(x + w / 2, y + h / 2);
+
+ Robot robot = new Robot();
+ robot.mouseMove(sourcePoint.x, sourcePoint.y);
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (; !sourcePoint.equals(targetPoint);
+ sourcePoint.translate(sign(targetPoint.x - sourcePoint.x),
+ sign(targetPoint.y - sourcePoint.y))) {
+ robot.mouseMove(sourcePoint.x, sourcePoint.y);
+ Thread.sleep(50);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+
+ Thread.sleep(FRAME_ACTIVATION_TIMEOUT);
+
+ if (process.isAlive()) {
+ process.destroy();
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ } // run()
+
+ public void init() {
+ //Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test",
+ "simply wait until it is done"
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ frame.setTitle("Drop target frame");
+ frame.setLocation(200, 200);
+
+ } // init()
+
+ public void start() {
+ DropTargetPanel panel = new DropTargetPanel();
+ frame.add(panel);
+ frame.pack();
+ frame.setVisible(true);
+
+ try {
+ Thread.sleep(FRAME_ACTIVATION_TIMEOUT);
+
+ Point p = frame.getLocationOnScreen();
+ Dimension d = frame.getSize();
+
+ String javaPath = System.getProperty("java.home", "");
+ String command = javaPath + File.separator + "bin" +
+ File.separator + "java -cp " + System.getProperty("test.classes", ".") +
+ " NoFormatsCrashTest " +
+ p.x + " " + p.y + " " + d.width + " " + d.height;
+
+ process = Runtime.getRuntime().exec(command);
+ ProcessResults pres = ProcessResults.doWaitFor(process);
+ System.err.println("Child VM return code: " + pres.exitValue);
+
+ if (pres.stderr != null && pres.stderr.length() > 0) {
+ System.err.println("========= Child VM System.err ========");
+ System.err.print(pres.stderr);
+ System.err.println("======================================");
+ }
+
+ if (pres.stdout != null && pres.stdout.length() > 0) {
+ System.err.println("========= Child VM System.out ========");
+ System.err.print(pres.stdout);
+ System.err.println("======================================");
+ }
+
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+
+ if (panel.isTestFailed()) {
+ throw new RuntimeException();
+ }
+ } // start()
+
+ public static int sign(int n) {
+ return n < 0 ? -1 : n > 0 ? 1 : 0;
+ }
+} // class NoFormatsCrashTest
+
+class TestTransferable implements Transferable {
+
+ public static DataFlavor dataFlavor = null;
+ static final Object data = new Object();
+
+ static {
+ DataFlavor df = null;
+ try {
+ df = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType +
+ "; class=java.lang.Object");
+ } catch (ClassNotFoundException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ dataFlavor = df;
+ }
+
+ public DataFlavor[] getTransferDataFlavors() {
+ return new DataFlavor[] { dataFlavor };
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor df) {
+ return dataFlavor.equals(df);
+ }
+
+ public Object getTransferData(DataFlavor df)
+ throws UnsupportedFlavorException, IOException {
+ if (!isDataFlavorSupported(df)) {
+ throw new UnsupportedFlavorException(df);
+ }
+ return data;
+ }
+}
+
+class DragSourcePanel extends Panel {
+ public DragSourcePanel() {
+ final Transferable t = new TestTransferable();
+ final DragSourceListener dsl = new DragSourceAdapter() {
+ public void dragDropEnd(DragSourceDropEvent dtde) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ // This finishes child VM
+ System.exit(0);
+ }
+ };
+ final DragGestureListener dgl = new DragGestureListener() {
+ public void dragGestureRecognized(DragGestureEvent dge) {
+ dge.startDrag(null, t, dsl);
+ }
+ };
+ final DragSource ds = DragSource.getDefaultDragSource();
+ final DragGestureRecognizer dgr =
+ ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY,
+ dgl);
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(100, 100);
+ }
+}
+
+class DropTargetPanel extends Panel {
+ private boolean testFailed = false;
+ public DropTargetPanel() {
+ final DropTargetListener dtl = new DropTargetAdapter() {
+ public void dragOver(DropTargetDragEvent dtde) {
+ try {
+ dtde.getCurrentDataFlavorsAsList();
+ } catch (Exception e) {
+ testFailed = true;
+ e.printStackTrace();
+ }
+ }
+ public void drop(DropTargetDropEvent dtde) {
+ dtde.rejectDrop();
+ }
+ };
+ final DropTarget dt = new DropTarget(this, dtl);
+ }
+
+ public boolean isTestFailed() {
+ return testFailed;
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(100, 100);
+ }
+}
+
+class ProcessResults {
+ public int exitValue;
+ public String stdout;
+ public String stderr;
+
+ public ProcessResults() {
+ exitValue = -1;
+ stdout = "";
+ stderr = "";
+ }
+
+ /**
+ * Method to perform a "wait" for a process and return its exit value.
+ * This is a workaround for <code>Process.waitFor()</code> never returning.
+ */
+ public static ProcessResults doWaitFor(Process p) {
+ ProcessResults pres = new ProcessResults();
+
+ InputStream in = null;
+ InputStream err = null;
+
+ try {
+ in = p.getInputStream();
+ err = p.getErrorStream();
+
+ boolean finished = false;
+
+ while (!finished) {
+ try {
+ while (in.available() > 0) {
+ pres.stdout += (char)in.read();
+ }
+ while (err.available() > 0) {
+ pres.stderr += (char)err.read();
+ }
+ // Ask the process for its exitValue. If the process
+ // is not finished, an IllegalThreadStateException
+ // is thrown. If it is finished, we fall through and
+ // the variable finished is set to true.
+ pres.exitValue = p.exitValue();
+ finished = true;
+ }
+ catch (IllegalThreadStateException e) {
+ // Process is not finished yet;
+ // Sleep a little to save on CPU cycles
+ Thread.currentThread().sleep(500);
+ }
+ }
+ if (in != null) in.close();
+ if (err != null) err.close();
+ }
+ catch (Throwable e) {
+ System.err.println("doWaitFor(): unexpected exception");
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ return pres;
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+ {
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.show();
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.show();
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+ }// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+ {
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("South", messageText);
+
+ pack();
+
+ show();
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ }
+
+ }// TestDialog class
diff --git a/test/java/awt/image/multiresolution/MultiResolutionToolkitImageTest.java b/test/java/awt/image/multiresolution/MultiResolutionToolkitImageTest.java
new file mode 100644
index 0000000..57a5438
--- /dev/null
+++ b/test/java/awt/image/multiresolution/MultiResolutionToolkitImageTest.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import static java.awt.image.ImageObserver.ALLBITS;
+import java.io.File;
+import javax.imageio.ImageIO;
+import sun.awt.OSInfo;
+import sun.awt.SunToolkit;
+import sun.awt.image.MultiResolutionToolkitImage;
+
+/**
+ * @test
+ * @bug 8040291
+ * @author Alexander Scherbatiy
+ * @summary [macosx] Http-Images are not fully loaded when using ImageIcon
+ * @run main MultiResolutionToolkitImageTest
+ */
+public class MultiResolutionToolkitImageTest {
+
+ private static final int IMAGE_WIDTH = 300;
+ private static final int IMAGE_HEIGHT = 200;
+ private static final Color COLOR_1X = Color.GREEN;
+ private static final Color COLOR_2X = Color.BLUE;
+ private static final String IMAGE_NAME_1X = "image.png";
+ private static final String IMAGE_NAME_2X = "image@2x.png";
+ private static final int WAIT_TIME = 400;
+ private static volatile boolean isImageLoaded = false;
+ private static volatile boolean isRVObserverCalled = false;
+
+ public static void main(String[] args) throws Exception {
+
+ if (!checkOS()) {
+ return;
+ }
+ generateImages();
+ testToolkitMultiResolutionImageLoad();
+ }
+
+ static void testToolkitMultiResolutionImageLoad() throws Exception {
+ File imageFile = new File(IMAGE_NAME_1X);
+ String fileName = imageFile.getAbsolutePath();
+ Image image = Toolkit.getDefaultToolkit().getImage(fileName);
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ toolkit.prepareImage(image, -1, -1, new LoadImageObserver());
+
+ final long time = WAIT_TIME + System.currentTimeMillis();
+ while ((!isImageLoaded || !isRVObserverCalled)
+ && System.currentTimeMillis() < time) {
+ Thread.sleep(50);
+ }
+
+ if(!isImageLoaded){
+ throw new RuntimeException("Image is not loaded!");
+ }
+
+ if(!isRVObserverCalled){
+ throw new RuntimeException("Resolution Variant observer is not called!");
+ }
+ }
+
+ static void generateImages() throws Exception {
+ if (!new File(IMAGE_NAME_1X).exists()) {
+ generateImage(1);
+ }
+
+ if (!new File(IMAGE_NAME_2X).exists()) {
+ generateImage(2);
+ }
+ }
+
+ static void generateImage(int scale) throws Exception {
+ BufferedImage image = new BufferedImage(scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics g = image.getGraphics();
+ g.setColor(scale == 1 ? COLOR_1X : COLOR_2X);
+ g.fillRect(0, 0, scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT);
+ File file = new File(scale == 1 ? IMAGE_NAME_1X : IMAGE_NAME_2X);
+ ImageIO.write(image, "png", file);
+ }
+
+ static boolean checkOS() {
+ return OSInfo.getOSType() == OSInfo.OSType.MACOSX;
+ }
+
+ static class LoadImageObserver implements ImageObserver {
+
+ @Override
+ public boolean imageUpdate(Image img, int infoflags, int x, int y,
+ int width, int height) {
+
+ if (isRVObserver()) {
+ isRVObserverCalled = true;
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Image resolutionVariant = getResolutionVariant(img);
+ int rvFlags = toolkit.checkImage(resolutionVariant, width, height,
+ new IdleImageObserver());
+ if (rvFlags < infoflags) {
+ throw new RuntimeException("Info flags are greater than"
+ + " resolution varint info flags");
+ }
+ } else if ((infoflags & ALLBITS) != 0) {
+ isImageLoaded = true;
+ }
+
+ return (infoflags & ALLBITS) == 0;
+ }
+ }
+
+ static boolean isRVObserver() {
+ Exception e = new Exception();
+
+ for (StackTraceElement elem : e.getStackTrace()) {
+ if (elem.getClassName().endsWith("MultiResolutionToolkitImage")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ static class IdleImageObserver implements ImageObserver {
+
+ @Override
+ public boolean imageUpdate(Image img, int infoflags, int x, int y,
+ int width, int height) {
+ return false;
+ }
+ }
+
+ static Image getResolutionVariant(Image image) {
+ return ((MultiResolutionToolkitImage) image).getResolutionVariant();
+ }
+}
diff --git a/test/java/awt/regtesthelpers/process/ProcessCommunicator.java b/test/java/awt/regtesthelpers/process/ProcessCommunicator.java
index 8c0e6db..8177a2d 100644
--- a/test/java/awt/regtesthelpers/process/ProcessCommunicator.java
+++ b/test/java/awt/regtesthelpers/process/ProcessCommunicator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,21 +25,22 @@
import java.io.*;
-/** This class is created to solve interprocess communication problems.
+/**
+ * This class is created to solve interprocess communication problems.
* When you need to write a regression test which should verify inter jvm
* behavior such as DnD data transfer, Clipboard data transfer, focus
* transfer etc., you could use the next scenario:
*
* 1. Write an implementation for the parent JVM, using applet test.
- * 2. Write an implimentation for the child JVM or native application, using
+ * 2. Write an implementation for the child JVM or native application, using
* main() function.
* 3. Execute child process using ProcessCommunicator.executeChildProcess()
* method.
- * 4. You can decide whetherthe test is passed on the basis of
+ * 4. You can decide whether the test is passed on the basis of
* ProcessResults class data.
*
- * Note: The class is not thread safe. You should access its methods only from the same
- * thread.
+ * Note: The class is not thread safe. You should access its methods only from
+ * the same thread.
*/
public class ProcessCommunicator {
@@ -48,31 +49,34 @@
private static final String javaPath = javaHome + File.separator + "bin" +
File.separator + "java ";
private static String command = "";
+ private static volatile Process process;
private ProcessCommunicator() {}
- /** The same as {#link #executeChildProcess(Class,String)} except
- * the {@code classPathArgument} parameter. The class path
- * parameter is for the debug purposes
+ /**
+ * The same as {#link #executeChildProcess(Class,String)} except
+ * the {@code classPathArgument} parameter. The class path
+ * parameter is for the debug purposes
*
- * @param classToExecute is passed to the child JVM
- * @param classPathArguments class path for the child JVM
- * @param args arguments that will be passed to the executed class
- * @return results of the executed {@code Process}
+ * @param classToExecute is passed to the child JVM
+ * @param classPathArguments class path for the child JVM
+ * @param args arguments that will be passed to the executed class
+ * @return results of the executed {@code Process}
*/
public static ProcessResults executeChildProcess(final Class classToExecute,
final String classPathArguments, final String [] args)
{
try {
String command = buildCommand(classToExecute, classPathArguments, args);
- Process process = Runtime.getRuntime().exec(command);
+ process = Runtime.getRuntime().exec(command);
return doWaitFor(process);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
- /** Executes child {code Process}
+ /**
+ * Executes child {code Process}
*
* @param classToExecute class to be executed as a child java process
* @param args args to be passed in to the child process
@@ -86,11 +90,11 @@
/**
* Waits for a process and return its results.
- * This is a workaround for <code>Process.waitFor()</code> never returning.
+ * This is a workaround for {@code Process.waitFor()} never returning.
*
* @return results of the executed {@code Process}
*/
- private static ProcessResults doWaitFor(final Process p) {
+ public static ProcessResults doWaitFor(final Process p) {
ProcessResults pres = new ProcessResults();
final InputStream in;
@@ -133,13 +137,14 @@
return pres;
}
- /** Builds command on the basis of the passed class name,
- * class path and arguments.
+ /**
+ * Builds command on the basis of the passed class name,
+ * class path and arguments.
*
* @param classToExecute with class will be executed in the new JVM
* @param classPathArguments java class path (only for test purposes)
* @param args arguments for the new application. This could be used
- * to pass some information from the parnent to child JVM.
+ * to pass some information from the parent to child JVM.
* @return command to execute the {@code Process}
*/
private static String buildCommand(final Class classToExecute,
@@ -162,11 +167,24 @@
return command;
}
- /** Could be used for the debug purposes.
+ /**
+ * Could be used for the debug purposes.
*
- * @return command that was build to execute the child process
+ * @return command that was build to execute the child process
*/
public static String getExecutionCommand () {
return command;
}
+
+ /**
+ * Terminates the process created by {@code executeChildProcess} methods.
+ */
+ public static void destroyProcess() {
+ if (process != null) {
+ if (process.isAlive()) {
+ process.destroy();
+ }
+ process = null;
+ }
+ }
}
diff --git a/test/java/io/BufferedInputStream/LargeCopyWithMark.java b/test/java/io/BufferedInputStream/LargeCopyWithMark.java
index 2555a1f..74aeda9 100644
--- a/test/java/io/BufferedInputStream/LargeCopyWithMark.java
+++ b/test/java/io/BufferedInputStream/LargeCopyWithMark.java
@@ -26,6 +26,7 @@
* @summary BufferedInputStream calculates negative array size with large
* streams and mark
* @library /lib/testlibrary
+ * @build jdk.testlibrary.*
* @run main/othervm LargeCopyWithMark
*/
diff --git a/test/java/lang/String/ToLowerCase.java b/test/java/lang/String/ToLowerCase.java
index 7cf35ed..bd5f1ee 100644
--- a/test/java/lang/String/ToLowerCase.java
+++ b/test/java/lang/String/ToLowerCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
@test
- @bug 4217441 4533872 4900935 8020037
+ @bug 4217441 4533872 4900935 8020037 8041791
@summary toLowerCase should lower-case Greek Sigma correctly depending
on the context (final/non-final). Also it should handle
Locale specific (lt, tr, and az) lowercasings and supplementary
@@ -72,8 +72,10 @@
// I-dot tests
test("\u0130", turkish, "i");
test("\u0130", az, "i");
- test("\u0130", lt, "i");
- test("\u0130", Locale.US, "i");
+ test("\u0130", lt, "\u0069\u0307");
+ test("\u0130", Locale.US, "\u0069\u0307");
+ test("\u0130", Locale.JAPAN, "\u0069\u0307");
+ test("\u0130", Locale.ROOT, "\u0069\u0307");
// Remove dot_above in the sequence I + dot_above (Turkish and Azeri)
test("I\u0307", turkish, "i");
diff --git a/test/java/lang/annotation/TypeVariableBounds.java b/test/java/lang/annotation/TypeVariableBounds.java
new file mode 100644
index 0000000..1a2e33a
--- /dev/null
+++ b/test/java/lang/annotation/TypeVariableBounds.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8038994
+ * @summary Test that getAnnotatedBounds().getType() match getBounds()
+ * @run testng TypeVariableBounds
+ */
+
+import java.io.Serializable;
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+import java.util.concurrent.Callable;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+public class TypeVariableBounds {
+ @Test(dataProvider = "classData")
+ public void testClass(Class<?> c) throws Exception {
+ assertNotEquals(c.getTypeParameters().length, 0);
+
+ TypeVariable[] tv = c.getTypeParameters();
+
+ for(TypeVariable t : tv)
+ testTv(t);
+
+ }
+
+ @Test(dataProvider = "methodData")
+ public void testMethod(Class<?>c) throws Exception {
+ Method m = c.getMethod("aMethod");
+ TypeVariable[] tv = m.getTypeParameters();
+
+ for(TypeVariable t : tv)
+ testTv(t);
+
+ }
+
+ public void testTv(TypeVariable<?> tv) {
+ Type[] t = tv.getBounds();
+ AnnotatedType[] at = tv.getAnnotatedBounds();
+
+ assertEquals(t.length, at.length, Arrays.asList(t) + " and " + Arrays.asList(at) + " should be the same length");
+
+ for (int i = 0; i < t.length; i++)
+ assertSame(at[i].getType(), t[i], "T: " + t[i] + ", AT: " + at[i] + ", AT.getType(): " + at[i].getType() + "\n");
+ }
+
+ @DataProvider
+ public Object[][] classData() { return CLASS_TESTS; }
+
+ @DataProvider
+ public Object[][] methodData() { return METHOD_TESTS; }
+
+ public static final Object[][] CLASS_TESTS = {
+ { Case1.class, },
+ { Case2.class, },
+ { Case5.class, },
+ { Case6.class, },
+ };
+
+ public static final Object[][] METHOD_TESTS = {
+ { Case3.class, },
+ { Case4.class, },
+ { Case5.class, },
+ { Case6.class, },
+ };
+
+ // Class type var
+ public static class Case1<C1T1, C1T2 extends AnnotatedElement, C1T3 extends AnnotatedElement & Type & Serializable> {}
+ public static class Case2<C2T0, @TA C2T1 extends Type, C2T2 extends @TB AnnotatedElement, C2T3 extends AnnotatedElement & @TB Type & Serializable> {}
+
+ // Method type var
+ public static class Case3 { public <C3T1, C3T2 extends AnnotatedElement, C3T3 extends AnnotatedElement & Type & Serializable> void aMethod() {}}
+ public static class Case4 { public <C4T0, @TA C4T1 extends List, C4T2 extends @TB Set, C4T3 extends Set & @TB Callable & Serializable> void aMethod() {}}
+
+ // Both
+ public static class Case5 <C5CT1, C5CT2 extends Runnable> {
+ public <C5MT1,
+ C5MT2 extends AnnotatedElement,
+ C5MT3 extends AnnotatedElement & Type & Serializable,
+ C5MT4 extends C5CT2>
+ void aMethod() {}}
+
+ public static class Case6 <@TA C6CT1, C6CT2 extends @TB Runnable> {
+ public <@TA C6MT1,
+ C6MT2 extends @TB AnnotatedElement,
+ C6MT3 extends @TB AnnotatedElement & @TB2 Type & Serializable,
+ C6MT4 extends @TB2 C6CT2>
+ void aMethod() {}}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE_PARAMETER)
+ public @interface TA {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE_USE)
+ public @interface TB {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE_USE)
+ public @interface TB2 {}
+}
diff --git a/test/java/lang/instrument/DaemonThread/TestDaemonThread.java b/test/java/lang/instrument/DaemonThread/TestDaemonThread.java
index 20c9077..12246b1 100644
--- a/test/java/lang/instrument/DaemonThread/TestDaemonThread.java
+++ b/test/java/lang/instrument/DaemonThread/TestDaemonThread.java
@@ -26,7 +26,7 @@
* @summary Assert in java.lang.instrument agents during shutdown when classloading occurs after shutdown
* @library /lib/testlibrary
*
- * @build DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread
+ * @build jdk.testlibrary.* DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread
* @run shell ../MakeJAR3.sh DummyAgent
* @run main TestDaemonThreadLauncher /timeout=240
*
diff --git a/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java b/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java
index 9d08a7b..a597569 100644
--- a/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java
+++ b/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java
@@ -30,7 +30,7 @@
* @bug 6289149
* @summary test when the agent's class is missing the premain() function.
* @library /lib/testlibrary
- * @run build DummyMain
+ * @build jdk.testlibrary.* DummyMain
* @run shell ../MakeJAR3.sh NoPremainAgent
* @run main NoPremainAgentTest
*/
diff --git a/test/java/lang/instrument/PremainClass/PremainClassTest.java b/test/java/lang/instrument/PremainClass/PremainClassTest.java
index 9ebe4a6..dd83fa8 100644
--- a/test/java/lang/instrument/PremainClass/PremainClassTest.java
+++ b/test/java/lang/instrument/PremainClass/PremainClassTest.java
@@ -30,7 +30,7 @@
* @bug 5055293
* @summary Test non ascii characters in the Premain-Class attribute.
* @library /lib/testlibrary
- * @run build DummyMain
+ * @build jdk.testlibrary.* DummyMain
* @run main PremainClassTest
*/
public class PremainClassTest {
diff --git a/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java b/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java
index 7b67e4c..1dadbd0 100644
--- a/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java
+++ b/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java
@@ -30,7 +30,7 @@
* @bug 6289149
* @summary test when the agent's class has a zero arg premain() function.
* @library /lib/testlibrary
- * @run build DummyMain
+ * @build jdk.testlibrary.* DummyMain
* @run shell ../MakeJAR3.sh ZeroArgPremainAgent
* @run main ZeroArgPremainAgentTest
*/
diff --git a/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java b/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java
index 739ca6d..38baeae 100644
--- a/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java
+++ b/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java
@@ -37,6 +37,7 @@
/* @test
* @library /lib/testlibrary/jsr292 /lib/testlibrary/
* @compile CatchExceptionTest.java
+ * @build jdk.testlibrary.*
* @run main/othervm -esa test.java.lang.invoke.MethodHandles.CatchExceptionTest
*/
public class CatchExceptionTest {
diff --git a/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java b/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java
index 42ae7d0..1309e9c 100644
--- a/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java
+++ b/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java
@@ -30,11 +30,9 @@
*
* @author Mandy Chung
*
- * @build CollectionUsageThreshold MemoryUtil
- * @run main/othervm/timeout=300 -XX:+PrintGCDetails -XX:+UseSerialGC CollectionUsageThreshold
- * @run main/othervm/timeout=300 -XX:+PrintGCDetails -XX:+UseParallelGC CollectionUsageThreshold
- * @run main/othervm/timeout=300 -XX:+PrintGCDetails -XX:+UseG1GC CollectionUsageThreshold
- * @run main/othervm/timeout=300 -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC CollectionUsageThreshold
+ * @library /lib/testlibrary/
+ * @build CollectionUsageThreshold MemoryUtil RunUtil
+ * @run main/timeout=300 CollectionUsageThreshold
*/
import java.util.*;
@@ -61,6 +59,20 @@
// finishes checking the low memory notification result
private static final CyclicBarrier barrier = new CyclicBarrier(2);
+ /**
+ * Run the test multiple times with different GC versions.
+ * First with default command line specified by the framework.
+ * Then with GC versions specified by the test.
+ */
+ public static void main(String a[]) throws Throwable {
+ final String main = "CollectionUsageThreshold$TestMain";
+ RunUtil.runTestKeepGcOpts(main);
+ RunUtil.runTestClearGcOpts(main, "-XX:+UseSerialGC");
+ RunUtil.runTestClearGcOpts(main, "-XX:+UseParallelGC");
+ RunUtil.runTestClearGcOpts(main, "-XX:+UseG1GC");
+ RunUtil.runTestClearGcOpts(main, "-XX:+UseConcMarkSweepGC");
+ }
+
static class PoolRecord {
private final MemoryPoolMXBean pool;
private final AtomicInteger listenerInvoked = new AtomicInteger(0);
@@ -110,88 +122,90 @@
}
}
- public static void main(String args[]) throws Exception {
- if (args.length > 0 && args[0].equals("trace")) {
- trace = true;
- }
+ private static class TestMain {
+ public static void main(String args[]) throws Exception {
+ if (args.length > 0 && args[0].equals("trace")) {
+ trace = true;
+ }
- List<MemoryPoolMXBean> pools = getMemoryPoolMXBeans();
- List<MemoryManagerMXBean> managers = getMemoryManagerMXBeans();
+ List<MemoryPoolMXBean> pools = getMemoryPoolMXBeans();
+ List<MemoryManagerMXBean> managers = getMemoryManagerMXBeans();
- if (trace) {
- MemoryUtil.printMemoryPools(pools);
- MemoryUtil.printMemoryManagers(managers);
- }
+ if (trace) {
+ MemoryUtil.printMemoryPools(pools);
+ MemoryUtil.printMemoryManagers(managers);
+ }
- // Find the Old generation which supports low memory detection
- for (MemoryPoolMXBean p : pools) {
- if (p.isUsageThresholdSupported() && p.isCollectionUsageThresholdSupported()) {
- if (p.getName().toLowerCase().contains("perm")) {
- // if we have a "perm gen" pool increase the number of expected
- // memory pools by one.
- numMemoryPools++;
- }
- PoolRecord pr = new PoolRecord(p);
- result.put(p.getName(), pr);
- if (result.size() == numMemoryPools) {
- break;
+ // Find the Old generation which supports low memory detection
+ for (MemoryPoolMXBean p : pools) {
+ if (p.isUsageThresholdSupported() && p.isCollectionUsageThresholdSupported()) {
+ if (p.getName().toLowerCase().contains("perm")) {
+ // if we have a "perm gen" pool increase the number of expected
+ // memory pools by one.
+ numMemoryPools++;
+ }
+ PoolRecord pr = new PoolRecord(p);
+ result.put(p.getName(), pr);
+ if (result.size() == numMemoryPools) {
+ break;
+ }
}
}
- }
- if (result.size() != numMemoryPools) {
- throw new RuntimeException("Unexpected number of selected pools");
- }
-
- try {
- // This test creates a checker thread responsible for checking
- // the low memory notifications. It blocks until a permit
- // from the signals semaphore is available.
- Checker checker = new Checker("Checker thread");
- checker.setDaemon(true);
- checker.start();
-
- for (PoolRecord pr : result.values()) {
- pr.getPool().setCollectionUsageThreshold(THRESHOLD);
- System.out.println("Collection usage threshold of " +
- pr.getPool().getName() + " set to " + THRESHOLD);
+ if (result.size() != numMemoryPools) {
+ throw new RuntimeException("Unexpected number of selected pools");
}
- SensorListener listener = new SensorListener();
- NotificationEmitter emitter = (NotificationEmitter) mm;
- emitter.addNotificationListener(listener, null, null);
+ try {
+ // This test creates a checker thread responsible for checking
+ // the low memory notifications. It blocks until a permit
+ // from the signals semaphore is available.
+ Checker checker = new Checker("Checker thread");
+ checker.setDaemon(true);
+ checker.start();
- // The main thread invokes GC to trigger the VM to perform
- // low memory detection and then waits until the checker thread
- // finishes its work to check for a low-memory notification.
- //
- // At GC time, VM will issue low-memory notification and invoke
- // the listener which will release a permit to the signals semaphore.
- // When the checker thread acquires the permit and finishes
- // checking the low-memory notification, it will also call
- // barrier.await() to signal the main thread to resume its work.
- for (int i = 0; i < NUM_GCS; i++) {
- invokeGC();
- barrier.await();
+ for (PoolRecord pr : result.values()) {
+ pr.getPool().setCollectionUsageThreshold(THRESHOLD);
+ System.out.println("Collection usage threshold of " +
+ pr.getPool().getName() + " set to " + THRESHOLD);
+ }
+
+ SensorListener listener = new SensorListener();
+ NotificationEmitter emitter = (NotificationEmitter) mm;
+ emitter.addNotificationListener(listener, null, null);
+
+ // The main thread invokes GC to trigger the VM to perform
+ // low memory detection and then waits until the checker thread
+ // finishes its work to check for a low-memory notification.
+ //
+ // At GC time, VM will issue low-memory notification and invoke
+ // the listener which will release a permit to the signals semaphore.
+ // When the checker thread acquires the permit and finishes
+ // checking the low-memory notification, it will also call
+ // barrier.await() to signal the main thread to resume its work.
+ for (int i = 0; i < NUM_GCS; i++) {
+ invokeGC();
+ barrier.await();
+ }
+ } finally {
+ // restore the default
+ for (PoolRecord pr : result.values()) {
+ pr.getPool().setCollectionUsageThreshold(0);
+ }
}
- } finally {
- // restore the default
- for (PoolRecord pr : result.values()) {
- pr.getPool().setCollectionUsageThreshold(0);
- }
+ System.out.println(RunUtil.successMessage);
}
- System.out.println("Test passed.");
- }
- private static void invokeGC() {
- System.out.println("Calling System.gc()");
- numGCs++;
- mm.gc();
+ private static void invokeGC() {
+ System.out.println("Calling System.gc()");
+ numGCs++;
+ mm.gc();
- if (trace) {
- for (PoolRecord pr : result.values()) {
- System.out.println("Usage after GC for: " + pr.getPool().getName());
- MemoryUtil.printMemoryUsage(pr.getPool().getUsage());
+ if (trace) {
+ for (PoolRecord pr : result.values()) {
+ System.out.println("Usage after GC for: " + pr.getPool().getName());
+ MemoryUtil.printMemoryUsage(pr.getPool().getUsage());
+ }
}
}
}
diff --git a/test/java/lang/management/MemoryMXBean/LowMemoryTest.java b/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
index e83eb06..379b129 100644
--- a/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
+++ b/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
@@ -30,19 +30,21 @@
*
* @author Mandy Chung
*
- * @build LowMemoryTest MemoryUtil
- * @run main/othervm/timeout=600 LowMemoryTest
+ * @library /lib/testlibrary/
+ * @build LowMemoryTest MemoryUtil RunUtil
+ * @run main/timeout=600 LowMemoryTest
*/
import java.lang.management.*;
import java.util.*;
+import java.util.concurrent.Phaser;
import javax.management.*;
import javax.management.openmbean.CompositeData;
public class LowMemoryTest {
- private static MemoryMXBean mm = ManagementFactory.getMemoryMXBean();
- private static List pools = ManagementFactory.getMemoryPoolMXBeans();
- private static List managers = ManagementFactory.getMemoryManagerMXBeans();
+ private static final MemoryMXBean mm = ManagementFactory.getMemoryMXBean();
+ private static final List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
+ private static final Phaser phaser = new Phaser(2);
private static MemoryPoolMXBean mpool = null;
private static boolean trace = false;
private static boolean testFailed = false;
@@ -50,8 +52,23 @@
private static final int NUM_CHUNKS = 2;
private static long chunkSize;
- private static boolean listenerInvoked = false;
+ /**
+ * Run the test multiple times with different GC versions.
+ * First with default command line specified by the framework.
+ * Then with GC versions specified by the test.
+ */
+ public static void main(String a[]) throws Throwable {
+ final String main = "LowMemoryTest$TestMain";
+ RunUtil.runTestKeepGcOpts(main);
+ RunUtil.runTestClearGcOpts(main, "-XX:+UseSerialGC");
+ RunUtil.runTestClearGcOpts(main, "-XX:+UseParallelGC");
+ RunUtil.runTestClearGcOpts(main, "-XX:+UseG1GC");
+ RunUtil.runTestClearGcOpts(main, "-XX:+UseConcMarkSweepGC");
+ }
+
+ private static volatile boolean listenerInvoked = false;
static class SensorListener implements NotificationListener {
+ @Override
public void handleNotification(Notification notif, Object handback) {
String type = notif.getType();
if (type.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED) ||
@@ -69,8 +86,9 @@
static class TestListener implements NotificationListener {
private int triggers = 0;
- private long[] count = new long[NUM_TRIGGERS * 2];
- private long[] usedMemory = new long[NUM_TRIGGERS * 2];
+ private final long[] count = new long[NUM_TRIGGERS * 2];
+ private final long[] usedMemory = new long[NUM_TRIGGERS * 2];
+ @Override
public void handleNotification(Notification notif, Object handback) {
MemoryNotificationInfo minfo = MemoryNotificationInfo.
from((CompositeData) notif.getUserData());
@@ -101,117 +119,97 @@
}
private static long newThreshold;
- public static void main(String args[]) throws Exception {
- if (args.length > 0 && args[0].equals("trace")) {
- trace = true;
- }
- // Find the Old generation which supports low memory detection
- ListIterator iter = pools.listIterator();
- while (iter.hasNext()) {
- MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next();
- if (p.getType() == MemoryType.HEAP &&
- p.isUsageThresholdSupported()) {
- mpool = p;
- if (trace) {
- System.out.println("Selected memory pool for low memory " +
- "detection.");
- MemoryUtil.printMemoryPool(mpool);
- }
- break;
+ private static class TestMain {
+ public static void main(String args[]) throws Exception {
+ if (args.length > 0 && args[0].equals("trace")) {
+ trace = true;
}
- }
- TestListener listener = new TestListener();
- SensorListener l2 = new SensorListener();
- NotificationEmitter emitter = (NotificationEmitter) mm;
- emitter.addNotificationListener(listener, null, null);
- emitter.addNotificationListener(l2, null, null);
+ // Find the Old generation which supports low memory detection
+ ListIterator iter = pools.listIterator();
+ while (iter.hasNext()) {
+ MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next();
+ if (p.getType() == MemoryType.HEAP &&
+ p.isUsageThresholdSupported()) {
+ mpool = p;
+ if (trace) {
+ System.out.println("Selected memory pool for low memory " +
+ "detection.");
+ MemoryUtil.printMemoryPool(mpool);
+ }
+ break;
+ }
+ }
- Thread allocator = new AllocatorThread();
- Thread sweeper = new SweeperThread();
+ TestListener listener = new TestListener();
+ SensorListener l2 = new SensorListener();
+ NotificationEmitter emitter = (NotificationEmitter) mm;
+ emitter.addNotificationListener(listener, null, null);
+ emitter.addNotificationListener(l2, null, null);
- // Now set threshold
- MemoryUsage mu = mpool.getUsage();
- chunkSize = (mu.getMax() - mu.getUsed()) / 20;
- newThreshold = mu.getUsed() + (chunkSize * NUM_CHUNKS);
+ Thread allocator = new AllocatorThread();
+ Thread sweeper = new SweeperThread();
- System.out.println("Setting threshold for " + mpool.getName() +
- " from " + mpool.getUsageThreshold() + " to " + newThreshold +
- ". Current used = " + mu.getUsed());
- mpool.setUsageThreshold(newThreshold);
+ // Now set threshold
+ MemoryUsage mu = mpool.getUsage();
+ chunkSize = (mu.getMax() - mu.getUsed()) / 20;
+ newThreshold = mu.getUsed() + (chunkSize * NUM_CHUNKS);
- if (mpool.getUsageThreshold() != newThreshold) {
- throw new RuntimeException("TEST FAILED: " +
+ System.out.println("Setting threshold for " + mpool.getName() +
+ " from " + mpool.getUsageThreshold() + " to " + newThreshold +
+ ". Current used = " + mu.getUsed());
+ mpool.setUsageThreshold(newThreshold);
+
+ if (mpool.getUsageThreshold() != newThreshold) {
+ throw new RuntimeException("TEST FAILED: " +
"Threshold for Memory pool " + mpool.getName() +
"is " + mpool.getUsageThreshold() + " but expected to be" +
newThreshold);
+ }
+
+
+ allocator.start();
+ // Force Allocator start first
+ phaser.arriveAndAwaitAdvance();
+ sweeper.start();
+
+
+ try {
+ allocator.join();
+ // Wait until AllocatorThread's done
+ phaser.arriveAndAwaitAdvance();
+ sweeper.join();
+ } catch (InterruptedException e) {
+ System.out.println("Unexpected exception:" + e);
+ testFailed = true;
+ }
+
+ listener.checkResult();
+
+ if (testFailed)
+ throw new RuntimeException("TEST FAILED.");
+
+ System.out.println(RunUtil.successMessage);
+
}
-
- allocator.start();
- sweeper.start();
-
- try {
- allocator.join();
- sweeper.join();
- } catch (InterruptedException e) {
- e.printStackTrace();
- System.out.println("Unexpected exception.");
- testFailed = true;
- }
-
- listener.checkResult();
-
- if (testFailed)
- throw new RuntimeException("TEST FAILED.");
-
- System.out.println("Test passed.");
-
}
private static void goSleep(long ms) {
try {
Thread.sleep(ms);
} catch (InterruptedException e) {
- e.printStackTrace();
- System.out.println("Unexpected exception.");
+ System.out.println("Unexpected exception:" + e);
testFailed = true;
}
}
- private static Object go = new Object();
- private static boolean waiting = false; // No thread is waiting.
-
- // Synchronizes two thread. If no thread is waiting then wait
- // for notification from a different thread and if it is
- // is waiting then send notification.
- // In this test case this method is used to synchronize sweeper
- // thread and alocater thread to reach a particular point.
- private static void wait_or_notify() {
- synchronized (go) {
- if (waiting == false) {
- waiting = true;
- System.out.println(" Waiting ");
- try {
- go.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- testFailed = true;
- }
- waiting = false;
- } else {
- System.out.println(" Notify ");
- go.notify();
- }
- }
- }
-
- private static List objectPool = new ArrayList();
+ private static final List<Object> objectPool = new ArrayList<>();
static class AllocatorThread extends Thread {
public void doTask() {
int iterations = 0;
int numElements = (int) (chunkSize / 4); // minimal object size
- while (!listenerInvoked) {
+ while (!listenerInvoked || mpool.getUsage().getUsed() < mpool.getUsageThreshold()) {
iterations++;
if (trace) {
System.out.println(" Iteration " + iterations +
@@ -234,23 +232,25 @@
goSleep(100);
}
}
+ @Override
public void run() {
for (int i = 1; i <= NUM_TRIGGERS; i++) {
- System.out.println("AllocatorThread is doing task " + i);
+ // Sync with SweeperThread's second phase.
+ phaser.arriveAndAwaitAdvance();
+ System.out.println("AllocatorThread is doing task " + i +
+ " phase " + phaser.getPhase());
doTask();
- synchronized (sweep) {
- sweep.notify();
+ // Sync with SweeperThread's first phase.
+ phaser.arriveAndAwaitAdvance();
+ System.out.println("AllocatorThread done task " + i +
+ " phase " + phaser.getPhase());
+ if (testFailed) {
+ return;
}
- // System.out.print(" Allocater Thread ");
- // If sweeper thread is waiting then send notify
- // else wait for notification from sweeper thread.
- wait_or_notify();
- if (testFailed) return;
}
}
}
- private static Object sweep = new Object();
static class SweeperThread extends Thread {
private void doTask() {
for (; mpool.getUsage().getUsed() >=
@@ -261,28 +261,21 @@
goSleep(100);
}
}
+ @Override
public void run() {
for (int i = 1; i <= NUM_TRIGGERS; i++) {
- synchronized (sweep) {
- while (!listenerInvoked) {
- try {
- sweep.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- System.out.println("Unexpected exception.");
- testFailed = true;
- }
- }
- }
- System.out.println("SweepThread is doing task " + i);
+ // Sync with AllocatorThread's first phase.
+ phaser.arriveAndAwaitAdvance();
+ System.out.println("SweepThread is doing task " + i +
+ " phase " + phaser.getPhase());
doTask();
listenerInvoked = false;
- // System.out.print(" Sweeper Thread ");
- // If Allocater thread is waiting wait send notify
- // else wait for notfication from allocater thread.
- wait_or_notify();
+ // Sync with AllocatorThread's second phase.
+ phaser.arriveAndAwaitAdvance();
+ System.out.println("SweepThread done task " + i +
+ " phase " + phaser.getPhase());
if (testFailed) return;
}
}
diff --git a/test/java/lang/management/MemoryMXBean/LowMemoryTestConcMarkSweepGC.sh b/test/java/lang/management/MemoryMXBean/LowMemoryTestConcMarkSweepGC.sh
deleted file mode 100644
index 159804d..0000000
--- a/test/java/lang/management/MemoryMXBean/LowMemoryTestConcMarkSweepGC.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-#
-# @test
-# @bug 4530538
-# @summary Test LowMemoryTest with concurrent mark sweep GC
-# @author Mandy Chung
-#
-# @run build LowMemoryTest
-# @run shell/timeout=600 LowMemoryTestConcMarkSweepGC.sh
-#
-
-#Set appropriate jdk
-
-if [ ! -z "${TESTJAVA}" ] ; then
- jdk="$TESTJAVA"
-else
- echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test."
- exit 1
-fi
-
-runOne()
-{
- echo "runOne $@"
- $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 2
-}
-
-# Test LowMemoryTest with concurrent collector
-runOne -XX:+UseConcMarkSweepGC LowMemoryTest
-
-exit 0
diff --git a/test/java/lang/management/MemoryMXBean/LowMemoryTestParallelGC.sh b/test/java/lang/management/MemoryMXBean/LowMemoryTestParallelGC.sh
deleted file mode 100644
index 985a2e2..0000000
--- a/test/java/lang/management/MemoryMXBean/LowMemoryTestParallelGC.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-#
-# @test
-# @bug 4530538
-# @summary Test LowMemoryTest with parallel GC
-# @author Mandy Chung
-#
-# @run build LowMemoryTest
-# @run shell/timeout=600 LowMemoryTestParallelGC.sh
-#
-
-#Set appropriate jdk
-
-if [ ! -z "${TESTJAVA}" ] ; then
- jdk="$TESTJAVA"
-else
- echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test."
- exit 1
-fi
-
-runOne()
-{
- echo "runOne $@"
- $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 2
-}
-
-# Test LowMemoryTest with parallel scavenger collector
-runOne -XX:+UseParallelGC LowMemoryTest
-
-exit 0
diff --git a/test/java/lang/management/MemoryMXBean/LowMemoryTestSerialGC.sh b/test/java/lang/management/MemoryMXBean/LowMemoryTestSerialGC.sh
deleted file mode 100644
index 2829019..0000000
--- a/test/java/lang/management/MemoryMXBean/LowMemoryTestSerialGC.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-#
-# @test
-# @bug 4530538
-# @summary Test LowMemoryTest with Serial GC
-# @author Mandy Chung
-#
-# @run build LowMemoryTest
-# @run shell/timeout=600 LowMemoryTestSerialGC.sh
-#
-
-#Set appropriate jdk
-
-if [ ! -z "${TESTJAVA}" ] ; then
- jdk="$TESTJAVA"
-else
- echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test."
- exit 1
-fi
-
-runOne()
-{
- echo "runOne $@"
- $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 2
-}
-
-# Test LowMemoryTest with serial collector
-runOne -XX:+UseSerialGC LowMemoryTest
-
-exit 0
diff --git a/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java b/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
index 312db6b..f15fd2b 100644
--- a/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
+++ b/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
@@ -32,11 +32,9 @@
* @summary Basic Test for MemoryPool.resetPeakUsage()
* @author Mandy Chung
*
- * @build ResetPeakMemoryUsage MemoryUtil
- * @run main/othervm -XX:+PrintGCDetails -XX:+UseSerialGC -Xms256m -XX:MarkSweepAlwaysCompactCount=1 -Xmn8m ResetPeakMemoryUsage
- * @run main/othervm -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -Xms256m -Xmn8m ResetPeakMemoryUsage
- * @run main/othervm -XX:+PrintGCDetails -XX:+UseParallelGC -Xms256m -Xmn8m ResetPeakMemoryUsage
- * @run main/othervm -XX:+PrintGCDetails -XX:+UseG1GC -Xms256m -Xmn8m -XX:G1HeapRegionSize=1m ResetPeakMemoryUsage
+ * @library /lib/testlibrary/
+ * @build ResetPeakMemoryUsage MemoryUtil RunUtil
+ * @run main ResetPeakMemoryUsage
*/
import java.lang.management.*;
@@ -47,24 +45,42 @@
// make public so that it can't be optimized away easily
public static Object[] obj;
- public static void main(String[] argv) {
- List pools = ManagementFactory.getMemoryPoolMXBeans();
- ListIterator iter = pools.listIterator();
- boolean found = false;
- while (iter.hasNext()) {
- MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next();
- // only check heap pools that support usage threshold
- // this is typically only the old generation space
- // since the other spaces are expected to get filled up
- if (p.getType() == MemoryType.HEAP &&
- p.isUsageThresholdSupported())
- {
- found = true;
- testPool(p);
+ /**
+ * Run the test multiple times with different GC versions.
+ * First with default command line specified by the framework.
+ * Then with all GC versions specified by the test.
+ */
+ public static void main(String a[]) throws Throwable {
+ final String main = "ResetPeakMemoryUsage$TestMain";
+ final String ms = "-Xms256m";
+ final String mn = "-Xmn8m";
+ RunUtil.runTestClearGcOpts(main, ms, mn, "-XX:+UseConcMarkSweepGC");
+ RunUtil.runTestClearGcOpts(main, ms, mn, "-XX:+UseParallelGC");
+ RunUtil.runTestClearGcOpts(main, ms, mn, "-XX:+UseG1GC", "-XX:G1HeapRegionSize=1m");
+ RunUtil.runTestClearGcOpts(main, ms, mn, "-XX:+UseSerialGC",
+ "-XX:MarkSweepAlwaysCompactCount=1");
+ }
+
+ private static class TestMain {
+ public static void main(String[] argv) {
+ List pools = ManagementFactory.getMemoryPoolMXBeans();
+ ListIterator iter = pools.listIterator();
+ boolean found = false;
+ while (iter.hasNext()) {
+ MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next();
+ // only check heap pools that support usage threshold
+ // this is typically only the old generation space
+ // since the other spaces are expected to get filled up
+ if (p.getType() == MemoryType.HEAP &&
+ p.isUsageThresholdSupported())
+ {
+ found = true;
+ testPool(p);
+ }
}
- }
- if (!found) {
- throw new RuntimeException("No heap pool found");
+ if (!found) {
+ throw new RuntimeException("No heap pool found");
+ }
}
}
@@ -142,7 +158,7 @@
formatSize("previous peak", peak2.getUsed()));
}
- System.out.println("Test passed.");
+ System.out.println(RunUtil.successMessage);
}
private static String INDENT = " ";
diff --git a/test/java/lang/management/MemoryMXBean/RunUtil.java b/test/java/lang/management/MemoryMXBean/RunUtil.java
new file mode 100644
index 0000000..5f9d07c
--- /dev/null
+++ b/test/java/lang/management/MemoryMXBean/RunUtil.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Utility class for launching a test in a separate JVM.
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.Utils;
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.JDKToolFinder;
+
+public class RunUtil {
+
+ // Used to mark that the test has passed successfully.
+ public static final String successMessage = "Test passed.";
+
+ public static void runTestClearGcOpts(String main, String... testOpts) throws Throwable {
+ runTest(main, true, testOpts);
+ }
+
+ public static void runTestKeepGcOpts(String main, String... testOpts) throws Throwable {
+ runTest(main, false, testOpts);
+ }
+
+ /**
+ * Runs a test in a separate JVM.
+ * command line like:
+ * {test_jdk}/bin/java {defaultopts} -cp {test.class.path} {testopts} main
+ *
+ * {defaultopts} are the default java options set by the framework.
+ * Default GC options in {defaultopts} may be removed.
+ * This is used when the test specifies its own GC options.
+ *
+ * @param main Name of the main class.
+ * @param clearGcOpts true if the default GC options should be removed.
+ * @param testOpts java options specified by the test.
+ */
+ private static void runTest(String main, boolean clearGcOpts, String... testOpts)
+ throws Throwable {
+ List<String> opts = new ArrayList<>();
+ opts.add(JDKToolFinder.getJDKTool("java"));
+ opts.addAll(Arrays.asList(Utils.getTestJavaOpts()));
+ opts.add("-cp");
+ opts.add(System.getProperty("test.class.path", "test.class.path"));
+ opts.add("-XX:+PrintGCDetails");
+
+ if (clearGcOpts) {
+ opts = Utils.removeGcOpts(opts);
+ }
+ opts.addAll(Arrays.asList(testOpts));
+ opts.add(main);
+
+ OutputAnalyzer output = ProcessTools.executeProcess(opts.toArray(new String[0]));
+ output.shouldHaveExitValue(0);
+ if (output.getStdout().indexOf(successMessage) < 0) {
+ throw new Exception("output missing '" + successMessage + "'");
+ }
+ }
+
+}
diff --git a/test/java/net/Authenticator/B8034170.java b/test/java/net/Authenticator/B8034170.java
new file mode 100644
index 0000000..3767732
--- /dev/null
+++ b/test/java/net/Authenticator/B8034170.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+/**
+ * @test
+ * @bug 8034170
+ * @summary Digest authentication interop issue
+ * @run main/othervm B8034170 unquoted
+ * @run main/othervm -Dhttp.auth.digest.quoteParameters=true B8034170 quoted
+ */
+
+public class B8034170 {
+
+ static boolean expectQuotes;
+
+ static class BasicServer extends Thread {
+
+ ServerSocket server;
+
+ Socket s;
+ InputStream is;
+ OutputStream os;
+
+ static final String realm = "wallyworld";
+
+ String reply1 = "HTTP/1.1 401 Unauthorized\r\n"+
+ "WWW-Authenticate: Digest realm=\""+realm+"\", qop=\"auth\"" +
+ ", nonce=\"8989de95ea2402b64d73cecdb15da255\"" +
+ ", opaque=\"bbfb4c9ee92ddccc73521c3e6e841ba2\"\r\n\r\n";
+
+ String OKreply = "HTTP/1.1 200 OK\r\n"+
+ "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" +
+ "Server: Apache/1.3.14 (Unix)\r\n" +
+ "Connection: close\r\n" +
+ "Content-Type: text/plain; charset=iso-8859-1\r\n" +
+ "Content-Length: 10\r\n\r\n";
+
+ String ERRreply = "HTTP/1.1 500 Internal server error\r\n"+
+ "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" +
+ "Server: Apache/1.3.14 (Unix)\r\n" +
+ "Connection: close\r\n" +
+ "Content-Length: 0\r\n\r\n";
+
+ BasicServer (ServerSocket s) {
+ server = s;
+ }
+
+ int readAll (Socket s, byte[] buf) throws IOException {
+ int pos = 0;
+ InputStream is = s.getInputStream ();
+ // wait two seconds for request, as client doesn't close
+ // the connection
+ s.setSoTimeout(2000);
+ try {
+ int n;
+ while ((n=is.read(buf, pos, buf.length-pos)) > 0)
+ pos +=n;
+ } catch (SocketTimeoutException x) { }
+ return pos;
+ }
+
+ public void run () {
+ byte[] buf = new byte[5000];
+ try {
+ System.out.println ("Server 1: accept");
+ s = server.accept ();
+ System.out.println ("accepted");
+ os = s.getOutputStream();
+ os.write (reply1.getBytes());
+ readAll (s, buf);
+ s.close ();
+
+ System.out.println ("Server 2: accept");
+ s = server.accept ();
+ System.out.println ("accepted");
+ os = s.getOutputStream();
+ int count = readAll (s, buf);
+ String reply = new String(buf, 0, count);
+
+ boolean error;
+
+ if (expectQuotes) {
+ error = false;
+ if (!reply.contains("qop=\"auth\"")) {
+ System.out.println ("Expecting quoted qop. Not found");
+ error = true;
+ }
+ if (!reply.contains("algorithm=\"MD5\"")) {
+ System.out.println ("Expecting quoted algorithm. Not found");
+ error = true;
+ }
+ } else {
+ error = false;
+ if (!reply.contains("qop=auth")) {
+ System.out.println ("Expecting unquoted qop. Not found");
+ error = true;
+ }
+ if (!reply.contains("algorithm=MD5")) {
+ System.out.println ("Expecting unquoted algorithm. Not found");
+ error = true;
+ }
+ }
+ if (error) {
+ os.write(ERRreply.getBytes());
+ os.flush();
+ s.close();
+ } else {
+ os.write((OKreply+"HelloWorld").getBytes());
+ os.flush();
+ s.close();
+ }
+ }
+ catch (Exception e) {
+ System.out.println (e);
+ }
+ finished ();
+ }
+
+ public synchronized void finished () {
+ notifyAll();
+ }
+
+ }
+
+ static class MyAuthenticator3 extends Authenticator {
+ PasswordAuthentication pw;
+ MyAuthenticator3 () {
+ super ();
+ pw = new PasswordAuthentication ("user", "passwordNotCheckedAnyway".toCharArray());
+ }
+
+ public PasswordAuthentication getPasswordAuthentication ()
+ {
+ System.out.println ("Auth called");
+ return pw;
+ }
+ }
+
+
+ static void read (InputStream is) throws IOException {
+ int c;
+ System.out.println ("reading");
+ while ((c=is.read()) != -1) {
+ System.out.write (c);
+ }
+ System.out.println ("");
+ System.out.println ("finished reading");
+ }
+
+ public static void main (String args[]) throws Exception {
+ expectQuotes = args[0].equals("quoted");
+
+ MyAuthenticator3 auth = new MyAuthenticator3 ();
+ Authenticator.setDefault (auth);
+ ServerSocket ss = new ServerSocket (0);
+ int port = ss.getLocalPort ();
+ BasicServer server = new BasicServer (ss);
+ synchronized (server) {
+ server.start();
+ System.out.println ("client 1");
+ URL url = new URL ("http://localhost:"+port+"/d1/d2/d3/foo.html");
+ URLConnection urlc = url.openConnection ();
+ InputStream is = urlc.getInputStream ();
+ read (is);
+ is.close ();
+ }
+ }
+}
diff --git a/test/java/net/URLClassLoader/closetest/CloseTest.java b/test/java/net/URLClassLoader/closetest/CloseTest.java
index 4fcb7a5..790c3bf 100644
--- a/test/java/net/URLClassLoader/closetest/CloseTest.java
+++ b/test/java/net/URLClassLoader/closetest/CloseTest.java
@@ -26,7 +26,7 @@
* @bug 4167874
* @library ../../../../com/sun/net/httpserver
* @library /lib/testlibrary
- * @build FileServerHandler jdk.testlibrary.FileUtils
+ * @build jdk.testlibrary.* FileServerHandler
* @run shell build.sh
* @run main/othervm CloseTest
* @summary URL-downloaded jar files can consume all available file descriptors
diff --git a/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java b/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java
index a11d58a..bffbb2c 100644
--- a/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java
+++ b/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java
@@ -25,7 +25,7 @@
* @test
* @bug 6899919
* @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @build jdk.testlibrary.*
* @run shell build2.sh
* @run main/othervm GetResourceAsStream
*/
diff --git a/test/java/net/URLPermission/nstest/lookup.sh b/test/java/net/URLPermission/nstest/lookup.sh
index 89cfd10..e97ea33 100644
--- a/test/java/net/URLPermission/nstest/lookup.sh
+++ b/test/java/net/URLPermission/nstest/lookup.sh
@@ -26,6 +26,7 @@
# @library /lib/testlibrary
# @compile -XDignore.symbol.file=true SimpleNameService.java
# LookupTest.java SimpleNameServiceDescriptor.java
+# @build jdk.testlibrary.*
# @run shell/timeout=50 lookup.sh
#
diff --git a/test/java/util/zip/ZipFile/MultiThreadedReadTest.java b/test/java/util/zip/ZipFile/MultiThreadedReadTest.java
index c1f69a9..d4cbd53 100644
--- a/test/java/util/zip/ZipFile/MultiThreadedReadTest.java
+++ b/test/java/util/zip/ZipFile/MultiThreadedReadTest.java
@@ -25,7 +25,7 @@
* @bug 8038491
* @summary Crash in ZipFile.read() when ZipFileInputStream is shared between threads
* @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @build jdk.testlibrary.*
* @run main MultiThreadedReadTest
*/
diff --git a/test/javax/management/monitor/StartStopTest.java b/test/javax/management/monitor/StartStopTest.java
index 80694c6..2f41759 100644
--- a/test/javax/management/monitor/StartStopTest.java
+++ b/test/javax/management/monitor/StartStopTest.java
@@ -28,9 +28,8 @@
* monitors are started and stopped in a loop.
* @author Luis-Miguel Alventosa
* @library /lib/testlibrary
- * @run build jdk.testlibrary.Utils
* @run clean StartStopTest
- * @run build StartStopTest
+ * @run build jdk.testlibrary.* StartStopTest
* @run main/othervm/timeout=300 StartStopTest 1
* @run main/othervm/timeout=300 StartStopTest 2
* @run main/othervm/timeout=300 StartStopTest 3
diff --git a/test/javax/swing/JComboBox/ConsumedEscTest/ConsumedEscTest.java b/test/javax/swing/JComboBox/ConsumedEscTest/ConsumedEscTest.java
new file mode 100644
index 0000000..9976730
--- /dev/null
+++ b/test/javax/swing/JComboBox/ConsumedEscTest/ConsumedEscTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import sun.awt.SunToolkit;
+
+/*
+ @test
+ @bug 8031485
+ @summary Combo box consuming escape and enter key events
+ @author Petr Pchelko
+ @run main ConsumedEscTest
+*/
+public class ConsumedEscTest {
+ private static volatile JFrame frame;
+ private static volatile boolean passed = false;
+
+ public static void main(String... args) throws Exception {
+ try {
+ SwingUtilities.invokeAndWait(() -> {
+ frame = new JFrame();
+ JComboBox<String> combo = new JComboBox<>(new String[]{"one", "two", "three"});
+ JPanel panel = new JPanel();
+ panel.add(combo);
+ combo.requestFocusInWindow();
+ frame.setBounds(100, 150, 300, 100);
+ addAction(panel);
+ frame.add(panel);
+ frame.setVisible(true);
+ });
+
+ Robot robot = new Robot();
+ robot.waitForIdle();
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.keyPress(KeyEvent.VK_ESCAPE);
+ robot.waitForIdle();
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.keyRelease(KeyEvent.VK_ESCAPE);
+ robot.waitForIdle();
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ if (!passed) {
+ throw new RuntimeException("FAILED: ESC was consumed by combo box");
+ }
+ } finally {
+ if (frame != null) {
+ frame.dispose();
+ }
+ }
+ }
+
+ private static void addAction(JComponent comp) {
+ KeyStroke k = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
+ Object actionKey = "cancel";
+ comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(k, actionKey);
+ Action cancelAction = new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent ev) {
+ passed = true;
+ }
+ };
+ comp.getActionMap().put(actionKey, cancelAction);
+ }
+
+}
diff --git a/test/javax/swing/plaf/nimbus/8041725/bug8041725.java b/test/javax/swing/plaf/nimbus/8041725/bug8041725.java
new file mode 100644
index 0000000..d668a34
--- /dev/null
+++ b/test/javax/swing/plaf/nimbus/8041725/bug8041725.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ @bug 8041725
+ @summary JList selection colors are not UIResource instances in Nimbus L&F
+ @author Anton Litvinov
+*/
+
+import java.awt.*;
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.nimbus.*;
+
+public class bug8041725 {
+ public static void main(String[] args) throws Exception {
+ UIManager.setLookAndFeel(new NimbusLookAndFeel());
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ JFrame frame = new JFrame("bug8041725");
+ frame.setSize(200, 200);
+ JList list = new JList(new String[]{"Item1", "Item2", "Item3"});
+ frame.getContentPane().add(list);
+ frame.pack();
+ frame.setVisible(true);
+
+ System.err.println("Test #1: No items are selected, list is enabled.");
+ testSelectionColors(list);
+
+ System.err.println("Test #2: No items are selected, list is disabled.");
+ list.setEnabled(false);
+ testSelectionColors(list);
+
+ System.err.println("Test #3: One item is selected, list is disabled.");
+ list.setSelectedIndex(0);
+ testSelectionColors(list);
+
+ System.err.println("Test #4: One item is selected, list is enabled.");
+ list.setEnabled(true);
+ testSelectionColors(list);
+
+ frame.dispose();
+ }
+ });
+ }
+
+ private static void testSelectionColors(JList list) {
+ Color selBackColor = list.getSelectionBackground();
+ if (!(selBackColor instanceof UIResource)) {
+ throw new RuntimeException(String.format(
+ "JList.getSelectionBackground() returned instance of '%s' instead of UIResource.",
+ selBackColor.getClass()));
+ }
+ Color selForeColor = list.getSelectionForeground();
+ if (!(selForeColor instanceof UIResource)) {
+ throw new RuntimeException(String.format(
+ "JList.getSelectionForeground() returned instance of '%s' instead of UIResource.",
+ selForeColor.getClass()));
+ }
+ }
+}
diff --git a/test/javax/swing/plaf/synth/Test8043627.java b/test/javax/swing/plaf/synth/Test8043627.java
new file mode 100644
index 0000000..2a36634
--- /dev/null
+++ b/test/javax/swing/plaf/synth/Test8043627.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.JButton;
+import javax.swing.plaf.synth.SynthButtonUI;
+
+/*
+ * @test
+ * @bug 8043627
+ * @summary Tests that SynthContext can be created with SecurityManager installed
+ * @author Sergey Malenkov
+ */
+
+public class Test8043627 {
+ public static void main(String[] args) {
+ System.setSecurityManager(new SecurityManager());
+ new SynthButtonUI().getContext(new JButton());
+ }
+}
diff --git a/test/lib/testlibrary/jdk/testlibrary/Utils.java b/test/lib/testlibrary/jdk/testlibrary/Utils.java
index 2388d1d..5d4a441 100644
--- a/test/lib/testlibrary/jdk/testlibrary/Utils.java
+++ b/test/lib/testlibrary/jdk/testlibrary/Utils.java
@@ -118,6 +118,26 @@
}
/**
+ * Removes any options specifying which GC to use, for example "-XX:+UseG1GC".
+ * Removes any options matching: -XX:(+/-)Use*GC
+ * Used when a test need to set its own GC version. Then any
+ * GC specified by the framework must first be removed.
+ * @return A copy of given opts with all GC options removed.
+ */
+ private static final Pattern useGcPattern = Pattern.compile("\\-XX\\:[\\+\\-]Use.+GC");
+ public static List<String> removeGcOpts(List<String> opts) {
+ List<String> optsWithoutGC = new ArrayList<String>();
+ for (String opt : opts) {
+ if (useGcPattern.matcher(opt).matches()) {
+ System.out.println("removeGcOpts: removed " + opt);
+ } else {
+ optsWithoutGC.add(opt);
+ }
+ }
+ return optsWithoutGC;
+ }
+
+ /**
* Splits a string by white space.
* Works like String.split(), but returns an empty array
* if the string is null or empty.
diff --git a/test/sun/awt/image/bug8038000.java b/test/sun/awt/image/bug8038000.java
new file mode 100644
index 0000000..2bfdc27
--- /dev/null
+++ b/test/sun/awt/image/bug8038000.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8038000
+ *
+ * @summary Verifies that we could create different type of Rasters with height 1
+ * and strideline which exceeds raster width.
+ * Also checks that a set of RasterOp work correctly with such kind of Rasters.
+ *
+ * @run main bug8038000
+ */
+
+import java.awt.*;
+import java.awt.color.ColorSpace;
+import java.awt.geom.AffineTransform;
+import java.awt.image.*;
+import java.util.Arrays;
+
+public class bug8038000 {
+
+ public static void main(String[] args) throws Exception {
+ new bug8038000().checkOps();
+
+ // No exceptions - Passed
+ }
+
+ private void checkOps() throws Exception {
+
+ RasterOp[] ops = new RasterOp[] {
+ new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_sRGB),
+ ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), null),
+ new AffineTransformOp(AffineTransform.getScaleInstance(1, 1.1), null)
+ };
+
+
+ for (RasterOp op: ops) {
+ // Banded rasters
+ checkOp(Raster.createBandedRaster(DataBuffer.TYPE_BYTE, 10, 1, 10,
+ new int[] {0, 1, 2}, new int[]{2,1,0}, null),
+ Raster.createBandedRaster(DataBuffer.TYPE_BYTE, 10, 1, 1001,
+ new int[] {0, 1, 2}, new int[]{2,1,0}, null), op);
+ checkOp(Raster.createBandedRaster(DataBuffer.TYPE_USHORT, 10, 1, 10,
+ new int[] {0, 1, 2}, new int[]{2,1,0}, null),
+ Raster.createBandedRaster(DataBuffer.TYPE_USHORT, 10, 1, 1001,
+ new int[] {0, 1, 2}, new int[]{2,1,0}, null), op);
+ checkOp(Raster.createBandedRaster(DataBuffer.TYPE_INT, 10, 1, 10,
+ new int[] {0, 1, 2}, new int[]{2,1,0}, null),
+ Raster.createBandedRaster(DataBuffer.TYPE_INT, 10, 1, 1001,
+ new int[] {0, 1, 2}, new int[]{2,1,0}, null), op);
+
+ // Interleaved rasters
+ checkOp(Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
+ 10, 1, 30, 3, new int[]{0, 1, 2}, null),
+ Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
+ 10, 1, 1001, 3, new int[]{0, 1, 2}, null),
+ op);
+
+ checkOp(Raster.createInterleavedRaster(DataBuffer.TYPE_USHORT,
+ 10, 1, 30, 3, new int[]{0, 1, 2}, null),
+ Raster.createInterleavedRaster(DataBuffer.TYPE_USHORT,
+ 10, 1, 1001, 3, new int[]{0, 1, 2}, null),
+ op);
+
+ // Packed rasters
+ checkOp(Raster.createPackedRaster(new DataBufferByte(10), 10, 1, 10,
+ new int[] {0x01, 0x02, 0x04}, null),
+ Raster.createPackedRaster(new DataBufferByte(10), 10, 1, 2000,
+ new int[] {0x01, 0x02, 0x04}, null),
+ op);
+ checkOp(Raster.createPackedRaster(new DataBufferInt(10), 10, 1, 10,
+ new int[] {0xff0000, 0x00ff00, 0x0000ff}, null),
+ Raster.createPackedRaster(new DataBufferInt(10), 10, 1, 20,
+ new int[] {0xff0000, 0x00ff00, 0x0000ff}, null),
+ op);
+
+ }
+ }
+
+ /**
+ * Takes two identical rasters (identical with the exception of scanline stride)
+ * fills their pixels with identical data, applies the RasterOp to both rasters
+ * and checks that the result is the same
+ */
+ private void checkOp(WritableRaster wr1, WritableRaster wr2, RasterOp op) {
+ System.out.println("Checking " + op + " with rasters: \n " + wr1 +
+ "\n " + wr2);
+ try {
+ WritableRaster r1 = op.filter(fillRaster(wr1), null);
+ WritableRaster r2 = op.filter(fillRaster(wr2), null);
+ compareRasters(r1, r2);
+ } catch (ImagingOpException e) {
+ System.out.println(" Skip: Op is not supported: " + e);
+ }
+ }
+
+ private WritableRaster fillRaster(WritableRaster wr) {
+ int c = 0;
+ for(int x = wr.getMinX(); x < wr.getMinX() + wr.getWidth(); x++) {
+ for(int y = wr.getMinY(); y < wr.getMinY() + wr.getHeight(); y++) {
+ for (int b = 0; b < wr.getNumBands(); b++) {
+ wr.setSample(x, y, b, c++);
+ }
+ }
+ }
+ return wr;
+ }
+
+ private void compareRasters(Raster r1, Raster r2) {
+ Rectangle bounds = r1.getBounds();
+ if (!bounds.equals(r2.getBounds())) {
+ throw new RuntimeException("Bounds differ.");
+ }
+
+ if (r1.getNumBands() != r2.getNumBands()) {
+ throw new RuntimeException("Bands differ.");
+ }
+
+ int[] b1 = new int[r1.getNumBands()];
+ int[] b2 = new int[r1.getNumBands()];
+
+ for (int x = (int) bounds.getX(); x < bounds.getMaxX(); x++) {
+ for (int y = (int) bounds.getY(); y < bounds.getMaxY(); y++) {
+ r1.getPixel(x,y, b1);
+ r2.getPixel(x,y, b2);
+ if (!Arrays.equals(b1, b2)) {
+ throw new RuntimeException("Pixels differ.");
+ }
+ }
+ }
+ }
+}
diff --git a/test/sun/management/jdp/JdpDefaultsTest.java b/test/sun/management/jdp/JdpDefaultsTest.java
index 9067be7..35a145f 100644
--- a/test/sun/management/jdp/JdpDefaultsTest.java
+++ b/test/sun/management/jdp/JdpDefaultsTest.java
@@ -28,7 +28,7 @@
* @test JdpDefaultsTest
* @summary Assert that we can read JDP packets from a multicast socket connection, on default IP and port.
* @library /lib/testlibrary
- * @build ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
+ * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
* @run main JdpDefaultsTest
*/
diff --git a/test/sun/management/jdp/JdpOffTest.java b/test/sun/management/jdp/JdpOffTest.java
index 7810400..15b082e 100644
--- a/test/sun/management/jdp/JdpOffTest.java
+++ b/test/sun/management/jdp/JdpOffTest.java
@@ -29,7 +29,7 @@
* @test JdpOffTest.java
* @summary Assert that no JDP packets are sent to the default address and port.
* @library /lib/testlibrary
- * @build ClientConnection JdpTestUtil JdpTestCase JdpOffTestCase DynamicLauncher
+ * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOffTestCase DynamicLauncher
* @run main JdpOffTest
*/
diff --git a/test/sun/management/jdp/JdpSpecificAddressTest.java b/test/sun/management/jdp/JdpSpecificAddressTest.java
index 8a79176..0b9d8e0 100644
--- a/test/sun/management/jdp/JdpSpecificAddressTest.java
+++ b/test/sun/management/jdp/JdpSpecificAddressTest.java
@@ -28,7 +28,7 @@
* @test JdpSpecificAddressTest
* @summary Assert that we can read JDP packets from a multicast socket connection, on specific IP and port.
* @library /lib/testlibrary
- * @build ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
+ * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
* @run main JdpSpecificAddressTest
*/
diff --git a/test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java b/test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java
index 620b828..777fde3 100644
--- a/test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java
+++ b/test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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,6 +44,7 @@
private static final SynchronousQueue<Exception> queue =
new SynchronousQueue<Exception>();
+ private static volatile boolean isRunning = true;
static final class Result extends Exception {
@@ -91,19 +92,23 @@
Thread t = new Thread() {
public void run() {
- while (true) {
+ while (isRunning) {
Exception error = Result.SUCCESS;
try {
System.err.println("Accepting: ");
final Socket ss = s.accept();
System.err.println(ss.getInetAddress() + " accepted");
} catch (Exception x) {
- x.printStackTrace();
+ if (isRunning) {
+ x.printStackTrace();
+ }
error = x;
} finally {
try {
- // wait for the client to get the exception.
- queue.put(error);
+ if (isRunning) {
+ // wait for the client to get the exception.
+ queue.put(error);
+ }
} catch (Exception x) {
// too bad!
System.err.println("Could't send result to client!");
@@ -114,32 +119,38 @@
}
}
};
- t.setDaemon(true);
- t.start();
- System.err.println("new Socket((String)null, port)");
- final Socket s1 = new Socket((String) null, port);
- checkError("new Socket((String)null, port)");
- s1.close();
- System.err.println("new Socket((String)null, port): PASSED");
+ try {
+ t.start();
- System.err.println("new Socket(InetAddress.getByName(null), port)");
- final Socket s2 = new Socket(InetAddress.getByName(null), port);
- checkError("new Socket(InetAddress.getByName(null), port)");
- s2.close();
- System.err.println("new Socket(InetAddress.getByName(null), port): PASSED");
+ System.err.println("new Socket((String)null, port)");
+ final Socket s1 = new Socket((String) null, port);
+ checkError("new Socket((String)null, port)");
+ s1.close();
+ System.err.println("new Socket((String)null, port): PASSED");
- System.err.println("new Socket(localhost, port)");
- final Socket s3 = new Socket("localhost", port);
- checkError("new Socket(localhost, port)");
- s3.close();
- System.err.println("new Socket(localhost, port): PASSED");
+ System.err.println("new Socket(InetAddress.getByName(null), port)");
+ final Socket s2 = new Socket(InetAddress.getByName(null), port);
+ checkError("new Socket(InetAddress.getByName(null), port)");
+ s2.close();
+ System.err.println("new Socket(InetAddress.getByName(null), port): PASSED");
- System.err.println("new Socket(127.0.0.1, port)");
- final Socket s4 = new Socket("127.0.0.1", port);
- checkError("new Socket(127.0.0.1, port)");
- s4.close();
- System.err.println("new Socket(127.0.0.1, port): PASSED");
+ System.err.println("new Socket(localhost, port)");
+ final Socket s3 = new Socket("localhost", port);
+ checkError("new Socket(localhost, port)");
+ s3.close();
+ System.err.println("new Socket(localhost, port): PASSED");
+ System.err.println("new Socket(127.0.0.1, port)");
+ final Socket s4 = new Socket("127.0.0.1", port);
+ checkError("new Socket(127.0.0.1, port)");
+ s4.close();
+ System.err.println("new Socket(127.0.0.1, port): PASSED");
+ }
+ finally {
+ isRunning = false;
+ s.close();
+ t.join();
+ }
}
}
diff --git a/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java b/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java
index ca44815..54c1b61 100644
--- a/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java
+++ b/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java
@@ -41,8 +41,7 @@
* @test
* @bug 6434402 8004926
* @library /lib/testlibrary
- * @build jdk.testlibrary.ProcessTools
- * @build TestManager TestApplication CustomLauncherTest
+ * @build jdk.testlibrary.* TestManager TestApplication CustomLauncherTest
* @run main/othervm CustomLauncherTest
* @author Jaroslav Bachorik
*/
diff --git a/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java b/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java
index 1d4bbb1..6eecbda 100644
--- a/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java
+++ b/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java
@@ -42,8 +42,7 @@
* without connection or username/password details.
* TestManager will attempt a connection to the address obtained from
* both agent properties and jvmstat buffer.
- * @build jdk.testlibrary.ProcessTools
- * @build TestManager TestApplication
+ * @build jdk.testlibrary.* TestManager TestApplication
* @run main/othervm/timeout=300 -XX:+UsePerfData LocalManagementTest
*/
diff --git a/test/sun/management/jmxremote/startstop/JMXStartStopTest.java b/test/sun/management/jmxremote/startstop/JMXStartStopTest.java
index fe3a774..cacb708 100644
--- a/test/sun/management/jmxremote/startstop/JMXStartStopTest.java
+++ b/test/sun/management/jmxremote/startstop/JMXStartStopTest.java
@@ -54,10 +54,7 @@
* @test
* @bug 7110104
* @library /lib/testlibrary
- * @build jdk.testlibrary.ProcessTools
- * @build jdk.testlibrary.JDKToolLauncher
- * @build jdk.testlibrary.Utils
- * @build JMXStartStopTest JMXStartStopDoSomething
+ * @build jdk.testlibrary.* JMXStartStopTest JMXStartStopDoSomething
* @run main/othervm JMXStartStopTest
* @summary Makes sure that enabling/disabling the management agent through
* JCMD achieves the desired results
diff --git a/test/sun/nio/cs/TestUTF8.java b/test/sun/nio/cs/TestUTF8.java
index c54ae66..010fbf1 100644
--- a/test/sun/nio/cs/TestUTF8.java
+++ b/test/sun/nio/cs/TestUTF8.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4486841 7040220 7096080
+ * @bug 4486841 7040220 7096080 8039751
* @summary Test UTF-8 charset
*/
@@ -291,14 +291,18 @@
{1, (byte)0xE0, (byte)0xC0, (byte)0xBF }, // invalid second byte
{2, (byte)0xE0, (byte)0xA0, (byte)0x7F }, // invalid third byte
{2, (byte)0xE0, (byte)0xA0, (byte)0xC0 }, // invalid third byte
+ {2, (byte)0xE1, (byte)0x80, (byte)0x42}, // invalid third byte
+
{1, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
{1, (byte)0xE0, (byte)0xC0, (byte)0x80 }, // invalid second byte
{1, (byte)0xE0, (byte)0x80, (byte)0xC0 }, // invalid first byte
{1, (byte)0xE0, (byte)0x41,}, // invalid second byte & 2 bytes
+ {1, (byte)0xE1, (byte)0x40,}, // invalid second byte & 2 bytes
{3, (byte)0xED, (byte)0xAE, (byte)0x80 }, // 3 bytes surrogate
{3, (byte)0xED, (byte)0xB0, (byte)0x80 }, // 3 bytes surrogate
+
// Four-byte sequences
{1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
{1, (byte)0xF0, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
@@ -323,6 +327,32 @@
{1, (byte)0xF4, (byte)0xC0, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
{1, (byte)0xF5, (byte)0x80, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
+ // #8039751
+ {1, (byte)0xF6, (byte)0x80, (byte)0x80, (byte)0x80 }, // out-range 1st byte
+ {1, (byte)0xF6, (byte)0x80, (byte)0x80, },
+ {1, (byte)0xF6, (byte)0x80, },
+ {1, (byte)0xF6, },
+ {1, (byte)0xF5, (byte)0x80, (byte)0x80, (byte)0x80 }, // out-range 1st byte
+ {1, (byte)0xF5, (byte)0x80, (byte)0x80, },
+ {1, (byte)0xF5, (byte)0x80, },
+ {1, (byte)0xF5 },
+
+ {1, (byte)0xF4, (byte)0x90, (byte)0x80, (byte)0x80 }, // out-range 2nd byte
+ {1, (byte)0xF4, (byte)0x90, (byte)0x80 },
+ {1, (byte)0xF4, (byte)0x90 },
+
+ {1, (byte)0xF4, (byte)0x7f, (byte)0x80, (byte)0x80 }, // out-range/ascii 2nd byte
+ {1, (byte)0xF4, (byte)0x7f, (byte)0x80 },
+ {1, (byte)0xF4, (byte)0x7f },
+
+ {1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80 }, // out-range 2nd byte
+ {1, (byte)0xF0, (byte)0x80, (byte)0x80 },
+ {1, (byte)0xF0, (byte)0x80 },
+
+ {1, (byte)0xF0, (byte)0xc0, (byte)0x80, (byte)0x80 }, // out-range 2nd byte
+ {1, (byte)0xF0, (byte)0xc0, (byte)0x80 },
+ {1, (byte)0xF0, (byte)0xc0 },
+
// Five-byte sequences
{1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80}, // invalid first byte
{1, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
@@ -553,7 +583,6 @@
check4ByteSurrs("UTF-8");
checkMalformed("UTF-8", malformed);
checkUnderOverflow("UTF-8");
-
checkRoundtrip("CESU-8");
check6ByteSurrs("CESU-8");
checkMalformed("CESU-8", malformed_cesu8);
diff --git a/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java b/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java
index ae5c659..063746b 100644
--- a/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java
+++ b/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java
@@ -28,6 +28,7 @@
* @author Robert Field
* @library /lib/testlibrary
* @compile -XDignore.symbol.file ManyNewInstanceAnonTest.java
+ * @build jdk.testlibrary.*
* @run main ClassFileInstaller ManyNewInstanceAnonTest
* @run main/othervm -Xbootclasspath/a:. -Xverify:all ManyNewInstanceAnonTest
* @run main/othervm -Xbootclasspath/a:. -Xverify:all -Dsun.reflection.noInflation=true ManyNewInstanceAnonTest
diff --git a/test/sun/tools/jstatd/JstatdTest.java b/test/sun/tools/jstatd/JstatdTest.java
index f07ce6b..0c003cf 100644
--- a/test/sun/tools/jstatd/JstatdTest.java
+++ b/test/sun/tools/jstatd/JstatdTest.java
@@ -27,6 +27,7 @@
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Arrays;
+import java.util.regex.Pattern;
import static jdk.testlibrary.Asserts.*;
import jdk.testlibrary.JDKToolLauncher;
@@ -34,6 +35,7 @@
import jdk.testlibrary.ProcessThread;
import jdk.testlibrary.TestThread;
import jdk.testlibrary.Utils;
+import jdk.testlibrary.ProcessTools;
/**
* The base class for tests of jstatd.
@@ -93,8 +95,11 @@
if (tool == "rmiregistry") {
processName = "registryimpl";
}
+
+ Pattern toolInJpsPattern =
+ Pattern.compile("^\\d+\\s{1}" + processName + "\\s{1}.*-dparent\\.pid\\." + ProcessTools.getProcessId() + ".*");
for (String line : lines) {
- if (line.toLowerCase().matches("^\\d+\\s{1}" + processName + "$")) {
+ if (toolInJpsPattern.matcher(line.toLowerCase()).matches()) {
pid = line.split(" ")[0];
count++;
}
@@ -167,6 +172,8 @@
private OutputAnalyzer runJps() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jps");
launcher.addVMArg("-XX:+UsePerfData");
+ // Run jps with -v flag to obtain -Dparent.pid.<pid>
+ launcher.addToolArg("-v");
launcher.addToolArg(getDestination());
String[] cmd = launcher.getCommand();
@@ -286,7 +293,7 @@
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy -n serverName
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy -p port -n serverName
*/
- private String[] getJstatdCmd() throws UnknownHostException {
+ private String[] getJstatdCmd() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstatd");
launcher.addVMArg("-XX:+UsePerfData");
String testSrc = System.getProperty("test.src");
@@ -294,6 +301,8 @@
assertTrue(policy.exists() && policy.isFile(),
"Security policy " + policy.getAbsolutePath() + " does not exist or not a file");
launcher.addVMArg("-Djava.security.policy=" + policy.getAbsolutePath());
+ // -Dparent.pid.<pid> will help to identify jstad process started by this test
+ launcher.addVMArg("-Dparent.pid." + ProcessTools.getProcessId());
if (port != null) {
launcher.addToolArg("-p");
launcher.addToolArg(port);
diff --git a/test/sun/tools/jstatd/TestJstatdDefaults.java b/test/sun/tools/jstatd/TestJstatdDefaults.java
index d68f384..c3973f8 100644
--- a/test/sun/tools/jstatd/TestJstatdDefaults.java
+++ b/test/sun/tools/jstatd/TestJstatdDefaults.java
@@ -25,7 +25,7 @@
* @test
* @bug 4990825
* @library /lib/testlibrary
- * @build JstatdTest JstatGCUtilParser
+ * @build jdk.testlibrary.* JstatdTest JstatGCUtilParser
* @run main/timeout=60 TestJstatdDefaults
*/
public class TestJstatdDefaults {
diff --git a/test/sun/tools/jstatd/TestJstatdExternalRegistry.java b/test/sun/tools/jstatd/TestJstatdExternalRegistry.java
index da81db1..fdf2e48 100644
--- a/test/sun/tools/jstatd/TestJstatdExternalRegistry.java
+++ b/test/sun/tools/jstatd/TestJstatdExternalRegistry.java
@@ -25,7 +25,7 @@
* @test
* @bug 4990825 7092186
* @library /lib/testlibrary
- * @build JstatdTest JstatGCUtilParser
+ * @build jdk.testlibrary.* JstatdTest JstatGCUtilParser
* @run main/timeout=60 TestJstatdExternalRegistry
*/
public class TestJstatdExternalRegistry {
diff --git a/test/sun/tools/jstatd/TestJstatdPort.java b/test/sun/tools/jstatd/TestJstatdPort.java
index f2d479b..bba8732 100644
--- a/test/sun/tools/jstatd/TestJstatdPort.java
+++ b/test/sun/tools/jstatd/TestJstatdPort.java
@@ -25,7 +25,7 @@
* @test
* @bug 4990825
* @library /lib/testlibrary
- * @build JstatdTest JstatGCUtilParser
+ * @build jdk.testlibrary.* JstatdTest JstatGCUtilParser
* @run main/timeout=60 TestJstatdPort
*/
public class TestJstatdPort {
diff --git a/test/sun/tools/jstatd/TestJstatdPortAndServer.java b/test/sun/tools/jstatd/TestJstatdPortAndServer.java
index e771561..6b516f9 100644
--- a/test/sun/tools/jstatd/TestJstatdPortAndServer.java
+++ b/test/sun/tools/jstatd/TestJstatdPortAndServer.java
@@ -25,7 +25,7 @@
* @test
* @bug 4990825
* @library /lib/testlibrary
- * @build JstatdTest JstatGCUtilParser
+ * @build jdk.testlibrary.* JstatdTest JstatGCUtilParser
* @run main/timeout=60 TestJstatdPortAndServer
*/
public class TestJstatdPortAndServer {
diff --git a/test/sun/tools/jstatd/TestJstatdServer.java b/test/sun/tools/jstatd/TestJstatdServer.java
index f8e87a6..fbf1c56 100644
--- a/test/sun/tools/jstatd/TestJstatdServer.java
+++ b/test/sun/tools/jstatd/TestJstatdServer.java
@@ -25,7 +25,7 @@
* @test
* @bug 4990825
* @library /lib/testlibrary
- * @build JstatdTest JstatGCUtilParser
+ * @build jdk.testlibrary.* JstatdTest JstatGCUtilParser
* @run main/timeout=60 TestJstatdServer
*/
public class TestJstatdServer {
diff --git a/test/sun/tools/jstatd/TestJstatdUsage.java b/test/sun/tools/jstatd/TestJstatdUsage.java
index 3fd5efc..abec798 100644
--- a/test/sun/tools/jstatd/TestJstatdUsage.java
+++ b/test/sun/tools/jstatd/TestJstatdUsage.java
@@ -28,7 +28,7 @@
* @test
* @bug 4990825
* @library /lib/testlibrary
- * @build jdk.testlibrary.JDKToolLauncher jdk.testlibrary.OutputAnalyzer
+ * @build jdk.testlibrary.*
* @run main TestJstatdUsage
*/
public class TestJstatdUsage {
diff --git a/test/sun/util/calendar/zi/tzdata/VERSION b/test/sun/util/calendar/zi/tzdata/VERSION
index 1c96650..c735be5 100644
--- a/test/sun/util/calendar/zi/tzdata/VERSION
+++ b/test/sun/util/calendar/zi/tzdata/VERSION
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2014b
+tzdata2014c
diff --git a/test/sun/util/calendar/zi/tzdata/africa b/test/sun/util/calendar/zi/tzdata/africa
index 3198e1c..6f1a147 100644
--- a/test/sun/util/calendar/zi/tzdata/africa
+++ b/test/sun/util/calendar/zi/tzdata/africa
@@ -358,11 +358,54 @@
# http://www.worldtimezone.com/dst_news/dst_news_egypt02.html
# </a>
+# From Ahmad El-Dardiry (2014-05-07):
+# Egypt is to change back to Daylight system on May 15
+# http://english.ahram.org.eg/NewsContent/1/64/100735/Egypt/Politics-/Egypts-government-to-reapply-daylight-saving-time-.aspx
+
+# From Gunther Vermier (2015-05-13):
+# our Egypt office confirms that the change will be at 15 May "midnight" (24:00)
+
+# From Paul Eggert (2014-05-13):
+# Sarah El Deeb and Lee Keath of AP report that the Egyptian government says
+# the change is because of blackouts in Cairo, even though Ahram Online (cited
+# above) says DST had no affect on electricity consumption. The AP story says
+# DST will not be observed during Ramadan. There is no information about when
+# DST will end. See:
+# http://abcnews.go.com/International/wireStory/el-sissi-pushes-egyptians-line-23614833
+#
+# For now, guess that later transitions will use 2010's rules, and that
+# Egypt will agree with Morocco (see below) about the date Ramadan starts and
+# ends, though (unlike Morocco) it will switch at 00:00 standard time. In
+# Egypt the spring-forward transitions are removed for 2020-2022, when the
+# guessed spring-forward date falls during the estimated Ramadan, and all
+# transitions removed for 2023-2038, where the estimated Ramadan falls entirely
+# outside the guessed daylight-saving time. Ramadan intrudes on the guessed
+# DST starting in 2039, but that's beyond our somewhat-arbitrary cutoff.
+
Rule Egypt 2008 only - Aug lastThu 23:00s 0 -
Rule Egypt 2009 only - Aug 20 23:00s 0 -
Rule Egypt 2010 only - Aug 11 0:00 0 -
Rule Egypt 2010 only - Sep 10 0:00 1:00 S
Rule Egypt 2010 only - Sep lastThu 23:00s 0 -
+Rule Egypt 2014 only - May 15 24:00 1:00 S
+Rule Egypt 2014 only - Jun 29 0:00s 0 -
+Rule Egypt 2014 only - Jul 29 0:00s 1:00 S
+Rule Egypt 2014 max - Sep lastThu 23:00s 0 -
+Rule Egypt 2015 2019 - Apr lastFri 0:00s 1:00 S
+Rule Egypt 2015 only - Jun 18 0:00s 0 -
+Rule Egypt 2015 only - Jul 18 0:00s 1:00 S
+Rule Egypt 2016 only - Jun 7 0:00s 0 -
+Rule Egypt 2016 only - Jul 7 0:00s 1:00 S
+Rule Egypt 2017 only - May 27 0:00s 0 -
+Rule Egypt 2017 only - Jun 26 0:00s 1:00 S
+Rule Egypt 2018 only - May 16 0:00s 0 -
+Rule Egypt 2018 only - Jun 15 0:00s 1:00 S
+Rule Egypt 2019 only - May 6 0:00s 0 -
+Rule Egypt 2019 only - Jun 5 0:00s 1:00 S
+Rule Egypt 2020 only - May 24 0:00s 1:00 S
+Rule Egypt 2021 only - May 13 0:00s 1:00 S
+Rule Egypt 2022 only - May 3 0:00s 1:00 S
+Rule Egypt 2023 max - Apr lastFri 0:00s 1:00 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Cairo 2:05:09 - LMT 1900 Oct
diff --git a/test/sun/util/calendar/zi/tzdata/asia b/test/sun/util/calendar/zi/tzdata/asia
index dc3c94b..595c8ed 100644
--- a/test/sun/util/calendar/zi/tzdata/asia
+++ b/test/sun/util/calendar/zi/tzdata/asia
@@ -1370,22 +1370,6 @@
# "Jordan will switch to winter time on Friday, October 27".
#
-# From Phil Pizzey (2009-04-02):
-# ...I think I may have spotted an error in the timezone data for
-# Jordan.
-# The current (2009d) asia file shows Jordan going to daylight
-# saving
-# time on the last Thursday in March.
-#
-# Rule Jordan 2000 max - Mar lastThu 0:00s 1:00 S
-#
-# However timeanddate.com, which I usually find reliable, shows Jordan
-# going to daylight saving time on the last Friday in March since 2002.
-# Please see
-# <a href="http://www.timeanddate.com/worldclock/timezone.html?n=11">
-# http://www.timeanddate.com/worldclock/timezone.html?n=11
-# </a>
-
# From Steffen Thorsen (2009-04-02):
# This single one might be good enough, (2009-03-24, Arabic):
# <a href="http://petra.gov.jo/Artical.aspx?Lng=2&Section=8&Artical=95279">
diff --git a/test/sun/util/calendar/zi/tzdata/europe b/test/sun/util/calendar/zi/tzdata/europe
index 2b0c561..226c393 100644
--- a/test/sun/util/calendar/zi/tzdata/europe
+++ b/test/sun/util/calendar/zi/tzdata/europe
@@ -2989,6 +2989,10 @@
# From Alexander Krivenyshev (2014-03-17):
# time change at 2:00 (2am) on March 30, 2014
# http://vz.ru/news/2014/3/17/677464.html
+# From Paul Eggert (2014-03-30):
+# Simferopol and Sevastopol reportedly changed their central town clocks
+# late the previous day, but this appears to have been ceremonial
+# and the discrepancies are small enough to not worry about.
2:00 EU EE%sT 2014 Mar 30 2:00
4:00 - MSK