Skip to content

Commit 8b24851

Browse files
author
Justin Lu
committed
8321480: ISO 4217 Amendment 176 Update
Reviewed-by: naoto
1 parent c328f95 commit 8b24851

File tree

5 files changed

+43
-33
lines changed

5 files changed

+43
-33
lines changed

make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2023, 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
@@ -32,6 +32,7 @@
3232
import java.io.FileOutputStream;
3333
import java.io.InputStream;
3434
import java.text.SimpleDateFormat;
35+
import java.util.Arrays;
3536
import java.util.Date;
3637
import java.util.HashMap;
3738
import java.util.Locale;
@@ -339,9 +340,15 @@ private static void buildOtherTables() {
339340
validCurrencyCodes.substring(i * 7 + 3, i * 7 + 6));
340341
checkCurrencyCode(currencyCode);
341342
int tableEntry = mainTable[(currencyCode.charAt(0) - 'A') * A_TO_Z + (currencyCode.charAt(1) - 'A')];
342-
if (tableEntry == INVALID_COUNTRY_ENTRY ||
343-
(tableEntry & SPECIAL_CASE_COUNTRY_MASK) != 0 ||
344-
(tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) != (currencyCode.charAt(2) - 'A')) {
343+
344+
// Do not allow a future currency to be classified as an otherCurrency,
345+
// otherwise it will leak out into Currency:getAvailableCurrencies
346+
boolean futureCurrency = Arrays.asList(specialCaseNewCurrencies).contains(currencyCode);
347+
boolean simpleCurrency = (tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) == (currencyCode.charAt(2) - 'A');
348+
349+
// If neither a simple currency, or one defined in the future
350+
// then the current currency is applicable to be added to the otherTable
351+
if (!futureCurrency && !simpleCurrency) {
345352
if (otherCurrenciesCount == maxOtherCurrencies) {
346353
throw new RuntimeException("too many other currencies");
347354
}

src/java.base/share/classes/sun/util/resources/CurrencyNames.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2005, 2023, 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
@@ -269,6 +269,7 @@ XBB=XBB
269269
XBC=XBC
270270
XBD=XBD
271271
XCD=XCD
272+
XCG=XCG
272273
XDR=XDR
273274
XFO=XFO
274275
XFU=XFU
@@ -494,6 +495,7 @@ xbb=European Monetary Unit
494495
xbc=European Unit of Account (XBC)
495496
xbd=European Unit of Account (XBD)
496497
xcd=East Caribbean Dollar
498+
xcg=Caribbean Guilder
497499
xdr=Special Drawing Rights
498500
xfo=French Gold Franc
499501
xfu=French UIC-Franc

src/java.base/share/data/currency/CurrencyData.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ formatVersion=3
3232
# Version of the currency code information in this class.
3333
# It is a serial number that accompanies with each amendment.
3434

35-
dataVersion=175
35+
dataVersion=176
3636

3737
# List of all valid ISO 4217 currency codes.
3838
# To ensure compatibility, do not remove codes.
@@ -55,7 +55,7 @@ all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036
5555
SRD968-SRG740-SSP728-STD678-STN930-SVC222-SYP760-SZL748-THB764-TJS972-TMM795-TMT934-TND788-TOP776-\
5656
TPE626-TRL792-TRY949-TTD780-TWD901-TZS834-UAH980-UGX800-USD840-USN997-USS998-UYI940-\
5757
UYU858-UZS860-VEB862-VED926-VEF937-VES928-VND704-VUV548-WST882-XAF950-XAG961-XAU959-XBA955-\
58-
XBB956-XBC957-XBD958-XCD951-XDR960-XFO000-XFU000-XOF952-XPD964-XPF953-\
58+
XBB956-XBC957-XBD958-XCD951-XCG532-XDR960-XFO000-XFU000-XOF952-XPD964-XPF953-\
5959
XPT962-XSU994-XTS963-XUA965-XXX999-YER886-YUM891-ZAR710-ZMK894-ZMW967-ZWD716-ZWL932-\
6060
ZWN942-ZWR935
6161

@@ -189,11 +189,11 @@ CR=CRC
189189
# COTE D'IVOIRE
190190
CI=XOF
191191
# CROATIA
192-
HR=HRK;2022-12-31-23-00-00;EUR
192+
HR=EUR
193193
# CUBA
194194
CU=CUP
195195
# Curaçao
196-
CW=ANG
196+
CW=ANG;2025-04-01-04-00-00;XCG
197197
# CYPRUS
198198
CY=EUR
199199
# CZECHIA
@@ -510,7 +510,7 @@ SR=SRD
510510
# SVALBARD AND JAN MAYEN
511511
SJ=NOK
512512
# Sint Maarten (Dutch part)
513-
SX=ANG
513+
SX=ANG;2025-04-01-04-00-00;XCG
514514
# ESWATINI
515515
SZ=SZL
516516
# SWEDEN

test/jdk/java/util/Currency/ValidateISO4217.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @test
2626
* @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759
2727
* 8039317 8074350 8074351 8145952 8187946 8193552 8202026 8204269
28-
* 8208746 8209775 8264792 8274658 8283277 8296239
28+
* 8208746 8209775 8264792 8274658 8283277 8296239 8321480
2929
* @summary Validate ISO 4217 data for Currency class.
3030
* @modules java.base/java.util:open
3131
* jdk.localedata
@@ -86,7 +86,7 @@ public class ValidateISO4217 {
8686
// Codes that are obsolete, do not have related country, extra currency
8787
private static final String otherCodes =
8888
"ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-BYR-CHE-CHW-CLF-COU-CUC-CYP-"
89-
+ "DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LTL-LUF-LVL-MGF-MRO-MTL-MXV-MZM-NLG-"
89+
+ "DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-HRK-IEP-ITL-LTL-LUF-LVL-MGF-MRO-MTL-MXV-MZM-NLG-"
9090
+ "PTE-ROL-RUR-SDD-SIT-SLL-SKK-SRG-STD-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-VED-"
9191
+ "XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-"
9292
+ "YUM-ZMK-ZWD-ZWN-ZWR";
@@ -168,7 +168,7 @@ private static void processColumns(StringTokenizer tokens, String country) throw
168168
if (format == null) {
169169
createDateFormat();
170170
}
171-
// If the cut-over already passed, test the changed data too
171+
// If the cut-over already passed, use the new curency for ISO4217Codes
172172
if (format.parse(tokens.nextToken()).getTime() < System.currentTimeMillis()) {
173173
currency = tokens.nextToken();
174174
numeric = tokens.nextToken();
@@ -267,20 +267,21 @@ private static List<Arguments> additionalCodesProvider() {
267267
* throws an IllegalArgumentException or returns null. The test data
268268
* supplied is every possible combination of AA -> ZZ.
269269
*/
270-
@ParameterizedTest
271-
@MethodSource("codeCombos")
272-
public void twoLetterCodesTest(String country) {
273-
if (codes[toIndex(country)] == UNDEFINED) {
274-
// if a code is undefined / 0, creating a Currency from it
275-
// should throw an IllegalArgumentException
276-
assertThrows(IllegalArgumentException.class,
277-
()-> Currency.getInstance(Locale.of("", country)),
278-
"Error: This should be an undefined code and throw IllegalArgumentException: " + country);
279-
} else if (codes[toIndex(country)] == SKIPPED) {
280-
// if a code is marked as skipped / 2, creating a Currency from it
281-
// should return null
282-
assertNull(Currency.getInstance(Locale.of("", country)),
283-
"Error: Currency.getInstance() for this locale should return null: " + country);
270+
@Test
271+
public void twoLetterCodesTest() {
272+
for (String country : codeCombos()) {
273+
if (codes[toIndex(country)] == UNDEFINED) {
274+
// if a code is undefined / 0, creating a Currency from it
275+
// should throw an IllegalArgumentException
276+
assertThrows(IllegalArgumentException.class,
277+
() -> Currency.getInstance(Locale.of("", country)),
278+
"Error: This should be an undefined code and throw IllegalArgumentException: " + country);
279+
} else if (codes[toIndex(country)] == SKIPPED) {
280+
// if a code is marked as skipped / 2, creating a Currency from it
281+
// should return null
282+
assertNull(Currency.getInstance(Locale.of("", country)),
283+
"Error: Currency.getInstance() for this locale should return null: " + country);
284+
}
284285
}
285286
}
286287

test/jdk/java/util/Currency/tablea1.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#
22
#
3-
# Amendments up until ISO 4217 AMENDMENT NUMBER 175
4-
# (As of 31 March 2023)
3+
# Amendments up until ISO 4217 AMENDMENT NUMBER 176
4+
# (As of 06 December 2023)
55
#
66

77
# Version
88
FILEVERSION=3
9-
DATAVERSION=175
9+
DATAVERSION=176
1010

1111
# ISO 4217 currency data
1212
AF AFN 971 2
@@ -67,9 +67,9 @@ CD CDF 976 2
6767
CK NZD 554 2
6868
CR CRC 188 2
6969
CI XOF 952 0
70-
HR HRK 191 2 2022-12-31-23-00-00 EUR 978 2
70+
HR EUR 978 2
7171
CU CUP 192 2
72-
CW ANG 532 2
72+
CW ANG 532 2 2025-04-01-04-00-00 XCG 532 2
7373
CY EUR 978 2
7474
CZ CZK 203 2
7575
DK DKK 208 2
@@ -233,7 +233,7 @@ LK LKR 144 2
233233
SD SDG 938 2
234234
SR SRD 968 2
235235
SJ NOK 578 2
236-
SX ANG 532 2
236+
SX ANG 532 2 2025-04-01-04-00-00 XCG 532 2
237237
SZ SZL 748 2
238238
SE SEK 752 2
239239
CH CHF 756 2

0 commit comments

Comments
 (0)