Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8001562

Collator.getAvailableLocales() doesn't return all locales for which localized instances are available

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 8
    • core-libs
    • b55
    • 8
    • b65
    • generic
    • generic

      The javadoc for Collator.getAvailableLocales() says:

      "Returns an array of all locales for which the getInstance methods of this class can return localized instances."

      In JDK 8, after JDK-7171324, many locales have been removed from the returned array, but localized instances could still be obtained for them.

      For example, both Collator.newInstance(Locale.JAPAN) and Collator.newInstance(Locale.JAPANESE) return a collator localized for Japanese, but only Locale.JAPANESE is in the returned array, so getAvailableLocales() doesn't return *all* locales for which localized instances could be obtained.

      This may cause compatibility problems for existing applications that use collators. If they check getAvailableLocales() before creating collators, they may work fine in ja_JP locale (and others) on JDK 7 and earlier, and stop working in that locale when they upgrade to JDK 8.

      For the applications that check the return value of getAvailableLocales() it's probably better if it returns all the locales it used to return in JDK 7.

            naoto Naoto Sato
            khatlen Knut Anders Hatlen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: