Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/util/Locale/PrintDefaultLocale.java
41149 views
1
/*
2
* Copyright (c) 2007, 2010, 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
*
26
* (C) Copyright IBM Corp. 1998 - All Rights Reserved
27
*
28
* Portions copyright (c) 2007 Sun Microsystems, Inc.
29
* All Rights Reserved.
30
*
31
* The original version of this source code and documentation
32
* is copyrighted and owned by Taligent, Inc., a wholly-owned
33
* subsidiary of IBM. These materials are provided under terms
34
* of a License Agreement between Taligent and Sun. This technology
35
* is protected by multiple US and International patents.
36
*
37
* This notice and attribution to Taligent may not be removed.
38
* Taligent is a registered trademark of Taligent, Inc.
39
*
40
* Permission to use, copy, modify, and distribute this software
41
* and its documentation for NON-COMMERCIAL purposes and without
42
* fee is hereby granted provided that this copyright notice
43
* appears in all copies. Please refer to the file "copyright.html"
44
* for further important copyright and licensing information.
45
*
46
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
47
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
48
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
49
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
50
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
51
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
52
*
53
*/
54
/*
55
@bug 4123370 4091969 4118731 4182108 4778440
56
57
The "at-test" tag was removed from this file, because there's no way to
58
run this test in an automated test harness. It depends on having various
59
different locales installed on the machine, and on Windows it depends
60
on the user going to the "Regional Settings" control panel and changing
61
the settings before running the test for each bug. We can run this test
62
manually from time to time to ensure that there has been no regression,
63
but it's not automated. -- lwerner, 7/6/98
64
65
INSTRUCTIONS FOR RUNNING THIS TEST
66
==================================
67
This test is designed to check for problems in the JVM code that initializes the
68
default Java locale (the locale returned by Locale.getDefault()) from the system
69
locale settings (or from command-line arguments). Since detecting a regression
70
usually requires setting the environment up in some way prior to running the test,
71
this is a manual test.
72
73
The test simply prints out the internal ID and display name of the default Java locale,
74
and the name of the default Java character encoding. It passes if these are what
75
you expect them to be, and fails if they're not.
76
77
Bug #4091969:
78
To test for bug #4091969, run this test on a Korean-localized version of
79
Windows, with the default locale set to Korean. You should get "ko_KR"
80
as the default locale.
81
82
Bug #4123370:
83
One part of bug #4123370 duplicates bug #4091969, which is covered by the
84
instructions above.
85
86
To test the unique part of bug #4123370, use the "Regional Settings" control
87
panel to set the currect locale to each of the different Spanish-language locales.
88
Run this test once for each Spanish-language locale. You should see the appropriate
89
locale ID and name for each locale. Both "Spanish - Traditional Sort" and
90
"Spanish - Modern Sort" should produce "es_ES" and "Spanish (Spain)".
91
92
Bug #4118731:
93
The basic issue here was that we had changed so that calling getDisplayName()
94
on a locale that didn't include a country code no longer included a country
95
name (instead of picking a default country name, as before), which is the
96
right answer. The problem is we weren't always getting back a system default
97
locale from Solaris that includes a country code, even though we should.
98
99
To test this, set the system default locale to a locale that doesn't include
100
a country code, such as "fr" or "de", using (in the C shell) "setenv LC_ALL fr"
101
(or whatever the locale ID you want is). Running PrintDefaultLocale should
102
still produce a locale ID, and a locale display name, that include a country
103
code (and country name). [Remember to make sure the locale is actually installed
104
first.]
105
106
To test the specific complaint in the bug, use "setenv LC_ALL ja". Also pay
107
special attention to Solaris locale IDs that don't match the corresponding java
108
locales, such as "su" (which should turn into "fi_FI"), "cz" (which should turn
109
into "cs_CZ"), and "en_UK" (which should turn into "en_GB").
110
111
Bug #4079167:
112
Test this bug the same way you test bug #4118731. Set the locale to each of
113
the specified locale IDs (e.g., "setenv LC_ALL japanese"), and then run
114
PrintDefaultLocale. You should get the following results:
115
Solaris ID Java ID Java display name Encoding
116
========== ======= ==================== ========
117
japanese ja_JP Japanese (Japan) --
118
korean ko_KR Korean (South Korea) --
119
tchinese zh_TW Chinese (Taiwan) --
120
big5 zh_TW Chinese (Taiwan) Big5
121
(Where "--" is marked for "encoding," the result isn't important-- it's the
122
default encoding for that locale, which we don't test. It should be something
123
plausible. Also note that this test presupposed you actually have locales
124
with these names installed on your system.)
125
126
Bug #4154559, 4778440:
127
Set the locale to Norwegian (Bokmal) and Norwegian (Nynorsk) using the
128
Regional Settings control panel on Windows. For each setting, run this program.
129
You should see no_NO and no_NO_NY, respectively.
130
131
Bug #4182108:
132
Test this bug the same way you test bug #4118731. Set the locale to
133
each of the specified locale IDs (e.g., "setenv LC_ALL japanese"), and
134
then run PrintDefaultLocale. You should get the following results:
135
136
Solaris ID Java ID Encoding
137
========== ======= ========
138
cz cs_CZ --
139
su fi_FI --
140
fr.ISO8859-15 fr_FR ISO8859-15
141
fr.ISO8859-15@euro fr_FR ISO8859-15
142
143
Where "--" is marked for "encoding," the result isn't important-- it's
144
the default encoding for that locale, which we don't test. It should be
145
something plausible. Also note that this test presupposed you actually
146
have locales with these names installed on your system.
147
148
As of this writing, there is a bug in Solaris or in the 8859-15/euro
149
patch for 2.6 (Solaris patch 106842-01) which causes nl_langinfo() to
150
return the wrong value for 8859-15 locales. As a result, the encoding
151
returned by this test is currency ISO8859-1 for 8859-15 locales.
152
153
Bug #4778440, 5005601, 5074060, 5107154:
154
Run the "deflocale" tool found in "data" directory (deflocale.sh on Unix,
155
deflocale.exe on Windows), and check the following:
156
157
4778440: Check that iw_IL is the default locale if the OS's locale is
158
Hebrew, and in_ID for Indonesian.
159
5005601: For Norwegian locales, no_NO is selected for Bokmal, and no_NO_NY
160
is selected for Nynorsk.
161
5074060, 5107154: On Windows XP ServicePack 2, check the default locales for the
162
following Windows locales. Compare with the golden data (deflocale.win):
163
Bengali - India
164
Croatian - Bosnia and Herzegovina
165
Bosnian - Bosnia and Herzegovina
166
Serbian (Latin) - Bosnia and Herzegovina
167
Serbian (Cyrillic) - Bosnia and Herzegovina
168
Welsh - United Kingdom
169
Maori - New Zealand
170
Malayalam - India
171
Maltese - Malta
172
Quechua - Bolivia
173
Quechua - Ecuador
174
Quechua - Peru
175
Setswana (Tswana) - South Africa
176
isiXhosa (Xhosa) - South Africa
177
isiZulu ( Zulu) - South Africa
178
Sesotho sa Leboa (Northern Sotho) - South Africa
179
Sami, Northern - Norway
180
Sami, Northern - Sweden
181
Sami, Northern - Finland
182
Sami, Lule - Norway
183
Sami, Lule - Sweden
184
Sami, Southern - Norway
185
Sami, Southern - Sweden
186
Sami, Skolt - Finland
187
Sami, Inari - Finland
188
189
Bug # 6409997:
190
Run the "deflocale.exe" tool found in "data" directory on Windows Vista.
191
It contains the following new locales:
192
Tajik (Cyrillic) (Tajikistan) - 1251
193
Upper Sorbian (Germany) - 1252
194
Turkmen (Turkmenistan) - 1250
195
Oriya (India) - 0
196
Assamese (India) - 0
197
Tibetan (People's Republic of China) - 0
198
Khmer (Cambodia) - 0
199
Lao (Lao P.D.R.) - 0
200
Sinhala (Sri Lanka) - 0
201
Inuktitut (Canada) - 0
202
Amharic (Ethiopia) - 0
203
Hausa (Latin) (Nigeria) - 1252
204
Yoruba (Nigeria) - 1252
205
Bashkir (Russia) - 1251
206
Greenlandic (Greenland) - 1252
207
Igbo (Nigeria) - 1252
208
Yi (People's Republic of China) - 0
209
Breton (France) - 1252
210
Uighur (People's Republic of China) - 1256
211
Occitan (France) - 1252
212
Corsican (France) - 1252
213
Alsatian (France) - 1252
214
Yakut (Russia) - 1251
215
K'iche (Guatemala) - 1252
216
Kinyarwanda (Rwanda) - 1252
217
Wolof (Senegal) - 1252
218
Dari (Afghanistan) - 1256
219
Lower Sorbian (Germany) - 1252
220
Bengali (Bangladesh) - 0
221
Mongolian (Traditional Mongolian) (People's Republic of China) - 0
222
Tamazight (Latin) (Algeria) - 1252
223
English (India) - 1252
224
English (Malaysia) - 1252
225
English (Singapore) - 1252
226
Spanish (United States) - 1252
227
228
*/
229
import java.nio.charset.Charset;
230
import java.util.Locale;
231
232
public class PrintDefaultLocale {
233
public static void main(String[] args) {
234
System.out.printf("default locale: ID: %s, Name: %s\n",
235
Locale.getDefault().toString(),
236
Locale.getDefault().getDisplayName(Locale.US));
237
System.out.printf("display locale: ID: %s, Name: %s\n",
238
Locale.getDefault(Locale.Category.DISPLAY).toString(),
239
Locale.getDefault(Locale.Category.DISPLAY).getDisplayName(Locale.US));
240
System.out.printf("format locale: ID: %s, Name: %s\n",
241
Locale.getDefault(Locale.Category.FORMAT).toString(),
242
Locale.getDefault(Locale.Category.FORMAT).getDisplayName(Locale.US));
243
System.out.printf("default charset: %s\n", Charset.defaultCharset());
244
}
245
}
246
247