Skip to content

Commit d0fa5c3

Browse files
author
naoto
committed
8234347: "Turkey" meta time zone does not generate composed localized names
8236548: Localized time zone name inconsistency between English and other locales Reviewed-by: joehw, rriggs
1 parent 834c0e6 commit d0fa5c3

File tree

10 files changed

+177
-255
lines changed

10 files changed

+177
-255
lines changed

make/CompileToolsJdk.gmk

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@ $(eval $(call IncludeCustomExtension, CompileTools.gmk))
3939
# Use += to be able to add to this from a custom extension
4040
BUILD_TOOLS_SRC_DIRS += \
4141
$(TOPDIR)/make/jdk/src/classes \
42-
$(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes \
4342
$(BUILDTOOLS_OUTPUTDIR)/interim_tzdb_classes \
4443
#
4544

make/CopyInterimCLDRConverter.gmk

-52
This file was deleted.

make/Main.gmk

+3-7
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,9 @@ ifneq ($(CREATING_BUILDJDK), true)
7878
interim-rmic:
7979
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterimRmic.gmk)
8080

81-
interim-cldrconverter:
82-
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimCLDRConverter.gmk)
83-
84-
interim-tzdb:
81+
interim-tzdb:
8582
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimTZDB.gmk)
8683

87-
8884
buildtools-jdk:
8985
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileToolsJdk.gmk)
9086

@@ -96,7 +92,7 @@ interim-tzdb:
9692
endif
9793

9894
ALL_TARGETS += buildtools-langtools interim-langtools \
99-
interim-rmic interim-cldrconverter interim-tzdb buildtools-jdk buildtools-modules \
95+
interim-rmic interim-tzdb buildtools-jdk buildtools-modules \
10096
buildtools-hotspot
10197

10298
################################################################################
@@ -689,7 +685,7 @@ else
689685

690686
interim-langtools: $(INTERIM_LANGTOOLS_GENSRC_TARGETS)
691687

692-
buildtools-jdk: interim-langtools interim-cldrconverter interim-tzdb
688+
buildtools-jdk: interim-langtools interim-tzdb
693689

694690
buildtools-hotspot: interim-langtools
695691

make/jdk/src/classes/build/tools/cldrconverter/Bundle.java

-41
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ Map<String, Object> getTargetMap() throws Exception {
297297
}
298298

299299
// First, weed out any empty timezone or metazone names from myMap.
300-
// Fill in any missing abbreviations if locale is "en".
301300
for (Iterator<String> it = myMap.keySet().iterator(); it.hasNext();) {
302301
String key = it.next();
303302
if (key.startsWith(CLDRConverter.TIMEZONE_ID_PREFIX)
@@ -310,10 +309,6 @@ Map<String, Object> getTargetMap() throws Exception {
310309
it.remove();
311310
continue;
312311
}
313-
314-
if (id.equals("en")) {
315-
fillInJREs(key, nameMap);
316-
}
317312
}
318313
}
319314
for (Iterator<String> it = myMap.keySet().iterator(); it.hasNext();) {
@@ -626,42 +621,6 @@ private String toMetaZoneKey(String tzKey) {
626621
return null;
627622
}
628623

629-
static List<Object[]> jreTimeZoneNames = Arrays.asList(TimeZoneNames.getContents());
630-
private void fillInJREs(String key, Map<String, String> map) {
631-
String tzid = null;
632-
633-
if (key.startsWith(CLDRConverter.METAZONE_ID_PREFIX)) {
634-
// Look for tzid
635-
String meta = key.substring(CLDRConverter.METAZONE_ID_PREFIX.length());
636-
if (meta.equals("GMT")) {
637-
tzid = meta;
638-
} else {
639-
for (String tz : CLDRConverter.handlerMetaZones.keySet()) {
640-
if (CLDRConverter.handlerMetaZones.get(tz).equals(meta)) {
641-
tzid = tz;
642-
break;
643-
}
644-
}
645-
}
646-
} else {
647-
tzid = key.substring(CLDRConverter.TIMEZONE_ID_PREFIX.length());
648-
}
649-
650-
if (tzid != null) {
651-
for (Object[] jreZone : jreTimeZoneNames) {
652-
if (jreZone[0].equals(tzid)) {
653-
for (int i = 0; i < ZONE_NAME_KEYS.length; i++) {
654-
if (map.get(ZONE_NAME_KEYS[i]) == null) {
655-
String[] jreNames = (String[])jreZone[1];
656-
map.put(ZONE_NAME_KEYS[i], jreNames[i]);
657-
}
658-
}
659-
break;
660-
}
661-
}
662-
}
663-
}
664-
665624
private void convert(CalendarType calendarType, char cldrLetter, int count, StringBuilder sb) {
666625
switch (cldrLetter) {
667626
case 'G':

make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java

+24-71
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
2525

2626
package build.tools.cldrconverter;
2727

28-
import static build.tools.cldrconverter.Bundle.jreTimeZoneNames;
2928
import build.tools.cldrconverter.BundleGenerator.BundleType;
3029
import java.io.File;
3130
import java.io.IOException;
@@ -87,7 +86,9 @@ public class CLDRConverter {
8786
static final String ZONE_NAME_PREFIX = "timezone.displayname.";
8887
static final String METAZONE_ID_PREFIX = "metazone.id.";
8988
static final String PARENT_LOCALE_PREFIX = "parentLocale.";
89+
static final String META_EMPTY_ZONE_NAME = "EMPTY_ZONE";
9090
static final String[] EMPTY_ZONE = {"", "", "", "", "", ""};
91+
static final String META_ETCUTC_ZONE_NAME = "ETC_UTC";
9192

9293
private static SupplementDataParseHandler handlerSuppl;
9394
private static LikelySubtagsParseHandler handlerLikelySubtags;
@@ -666,68 +667,21 @@ private static Map<String, Object> extractCurrencyNames(Map<String, Object> map,
666667
private static Map<String, Object> extractZoneNames(Map<String, Object> map, String id) {
667668
Map<String, Object> names = new HashMap<>();
668669

669-
// Copy over missing time zone ids from JRE for English locale
670-
if (id.equals("en")) {
671-
Map<String[], String> jreMetaMap = new HashMap<>();
672-
jreTimeZoneNames.stream().forEach(e -> {
673-
String tzid = (String)e[0];
674-
String[] data = (String[])e[1];
675-
676-
if (map.get(TIMEZONE_ID_PREFIX + tzid) == null &&
677-
handlerMetaZones.get(tzid) == null ||
678-
handlerMetaZones.get(tzid) != null &&
679-
map.get(METAZONE_ID_PREFIX + handlerMetaZones.get(tzid)) == null) {
680-
681-
// First, check the alias
682-
String canonID = canonicalTZMap.get(tzid);
683-
if (canonID != null && !tzid.equals(canonID)) {
684-
Object value = map.get(TIMEZONE_ID_PREFIX + canonID);
685-
if (value != null) {
686-
names.put(tzid, value);
687-
return;
688-
} else {
689-
String meta = handlerMetaZones.get(canonID);
690-
if (meta != null) {
691-
value = map.get(METAZONE_ID_PREFIX + meta);
692-
if (value != null) {
693-
names.put(tzid, meta);
694-
return;
695-
}
696-
}
697-
}
698-
}
699-
700-
// Check the CLDR meta key
701-
Optional<Map.Entry<String, String>> cldrMeta =
702-
handlerMetaZones.getData().entrySet().stream()
703-
.filter(me ->
704-
Arrays.deepEquals(data,
705-
(String[])map.get(METAZONE_ID_PREFIX + me.getValue())))
706-
.findAny();
707-
cldrMeta.ifPresentOrElse(meta -> names.put(tzid, meta.getValue()), () -> {
708-
// Check the JRE meta key, add if there is not.
709-
Optional<Map.Entry<String[], String>> jreMeta =
710-
jreMetaMap.entrySet().stream()
711-
.filter(jm -> Arrays.deepEquals(data, jm.getKey()))
712-
.findAny();
713-
jreMeta.ifPresentOrElse(meta -> names.put(tzid, meta.getValue()), () -> {
714-
String metaName = "JRE_" + tzid.replaceAll("[/-]", "_");
715-
names.put(METAZONE_ID_PREFIX + metaName, data);
716-
names.put(tzid, metaName);
717-
});
718-
});
719-
}
720-
});
721-
}
722-
723670
getAvailableZoneIds().stream().forEach(tzid -> {
724671
// If the tzid is deprecated, get the data for the replacement id
725672
String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid))
726673
.orElse(tzid);
727674
Object data = map.get(TIMEZONE_ID_PREFIX + tzKey);
728675

729676
if (data instanceof String[]) {
730-
names.put(tzid, data);
677+
// Hack for UTC. UTC is an alias to Etc/UTC in CLDR
678+
if (tzid.equals("Etc/UTC") && !map.containsKey(TIMEZONE_ID_PREFIX + "UTC")) {
679+
names.put(METAZONE_ID_PREFIX + META_ETCUTC_ZONE_NAME, data);
680+
names.put(tzid, META_ETCUTC_ZONE_NAME);
681+
names.put("UTC", META_ETCUTC_ZONE_NAME);
682+
} else {
683+
names.put(tzid, data);
684+
}
731685
} else {
732686
String meta = handlerMetaZones.get(tzKey);
733687
if (meta != null) {
@@ -744,24 +698,23 @@ private static Map<String, Object> extractZoneNames(Map<String, Object> map, Str
744698

745699
// exemplar cities.
746700
Map<String, Object> exCities = map.entrySet().stream()
747-
.filter(e -> e.getKey().startsWith(CLDRConverter.EXEMPLAR_CITY_PREFIX))
748-
.collect(Collectors
749-
.toMap(Map.Entry::getKey, Map.Entry::getValue));
701+
.filter(e -> e.getKey().startsWith(CLDRConverter.EXEMPLAR_CITY_PREFIX))
702+
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
750703
names.putAll(exCities);
751704

752-
if (!id.equals("en") &&
753-
!names.isEmpty()) {
754-
// CLDR does not have UTC entry, so add it here.
755-
names.put("UTC", EMPTY_ZONE);
756-
757-
// no metazone zones
758-
Arrays.asList(handlerMetaZones.get(MetaZonesParseHandler.NO_METAZONE_KEY)
759-
.split("\\s")).stream()
760-
.forEach(tz -> {
761-
names.put(tz, EMPTY_ZONE);
762-
});
705+
// If there's no UTC entry at this point, add an empty one
706+
if (!names.isEmpty() && !names.containsKey("UTC")) {
707+
names.putIfAbsent(METAZONE_ID_PREFIX + META_EMPTY_ZONE_NAME, EMPTY_ZONE);
708+
names.put("UTC", META_EMPTY_ZONE_NAME);
763709
}
764710

711+
// Finally some compatibility stuff
712+
ZoneId.SHORT_IDS.entrySet().stream()
713+
.filter(e -> !names.containsKey(e.getKey()) && names.containsKey(e.getValue()))
714+
.forEach(e -> {
715+
names.put(e.getKey(), names.get(e.getValue()));
716+
});
717+
765718
return names;
766719
}
767720

src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -4232,9 +4232,15 @@ public int parse(DateTimeParseContext context, CharSequence text, int position)
42324232
char nextNextChar = text.charAt(position + 1);
42334233
if (context.charEquals(nextChar, 'U') && context.charEquals(nextNextChar, 'T')) {
42344234
if (length >= position + 3 && context.charEquals(text.charAt(position + 2), 'C')) {
4235-
return parseOffsetBased(context, text, position, position + 3, OffsetIdPrinterParser.INSTANCE_ID_ZERO);
4235+
// There are localized zone texts that start with "UTC", e.g.
4236+
// "UTC\u221210:00" (MINUS SIGN instead of HYPHEN-MINUS) in French.
4237+
// Exclude those ZoneText cases.
4238+
if (!(this instanceof ZoneTextPrinterParser)) {
4239+
return parseOffsetBased(context, text, position, position + 3, OffsetIdPrinterParser.INSTANCE_ID_ZERO);
4240+
}
4241+
} else {
4242+
return parseOffsetBased(context, text, position, position + 2, OffsetIdPrinterParser.INSTANCE_ID_ZERO);
42364243
}
4237-
return parseOffsetBased(context, text, position, position + 2, OffsetIdPrinterParser.INSTANCE_ID_ZERO);
42384244
} else if (context.charEquals(nextChar, 'G') && length >= position + 3 &&
42394245
context.charEquals(nextNextChar, 'M') && context.charEquals(text.charAt(position + 2), 'T')) {
42404246
if (length >= position + 4 && context.charEquals(text.charAt(position + 3), '0')) {

0 commit comments

Comments
 (0)