On Wed, 8 Jul 2026 21:07:01 GMT, Naoto Sato <[email protected]> wrote:

>> src/java.base/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java
>>  line 376:
>> 
>>> 374:                 // Extensions can exist while variant is ill-formed
>>> 375:                 // Simply strip the extensions so that all fields are 
>>> preserved
>>> 376:                 lookupLocale = lookupLocale.stripExtensions();
>> 
>> The old comment was wrong, it was entirely possible for a locale to have 
>> non-empty extensions with ill-formed variant. For example, 
>> `"en-Latn-US-a-foo-x-lvariant-xy"` and this catch block is entirely 
>> possible. I think stripping the extension is a better solution than trying 
>> to reconstruct with the `of` factory since the script is retained.
>
> Although chances are slim, technically this is a behavioral change. Maybe it 
> is worth describing this in the CSR

I will include this when I update the CSR. I am actually not sure what the 
reason was with the original code to drop the extensions **and script**, when 
we could just drop the extensions only via `stripExtensions`. Perhaps it stems 
from the incorrect assumption in the comment that thought that block could 
never actually be reached. I am not sure. Ultimately like you said this is an 
edge case, so slim impact.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31728#discussion_r3547404788

Reply via email to