Skip to content

Commit 5279a2d

Browse files
authored
Fix for i18n for JDK22+ onwards (#6651)
* Fix for i18n for JDK22+ onwards Month format is changed from jdk22 onwards from M\uc6d4 to MMMM Signed-off-by: Pratiksha Sawant <[email protected]> * Removing try catch duplication and introducing a new function to get ResourceBundle Signed-off-by: Pratiksha Sawant <[email protected]> --------- Signed-off-by: Pratiksha Sawant <[email protected]>
1 parent c0cd9d7 commit 5279a2d

File tree

4 files changed

+173
-22
lines changed

4 files changed

+173
-22
lines changed

functional/MBCS_Tests/i18n/playlist.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ limitations under the License.
3232
<testCaseName>MBCS_Tests_i18n_ko_KR_linux</testCaseName>
3333
<command>LANG=ko_KR.UTF-8 perl $(TEST_RESROOT)$(D)test.pl; \
3434
$(TEST_STATUS)</command>
35-
<disables>
36-
<disable>
37-
<comment>https://github.com/adoptium/aqa-tests/issues/5148</comment>
38-
<version>22+</version>
39-
<impl>hotspot</impl>
40-
</disable>
41-
<disable>
42-
<comment>https://github.com/eclipse-openj9/openj9/issues/19083</comment>
43-
<version>22+</version>
44-
<impl>openj9</impl>
45-
</disable>
46-
</disables>
4735
<platformRequirements>os.linux</platformRequirements>
4836
<levels>
4937
<level>special</level>

functional/MBCS_Tests/i18n/src/DateFormatTest.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@ public DateFormatTest(Locale locale) {
3434
version = version.substring(index1+1, index2);
3535
}
3636
}
37-
long feature = JavaVersion.getFeature();
38-
if (feature == 16L) {
39-
try {
40-
resource = ResourceBundle.getBundle("ResourceBundleTest_16", locale);
41-
} catch (MissingResourceException e) {} // Do nothing
42-
} else if (feature >= 19L) {
43-
try {
44-
resource = ResourceBundle.getBundle("ResourceBundleTest_19", locale);
45-
} catch (MissingResourceException e) {} // Do nothing
46-
}
37+
long feature = JavaVersion.getFeature();
38+
if (feature >= 22L) {
39+
resource = tryGetBundle("ResourceBundleTest_22", locale);
40+
} else if (feature >= 19L) {
41+
resource = tryGetBundle("ResourceBundleTest_19", locale);
42+
} else if (feature == 16L) {
43+
resource = tryGetBundle("ResourceBundleTest_16", locale);
44+
}
4745
if (resource == null){
4846
resource = ResourceBundle.getBundle("ResourceBundleTest", locale);
4947
}
@@ -56,6 +54,14 @@ public DateFormatTest(Locale locale) {
5654
}
5755
}
5856

57+
private ResourceBundle tryGetBundle(String baseName, Locale locale) {
58+
try {
59+
return ResourceBundle.getBundle(baseName, locale);
60+
} catch (MissingResourceException e) {
61+
return null;
62+
}
63+
}
64+
5965
public DateFormatTest() {
6066
this(Locale.getDefault());
6167
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*******************************************************************************
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*******************************************************************************/
14+
import java.util.ListResourceBundle;
15+
16+
public class ResourceBundleTest_22_ko extends ListResourceBundle {
17+
public Object[][] getContents(){
18+
return contents;
19+
}
20+
21+
/* *_4 is for Java1.4.x */
22+
static final Object[][] contents = {
23+
{"locale","\uc5b8\uc5b4"},
24+
{"timezone","\uc2dc\uac04"},
25+
{"date","\ub0a0\uc9dc"},
26+
{"number","\uc22b\uc790"},
27+
{"currency","\ud1b5\ud654"},
28+
{"percent","\ud37c\uc13c\ud2b8"},
29+
{"FullFormat","y\ub144 MMMM d\uc77c EEEE a h\uc2dc m\ubd84 s\ucd08 zzzz"},
30+
{"LongFormat","y\ub144 MMMM d\uc77c a h\uc2dc m\ubd84 s\ucd08 z"},
31+
{"MediumFormat","y. M. d. a h:mm:ss"},
32+
{"ShortFormat","yy. M. d. a h:mm"},
33+
/* for E,EE,EEE */
34+
{"Day1","\uc77c"},
35+
{"Day2","\uc6d4"},
36+
{"Day3","\ud654"},
37+
{"Day4","\uc218"},
38+
{"Day5","\ubaa9"},
39+
{"Day6","\uae08"},
40+
{"Day7","\ud1a0"},
41+
/* for EEEE */
42+
{"Day1F","\uc77c\uc694\uc77c"},
43+
{"Day2F","\uc6d4\uc694\uc77c"},
44+
{"Day3F","\ud654\uc694\uc77c"},
45+
{"Day4F","\uc218\uc694\uc77c"},
46+
{"Day5F","\ubaa9\uc694\uc77c"},
47+
{"Day6F","\uae08\uc694\uc77c"},
48+
{"Day7F","\ud1a0\uc694\uc77c"},
49+
/* for MMM */
50+
{"Month1","1\uc6d4"},
51+
{"Month2","2\uc6d4"},
52+
{"Month3","3\uc6d4"},
53+
{"Month4","4\uc6d4"},
54+
{"Month5","5\uc6d4"},
55+
{"Month6","6\uc6d4"},
56+
{"Month7","7\uc6d4"},
57+
{"Month8","8\uc6d4"},
58+
{"Month9","9\uc6d4"},
59+
{"Month10","10\uc6d4"},
60+
{"Month11","11\uc6d4"},
61+
{"Month12","12\uc6d4"},
62+
/* for MMMM */
63+
{"Month1F","1\uc6d4"},
64+
{"Month2F","2\uc6d4"},
65+
{"Month3F","3\uc6d4"},
66+
{"Month4F","4\uc6d4"},
67+
{"Month5F","5\uc6d4"},
68+
{"Month6F","6\uc6d4"},
69+
{"Month7F","7\uc6d4"},
70+
{"Month8F","8\uc6d4"},
71+
{"Month9F","9\uc6d4"},
72+
{"Month10F","10\uc6d4"},
73+
{"Month11F","11\uc6d4"},
74+
{"Month12F","12\uc6d4"},
75+
/* for a */
76+
{"AM","\uc624\uc804"},
77+
{"PM","\uc624\ud6c4"},
78+
};
79+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*******************************************************************************
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*******************************************************************************/
14+
import java.util.ListResourceBundle;
15+
16+
public class ResourceBundleTest_22_zh_CN extends ListResourceBundle {
17+
public Object[][] getContents(){
18+
return contents;
19+
}
20+
21+
static final Object[][] contents = {
22+
{"locale","Locale"},
23+
{"timezone","Time Zone"},
24+
{"date","Date"},
25+
{"number","Number"},
26+
{"currency","Currency"},
27+
{"percent","Percent"},
28+
{"FullFormat","y\u5e74M\u6708d\u65e5EEEE zzzz HH:mm:ss"},
29+
{"LongFormat","y\u5e74M\u6708d\u65e5 z HH:mm:ss"},
30+
{"MediumFormat","y\u5e74M\u6708d\u65e5 HH:mm:ss"},
31+
{"ShortFormat","y/M/d HH:mm"},
32+
/* for E,EE,EEE */
33+
{"Day1","\u65e5"},
34+
{"Day2","\u4e00"},
35+
{"Day3","\u4e8c"},
36+
{"Day4","\u4e09"},
37+
{"Day5","\u56db"},
38+
{"Day6","\u4e94"},
39+
{"Day7","\u516d"},
40+
/* for EEEE */
41+
{"Day1F","\u661f\u671f\u65e5"},
42+
{"Day2F","\u661f\u671f\u4e00"},
43+
{"Day3F","\u661f\u671f\u4e8c"},
44+
{"Day4F","\u661f\u671f\u4e09"},
45+
{"Day5F","\u661f\u671f\u56db"},
46+
{"Day6F","\u661f\u671f\u4e94"},
47+
{"Day7F","\u661f\u671f\u516d"},
48+
/* for MMM */
49+
{"Month1","1"},
50+
{"Month2","2"},
51+
{"Month3","3"},
52+
{"Month4","4"},
53+
{"Month5","5"},
54+
{"Month6","6"},
55+
{"Month7","7"},
56+
{"Month8","8"},
57+
{"Month9","9"},
58+
{"Month10","10"},
59+
{"Month11","11"},
60+
{"Month12","12"},
61+
/* for MMMM */
62+
{"Month1F","1\u6708"},
63+
{"Month2F","2\u6708"},
64+
{"Month3F","3\u6708"},
65+
{"Month4F","4\u6708"},
66+
{"Month5F","5\u6708"},
67+
{"Month6F","6\u6708"},
68+
{"Month7F","7\u6708"},
69+
{"Month8F","8\u6708"},
70+
{"Month9F","9\u6708"},
71+
{"Month10F","10\u6708"},
72+
{"Month11F","11\u6708"},
73+
{"Month12F","12\u6708"},
74+
/* for a */
75+
{"AM","\u4e0a\u5348"},
76+
{"PM","\u4e0b\u5348"},
77+
};
78+
}

0 commit comments

Comments
 (0)