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

Justin Lu jlu at openjdk.org
Thu May 22 16:46:10 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.

Comments addressed in https://github.com/openjdk/jdk/pull/25371/commits/2d778a85ebff14e5080a15556083c3e16986edf4. Chen, that's a good point, those getters are fragile. I opted to maintain the unmodifiable quality of the list fields, this code isn't perf sensitive and is more predictable this way. I wrapped the lists during parsing so we can drop overriding the getters altogether.

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

PR Comment: https://git.openjdk.org/jdk/pull/25371#issuecomment-2901903043


More information about the i18n-dev mailing list