On Sun, 11 May 2025 08:42:41 GMT, Abhishek N <d...@openjdk.org> wrote:
>> Create a Test case to have special cases coverage for currency.getInstance(). >> >> The test Validates that all currency codes and country-currency mappings in >> the input file are consistent with the Java Currency API. >> >> test results: >> >> jdk-24.0.2/bin/java -jar jtreg/lib/jtreg.jar -testjdk:jdk-24.0.2 >> -dir:jdk/test/jdk/ >> java/util/Currency/currencyEnhancedCoverage/ValidateCurrencyCoverage.java >> Directory "JTwork" not found: creating >> Directory "JTreport" not found: creating >> Test results: passed: 1 >> Report written to JTreport\html\report.html >> Results written to JTwork > > Abhishek N has updated the pull request incrementally with one additional > commit since the last revision: > > correcting jtreg header order, add meaningful comments for each test > methods and properties file This test is not effectively testing standard ISO 4217 future transition currencies. For example, with your patch, if I supply the following changes to the ISO 4217 currency data: (i.e. Make country `LK` have a transition currency of `XCH` in July) --- a/src/java.base/share/data/currency/CurrencyData.properties +++ b/src/java.base/share/data/currency/CurrencyData.properties @@ -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-XCG532-XDR960-XFO000-XFU000-XOF952-XPD964-XPF953-\ + XBB956-XBC957-XBD958-XCD951-XCG532-XCH533-XDR960-XFO000-XFU000-XOF952-XPD964-XPF953-\ XPT962-XSU994-XTS963-XUA965-XXX999-YER886-YUM891-ZAR710-ZMK894-ZMW967-ZWD716-ZWG924-\ ZWL932-ZWN942-ZWR935 @@ -502,7 +502,7 @@ GS=GBP # SPAIN ES=EUR # SRI LANKA -LK=LKR +LK=LKR;2025-07-01-04-00-00;XCH and break some functionality related to _future/special_ currencies in `Currency.getInstance(String)`, (Similar to 8, prior to the fix backported) --- a/src/java.base/share/classes/java/util/Currency.java +++ b/src/java.base/share/classes/java/util/Currency.java @@ -326,13 +326,6 @@ private static Currency getInstance(String currencyCode, int defaultFractionDigi defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT; numericCode = (tableEntry & NUMERIC_CODE_MASK) >> NUMERIC_CODE_SHIFT; found = true; - } else { //special case - int[] fractionAndNumericCode = SpecialCaseEntry.findEntry(currencyCode); - if (fractionAndNumericCode != null) { - defaultFractionDigits = fractionAndNumericCode[0]; - numericCode = fractionAndNumericCode[1]; - found = true; - } } With the above changes, we would expect this test to fail, since `getInstance("XCH")` should throw an exception. However, your test still passes. What this patch is doing is selectively testing a handful of Currencies with the system property override. This is not sufficient to ensure test coverage for testing a standard ISO 4217 transition currency after the transition date has passed. As mentioned above, the system property override does not mock a standard ISO 4217 transition currency, (they have different functionality). Also as @weibxiao has mentioned, we already have such a test in mainline. Additional testing would be required as backports for LTS releases only. ------------- PR Comment: https://git.openjdk.org/jdk/pull/25057#issuecomment-2884773970