JDK-8209047 : "Illegal pattern character 'B'" IllegalArgumentException with Burmese locales
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 11
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2018-08-03
  • Updated: 2018-08-29
  • Resolved: 2018-08-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12
11 b27Fixed 12Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Mac OSX 10.13.6
Output of java -version:

openjdk version "11-ea" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11-ea+25)
OpenJDK 64-Bit Server VM 18.9 (build 11-ea+25, mixed mode)

A DESCRIPTION OF THE PROBLEM :
When invoking DateFormat.getTimeInstance(DateFormat.SHORT, locale) when locale is either "Burmese" or "Burmese (Myanmar (Burma))", an IllegalArgumentException is thrown with the message: "Illegal pattern character 'B'".

The exception does not occur in production versions of Java (neither Java 1.8.0_181 nor 10.0.2 encounter this problem).

REGRESSION : Last worked in version 10.0.2

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the test case source code.
2. Run the class using Java 10.0.2, piping through grep for 'FAIL'. e.g.:
   java LocaleTest |grep 'FAIL'

You should get no output.

3. Repeat step 2, except use Java 11-ea build 11-ea+25

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
There should also be no output.
ACTUAL -
Burmese: FAIL
Burmese (Myanmar (Burma)): FAIL

---------- BEGIN SOURCE ----------
import java.text.DateFormat;
import java.util.Arrays;
import java.util.Locale;

public class LocaleTest {
    public static void main(String[] args) {
        Arrays.asList(Locale.getAvailableLocales()).forEach(locale -> {
            System.out.print(locale.getDisplayName()+": ");
            try {
                DateFormat.getTimeInstance(DateFormat.SHORT, locale);
                System.out.println("PASS");
            } catch(IllegalArgumentException ex) {
                System.out.println("FAIL");
            }
        });
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Not investigated

FREQUENCY : always



Comments
Verified with jdk11 build 28, passed.
29-08-2018

Unfortunately, It's fix got pushed with wrong bug id. http://hg.openjdk.java.net/jdk/jdk11/rev/7bd2a286e637
14-08-2018

Fix Request Its important to fix this defect, as its a regression. Failure happens on calling DateFormat.getTimeInstance(locale) for Burmese locale. Fix has no risk associated with it, Pattern for Burmese locale will be replaced with of CLDR 29's pattern, until JDK-8209175 is resolved.
13-08-2018

Fix request approved Please change the visibility of "Fix Request" comment to "open."
13-08-2018

Fix Request NMI Removing CLDR Burmese falls back to COMPAT, which does not support Burmese. Thus the default format (English) will be displayed, which may not be ideal. Suggesting to replace the offending format to the previous CLDR release's ones.
09-08-2018

The issue is because of the 'B' character introduced in the CLDR time patterns "B HH:mm:ss", "B H:mm" (where B represents the 'day period') for "my" (Burmese) locale, which I guess was not there earlier in the SHORT/LONG/FULL patterns. If I understand correctly, this character is not supported in java.text.SimpleDateFormat and in java.time.DateTimeFormatter. This is the reason it is throwing IllegalArgumentException. Tried reproducing the same issue with the DateTimeFormatter in Burmese locale, it also throws exception because of the same reason. Below is the code snippet for DateTimeFormatter. DateTimeFormatter format = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT).withLocale(new Locale("my")); String out = format.format(LocalTime.of(12, 12, 12)); System.out.println(out);
07-08-2018

This has started failing from JDK 11ea+19 onwards, CLDR was upgraded to v 33 which may be the cause. Here are the results of the attached test case : JDK 10.0.2 - Pass JDK 11-ea + 18 - Pass JDK 11-ea + 19 - Fail JDK 11-ea+24 - Fail Output : Exception in thread "main" java.lang.IllegalArgumentException: Illegal pattern character 'B' at java.base/java.text.SimpleDateFormat.compile(SimpleDateFormat.java:845) at java.base/java.text.SimpleDateFormat.applyPatternImpl(SimpleDateFormat.java:2350) at java.base/java.text.SimpleDateFormat.applyPattern(SimpleDateFormat.java:2346) at java.base/sun.util.locale.provider.DateFormatProviderImpl.getInstance(DateFormatProviderImpl.java:160) at java.base/sun.util.locale.provider.DateFormatProviderImpl.getTimeInstance(DateFormatProviderImpl.java:90) at java.base/java.text.DateFormat.get(DateFormat.java:841) at java.base/java.text.DateFormat.get(DateFormat.java:827) at java.base/java.text.DateFormat.getTimeInstance(DateFormat.java:520) at JI9056465.main(JI9056465.java:7)
07-08-2018