RFR: 8370250: Locale should mention the behavior for duplicate subtags

Naoto Sato naoto at openjdk.org
Mon Oct 20 23:39:03 UTC 2025


On Mon, 20 Oct 2025 22:52:19 GMT, Justin Lu <jlu at openjdk.org> wrote:

> Please review this PR which is a first stab at clarifying the behavior of duplicate variants, extension singletons, and U extension keys and attributes for BCP47 subtags in the Locale specification. This is a follow up to https://bugs.openjdk.org/browse/JDK-8369739.
> 
> Changes are made under the BCP47 and U extension sections that define "well-formed" in the class description.
> Additionally, changes are made under the relevant Locale and Locale.Builder methods themselves.
> 
> Will update the CSR accordingly when the proposed wording changes are finalized.

Looks good. Left a couple of comments. Also we might want to add RFC 6067 for reference.

src/java.base/share/classes/java/util/Locale.java line 253:

> 251:  * {@code [0-9a-zA-Z]{3,8}} (it is a single subtag with the same
> 252:  * form as a locale type subtag). {@code Locale} does not enforce uniqueness of
> 253:  * locale keys nor attributes. For methods in {@code Locale} and {@code Locale.Builder}

This could be misleading as we are enforcing uniqueness, by ignoring the duplicates. The validity is what is not enforced here.

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.

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

PR Review: https://git.openjdk.org/jdk/pull/27909#pullrequestreview-3358253558
PR Review Comment: https://git.openjdk.org/jdk/pull/27909#discussion_r2446360376
PR Review Comment: https://git.openjdk.org/jdk/pull/27909#discussion_r2446369473


More information about the core-libs-dev mailing list