<i18n dev> RFR: 8357281: sun.util.Locale.LanguageTag should be immutable

Shaojin Wen swen at openjdk.org
Thu May 22 01:29:05 UTC 2025


On Wed, 21 May 2025 21:19:36 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.

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

> 456:                 baseLanguage = "id";
> 457:             }
> 458:             language = baseLanguage;

Suggestion:

            language = switch(baseLanguage) {
                case "iw" -> "he";
                case "ji" -> "yi";
                case "in" -> "id";
                default   -> baseLanguage;
            };

use switch expression

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25371#discussion_r2101446785


More information about the i18n-dev mailing list