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

Clarify matching order of MessageFormat subformat factory styles

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 24
    • core-libs
    • None
    • behavioral
    • minimal
    • Minimal risk, as doc only update.
    • Java API
    • SE

      Summary

      Make apparent that MessageFormat.toPattern() does not guarantee the order of equivalence checking for FormatStyles.

      Problem

      MessageFormat provides pre-defined styles for subformats. For example, a pattern such as "date,long". The issue is that multiple styles could be equivalent, for example, the JDK 23 CLDR Chinese date format has equivalent long and medium styles. Users should not assume that the style they used when creating/setting the MessageFormat will be equivalent to the one produced by toPattern, as this depends on the order that the implementation performs equivalence checking.

      Solution

      Make apparent in the normative specification that the method does not guarantee any particular order. The added wording is loose enough to still accommodate a particular implementation, if it does want to guarantee such an order.

      Specification

      Add the following to MessageFormat.toPattern(),

      -     * does not necessarily equal the previously applied pattern.
      +     * does not necessarily equal the previously applied pattern. The order of
      +     * {@code FormatStyle} matching is not guaranteed. That is, a {@code
      +     * FormatStyle} produced may not be equivalent to the corresponding style passed,
      +     * in the instance that multiple styles are equivalent.

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

              Created:
              Updated:
              Resolved: