Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/util/Locale/Bug8001562.java
38813 views
1
/*
2
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 8001562
27
* @summary Verify that getAvailableLocales() in locale sensitive services
28
* classes return compatible set of locales as in JDK7.
29
* @run main Bug8001562
30
*/
31
32
import java.text.*;
33
import java.util.*;
34
35
public class Bug8001562 {
36
37
static final String[] jdk7availTags = {
38
"ar", "ar-AE", "ar-BH", "ar-DZ", "ar-EG", "ar-IQ", "ar-JO", "ar-KW",
39
"ar-LB", "ar-LY", "ar-MA", "ar-OM", "ar-QA", "ar-SA", "ar-SD", "ar-SY",
40
"ar-TN", "ar-YE", "be", "be-BY", "bg", "bg-BG", "ca", "ca-ES", "cs",
41
"cs-CZ", "da", "da-DK", "de", "de-AT", "de-CH", "de-DE", "de-LU", "el",
42
"el-CY", "el-GR", "en", "en-AU", "en-CA", "en-GB", "en-IE", "en-IN",
43
"en-MT", "en-NZ", "en-PH", "en-SG", "en-US", "en-ZA", "es", "es-AR",
44
"es-BO", "es-CL", "es-CO", "es-CR", "es-DO", "es-EC", "es-ES", "es-GT",
45
"es-HN", "es-MX", "es-NI", "es-PA", "es-PE", "es-PR", "es-PY", "es-SV",
46
"es-US", "es-UY", "es-VE", "et", "et-EE", "fi", "fi-FI", "fr", "fr-BE",
47
"fr-CA", "fr-CH", "fr-FR", "fr-LU", "ga", "ga-IE", "he", "he-IL",
48
"hi-IN", "hr", "hr-HR", "hu", "hu-HU", "id", "id-ID", "is", "is-IS",
49
"it", "it-CH", "it-IT", "ja", "ja-JP",
50
"ja-JP-u-ca-japanese-x-lvariant-JP", "ko", "ko-KR", "lt", "lt-LT", "lv",
51
"lv-LV", "mk", "mk-MK", "ms", "ms-MY", "mt", "mt-MT", "nl", "nl-BE",
52
"nl-NL", "no", "no-NO", "no-NO-x-lvariant-NY", "pl", "pl-PL", "pt",
53
"pt-BR", "pt-PT", "ro", "ro-RO", "ru", "ru-RU", "sk", "sk-SK", "sl",
54
"sl-SI", "sq", "sq-AL", "sr", "sr-BA", "sr-CS", "sr-Latn", "sr-Latn-BA",
55
"sr-Latn-ME", "sr-Latn-RS", "sr-ME", "sr-RS", "sv", "sv-SE", "th",
56
"th-TH", "th-TH-u-nu-thai-x-lvariant-TH", "tr", "tr-TR", "uk", "uk-UA",
57
"vi", "vi-VN", "zh", "zh-CN", "zh-HK", "zh-SG", "zh-TW", };
58
static List<Locale> jdk7availLocs = new ArrayList<>();
59
static {
60
for (String locStr : jdk7availTags) {
61
jdk7availLocs.add(Locale.forLanguageTag(locStr));
62
}
63
}
64
65
public static void main(String[] args) {
66
List<Locale> avail = Arrays.asList(BreakIterator.getAvailableLocales());
67
diffLocale(BreakIterator.class, avail);
68
69
avail = Arrays.asList(Collator.getAvailableLocales());
70
diffLocale(Collator.class, avail);
71
72
avail = Arrays.asList(DateFormat.getAvailableLocales());
73
diffLocale(DateFormat.class, avail);
74
75
avail = Arrays.asList(DateFormatSymbols.getAvailableLocales());
76
diffLocale(DateFormatSymbols.class, avail);
77
78
avail = Arrays.asList(DecimalFormatSymbols.getAvailableLocales());
79
diffLocale(DecimalFormatSymbols.class, avail);
80
81
avail = Arrays.asList(NumberFormat.getAvailableLocales());
82
diffLocale(NumberFormat.class, avail);
83
84
avail = Arrays.asList(Locale.getAvailableLocales());
85
diffLocale(Locale.class, avail);
86
}
87
88
static void diffLocale(Class c, List<Locale> locs) {
89
String diff = "";
90
91
System.out.printf("Only in target locales (%s.getAvailableLocales()): ", c.getSimpleName());
92
for (Locale l : locs) {
93
if (!jdk7availLocs.contains(l)) {
94
diff += "\""+l.toLanguageTag()+"\", ";
95
}
96
}
97
System.out.println(diff);
98
diff = "";
99
100
System.out.printf("Only in JDK7 (%s.getAvailableLocales()): ", c.getSimpleName());
101
for (Locale l : jdk7availLocs) {
102
if (!locs.contains(l)) {
103
diff += "\""+l.toLanguageTag()+"\", ";
104
}
105
}
106
System.out.println(diff);
107
108
if (diff.length() > 0) {
109
throw new RuntimeException("Above locale(s) were not included in the target available locales");
110
}
111
}
112
}
113
114