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

Flight Recorder VM Option causes wrong initialization of Locale Providers

    XMLWordPrintable

Details

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Tested on Windows 10 1803
      Issue can be confirmed for at least the following JDKs:
      Corretto 11.0.8.10.1
      Corretto 11.0.9.11.2
      Corretto 11.0.10.9.1
      AdoptOpen 11.0.10
      -----
      The issue does NOT occur in the following JDKs:
      Corretto 15.0.2.7.1
      Corretto 11.0.7.10.1




      A DESCRIPTION OF THE PROBLEM :
      When setting the VM Option "-XX:FlightRecorderOptions=maxchunksize=1M" the locale providers (like JRELocaleProviderAdapter and CLDRLocaleProviderAdapter) will not be properly initialized, leading to missing language specific date and time formats. Setting the flag causes the language providers to be loaded very early in the startup process (observed via class loader debug output). It seems that during this early phase the additional meta information service lookup fails in both providers, leading to the situation where only the default locales (en_US) are available for the "FormatData" localization configuration.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The Issue can be reproduced by using the vm options "-XX:FlightRecorderOptions=maxchunksize=1M" together with the example code. The additional flag "-Djava.locale.providers=COMPAT,CLDR" may change the result of the date time pattern for non-en/us locales, but still produces wrong results.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The default date/time pattern for the german locale should always be "dd.MM.yy HH:mm"
      ACTUAL -
      The date time pattern for the german locale is
      "y-MM-dd HH:mm"
      or
      "M/d/yy h:mm a" when using "-Djava.locale.providers=COMPAT,CLDR"

      ---------- BEGIN SOURCE ----------
      import java.time.chrono.IsoChronology;
      import java.time.format.DateTimeFormatterBuilder;
      import java.time.format.FormatStyle;
      import java.util.Locale;

      public class FRLocaleTest {
        public static void main(String[] args) {
          String germanPattern = DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.GERMAN);
          System.out.println(String.format("Pattern %s for locale %s is correct: %s", germanPattern, Locale.GERMAN, "dd.MM.yy HH:mm".equals(germanPattern)));
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Not using the vm option -XX:FlightRecorderOptions=maxchunksize=1M solves the issue. Issue is not present on every jdk implementation and version.

      FREQUENCY : always


      Attachments

        Activity

          People

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: