On Mon, 19 May 2025 23:50:59 GMT, Justin Lu <j...@openjdk.org> wrote:
>> 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. > > An exception is thrown when more than three extlang subtags are provided > (ill-formed). The new wording is when an allowed amount of extlang subtags > are provided (not ill-formed). For example, > > `new Locale.Builder().setLanguageTag("zh-yue-gan-cmn-czh-CN").build()` // > throws > `new Locale.Builder().setLanguageTag("zh-yue-gan-cmn-CN").build()` // ==> > yue_CN > > i.e. if one to three extlang subtags occur, discard extras. If more than 3 > occur, then it is ill-formed, and the method is already specified to throw on > ill-formed tags. (Edit: Forgot to adjust the example) OK. I would add these examples here too, which may be more helpful. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25309#discussion_r2096650651