<i18n dev> RFR: 8368981: Case Fold Locale Legacy Tags On Demand [v2]
Roger Riggs
rriggs at openjdk.org
Thu Oct 2 15:05:59 UTC 2025
On Wed, 1 Oct 2025 22:51:30 GMT, Justin Lu <jlu at openjdk.org> wrote:
>> Please review this PR which case folds grandfathered BCP47 tags on demand. (Instead of keeping the case compliant versions stored.)
>>
>> This facilitates the cleanup of the `LEGACY` map (which contains a String to String Array mapping). The 2D String array, creation and populating of the `LEGACY` map, as well as lower case folding of the legacy tags can now be removed from the static block of _sun.util.locale.LanguageTag_.
>>
>> Legacy tags are a small subset compared to the entire set of valid BCP47 tags. Reducing the cost for supporting them would be ideal. Instead, legacy tags can now be checked against and folded on demand via a switch statement.
>>
>> The commented grandfathered syntax is removed because the values themselves already exist as code, and the exact case can be found in the provided RFC link.
>
> Justin Lu has updated the pull request incrementally with one additional commit since the last revision:
>
> implemenet Naoto's review
src/java.base/share/classes/sun/util/locale/LanguageTag.java line 345:
> 343: }
> 344: }
> 345: bldr.deleteCharAt(bldr.length() - 1); // Remove trailing '-'
`bldr.setLength(bldr.length() - 1)` might be better?
src/java.base/share/classes/sun/util/locale/LanguageTag.java line 516:
> 514: if (tag.length() > 11 || tag.length() < 5) {
> 515: return null;
> 516: }
I can see the < 5 having some saving if most of the tags are short.
I doubt the > 11 saves anything and it creates a maintenance gotcha, if a tag is added that is longer.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27596#discussion_r2399143786
PR Review Comment: https://git.openjdk.org/jdk/pull/27596#discussion_r2399105662
More information about the i18n-dev
mailing list