提交 f9cd70e2 编写于 作者: A asaha

Merge

......@@ -183,9 +183,9 @@ COPY_FILES += $(LIBDIR)/hijrah-config-umalqura.properties
##########################################################################################
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)
......
#
#
# 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
......@@ -510,15 +510,17 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
}
};
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();
}
};
......
......@@ -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>
......
......@@ -142,10 +142,9 @@ SplashInitPlatform(Splash * splash) {
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
......
......@@ -732,6 +732,9 @@ SetClassPath(const char *s)
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 @@ AddApplicationOptions(int cpathc, const char **cpathv)
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);
}
}
}
......
......@@ -226,7 +226,9 @@ public class MediaTracker implements java.io.Serializable {
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 @@ public class MediaTracker implements java.io.Serializable {
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".
}
......
......@@ -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 @@ public class DataFlavor implements Externalizable, Cloneable {
* @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 @@ public class DataFlavor implements Externalizable, Cloneable {
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 @@ public class DataFlavor implements Externalizable, Cloneable {
}
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 @@ public class DataFlavor implements Externalizable, Cloneable {
// 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 @@ public class DataFlavor implements Externalizable, Cloneable {
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?
*/
......
......@@ -576,9 +576,9 @@ public class DragSourceContext
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 @@ public class DragSourceContext
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();
......
......@@ -62,6 +62,7 @@ final class ConditionalSpecialCasing {
//# 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 @@ final class ConditionalSpecialCasing {
//# ================================================================================
//# 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 @@ final class ConditionalSpecialCasing {
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) {
......
......@@ -2597,7 +2597,9 @@ public final class String
} 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);
......
......@@ -874,7 +874,7 @@ class Random implements java.io.Serializable {
* (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 @@ class Random implements java.io.Serializable {
* (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)}.
......
/*
* 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 @@ final class JceSecurity {
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 {
......
......@@ -379,15 +379,11 @@ public class BasicInternalFrameTitlePane extends JComponent
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);
}
......
......@@ -31,6 +31,7 @@ import javax.swing.*;
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 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
} 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
......
<?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>
......@@ -138,9 +138,7 @@ public class SynthButtonUI extends BasicButtonUI implements
}
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);
}
/**
......
......@@ -128,8 +128,7 @@ public class SynthColorChooserUI extends BasicColorChooserUI implements
}
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) {
......
......@@ -208,8 +208,7 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements
}
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) {
......
......@@ -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 @@ import java.util.*;
* @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() {
}
......
......@@ -142,9 +142,7 @@ public class SynthDesktopIconUI extends BasicDesktopIconUI
}
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) {
......
......@@ -430,8 +430,7 @@ public class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
}
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) {
......
......@@ -139,8 +139,7 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
}
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) {
......
......@@ -67,8 +67,7 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
}
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) {
......
......@@ -141,8 +141,7 @@ public class SynthInternalFrameUI extends BasicInternalFrameUI
}
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) {
......
......@@ -91,8 +91,7 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
}
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) {
......
......@@ -188,8 +188,7 @@ public class SynthListUI extends BasicListUI
}
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) {
......
......@@ -116,8 +116,7 @@ public class SynthMenuBarUI extends BasicMenuBarUI
}
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) {
......
......@@ -170,8 +170,7 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
}
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 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
}
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) {
......
......@@ -170,9 +170,7 @@ public class SynthMenuUI extends BasicMenuUI
}
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 @@ public class SynthMenuUI extends BasicMenuUI
}
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) {
......
......@@ -140,8 +140,7 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements
}
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) {
......
......@@ -127,8 +127,7 @@ public class SynthPanelUI extends BasicPanelUI
}
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) {
......
......@@ -67,6 +67,7 @@ import org.xml.sax.SAXParseException;
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 @@ class SynthParser extends DefaultHandler {
}
else {
try {
typeClass = Class.forName(typeName.substring(
typeClass = ReflectUtil.forName(typeName.substring(
0, classIndex));
} catch (ClassNotFoundException cnfe) {
throw new SAXException("Unknown class: " +
......
......@@ -123,8 +123,7 @@ public class SynthPopupMenuUI extends BasicPopupMenuUI
}
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) {
......
......@@ -138,8 +138,7 @@ public class SynthProgressBarUI extends BasicProgressBarUI
}
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) {
......
......@@ -80,8 +80,7 @@ public class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
}
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) {
......
......@@ -185,8 +185,7 @@ public class SynthScrollBarUI extends BasicScrollBarUI
}
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 @@ public class SynthScrollBarUI extends BasicScrollBarUI
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) {
......
......@@ -211,8 +211,7 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI
}
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) {
......
......@@ -248,8 +248,7 @@ public class SynthSeparatorUI extends SeparatorUI
}
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) {
......
......@@ -722,8 +722,7 @@ public class SynthSliderUI extends BasicSliderUI
}
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 @@ public class SynthSliderUI extends BasicSliderUI
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) {
......
......@@ -278,8 +278,7 @@ public class SynthSpinnerUI extends BasicSpinnerUI
}
private SynthContext getContext(JComponent c, int state) {
return SynthContext.getContext(SynthContext.class, c,
SynthLookAndFeel.getRegion(c), style, state);
return SynthContext.getContext(c, style, state);
}
/**
......
......@@ -209,8 +209,7 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
}
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 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
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) {
......
......@@ -235,13 +235,11 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
}
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 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
else if (subregion == Region.TABBED_PANE_CONTENT) {
style = tabContentStyle;
}
return SynthContext.getContext(klass, c, subregion, style, state);
return SynthContext.getContext(c, subregion, style, state);
}
/**
......
......@@ -193,8 +193,7 @@ public class SynthTableHeaderUI extends BasicTableHeaderUI
}
private SynthContext getContext(JComponent c, int state) {
return SynthContext.getContext(SynthContext.class, c,
SynthLookAndFeel.getRegion(c), style, state);
return SynthContext.getContext(c, style, state);
}
/**
......
......@@ -246,8 +246,7 @@ public class SynthTableUI extends BasicTableUI
}
private SynthContext getContext(JComponent c, int state) {
return SynthContext.getContext(SynthContext.class, c,
SynthLookAndFeel.getRegion(c), style, state);
return SynthContext.getContext(c, style, state);
}
//
......
......@@ -118,8 +118,7 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI {
}
private SynthContext getContext(JComponent c, int state) {
return SynthContext.getContext(SynthContext.class, c,
SynthLookAndFeel.getRegion(c), style, state);
return SynthContext.getContext(c, style, state);
}
/**
......
......@@ -156,8 +156,7 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI {
}
private SynthContext getContext(JComponent c, int state) {
return SynthContext.getContext(SynthContext.class, c,
SynthLookAndFeel.getRegion(c), style, state);
return SynthContext.getContext(c, style, state);
}
/**
......
......@@ -178,19 +178,17 @@ public class SynthToolBarUI extends BasicToolBarUI
}
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) {
......
......@@ -107,8 +107,7 @@ public class SynthToolTipUI extends BasicToolTipUI
}
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) {
......
......@@ -173,8 +173,7 @@ public class SynthTreeUI extends BasicTreeUI
}
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 @@ public class SynthTreeUI extends BasicTreeUI
}
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) {
......
......@@ -141,8 +141,7 @@ public class SynthViewportUI extends ViewportUI
}
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) {
......
......@@ -851,22 +851,30 @@ public abstract class SunToolkit extends Toolkit
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) {
......
......@@ -755,10 +755,22 @@ public class ByteBandedRaster extends SunWritableRaster {
+ 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);
}
}
}
......
......@@ -885,15 +885,31 @@ public class ByteComponentRaster extends SunWritableRaster {
}
}
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 ||
......
......@@ -1386,13 +1386,28 @@ public class BytePackedRaster extends SunWritableRaster {
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);
}
}
long lastbit = (long) dataBitOffset
+ (long) (height - 1) * (long) scanlineStride * 8
+ (long) (width - 1) * (long) pixelBitStride
......
......@@ -654,15 +654,31 @@ public class IntegerComponentRaster extends SunWritableRaster {
") 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 ||
......
......@@ -66,6 +66,14 @@ public class MultiResolutionToolkitImage extends ToolkitImage implements MultiRe
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 @@ public class MultiResolutionToolkitImage extends ToolkitImage implements MultiRe
y /= 2;
}
if(concatenateInfo){
flags &= ((ToolkitImage) image).
getImageRep().check(null);
}
return observer.imageUpdate(
image, flags, x, y, width, height);
};
......
......@@ -754,10 +754,21 @@ public class ShortBandedRaster extends SunWritableRaster {
+ 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);
}
}
}
......
......@@ -819,15 +819,31 @@ public class ShortComponentRaster extends SunWritableRaster {
}
}
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 ||
......
......@@ -34,8 +34,11 @@ import java.util.StringTokenizer;
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 @@ class DigestAuthentication extends AuthenticationInfo {
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 @@ class DigestAuthentication extends AuthenticationInfo {
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;
}
......
......@@ -111,12 +111,18 @@ class UTF_8 extends Unicode
(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 @@ class UTF_8 extends Unicode
// 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 @@ class UTF_8 extends Unicode
// 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 @@ class UTF_8 extends Unicode
}
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;
}
......
......@@ -75,7 +75,7 @@ public final class TypeAnnotationParser {
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 @@ public final class TypeAnnotationParser {
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 @@ public final class TypeAnnotationParser {
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;
}
......
......@@ -151,7 +151,7 @@ le_int32 IndicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[],
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);
......
......@@ -1096,9 +1096,13 @@ void IndicReordering::finalReordering(LEGlyphStorage &glyphStorage, le_int32 cou
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);
......
......@@ -181,7 +181,7 @@ public:
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);
......
......@@ -262,12 +262,6 @@ enum ScriptCodes {
khojScriptCode = 157,
tirhScriptCode = 158,
/**
* @stable ICU 52
*/
aghbScriptCode = 159,
mahjScriptCode = 160,
/**
* @stable ICU 2.2
*/
......
/*
* 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 *ETC_TIMEZONE_FILE = "/etc/timezone";
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 @@ getSolarisDefaultZoneID() {
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 @@ findJavaTZ_md(const char *java_home_dir, const char *country)
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 @@ getGMTOffsetID()
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
......@@ -200,7 +200,10 @@ AwtTextField::HandleEvent(MSG *msg, BOOL synthetic)
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);
......
......@@ -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
*
*/
......
......@@ -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;
......
......@@ -38,7 +38,7 @@ import jdk.testlibrary.ProcessThread;
* @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.
......
......@@ -34,7 +34,7 @@ import jdk.testlibrary.ProcessThread;
* @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 -
......
......@@ -33,7 +33,7 @@ import com.sun.tools.attach.spi.AttachProvider;
* @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.
......
/*
* 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) { }
}
}
/*
* 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);
}
}
}
/*
* 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!");
}
}
}
/*
* 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
/*
* 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);
}
}
}
<!--
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>
/*
* 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
/*
* 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));
}
}
/*
* 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;
}
/*
* 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"));
}
}
/*
* 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;
}
}
<!--
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>
/*
* 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
<!--
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>
/*
* 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
/*
* 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();
}
}
/*
* 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 @@ package test.java.awt.regtesthelpers.process;
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 @@ public class ProcessCommunicator {
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 @@ public class ProcessCommunicator {
/**
* 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 @@ public class ProcessCommunicator {
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 @@ public class ProcessCommunicator {
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;
}
}
}
......@@ -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
*/
......
此差异已折叠。
......@@ -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
*
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册