--- a/src/java.base/windows/conf/tzmappings Thu Sep 13 13:03:50 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,226 +0,0 @@
-#
-# This file describes mapping information between Windows and Java
-# time zones.
-# Format: Each line should include a colon separated fields of Windows
-# time zone registry key, time zone mapID, locale (which is most
-# likely used in the time zone), and Java time zone ID. Blank lines
-# and lines that start with '#' are ignored. Data lines must be sorted
-# by mapID (ASCII order).
-#
-# NOTE
-# This table format is not a public interface of any Java
-# platforms. No applications should depend on this file in any form.
-#
-# This table has been generated by a program and should not be edited
-# manually.
-#
-Romance:-1,64::Europe/Paris:
-Romance Standard Time:-1,64::Europe/Paris:
-Warsaw:-1,65::Europe/Warsaw:
-Central Europe:-1,66::Europe/Prague:
-Central Europe Standard Time:-1,66::Europe/Prague:
-Prague Bratislava:-1,66::Europe/Prague:
-W. Central Africa Standard Time:-1,66:AO:Africa/Luanda:
-FLE:-1,67:FI:Europe/Helsinki:
-FLE Standard Time:-1,67:FI:Europe/Helsinki:
-GFT:-1,67::Europe/Athens:
-GFT Standard Time:-1,67::Europe/Athens:
-GTB:-1,67::Europe/Athens:
-GTB Standard Time:-1,67::Europe/Athens:
-Israel:-1,70::Asia/Jerusalem:
-Israel Standard Time:-1,70::Asia/Jerusalem:
-Arab:-1,71::Asia/Riyadh:
-Arab Standard Time:-1,71::Asia/Riyadh:
-Arabic Standard Time:-1,71:IQ:Asia/Baghdad:
-E. Africa:-1,71:KE:Africa/Nairobi:
-E. Africa Standard Time:-1,71:KE:Africa/Nairobi:
-Saudi Arabia:-1,71::Asia/Riyadh:
-Saudi Arabia Standard Time:-1,71::Asia/Riyadh:
-Iran:-1,72::Asia/Tehran:
-Iran Standard Time:-1,72::Asia/Tehran:
-Afghanistan:-1,73::Asia/Kabul:
-Afghanistan Standard Time:-1,73::Asia/Kabul:
-India:-1,74::Asia/Calcutta:
-India Standard Time:-1,74::Asia/Calcutta:
-Myanmar Standard Time:-1,74::Asia/Rangoon:
-Nepal Standard Time:-1,74::Asia/Katmandu:
-Sri Lanka:-1,74:LK:Asia/Colombo:
-Sri Lanka Standard Time:-1,74:LK:Asia/Colombo:
-Beijing:-1,75::Asia/Shanghai:
-China:-1,75::Asia/Shanghai:
-China Standard Time:-1,75::Asia/Shanghai:
-AUS Central:-1,76::Australia/Darwin:
-AUS Central Standard Time:-1,76::Australia/Darwin:
-Cen. Australia:-1,76::Australia/Adelaide:
-Cen. Australia Standard Time:-1,76::Australia/Adelaide:
-Vladivostok:-1,77::Asia/Vladivostok:
-Vladivostok Standard Time:-1,77::Asia/Vladivostok:
-West Pacific:-1,77:GU:Pacific/Guam:
-West Pacific Standard Time:-1,77:GU:Pacific/Guam:
-E. South America:-1,80::America/Sao_Paulo:
-E. South America Standard Time:-1,80::America/Sao_Paulo:
-Greenland Standard Time:-1,80:GL:America/Godthab:
-Newfoundland:-1,81::America/St_Johns:
-Newfoundland Standard Time:-1,81::America/St_Johns:
-Pacific SA:-1,82::America/Santiago:
-Pacific SA Standard Time:-1,82::America/Santiago:
-SA Western:-1,82:BO:America/La_Paz:
-SA Western Standard Time:-1,82:BO:America/La_Paz:
-SA Pacific:-1,83::America/Bogota:
-SA Pacific Standard Time:-1,83::America/Bogota:
-US Eastern:-1,84::America/Indianapolis:
-US Eastern Standard Time:-1,84::America/Indianapolis:
-Central America Standard Time:-1,85::America/Regina:
-Mexico:-1,85::America/Mexico_City:
-Mexico Standard Time:-1,85::America/Mexico_City:
-Canada Central:-1,86::America/Regina:
-Canada Central Standard Time:-1,86::America/Regina:
-US Mountain:-1,87::America/Phoenix:
-US Mountain Standard Time:-1,87::America/Phoenix:
-GMT:0,1::Europe/London:
-GMT Standard Time:0,1::Europe/London:
-Ekaterinburg:10,11::Asia/Yekaterinburg:
-Ekaterinburg Standard Time:10,11::Asia/Yekaterinburg:
-West Asia:10,11:UZ:Asia/Tashkent:
-West Asia Standard Time:10,11:UZ:Asia/Tashkent:
-Central Asia:12,13::Asia/Almaty:
-Central Asia Standard Time:12,13::Asia/Almaty:
-N. Central Asia Standard Time:12,13::Asia/Novosibirsk:
-Bangkok:14,15::Asia/Bangkok:
-Bangkok Standard Time:14,15::Asia/Bangkok:
-North Asia Standard Time:14,15::Asia/Krasnoyarsk:
-SE Asia:14,15::Asia/Bangkok:
-SE Asia Standard Time:14,15::Asia/Bangkok:
-North Asia East Standard Time:16,17:RU:Asia/Irkutsk:
-Singapore:16,17:SG:Asia/Singapore:
-Singapore Standard Time:16,17:SG:Asia/Singapore:
-Taipei:16,17::Asia/Taipei:
-Taipei Standard Time:16,17::Asia/Taipei:
-W. Australia:16,17:AU:Australia/Perth:
-W. Australia Standard Time:16,17:AU:Australia/Perth:
-Korea:18,19:KR:Asia/Seoul:
-Korea Standard Time:18,19:KR:Asia/Seoul:
-Tokyo:18,19::Asia/Tokyo:
-Tokyo Standard Time:18,19::Asia/Tokyo:
-Yakutsk:18,19:RU:Asia/Yakutsk:
-Yakutsk Standard Time:18,19:RU:Asia/Yakutsk:
-Central European:2,3:CS:Europe/Belgrade:
-Central European Standard Time:2,3:CS:Europe/Belgrade:
-W. Europe:2,3::Europe/Berlin:
-W. Europe Standard Time:2,3::Europe/Berlin:
-Tasmania:20,-1::Australia/Hobart:
-Tasmania Standard Time:20,-1::Australia/Hobart:
-AUS Eastern:20,21::Australia/Sydney:
-AUS Eastern Standard Time:20,21::Australia/Sydney:
-E. Australia:20,21::Australia/Brisbane:
-E. Australia Standard Time:20,21::Australia/Brisbane:
-Sydney Standard Time:20,21::Australia/Sydney:
-Tasmania Standard Time:20,65::Australia/Hobart:
-Central Pacific:22,23::Pacific/Guadalcanal:
-Central Pacific Standard Time:22,23::Pacific/Guadalcanal:
-Dateline:24,25::GMT-1200:
-Dateline Standard Time:24,25::GMT-1200:
-Fiji:24,25::Pacific/Fiji:
-Fiji Standard Time:24,25::Pacific/Fiji:
-Samoa:26,27::Pacific/Apia:
-Samoa Standard Time:26,27::Pacific/Apia:
-Hawaiian:28,29::Pacific/Honolulu:
-Hawaiian Standard Time:28,29::Pacific/Honolulu:
-Alaskan:30,31::America/Anchorage:
-Alaskan Standard Time:30,31::America/Anchorage:
-Pacific:32,33::America/Los_Angeles:
-Pacific Standard Time:32,33::America/Los_Angeles:
-Mexico Standard Time 2:34,35:MX:America/Chihuahua:
-Mountain:34,35::America/Denver:
-Mountain Standard Time:34,35::America/Denver:
-Central:36,37::America/Chicago:
-Central Standard Time:36,37::America/Chicago:
-Eastern:38,39::America/New_York:
-Eastern Standard Time:38,39::America/New_York:
-E. Europe:4,5::EET:
-E. Europe Standard Time:4,5::EET:
-Egypt:4,68::Africa/Cairo:
-Egypt Standard Time:4,68::Africa/Cairo:
-South Africa:4,69::Africa/Harare:
-South Africa Standard Time:4,69::Africa/Harare:
-Atlantic:40,41::America/Halifax:
-Atlantic Standard Time:40,41::America/Halifax:
-SA Eastern:42,43:GF:America/Cayenne:
-SA Eastern Standard Time:42,43:GF:America/Cayenne:
-Mid-Atlantic:44,45::Atlantic/South_Georgia:
-Mid-Atlantic Standard Time:44,45::Atlantic/South_Georgia:
-Azores:46,47::Atlantic/Azores:
-Azores Standard Time:46,47::Atlantic/Azores:
-Cape Verde Standard Time:46,47::Atlantic/Cape_Verde:
-Russian:6,7::Europe/Moscow:
-Russian Standard Time:6,7::Europe/Moscow:
-New Zealand:78,79::Pacific/Auckland:
-New Zealand Standard Time:78,79::Pacific/Auckland:
-Tonga Standard Time:78,79::Pacific/Tongatapu:
-Arabian:8,9::Asia/Muscat:
-Arabian Standard Time:8,9::Asia/Muscat:
-Caucasus:8,9:AM:Asia/Yerevan:
-Caucasus Standard Time:8,9:AM:Asia/Yerevan:
-GMT Standard Time:88,89::GMT:
-Greenwich:88,89::GMT:
-Greenwich Standard Time:88,89::GMT:
-Aleutian Standard Time:900,900:US:America/Adak:
-Altai Standard Time:901,901::Asia/Barnaul:
-Argentina Standard Time:902,902::America/Buenos_Aires:
-Armenian Standard Time:903,903:AM:Asia/Yerevan:
-Astrakhan Standard Time:904,904::Europe/Astrakhan:
-Aus Central W. Standard Time:905,905::Australia/Eucla:
-Azerbaijan Standard Time:906,906:AZ:Asia/Baku:
-Bahia Standard Time:907,907::America/Bahia:
-Bangladesh Standard Time:908,908::Asia/Dhaka:
-Belarus Standard Time:909,909:BY:Europe/Minsk:
-Bougainville Standard Time:910,910::Pacific/Bougainville:
-Central Brazilian Standard Time:911,911:BR:America/Cuiaba:
-Central Standard Time (Mexico):912,912::America/Mexico_City:
-Chatham Islands Standard Time:913,913::Pacific/Chatham:
-Cuba Standard Time:914,914:CU:America/Havana:
-Easter Island Standard Time:915,915:CL:Pacific/Easter:
-Eastern Standard Time (Mexico):916,916::America/Cancun:
-Georgian Standard Time:917,917:GE:Asia/Tbilisi:
-Haiti Standard Time:918,918:HT:America/Port-au-Prince:
-Jordan Standard Time:919,919:JO:Asia/Amman:
-Kaliningrad Standard Time:920,920:RU:Europe/Kaliningrad:
-Kamchatka Standard Time:921,921:RU:Asia/Kamchatka:
-Libya Standard Time:922,922:LY:Africa/Tripoli:
-Line Islands Standard Time:923,923::Pacific/Kiritimati:
-Lord Howe Standard Time:924,924::Australia/Lord_Howe:
-Magadan Standard Time:925,925::Asia/Magadan:
-Marquesas Standard Time:926,926::Pacific/Marquesas:
-Mauritius Standard Time:927,927:MU:Indian/Mauritius:
-Middle East Standard Time:928,928:LB:Asia/Beirut:
-Montevideo Standard Time:929,929:UY:America/Montevideo:
-Morocco Standard Time:930,930:MA:Africa/Casablanca:
-Mountain Standard Time (Mexico):931,931:MX:America/Chihuahua:
-Namibia Standard Time:932,932:NA:Africa/Windhoek:
-Norfolk Standard Time:933,933::Pacific/Norfolk:
-North Korea Standard Time:934,934:KP:Asia/Pyongyang:
-Pacific Standard Time (Mexico):935,935:MX:America/Tijuana:
-Pakistan Standard Time:936,936::Asia/Karachi:
-Paraguay Standard Time:937,937:PY:America/Asuncion:
-Russia Time Zone 10:938,938::Asia/Srednekolymsk:
-Russia Time Zone 11:939,939::Asia/Anadyr:
-Russia Time Zone 3:940,940::Europe/Samara:
-Saint Pierre Standard Time:941,941:PM:America/Miquelon:
-Sakhalin Standard Time:942,942::Asia/Sakhalin:
-Syria Standard Time:943,943:SY:Asia/Damascus:
-Tocantins Standard Time:944,944::America/Araguaina:
-Tomsk Standard Time:945,945::Asia/Tomsk:
-Transbaikal Standard Time:946,946::Asia/Chita:
-Turkey Standard Time:947,947::Asia/Istanbul:
-Turks And Caicos Standard Time:948,948:TC:America/Grand_Turk:
-UTC+12:949,949::GMT+1200:
-UTC-02:950,950::GMT-0200:
-UTC-08:951,951::GMT-0800:
-UTC-09:952,952::GMT-0900:
-UTC-11:953,953::GMT-1100:
-UTC:954,954::UTC:
-Ulaanbaatar Standard Time:955,955::Asia/Ulaanbaatar:
-Venezuela Standard Time:956,956::America/Caracas:
-W. Mongolia Standard Time:957,957::Asia/Hovd:
-West Bank Standard Time:958,958::Asia/Gaza:
-Western Brazilian Standard Time:959,959:BR:America/Rio_Branco:
--- a/src/java.base/windows/native/libjava/TimeZone_md.c Thu Sep 13 13:03:50 2018 -0700
+++ b/src/java.base/windows/native/libjava/TimeZone_md.c Thu Sep 13 13:41:17 2018 -0700
@@ -36,6 +36,7 @@
#define MAX_ZONE_CHAR 256
#define MAX_MAPID_LENGTH 32
+#define MAX_REGION_LENGTH 4
#define NT_TZ_KEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"
#define WIN_TZ_KEY "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Time Zones"
@@ -145,7 +146,7 @@
/*
* Gets the current time zone entry in the "Time Zones" registry.
*/
-static int getWinTimeZone(char *winZoneName, char *winMapID)
+static int getWinTimeZone(char *winZoneName)
{
DYNAMIC_TIME_ZONE_INFORMATION dtzi;
DWORD timeType;
@@ -231,7 +232,6 @@
WCHAR stdNameInReg[MAX_ZONE_CHAR];
TziValue tempTzi;
WCHAR *stdNamePtr = tzi.StandardName;
- DWORD valueSize;
int onlyMapID;
timeType = GetTimeZoneInformation(&tzi);
@@ -372,24 +372,7 @@
(void) RegCloseKey(hSubKey);
}
- /*
- * Get the "MapID" value of the registry to be able to eliminate
- * duplicated key names later.
- */
- valueSize = MAX_MAPID_LENGTH;
- ret = RegQueryValueExA(hSubKey, "MapID", NULL, &valueType, winMapID, &valueSize);
- (void) RegCloseKey(hSubKey);
(void) RegCloseKey(hKey);
-
- if (ret != ERROR_SUCCESS) {
- /*
- * Vista doesn't have mapID. VALUE_UNKNOWN should be returned
- * only for Windows NT.
- */
- if (onlyMapID == 1) {
- return VALUE_UNKNOWN;
- }
- }
}
return VALUE_KEY;
@@ -410,24 +393,17 @@
* Index values for the mapping table.
*/
#define TZ_WIN_NAME 0
-#define TZ_MAPID 1
-#define TZ_REGION 2
-#define TZ_JAVA_NAME 3
+#define TZ_REGION 1
+#define TZ_JAVA_NAME 2
-#define TZ_NITEMS 4 /* number of items (fields) */
+#define TZ_NITEMS 3 /* number of items (fields) */
/*
* Looks up the mapping table (tzmappings) and returns a Java time
* zone ID (e.g., "America/Los_Angeles") if found. Otherwise, NULL is
* returned.
- *
- * value_type is one of the following values:
- * VALUE_KEY for exact key matching
- * VALUE_MAPID for MapID (this is
- * required for the old Windows, such as NT 4.0 SP3).
*/
-static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName,
- char *mapID)
+static char *matchJavaTZ(const char *java_home_dir, char *tzName)
{
int line;
int IDmatched = 0;
@@ -436,9 +412,22 @@
char *items[TZ_NITEMS];
char *mapFileName;
char lineBuffer[MAX_ZONE_CHAR * 4];
- int noMapID = *mapID == '\0'; /* no mapID on Vista and later */
int offset = 0;
const char* errorMessage = "unknown error";
+ char region[MAX_REGION_LENGTH];
+
+ // Get the user's location
+ if (GetGeoInfo(GetUserGeoID(GEOCLASS_NATION),
+ GEO_ISO2, region, MAX_REGION_LENGTH, 0) == 0) {
+ // If GetGeoInfo fails, fallback to LCID's country
+ LCID lcid = GetUserDefaultLCID();
+ if (GetLocaleInfo(lcid,
+ LOCALE_SISO3166CTRYNAME, region, MAX_REGION_LENGTH) == 0 &&
+ GetLocaleInfo(lcid,
+ LOCALE_SISO3166CTRYNAME2, region, MAX_REGION_LENGTH) == 0) {
+ region[0] = '\0';
+ }
+ }
mapFileName = malloc(strlen(java_home_dir) + strlen(MAPPINGS_FILE) + 1);
if (mapFileName == NULL) {
@@ -494,28 +483,20 @@
goto illegal_format;
}
- if (noMapID || strcmp(mapID, items[TZ_MAPID]) == 0) {
+ /*
+ * We need to scan items until the
+ * exact match is found or the end of data is detected.
+ */
+ if (strcmp(items[TZ_WIN_NAME], tzName) == 0) {
/*
- * When there's no mapID, we need to scan items until the
- * exact match is found or the end of data is detected.
+ * Found the time zone in the mapping table.
+ * Check the region code and select the appropriate entry
*/
- if (!noMapID) {
- IDmatched = 1;
- }
- if (strcmp(items[TZ_WIN_NAME], tzName) == 0) {
- /*
- * Found the time zone in the mapping table.
- */
+ if (strcmp(items[TZ_REGION], region) == 0 ||
+ strcmp(items[TZ_REGION], "001") == 0) {
javaTZName = _strdup(items[TZ_JAVA_NAME]);
break;
}
- } else {
- if (IDmatched == 1) {
- /*
- * No need to look up the mapping table further.
- */
- break;
- }
}
}
fclose(fp);
@@ -535,19 +516,16 @@
char *findJavaTZ_md(const char *java_home_dir)
{
char winZoneName[MAX_ZONE_CHAR];
- char winMapID[MAX_MAPID_LENGTH];
char *std_timezone = NULL;
int result;
- winMapID[0] = 0;
- result = getWinTimeZone(winZoneName, winMapID);
+ result = getWinTimeZone(winZoneName);
if (result != VALUE_UNKNOWN) {
if (result == VALUE_GMTOFFSET) {
std_timezone = _strdup(winZoneName);
} else {
- std_timezone = matchJavaTZ(java_home_dir, result,
- winZoneName, winMapID);
+ std_timezone = matchJavaTZ(java_home_dir, winZoneName);
if (std_timezone == NULL) {
std_timezone = getGMTOffsetID();
}