Skip to content

Commit

Permalink
8321480: ISO 4217 Amendment 176 Update
Browse files Browse the repository at this point in the history
Reviewed-by: mbaesken
Backport-of: 8b24851b9d3619c41c7a6cdb9193ed26a9b732dc
  • Loading branch information
Andrew Lu committed Feb 6, 2024
1 parent fc49554 commit 223018a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 33 deletions.
10 changes: 5 additions & 5 deletions make/data/currency/CurrencyData.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ formatVersion=3
# Version of the currency code information in this class.
# It is a serial number that accompanies with each amendment.

dataVersion=175
dataVersion=176

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

Expand Down Expand Up @@ -189,11 +189,11 @@ CR=CRC
# COTE D'IVOIRE
CI=XOF
# CROATIA
HR=HRK;2022-12-31-23-00-00;EUR
HR=EUR
# CUBA
CU=CUP
# Cura\u00e7ao
CW=ANG
CW=ANG;2025-04-01-04-00-00;XCG
# CYPRUS
CY=EUR
# CZECHIA
Expand Down Expand Up @@ -510,7 +510,7 @@ SR=SRD
# SVALBARD AND JAN MAYEN
SJ=NOK
# Sint Maarten (Dutch part)
SX=ANG
SX=ANG;2025-04-01-04-00-00;XCG
# ESWATINI
SZ=SZL
# SWEDEN
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -32,6 +32,7 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
Expand Down Expand Up @@ -339,9 +340,15 @@ private static void buildOtherTables() {
validCurrencyCodes.substring(i * 7 + 3, i * 7 + 6));
checkCurrencyCode(currencyCode);
int tableEntry = mainTable[(currencyCode.charAt(0) - 'A') * A_TO_Z + (currencyCode.charAt(1) - 'A')];
if (tableEntry == INVALID_COUNTRY_ENTRY ||
(tableEntry & SPECIAL_CASE_COUNTRY_MASK) != 0 ||
(tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) != (currencyCode.charAt(2) - 'A')) {

// Do not allow a future currency to be classified as an otherCurrency,
// otherwise it will leak out into Currency:getAvailableCurrencies
boolean futureCurrency = Arrays.asList(specialCaseNewCurrencies).contains(currencyCode);
boolean simpleCurrency = (tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) == (currencyCode.charAt(2) - 'A');

// If neither a simple currency, or one defined in the future
// then the current currency is applicable to be added to the otherTable
if (!futureCurrency && !simpleCurrency) {
if (otherCurrenciesCount == maxOtherCurrencies) {
throw new RuntimeException("too many other currencies");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -266,6 +266,7 @@ XBB=XBB
XBC=XBC
XBD=XBD
XCD=XCD
XCG=XCG
XDR=XDR
XFO=XFO
XFU=XFU
Expand Down Expand Up @@ -491,6 +492,7 @@ xbb=European Monetary Unit
xbc=European Unit of Account (XBC)
xbd=European Unit of Account (XBD)
xcd=East Caribbean Dollar
xcg=Caribbean Guilder
xdr=Special Drawing Rights
xfo=French Gold Franc
xfu=French UIC-Franc
Expand Down
35 changes: 18 additions & 17 deletions test/jdk/java/util/Currency/ValidateISO4217.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @test
* @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759
* 8039317 8074350 8074351 8145952 8187946 8193552 8202026 8204269
* 8208746 8209775 8264792 8274658 8283277 8296239
* 8208746 8209775 8264792 8274658 8283277 8296239 8321480
* @summary Validate ISO 4217 data for Currency class.
* @modules java.base/java.util:open
* jdk.localedata
Expand Down Expand Up @@ -86,7 +86,7 @@ public class ValidateISO4217 {
// Codes that are obsolete, do not have related country, extra currency
private static final String otherCodes =
"ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-BYR-CHE-CHW-CLF-COU-CUC-CYP-"
+ "DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LTL-LUF-LVL-MGF-MRO-MTL-MXV-MZM-NLG-"
+ "DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-HRK-IEP-ITL-LTL-LUF-LVL-MGF-MRO-MTL-MXV-MZM-NLG-"
+ "PTE-ROL-RUR-SDD-SIT-SLL-SKK-SRG-STD-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-VED-"
+ "XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-"
+ "YUM-ZMK-ZWD-ZWN-ZWR";
Expand Down Expand Up @@ -168,7 +168,7 @@ private static void processColumns(StringTokenizer tokens, String country) throw
if (format == null) {
createDateFormat();
}
// If the cut-over already passed, test the changed data too
// If the cut-over already passed, use the new curency for ISO4217Codes
if (format.parse(tokens.nextToken()).getTime() < System.currentTimeMillis()) {
currency = tokens.nextToken();
numeric = tokens.nextToken();
Expand Down Expand Up @@ -267,20 +267,21 @@ private static List<Arguments> additionalCodesProvider() {
* throws an IllegalArgumentException or returns null. The test data
* supplied is every possible combination of AA -> ZZ.
*/
@ParameterizedTest
@MethodSource("codeCombos")
public void twoLetterCodesTest(String country) {
if (codes[toIndex(country)] == UNDEFINED) {
// if a code is undefined / 0, creating a Currency from it
// should throw an IllegalArgumentException
assertThrows(IllegalArgumentException.class,
()-> Currency.getInstance(new Locale("", country)),
"Error: This should be an undefined code and throw IllegalArgumentException: " + country);
} else if (codes[toIndex(country)] == SKIPPED) {
// if a code is marked as skipped / 2, creating a Currency from it
// should return null
assertNull(Currency.getInstance(new Locale("", country)),
"Error: Currency.getInstance() for this locale should return null: " + country);
@Test
public void twoLetterCodesTest() {
for (String country : codeCombos()) {
if (codes[toIndex(country)] == UNDEFINED) {
// if a code is undefined / 0, creating a Currency from it
// should throw an IllegalArgumentException
assertThrows(IllegalArgumentException.class,
() -> Currency.getInstance(new Locale("", country)),
"Error: This should be an undefined code and throw IllegalArgumentException: " + country);
} else if (codes[toIndex(country)] == SKIPPED) {
// if a code is marked as skipped / 2, creating a Currency from it
// should return null
assertNull(Currency.getInstance(new Locale("", country)),
"Error: Currency.getInstance() for this locale should return null: " + country);
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions test/jdk/java/util/Currency/tablea1.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#
#
# Amendments up until ISO 4217 AMENDMENT NUMBER 175
# (As of 31 March 2023)
# Amendments up until ISO 4217 AMENDMENT NUMBER 176
# (As of 06 December 2023)
#

# Version
FILEVERSION=3
DATAVERSION=175
DATAVERSION=176

# ISO 4217 currency data
AF AFN 971 2
Expand Down Expand Up @@ -67,9 +67,9 @@ CD CDF 976 2
CK NZD 554 2
CR CRC 188 2
CI XOF 952 0
HR HRK 191 2 2022-12-31-23-00-00 EUR 978 2
HR EUR 978 2
CU CUP 192 2
CW ANG 532 2
CW ANG 532 2 2025-04-01-04-00-00 XCG 532 2
CY EUR 978 2
CZ CZK 203 2
DK DKK 208 2
Expand Down Expand Up @@ -233,7 +233,7 @@ LK LKR 144 2
SD SDG 938 2
SR SRD 968 2
SJ NOK 578 2
SX ANG 532 2
SX ANG 532 2 2025-04-01-04-00-00 XCG 532 2
SZ SZL 748 2
SE SEK 752 2
CH CHF 756 2
Expand Down

3 comments on commit 223018a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnu-andrew
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 223018a Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnu-andrew Could not automatically backport 223018a3 to openjdk/jdk11u-dev due to conflicts in the following files:

  • make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
  • test/jdk/java/util/Currency/ValidateISO4217.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk11u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk11u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-gnu-andrew-223018a3

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev.git 223018a3aabc319992d9790fa1d6c88b02fcca9f

# Backport the commit
$ git cherry-pick --no-commit 223018a3aabc319992d9790fa1d6c88b02fcca9f
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 223018a3aabc319992d9790fa1d6c88b02fcca9f'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport 223018a3aabc319992d9790fa1d6c88b02fcca9f.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 223018a3 from the openjdk/jdk17u-dev repository.

The commit being backported was authored by Andrew Lu on 6 Feb 2024 and was reviewed by Matthias Baesken.

Thanks!

Please sign in to comment.