On Tue, 1 Oct 2024 21:46:44 GMT, Justin Lu <j...@openjdk.org> wrote: > Please review this PR which modifies a suspicious check in the fallback of > `Locale.getDisplayName(Locale inLocale)`. > > As a fallback, a hard coded pattern is used. The previous code outputted the > qualifiers if the `displayNames` array had length greater than 2. Just a few > lines above, the array is initialized with a length of 3 and so the check is > pointless. > > It would be better, if replaced with a null check for the last element of the > `displayNames` array, as that element may be null if there are no qualifiers. > See L2317 , > > `qualifierNames.length != 0 ? formatList(qualifierNames, > listCompositionPattern) : null` > > For example, now a fallback (with no qualifiers) might look like: `German` > instead of `German (null)`. > But will remain the same (with qualifiers): `German (Germany)`.
LGTM src/java.base/share/classes/java/util/Locale.java line 2331: > 2329: result.append(" ("); > 2330: result.append((String) displayNames[2]); > 2331: result.append(')'); These `append`s can be chained, but probably it's my preference. ------------- Marked as reviewed by naoto (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/21298#pullrequestreview-2355583322 PR Review Comment: https://git.openjdk.org/jdk/pull/21298#discussion_r1792537903