RFR: 8357281: sun.util.Locale.LanguageTag should be immutable [v2]

Chen Liang liach at openjdk.org
Thu May 22 17:17:59 UTC 2025


On Thu, 22 May 2025 16:46:10 GMT, Justin Lu <jlu at openjdk.org> wrote:

>> _sun.util.Locale.LanguageTag_ is essentially a BCP47 language tag data carrier for Locale. The class, once created is not modified; the class should be made immutable. Converting the class to a record accomplishes this and also simplifies some of the existing code.
>
> Justin Lu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   review: subtag -> subtags, switch on baseLang, improve fragility of list field accessors

Everything else looks good.

src/java.base/share/classes/sun/util/locale/LanguageTag.java line 249:

> 247:             return EMPTY_SUBTAGS;
> 248:         }
> 249:         List<String> extLangs = null;

Do we want to name this `extLangs` or `extlangs`? The parsing method and the record uses `extlangs`.

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

PR Review: https://git.openjdk.org/jdk/pull/25371#pullrequestreview-2862000028
PR Review Comment: https://git.openjdk.org/jdk/pull/25371#discussion_r2103042373


More information about the core-libs-dev mailing list