RFR: 8357275: Locale.Builder.setLanguageTag should explicitly state extlangs are allowed

Naoto Sato naoto at openjdk.org
Mon May 19 23:43:51 UTC 2025


On Mon, 19 May 2025 20:56:55 GMT, Justin Lu <jlu at openjdk.org> wrote:

> It is not clear that `Locale.Builder.setLanguageTag(String)` accepts _extlang_ subtags in the input as well as what behavior occurs. Additionally, both this method and `Locale.forLanguageTag(String)` should mention their behavior when more than three _extlang_ subtags are provided. This PR clarifies the lack of context in the specification.

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

> 2790:          * tag). {@code languageTag} may contain up to three extlang subtags.
> 2791:          + For such occurrences, the first extlang subtag is used as the language,
> 2792:          * and the primary language subtag and other extlang subtags are ignored.

Should we throw an exeption here? I had an impression that the new description actually contradicts to the previous sentense, which asserts exception on ill-formed tag.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25309#discussion_r2096613695


More information about the core-libs-dev mailing list