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

With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 13
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      The newly added serializable fields are not accessible via public APIs, hence the compatibility risk is minimal.
    • Interface Kind:
      Other
    • Scope:
      SE

      Description

      Summary

      Add serializable String fields in java.text.DecimalFormatSymbols for percent, per mille, and minus sign, parallel to corresponding fields of their char variations.

      Problem

      As demonstrated in JDK-8220224, a single char is not sufficient to represent those symbols for BiDi languages, which may include Directional Formatting Characters in those symbols.

      Solution

      Define String variation of those existing symbol fields. These fields are to retain the symbols beyond serialization/deserialization, thus should be @serial. These fields are used internally to the java.text package using data read from the CLDR resources. Although it may be considered at a later time (JDK-8220309), no new public API is provided to directly access those fields.

      Specification

      Add the following serializable fields in java.text.DecimalFormatSymbols

      /**
       * String representation of per mille sign, which may include 
       * formatting characters, such as BiDi control characters.
       * The first non-format character of this string is the same as
       * <code>perMill</code>.
       *
       * @serial
       * @since 13
       */
      private  String perMillText;
      
      /**
       * String representation of percent sign, which may include
       * formatting characters, such as BiDi control characters.
       * The first non-format character of this string is the same as
       * <code>percent</code>.
       *
       * @serial
       * @since 13
       */
      private  String percentText;
      
      /**
       * String representation of minus sign, which may include
       * formatting characters, such as BiDi control characters.
       * The first non-format character of this string is the same as
       * <code>minusSign</code>.
       *
       * @serial
       * @since 13
       */
      private  String minusSignText;

      Change the method description of DecimalFormatSymbols#readObject() from:

      /**
       * Reads the default serializable fields, provides default values for objects
       * in older serial versions, and initializes non-serializable fields.
       * If <code>serialVersionOnStream</code>
       * is less than 1, initializes <code>monetarySeparator</code> to be
       * the same as <code>decimalSeparator</code> and <code>exponential</code>
       * to be 'E'.
       * If <code>serialVersionOnStream</code> is less than 2,
       * initializes <code>locale</code>to the root locale, and initializes
       * If <code>serialVersionOnStream</code> is less than 3, it initializes
       * <code>exponentialSeparator</code> using <code>exponential</code>.
       * Sets <code>serialVersionOnStream</code> back to the maximum allowed value so that
       * default serialization will work properly if this object is streamed out again.
       * Initializes the currency from the intlCurrencySymbol field.
       *
       * @since  1.1.6
       */

      to:

      /**
       * Reads the default serializable fields, provides default values for objects
       * in older serial versions, and initializes non-serializable fields.
       * If <code>serialVersionOnStream</code>
       * is less than 1, initializes <code>monetarySeparator</code> to be
       * the same as <code>decimalSeparator</code> and <code>exponential</code>
       * to be 'E'.
       * If <code>serialVersionOnStream</code> is less than 2,
       * initializes <code>locale</code>to the root locale, and initializes
       * If <code>serialVersionOnStream</code> is less than 3, it initializes
       * <code>exponentialSeparator</code> using <code>exponential</code>.
       * If <code>serialVersionOnStream</code> is less than 4, it initializes
       * <code>perMillText</code>, <code>percentText</code>, and
       * <code>minusSignText</code> using <code>perMill</code>, <code>percent</code>, and
       * <code>minusSign</code> respectively.
       * Sets <code>serialVersionOnStream</code> back to the maximum allowed value so that
       * default serialization will work properly if this object is streamed out again.
       * Initializes the currency from the intlCurrencySymbol field.
       *
       * @throws InvalidObjectException if <code>char</code> and <code>String</code>
       *      representations of either percent, per mille, and/or minus sign disagree.
       * @since  1.1.6
       */

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                naoto Naoto Sato
                Reporter:
                dzhou Dora Zhou
                Reviewed By:
                Roger Riggs
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: