RFR: 8370250: Locale should mention the behavior for duplicate subtags [v2]
Naoto Sato
naoto at openjdk.org
Tue Oct 21 17:36:31 UTC 2025
On Tue, 21 Oct 2025 16:28:58 GMT, Justin Lu <jlu at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/Locale.java line 2736:
>>
>>> 2734: * are accepted but ignored. The same behavior applies to duplicate locale
>>> 2735: * keys and attributes within a U extension.
>>> 2736: *
>>
>> "Note that..." in the prior occurence of this wording might apply here for consistency.
>
> `Locale.forLanguageTag` is specified to _ignore subsequent subtags on ill-formed input_, so a heads up is warranted. Since `Lcoale.Builder.setLanguageTag` either throws or does not (and duplicate tags do not throw), I think it is implied subsequent subtags are processed. However, that's just my opinion, if you think it is not obvious, I will add it in.
I think explicity specifying the note would not hurt here, otherwise missing "note" might unnecessarilly make readers wonder why
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27909#discussion_r2449159863
More information about the core-libs-dev
mailing list