Locale.getISOCountries does not specify the returned set is unmodifiable

XMLWordPrintable

    • Type: CSR
    • Resolution: Approved
    • Priority: P4
    • 25
    • Component/s: 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}
      

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

              Created:
              Updated:
              Resolved: