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

Incorrect currency instance returned by java.util.Currency.getInstance()

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 11
    • core-libs
    • None
    • behavioral
    • low
    • Users that would have expected the existence of multiple (inconsistent) Currency instances for the same currency code would no longer see the existing behavior.
    • Java API, File or wire format
    • SE

      Summary

      Clarification about the currency superseding feature specification w.r.t. inconsistent entries.

      Problem

      The design principle of the Currency class states that "there's never more than one Currency instance for any given currency", but currency superseding feature allows possibility of two similar Currency instances for a currency code.

      Solution

      Update the currency superseding feature such that

      • If there is any ISO 4217 currency data with same currency code as the currency entry given in the properties file (that java.util.currency.data designates), then the existing Currency data should be updated with the given currency values.
      • Ignore the inconsistent entries. Multiple entries are considered as inconsistent, if they point to the currency data with same currency code but different numeric code and/or minor unit

      Specification

      Update the API specification

      from:

       * <p>
       * <code>
       * #Sample currency properties<br>
       * JP=JPZ,999,0
       * </code>
       * <p>
       * will supersede the currency data for Japan.

      to:

       * <p>
       * <code>
       * #Sample currency properties<br>
       * JP=JPZ,999,0
       * </code>
       * <p>
       * will supersede the currency data for Japan. If JPZ is one of the existing
       * ISO 4217 currency code referred by other countries, the existing
       * JPZ currency data is updated with the given numeric code and minor
       * unit value.

      For inconsistent entries:

      from:

       * Where syntactically malformed entries are encountered, the entry is ignored
       * and the remainder of entries in file are processed. For instances where duplicate
       * country code entries exist, the behavior of the Currency information for that
       * {@code Currency} is undefined and the remainder of entries in file are processed.

      to:

       * Where syntactically malformed entries are encountered, the entry is ignored
       * and the remainder of entries in file are processed. For instances where duplicate
       * country code entries exist, the behavior of the Currency information for that
       * {@code Currency} is undefined and the remainder of entries in file are processed.
       * <p>
       * If multiple property entries with same currency code but different numeric code
       * and/or minor unit are encountered, those entries are ignored and the remainder
       * of entries in file are processed.

            nishjain Nishit Jain
            nishjain Nishit Jain
            Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: