From 86800eb2b34bd6ea7a77e7a9ac2f7dbce89c11fb Mon Sep 17 00:00:00 2001 From: Justin Lu Date: Tue, 3 Mar 2026 17:11:17 +0000 Subject: [PATCH] 8378723: Locale variant delimiter is unclear Reviewed-by: naoto --- src/java.base/share/classes/java/util/Locale.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/util/Locale.java b/src/java.base/share/classes/java/util/Locale.java index f45a52c14fa..682476d8082 100644 --- a/src/java.base/share/classes/java/util/Locale.java +++ b/src/java.base/share/classes/java/util/Locale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -176,7 +176,10 @@ import sun.util.locale.provider.TimeZoneNameUtility; * SUBTAG (('_'|'-') SUBTAG)*} where {@code SUBTAG = * [0-9][0-9a-zA-Z]{3} | [0-9a-zA-Z]{5,8}}. *
BCP 47 deviation: BCP 47 only - * uses hyphen ('-') as a delimiter, {@code Locale} is more lenient.
+ * uses hyphen ('-') as a delimiter and APIs provided by {@code Locale} which accept + * BCP 47 language tags expect as such. However, for backwards compatibility, + * {@link Locale.Builder#setVariant(String)} also accepts underscore ('_'). + * {@link Locale#of(String, String, String)} accepts only underscore ('_'). * *
Example: "polyton" (Polytonic Greek), "POSIX"
*