8206965: java/util/TimeZone/Bug8149452.java failed on de_DE and ja_JP locale
Generated display names for missing timezones at run time. Reviewed-by: naoto
This commit is contained in:
parent
6c703b8589
commit
50a3c19ffc
@ -44,12 +44,14 @@ import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
@ -308,26 +310,37 @@ public class LocaleResources {
|
||||
Set<String> keyset = getZoneIDs();
|
||||
// Use a LinkedHashSet to preseve the order
|
||||
Set<String[]> value = new LinkedHashSet<>();
|
||||
Set<String> tzIds = new HashSet<>(Set.of(TimeZone.getAvailableIDs()));
|
||||
for (String key : keyset) {
|
||||
if (!key.startsWith(TZNB_EXCITY_PREFIX)) {
|
||||
value.add(rb.getStringArray(key));
|
||||
tzIds.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
// Add aliases data for CLDR
|
||||
if (type == LocaleProviderAdapter.Type.CLDR) {
|
||||
// Note: TimeZoneNamesBundle creates a String[] on each getStringArray call.
|
||||
// Add aliases data for CLDR
|
||||
Map<String, String> aliases = ZoneInfo.getAliasTable();
|
||||
for (String alias : aliases.keySet()) {
|
||||
if (!keyset.contains(alias)) {
|
||||
String tzid = aliases.get(alias);
|
||||
if (keyset.contains(tzid)) {
|
||||
String[] val = rb.getStringArray(tzid);
|
||||
val[0] = alias;
|
||||
// Note: TimeZoneNamesBundle creates a String[] on each getStringArray call.
|
||||
|
||||
// Add timezones which are not present in this keyset,
|
||||
// so that their fallback names will be generated at runtime.
|
||||
tzIds.stream().filter(i -> (!i.startsWith("Etc/GMT")
|
||||
&& !i.startsWith("GMT")
|
||||
&& !i.startsWith("SystemV")))
|
||||
.forEach(tzid -> {
|
||||
String[] val = new String[7];
|
||||
if (keyset.contains(tzid)) {
|
||||
val = rb.getStringArray(tzid);
|
||||
} else {
|
||||
String tz = aliases.get(tzid);
|
||||
if (keyset.contains(tz)) {
|
||||
val = rb.getStringArray(tz);
|
||||
}
|
||||
}
|
||||
val[0] = tzid;
|
||||
value.add(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return value.toArray(new String[0][]);
|
||||
}
|
||||
|
@ -604,6 +604,10 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
|
||||
{"Asia/Ashkhabad", TMT},
|
||||
{"Asia/Baghdad", ARAST},
|
||||
{"Asia/Bahrain", ARAST},
|
||||
{"Asia/Barnaul", new String[] {"Barnaul Standard Time", "GMT+07:00",
|
||||
"Barnaul Daylight Time", "GMT+07:00",
|
||||
"Barnaul Time" , "GMT+07:00"}},
|
||||
|
||||
{"Asia/Baku", new String[] {"Azerbaijan Time", "AZT",
|
||||
"Azerbaijan Summer Time", "AZST",
|
||||
"Azerbaijan Time", "AZT"}},
|
||||
@ -711,6 +715,9 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
|
||||
{"Asia/Tehran", IRT},
|
||||
{"Asia/Thimbu", BTT},
|
||||
{"Asia/Thimphu", BTT},
|
||||
{"Asia/Tomsk", new String[] {"Tomsk Standard Time", "GMT+07:00",
|
||||
"Tomsk Daylight Time", "GMT+07:00",
|
||||
"Tomsk Time" , "GMT+07:00"}},
|
||||
{"Asia/Ujung_Pandang", CIT},
|
||||
{"Asia/Ulaanbaatar", ULAT},
|
||||
{"Asia/Ulan_Bator", ULAT},
|
||||
@ -827,6 +834,9 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
|
||||
{"Europe/Jersey", GMTBST},
|
||||
{"Europe/Kaliningrad", EET},
|
||||
{"Europe/Kiev", EET},
|
||||
{"Europe/Kirov", new String[] {"Kirov Standard Time", "GMT+03:00",
|
||||
"Kirov Daylight Time", "GMT+03:00",
|
||||
"Kirov Time", "GMT+03:00"}},
|
||||
{"Europe/Lisbon", WET},
|
||||
{"Europe/Ljubljana", CET},
|
||||
{"Europe/London", GMTBST},
|
||||
|
@ -20,10 +20,14 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
/*
|
||||
* @test
|
||||
* @bug 8149452 8151876 8181157
|
||||
* @summary Check the missing time zone names.
|
||||
* @bug 8149452 8151876 8181157 8206965
|
||||
* @modules java.base/sun.util.calendar
|
||||
* @run main/othervm -Duser.language=de -Duser.country=DE Bug8149452
|
||||
* @run main/othervm -Duser.language=ja -Duser.country=JP Bug8149452
|
||||
* @run main/othervm -Duser.language=en -Duser.country=US Bug8149452
|
||||
* @summary Check the missing time zone names for English, German and Japanese locales.
|
||||
*/
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
@ -34,21 +38,6 @@ import java.util.List;
|
||||
public class Bug8149452 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// These zone ids are new in tzdb and yet to be reflected in
|
||||
// CLDR data. Needs to be excluded from the test.
|
||||
// This list is as of CLDR version 29, and should be examined
|
||||
// on the CLDR data upgrade.
|
||||
List<String> NEW_ZONEIDS = List.of(
|
||||
"America/Punta_Arenas",
|
||||
"Asia/Atyrau",
|
||||
"Asia/Barnaul",
|
||||
"Asia/Famagusta",
|
||||
"Asia/Tomsk",
|
||||
"Europe/Astrakhan",
|
||||
"Europe/Kirov",
|
||||
"Europe/Saratov",
|
||||
"Europe/Ulyanovsk");
|
||||
|
||||
List<String> listNotFound = new ArrayList<>();
|
||||
String[][] zoneStrings = DateFormatSymbols.getInstance()
|
||||
.getZoneStrings();
|
||||
@ -57,8 +46,7 @@ public class Bug8149452 {
|
||||
.anyMatch(zone -> tzID.equalsIgnoreCase(zone[0]))) {
|
||||
// to ignore names for Etc/GMT[+-][0-9]+ which are not supported
|
||||
if (!tzID.startsWith("Etc/GMT")
|
||||
&& !tzID.startsWith("GMT")
|
||||
&& !NEW_ZONEIDS.contains(tzID)) {
|
||||
&& !tzID.startsWith("GMT")) {
|
||||
listNotFound.add(tzID);
|
||||
}
|
||||
}
|
||||
@ -68,7 +56,5 @@ public class Bug8149452 {
|
||||
throw new RuntimeException("Test Failed: Time Zone Strings for "
|
||||
+ listNotFound + " not found");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user