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

Locale.getISOCountries does not specify the returned set is unmodifiable

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 25
    • core-libs
    • None
    • minimal
    • Specification-only change to align with existing behavior.
    • Java API
    • SE

      Summary

      Specify that the set returned from Locale.getISOCountries(Locale.IsoCountryCode type) is unmodifiable.

      Problem

      Locale.getISOCountries(Locale.IsoCountryCode type) returns an unmodifiable Set. This behavior is not specified in the method, and users can encounter an unexpected java.lang.UnsupportedOperationException if they attempt to modify the returned Set.

      Solution

      Specify the returned set is unmodifiable. This behavior is consistent with the other Set returning methods of Locale.

      Specification

      In Locale.getISOCountries(Locale.IsoCountryCode type),

      -     * {@return a {@code Set} of ISO3166 country codes for the specified type}
      +     * {@return an unmodifiable {@code Set} of ISO3166 country codes for the specified type}

            jlu Justin Lu
            jlu Justin Lu
            Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: