<i18n dev> RFR: 8341366: Suspicious check in Locale.getDisplayName(Locale inLocale)

Justin Lu jlu at openjdk.org
Tue Oct 1 22:07:48 UTC 2024


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)`.

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

Commit messages:
 - init

Changes: https://git.openjdk.org/jdk/pull/21298/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21298&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8341366
  Stats: 4 lines in 1 file changed: 0 ins; 1 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/21298.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21298/head:pull/21298

PR: https://git.openjdk.org/jdk/pull/21298


More information about the i18n-dev mailing list