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

Assertion in sun/util/locale/provider/CalendarDataUtility on Windows after JDK-8218960

XMLWordPrintable

    • 12
    • b28
    • windows

        When running Java code that calls "DateFormat.getDateInstance(DateFormat.FULL, Locale.US);" on Windows, with java options "-ea -esa -Djava.locale.providers=HOST" one encounters an assertion:

        Exception in thread "main" java.lang.AssertionError
                at java.base/sun.util.locale.provider.CalendarDataUtility$CalendarWeekParameterGetter.getObject(CalendarDataUtility.java:260)
                at java.base/sun.util.locale.provider.CalendarDataUtility$CalendarWeekParameterGetter.getObject(CalendarDataUtility.java:236)
                at java.base/sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObjectImpl(LocaleServiceProviderPool.java:281)
                at java.base/sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObject(LocaleServiceProviderPool.java:262)
                at java.base/sun.util.locale.provider.CalendarDataUtility.retrieveMinimalDaysInFirstWeek(CalendarDataUtility.java:85)
                at java.base/java.util.Calendar.setWeekCountData(Calendar.java:3414)
                at java.base/java.util.Calendar.<init>(Calendar.java:1611)
                at java.base/java.util.GregorianCalendar.<init>(GregorianCalendar.java:738)
                at java.base/java.util.Calendar$Builder.build(Calendar.java:1493)
                at java.base/sun.util.locale.provider.HostLocaleProviderAdapterImpl$7.getInstance(HostLocaleProviderAdapterImpl.java:435)
                at java.base/java.util.Calendar.createCalendar(Calendar.java:1696)
                at java.base/java.util.Calendar.getInstance(Calendar.java:1660)
                at java.base/java.text.SimpleDateFormat.initializeCalendar(SimpleDateFormat.java:676)
                at java.base/java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:620)
                at java.base/sun.util.locale.provider.HostLocaleProviderAdapterImpl$1.getDateInstance(HostLocaleProviderAdapterImpl.java:156)
                at java.base/java.text.DateFormat.get(DateFormat.java:838)
                at java.base/java.text.DateFormat.get(DateFormat.java:827)
                at java.base/java.text.DateFormat.getDateInstance(DateFormat.java:566)

        This will also be reproduced with test jdk/java/util/Locale/LocaleProvidersRun.java after JDK-8226869 is resolved.

        The reason is the fix for JDK-8218960, which added an assertion: http://hg.openjdk.java.net/jdk/jdk/rev/dfea18758dfa#l2.14

        This bails with the Windows implementation of CalendarDataProvider in sun/util/locale/provider/HostLocaleProviderAdapterImpl.java:
        http://hg.openjdk.java.net/jdk/jdk/file/1761df20fa12/src/java.base/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java#l368

        I guess the fix would be to return some sensible value instead of 0 in there.

              naoto Naoto Sato
              clanger Christoph Langer
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: