On Tue, 27 Oct 2026 21:32:11 GMT, Naoto Sato <[email protected]> wrote:

>> Justin Lu has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   preserve exception msg - move format validation out
>
> src/java.base/share/classes/java/util/Currency.java line 397:
> 
>> 395: 
>> 396:         String country = 
>> CalendarDataUtility.findRegionOverride(locale).getCountry();
>> 397:         if (country.length() != 2) {
> 
> I think an ASCII range check is still needed here (no need for regex). 
> Otherwise, invalid country codes such as "C1" will end up throwing an IAE 
> with a different error message in `getMainTableEntry`, which only includes 
> the invalid country code. That would be missing other input locale 
> information, eg its language code.

You're right, I thought this would be acceptable because the new message 
identified the invalid code. However, it helps to preserve the extra locale 
context as you said. 
https://github.com/openjdk/jdk/pull/33594/commits/5f7de6e7b9d4aaf9f36022873b400410d80f3fe6
 updates it such that the ISO 3166 format check is pulled out of 
`getMainTableEntry`.  This is reasonable because half of the call sites already 
validated beforehand. Now  `getInstance(String)` and `getInstance(Locale)` can 
easily call the method and supply their desired exception.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/33594#discussion_r4394888191

Reply via email to