On Thu, 15 May 2025 18:50:35 GMT, Justin Lu <j...@openjdk.org> wrote:
>> 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 tran... @justin-curtis-lu @weibxiao Our objective is to ensure the proper functionality of the Currency.getInstance() methods—particularly to guarantee that currencies defined with special conditions (such as future cutover dates) will work correctly once the system date passes those thresholds. For example, in the case of the mapping: LK=LKR;2025-07-01-04-00-00;XCH we want to ensure that, once the system date passes 2025-07-01T04:00:00, both Currency.getInstance("XCH") and Currency.getInstance(new Locale("LK")) will work as expected and not throw an IllegalArgumentException. To facilitate this, we use a custom currency.properties file that includes entries for currencies with such special conditions, where the cutover date has already passed. An example entry would be: BI=BFI,108,0,2022-12-15T04:00:00 Without this customization, in earlier JDK versions (which do not include recent fixes), calling Currency.getInstance("BFI") would result in an IllegalArgumentException and issues such as JDK-8353433 would have been caught in earlier stages itself. Including these entries allows us to surface such issues earlier in the development or testing lifecycle. **The test in mainline utilize the ClassFile API for mocking system time (such as System::currentTimeMillis), the ClassFile API is not supported in lower LTS JDK versions. Therefore, we rely on the custom currency properties approach to simulate post-cutover behavior for those environments.** **Since additional currencies with similar cutover rules may be introduced in the future, our approach ensures that Currency.getInstance() continues to function reliably across all supported LTS JDK versions—even before the actual cutover date is reached—by validating currency data early using the custom CurrencyData.properties..** ------------- PR Comment: https://git.openjdk.org/jdk/pull/25057#issuecomment-2898918478