Performance regression with java.text.MessageFormat subformat patterns

XMLWordPrintable

    • Fix Understood
    • generic

      A DESCRIPTION OF THE PROBLEM :
      sun.util.resources.cldr.LocaleNames / sun.util.resources.LocaleNames

      DisplayNamePattern : `{0,choice,0#|1#{1}|2#{1} ({2})}`

      when we try java.util.Locale#getDisplayName() , the JDK internal will cause java.lang.IllegalArgumentException exception
          
      ```
      at java.base/java.text.MessageFormat$FormatStyle.fromString(MessageFormat.java:2013)
          at java.base/java.text.MessageFormat.formatFromPattern(MessageFormat.java:1718)
          at java.base/java.text.MessageFormat.setFormatFromPattern(MessageFormat.java:1679)
          at java.base/java.text.MessageFormat.applyPatternImpl(MessageFormat.java:660)
          at java.base/java.text.MessageFormat.<init>(MessageFormat.java:516)
          at java.base/java.util.Locale.getDisplayName(Locale.java:2309)
      ```
      I know MessageFormat will try to catch this with but I think JDK always use try catch this message is not very good implementation
      ```
       try {
                  fStyle = FormatStyle.fromString(style);
              } catch (IllegalArgumentException iae) {
                  fStyle = FormatStyle.SUBFORMATPATTERN;
              }
      ```

      REGRESSION : Last worked in version 21.0.9

      FREQUENCY :
      ALWAYS

            Assignee:
            Justin Lu
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: