Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java
41149 views
1
/*
2
* Copyright (c) 2016, 2021, 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
import java.nio.file.Path;
25
import java.util.Arrays;
26
import java.util.ArrayList;
27
import java.util.List;
28
import java.util.Locale;
29
import java.util.stream.Collectors;
30
31
import jdk.tools.jlink.plugin.Plugin;
32
import jdk.tools.jlink.plugin.PluginException;
33
import jdk.tools.jlink.internal.PluginRepository;
34
import jdk.tools.jlink.internal.TaskHelper;
35
import jdk.tools.jlink.internal.plugins.PluginsResourceBundle;
36
import tests.Helper;
37
import tests.JImageGenerator;
38
import tests.JImageValidator;
39
import tests.Result;
40
41
/*
42
* @test
43
* @bug 8152143 8152704 8155649 8165804 8185841 8176841 8190918
44
* 8179071 8202537 8221432 8222098 8251317 8258794
45
* @summary IncludeLocalesPlugin tests
46
* @author Naoto Sato
47
* @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g)
48
* @library ../../lib
49
* @modules java.base/jdk.internal.jimage
50
* jdk.jdeps/com.sun.tools.classfile
51
* jdk.jlink/jdk.tools.jlink.internal
52
* jdk.jlink/jdk.tools.jlink.internal.plugins
53
* jdk.jlink/jdk.tools.jlink.plugin
54
* jdk.jlink/jdk.tools.jmod
55
* jdk.jlink/jdk.tools.jimage
56
* jdk.compiler
57
* @build tests.*
58
* @build tools.jlink.plugins.GetAvailableLocales
59
* @run main/othervm/timeout=180 -Xmx1g IncludeLocalesPluginTest
60
*/
61
public class IncludeLocalesPluginTest {
62
63
private final static String moduleName = "IncludeLocalesTest";
64
private static Helper helper;
65
private final static int INCLUDE_LOCALES_OPTION = 0;
66
private final static int ADDMODS_OPTION = 1;
67
private final static int EXPECTED_LOCATIONS = 2;
68
private final static int UNEXPECTED_PATHS = 3;
69
private final static int AVAILABLE_LOCALES = 4;
70
private final static int ERROR_MESSAGE = 5;
71
72
private static int errors;
73
74
private final static Object[][] testData = {
75
// Test data should include:
76
// - --include-locales command line option
77
// - --add-modules command line option values
78
// - List of required resources in the result image
79
// - List of resources that should not exist in the result image
80
// - List of available locales in the result image
81
// - Error message
82
83
// without --include-locales option: should include all locales
84
{
85
"",
86
"jdk.localedata",
87
List.of(
88
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
89
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
90
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
91
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class",
92
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
93
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
94
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class",
95
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
96
List.of(),
97
Arrays.stream(Locale.getAvailableLocales())
98
// "(root)" for Locale.ROOT rather than ""
99
.map(loc -> loc.equals(Locale.ROOT) ? "(root)" : loc.toString())
100
.collect(Collectors.toList()),
101
"",
102
},
103
104
// Asterisk works exactly the same as above
105
{
106
"--include-locales=*",
107
"jdk.localedata",
108
List.of(
109
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
110
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
111
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
112
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class",
113
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
114
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
115
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class",
116
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
117
List.of(),
118
Arrays.stream(Locale.getAvailableLocales())
119
// "(root)" for Locale.ROOT rather than ""
120
.map(loc -> loc.equals(Locale.ROOT) ? "(root)" : loc.toString())
121
.collect(Collectors.toList()),
122
"",
123
},
124
125
// World English/Spanish in Latin America
126
{
127
"--include-locales=en-001,es-419",
128
"jdk.localedata",
129
List.of(
130
"/jdk.localedata/sun/text/resources/ext/FormatData_en_AU.class",
131
"/jdk.localedata/sun/text/resources/ext/FormatData_es.class",
132
"/jdk.localedata/sun/text/resources/ext/FormatData_es_AR.class",
133
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
134
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_150.class",
135
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_AT.class",
136
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_es.class",
137
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_es_419.class",
138
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_es_AR.class"),
139
List.of(
140
"/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
141
"/jdk.localedata/sun/text/resources/ext/thai_dict",
142
"/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
143
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
144
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
145
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
146
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
147
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"),
148
List.of(
149
"(root)", "en", "en_US", "en_US_#Latn", "en_US_POSIX", "en_001", "en_150", "en_AG", "en_AI",
150
"en_AT", "en_AU", "en_BB", "en_BE", "en_BM", "en_BS", "en_BW", "en_BZ",
151
"en_CA", "en_CC", "en_CH", "en_CK", "en_CM", "en_CX", "en_CY", "en_DE",
152
"en_DG", "en_DK", "en_DM", "en_ER", "en_FI", "en_FJ", "en_FK", "en_FM",
153
"en_GB", "en_GD", "en_GG", "en_GH", "en_GI", "en_GM", "en_GY", "en_HK",
154
"en_IE", "en_IL", "en_IM", "en_IN", "en_IO", "en_JE", "en_JM", "en_KE",
155
"en_KI", "en_KN", "en_KY", "en_LC", "en_LR", "en_LS", "en_MG", "en_MO",
156
"en_MS", "en_MT", "en_MU", "en_MW", "en_MY", "en_NA", "en_NF", "en_NG",
157
"en_NL", "en_NR", "en_NU", "en_NZ", "en_PG", "en_PH", "en_PK", "en_PN",
158
"en_PW", "en_RW", "en_SB", "en_SC", "en_SD", "en_SE", "en_SG", "en_SH",
159
"en_SI", "en_SL", "en_SS", "en_SX", "en_SZ", "en_TC", "en_TK", "en_TO",
160
"en_TT", "en_TV", "en_TZ", "en_UG", "en_VC", "en_VG", "en_VU", "en_WS",
161
"en_ZA", "en_ZM", "en_ZW", "es", "es_419", "es_AR", "es_BO", "es_BR", "es_BZ",
162
"es_CL", "es_CO", "es_CR", "es_CU", "es_DO", "es_EC", "es_GT", "es_HN",
163
"es_MX", "es_NI", "es_PA", "es_PE", "es_PR", "es_PY", "es_SV", "es_US",
164
"es_UY", "es_VE"),
165
"",
166
},
167
168
// All English and Japanese locales
169
{
170
"--include-locales=en,ja",
171
"jdk.localedata",
172
List.of(
173
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
174
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
175
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
176
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class"),
177
List.of(
178
"/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
179
"/jdk.localedata/sun/text/resources/ext/thai_dict",
180
"/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
181
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
182
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
183
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class",
184
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class",
185
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
186
List.of(
187
"(root)", "en", "en_001", "en_150", "en_AE", "en_AG", "en_AI", "en_AS", "en_AT",
188
"en_AU", "en_BB", "en_BE", "en_BI", "en_BM", "en_BS", "en_BW", "en_BZ",
189
"en_CA", "en_CC", "en_CH", "en_CK", "en_CM", "en_CX", "en_CY", "en_DE",
190
"en_DG", "en_DK", "en_DM", "en_ER", "en_FI", "en_FJ", "en_FK", "en_FM",
191
"en_GB", "en_GD", "en_GG", "en_GH", "en_GI", "en_GM", "en_GU", "en_GY",
192
"en_HK", "en_IE", "en_IL", "en_IM", "en_IN", "en_IO", "en_JE", "en_JM",
193
"en_KE", "en_KI", "en_KN", "en_KY", "en_LC", "en_LR", "en_LS", "en_MG",
194
"en_MH", "en_MO", "en_MP", "en_MS", "en_MT", "en_MU", "en_MW", "en_MY",
195
"en_NA", "en_NF", "en_NG", "en_NL", "en_NR", "en_NU", "en_NZ", "en_PG",
196
"en_PH", "en_PK", "en_PN", "en_PR", "en_PW", "en_RW", "en_SB", "en_SC",
197
"en_SD", "en_SE", "en_SG", "en_SH", "en_SI", "en_SL", "en_SS", "en_SX",
198
"en_SZ", "en_TC", "en_TK", "en_TO", "en_TT", "en_TV", "en_TZ", "en_UG",
199
"en_UM", "en_US", "en_US_#Latn", "en_US_POSIX", "en_VC", "en_VG", "en_VI", "en_VU",
200
"en_WS", "en_ZA", "en_ZM", "en_ZW", "ja", "ja_JP", "ja_JP_#Jpan",
201
"ja_JP_JP_#u-ca-japanese"),
202
"",
203
},
204
205
// All locales in Austria
206
{
207
"--include-locales=*-AT",
208
"jdk.localedata",
209
List.of(
210
"/jdk.localedata/sun/text/resources/ext/FormatData_de.class",
211
"/jdk.localedata/sun/text/resources/ext/FormatData_de_AT.class",
212
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_de.class",
213
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_de_AT.class",
214
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
215
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_150.class",
216
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_AT.class"),
217
List.of(
218
"/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
219
"/jdk.localedata/sun/text/resources/ext/thai_dict",
220
"/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
221
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
222
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
223
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
224
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
225
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
226
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"),
227
List.of(
228
"(root)", "en", "en_001", "en_150", "en_AT", "en_US", "en_US_#Latn", "en_US_POSIX",
229
"de", "de_AT"),
230
"",
231
},
232
233
// All locales in India
234
{
235
"--include-locales=*-IN",
236
"jdk.localedata",
237
List.of(
238
"/jdk.localedata/sun/text/resources/ext/FormatData_en_IN.class",
239
"/jdk.localedata/sun/text/resources/ext/FormatData_hi_IN.class",
240
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
241
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_IN.class"),
242
List.of(
243
"/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
244
"/jdk.localedata/sun/text/resources/ext/thai_dict",
245
"/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
246
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
247
"/jdk.localedata/sun/text/resources/ext/BreakIteratorResources_th.class",
248
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
249
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
250
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
251
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class",
252
"/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_as_IN.class",
253
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
254
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class",
255
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
256
List.of(
257
"(root)", "as", "as_IN", "as_IN_#Beng", "bn", "bn_IN", "bo", "bo_IN", "brx", "brx_IN",
258
"brx_IN_#Deva", "ccp", "ccp_IN", "doi", "doi_IN", "doi_IN_#Deva", "en", "en_001", "en_IN",
259
"en_US", "en_US_#Latn", "en_US_POSIX", "gu", "gu_IN", "gu_IN_#Gujr", "hi", "hi_IN",
260
"hi_IN_#Deva", "kn", "kn_IN", "kn_IN_#Knda", "kok", "kok_IN", "kok_IN_#Deva", "ks_IN_#Arab",
261
"ks_IN", "ks__#Arab", "ks", "mai", "mai_IN", "mai_IN_#Deva", "mni", "mni__#Beng",
262
"mni_IN", "mni_IN_#Beng", "ml", "ml_IN", "ml_IN_#Mlym", "mr", "mr_IN", "mr_IN_#Deva", "ne",
263
"ne_IN", "or", "or_IN", "or_IN_#Orya", "pa", "pa__#Guru", "pa_IN", "pa_IN_#Guru", "sa",
264
"sa_IN", "sa_IN_#Deva", "sat", "sat__#Olck", "sat_IN", "sat_IN_#Olck", "sd", "sd__#Deva",
265
"sd_IN", "sd_IN_#Deva", "ta", "ta_IN", "ta_IN_#Taml", "te", "te_IN", "te_IN_#Telu", "ur_IN", "ur"),
266
"",
267
},
268
269
// Thai
270
{
271
"--include-locales=th",
272
"jdk.localedata",
273
List.of(
274
"/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
275
"/jdk.localedata/sun/text/resources/ext/thai_dict",
276
"/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
277
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
278
"/jdk.localedata/sun/text/resources/ext/BreakIteratorResources_th.class",
279
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class"),
280
List.of(
281
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
282
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
283
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class",
284
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
285
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
286
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
287
List.of(
288
"(root)", "en", "en_US", "en_US_#Latn", "en_US_POSIX", "th", "th_TH",
289
"th_TH_#Thai", "th_TH_TH_#u-nu-thai"),
290
"",
291
},
292
293
// Hong Kong
294
{
295
"--include-locales=zh-HK",
296
"jdk.localedata",
297
List.of(
298
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class",
299
"/jdk.localedata/sun/text/resources/ext/FormatData_zh_HK.class",
300
"/jdk.localedata/sun/text/resources/ext/FormatData_zh_TW.class",
301
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
302
List.of(
303
"/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
304
"/jdk.localedata/sun/text/resources/ext/thai_dict",
305
"/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
306
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
307
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
308
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
309
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
310
"/jdk.localedata/sun/text/resources/ext/FormatData_zh_CN.class",
311
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
312
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
313
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"),
314
List.of(
315
"(root)", "en", "en_US", "en_US_#Latn", "en_US_POSIX", "zh", "zh__#Hans", "zh__#Hant",
316
"zh_HK", "zh_HK_#Hans", "zh_HK_#Hant"),
317
"",
318
},
319
320
// Simplified Chinese
321
{
322
"--include-locales=zh-Hans",
323
"jdk.localedata",
324
List.of(
325
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class",
326
"/jdk.localedata/sun/text/resources/ext/FormatData_zh_CN.class",
327
"/jdk.localedata/sun/text/resources/ext/FormatData_zh_SG.class",
328
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
329
List.of(
330
"/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
331
"/jdk.localedata/sun/text/resources/ext/thai_dict",
332
"/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
333
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
334
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
335
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
336
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
337
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
338
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
339
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"),
340
List.of(
341
"(root)", "en", "en_US", "en_US_#Latn", "en_US_POSIX", "zh", "zh__#Hans", "zh_CN",
342
"zh_CN_#Hans", "zh_HK", "zh_HK_#Hans", "zh_MO", "zh_MO_#Hans", "zh_SG", "zh_SG_#Hans"),
343
"",
344
},
345
346
// Norwegian
347
{
348
"--include-locales=nb,nn,no",
349
"jdk.localedata",
350
List.of(
351
"/jdk.localedata/sun/text/resources/ext/FormatData_no.class",
352
"/jdk.localedata/sun/text/resources/ext/FormatData_no_NO.class",
353
"/jdk.localedata/sun/text/resources/ext/FormatData_no_NO_NY.class",
354
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_nb.class",
355
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_nn.class",
356
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_no.class"),
357
List.of(
358
"/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
359
"/jdk.localedata/sun/text/resources/ext/thai_dict",
360
"/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
361
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
362
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
363
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
364
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
365
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
366
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
367
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"),
368
List.of(
369
"(root)", "en", "en_US", "en_US_#Latn", "en_US_POSIX", "nb", "nb_NO",
370
"nb_NO_#Latn", "nb_SJ", "nn", "nn_NO", "nn_NO_#Latn", "no", "no_NO", "no_NO_NY",
371
"no_NO_#Latn"),
372
"",
373
},
374
375
// Hebrew/Indonesian/Yiddish
376
{
377
"--include-locales=he,id,yi",
378
"jdk.localedata",
379
List.of(
380
"/jdk.localedata/sun/text/resources/ext/FormatData_he.class",
381
"/jdk.localedata/sun/text/resources/ext/FormatData_he_IL.class",
382
"/jdk.localedata/sun/text/resources/ext/FormatData_id.class",
383
"/jdk.localedata/sun/text/resources/ext/FormatData_id_ID.class",
384
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_he.class",
385
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_id.class",
386
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_yi.class"),
387
List.of(
388
"/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
389
"/jdk.localedata/sun/text/resources/ext/thai_dict",
390
"/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
391
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
392
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
393
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
394
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
395
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
396
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
397
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"),
398
List.of(
399
"(root)", "en", "en_US", "en_US_#Latn", "en_US_POSIX", "id", "id_ID",
400
"id_ID_#Latn", "he", "he_IL", "he_IL_#Hebr", "yi", "yi_001", "yi_001_#Hebr"),
401
"",
402
},
403
404
// Langtag including extensions. Should be ignored.
405
{
406
"--include-locales=en,ja-u-nu-thai",
407
"jdk.localedata",
408
List.of(
409
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
410
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class"),
411
List.of(
412
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
413
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class"),
414
List.of(
415
"(root)", "en", "en_001", "en_150", "en_AE", "en_AG", "en_AI", "en_AS", "en_AT",
416
"en_AU", "en_BB", "en_BE", "en_BI", "en_BM", "en_BS", "en_BW", "en_BZ",
417
"en_CA", "en_CC", "en_CH", "en_CK", "en_CM", "en_CX", "en_CY", "en_DE",
418
"en_DG", "en_DK", "en_DM", "en_ER", "en_FI", "en_FJ", "en_FK", "en_FM",
419
"en_GB", "en_GD", "en_GG", "en_GH", "en_GI", "en_GM", "en_GU", "en_GY",
420
"en_HK", "en_IE", "en_IL", "en_IM", "en_IN", "en_IO", "en_JE", "en_JM",
421
"en_KE", "en_KI", "en_KN", "en_KY", "en_LC", "en_LR", "en_LS", "en_MG",
422
"en_MH", "en_MO", "en_MP", "en_MS", "en_MT", "en_MU", "en_MW", "en_MY",
423
"en_NA", "en_NF", "en_NG", "en_NL", "en_NR", "en_NU", "en_NZ", "en_PG",
424
"en_PH", "en_PK", "en_PN", "en_PR", "en_PW", "en_RW", "en_SB", "en_SC",
425
"en_SD", "en_SE", "en_SG", "en_SH", "en_SI", "en_SL", "en_SS", "en_SX",
426
"en_SZ", "en_TC", "en_TK", "en_TO", "en_TT", "en_TV", "en_TZ", "en_UG",
427
"en_UM", "en_US", "en_US_#Latn", "en_US_POSIX", "en_VC", "en_VG", "en_VI", "en_VU",
428
"en_WS", "en_ZA", "en_ZM", "en_ZW"),
429
"",
430
},
431
432
// Error case: No matching locales
433
{
434
"--include-locales=xyz",
435
"jdk.localedata",
436
null,
437
null,
438
null,
439
new PluginException(String.format(
440
PluginsResourceBundle.getMessage("include-locales.nomatchinglocales"), "xyz"))
441
.getMessage(),
442
},
443
444
// Error case: Invalid argument
445
{
446
"--include-locales=en,zh_HK",
447
"jdk.localedata",
448
null,
449
null,
450
null,
451
new PluginException(String.format(
452
PluginsResourceBundle.getMessage("include-locales.invalidtag"), "zh_hk"))
453
.getMessage(),
454
},
455
456
// Error case: jdk.localedata is not added
457
{
458
"--include-locales=en-US",
459
"java.base",
460
null,
461
null,
462
null,
463
new PluginException(
464
PluginsResourceBundle.getMessage("include-locales.localedatanotfound"))
465
.getMessage(),
466
},
467
};
468
469
public static void main(String[] args) throws Exception {
470
helper = Helper.newHelper();
471
if (helper == null) {
472
System.err.println("Test not run");
473
return;
474
}
475
helper.generateDefaultModules();
476
477
for (Object[] data : testData) {
478
// create image for each test data
479
Result result;
480
if (data[INCLUDE_LOCALES_OPTION].toString().isEmpty()) {
481
System.out.println("Invoking jlink with no --include-locales option");
482
result = JImageGenerator.getJLinkTask()
483
.modulePath(helper.defaultModulePath())
484
.output(helper.createNewImageDir(moduleName))
485
.addMods((String) data[ADDMODS_OPTION])
486
.call();
487
} else {
488
System.out.println("Invoking jlink with \"" + data[INCLUDE_LOCALES_OPTION] + "\"");
489
result = JImageGenerator.getJLinkTask()
490
.modulePath(helper.defaultModulePath())
491
.output(helper.createNewImageDir(moduleName))
492
.addMods((String) data[ADDMODS_OPTION])
493
.option((String) data[INCLUDE_LOCALES_OPTION])
494
.call();
495
}
496
497
String errorMsg = (String) data[ERROR_MESSAGE];
498
if (errorMsg.isEmpty()) {
499
Path image = result.assertSuccess();
500
501
// test locale data entries
502
testLocaleDataEntries(image,
503
(List<String>) data[EXPECTED_LOCATIONS],
504
(List<String>) data[UNEXPECTED_PATHS]);
505
506
// test available locales
507
testAvailableLocales(image, (List<String>) data[AVAILABLE_LOCALES]);
508
} else {
509
result.assertFailure(new TaskHelper(TaskHelper.JLINK_BUNDLE)
510
.getMessage("error.prefix") + " " +errorMsg);
511
System.out.println("\tExpected failure: " + result.getMessage());
512
}
513
}
514
515
if (errors > 0) {
516
throw new RuntimeException("Test failed");
517
}
518
}
519
520
private static void testLocaleDataEntries(Path image, List<String> expectedLocations,
521
List<String> unexpectedPaths) throws Exception {
522
System.out.println("testLocaleDataEntries:");
523
try {
524
JImageValidator.validate(
525
image.resolve("lib").resolve("modules"),
526
expectedLocations, unexpectedPaths);
527
} catch (Exception e) {
528
System.out.println("\tFailed with: " + e);
529
e.printStackTrace();
530
errors++;
531
}
532
}
533
534
private static void testAvailableLocales(Path image, List<String> availableLocales) throws Exception {
535
System.out.println("testAvailableLocales:");
536
Path launcher = image.resolve("bin/java" +
537
(System.getProperty("os.name").startsWith("Windows") ? ".exe" : ""));
538
List<String> args = new ArrayList<>(availableLocales.size() + 2);
539
args.add(launcher.toString());
540
args.add("GetAvailableLocales");
541
args.addAll(availableLocales);
542
Process proc = new ProcessBuilder(args).inheritIO().start();
543
544
int len = Math.min(10, args.size());
545
String command = args.subList(0, len).stream().collect(Collectors.joining(" "))
546
+ (len < availableLocales.size() ? " ..." : "");
547
548
int status = proc.waitFor();
549
if (status == 0) {
550
System.out.println("\tDone\t" + command);
551
} else {
552
System.out.println("\tExit " + status + "\t" + command);
553
errors++;
554
}
555
System.out.println();
556
}
557
}
558
559