JDK-8226876 : Assertion in sun/util/locale/provider/CalendarDataUtility on Windows after JDK-8218960
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 11,12,13,14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • Submitted: 2019-06-27
  • Updated: 2019-08-07
  • Resolved: 2019-06-28
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 13 JDK 14
11.0.4Fixed 13 b28Fixed 14Fixed
Related Reports
Relates :  
Relates :  
Description
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.
Comments
Fix request (11u): Need to backport this to fix the regression with JDK-8218960. Fix should apply cleanly. Will be tested @SAP.
27-06-2019

As it stands now, the issue would be part of OpenJDK Update 11.0.4. I'm wondering whether the backport of JDK-8218960 should be backed out there. Unfortunately 11.0.4 just went to security updates rampdown phase.
27-06-2019

We see this issue on AdoptOpenJDK EA build tests: https://ci.adoptopenjdk.net/view/Test_upstream/job/Test_upstream_openjdk11_hs_sanity.openjdk_x86-64_windows/4/console 01:41:44 C:/Users/jenkins/workspace/Test_upstream_openjdk11_hs_sanity.openjdk_x86-64_windows/openjdkbinary/j2sdk-image\bin\java -ea -esa -Xmx512m --add-exports java.base/sun.util.locale=ALL-UNNAMED --add-exports java.base/sun.util.locale.provider=ALL-UNNAMED -classpath C:/Users/jenkins/workspace/Test_upstream_openjdk11_hs_sanity.openjdk_x86-64_windows/openjdk-tests/TestConfig/test_output_15615895471106/jdk_util_0/work/classes/2/java/util/Locale/LocaleProviders.d; -Djava.locale.providers=HOST LocaleProviders bug7198834Test 01:41:44 Execution of the test case failed. 01:41:44 STDERR: 01:41:44 Exception in thread "main" java.lang.AssertionError 01:41:44 at java.base/sun.util.locale.provider.CalendarDataUtility$CalendarWeekParameterGetter.getObject(CalendarDataUtility.java:257) 01:41:44 at java.base/sun.util.locale.provider.CalendarDataUtility$CalendarWeekParameterGetter.getObject(CalendarDataUtility.java:233) 01:41:44 at java.base/sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObjectImpl(LocaleServiceProviderPool.java:281) 01:41:44 at java.base/sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObject(LocaleServiceProviderPool.java:262) 01:41:44 at java.base/sun.util.locale.provider.CalendarDataUtility.retrieveMinimalDaysInFirstWeek(CalendarDataUtility.java:84) 01:41:44 at java.base/java.util.Calendar.setWeekCountData(Calendar.java:3412) 01:41:44 at java.base/java.util.Calendar.<init>(Calendar.java:1611) 01:41:44 at java.base/java.util.GregorianCalendar.<init>(GregorianCalendar.java:738) 01:41:44 at java.base/java.util.Calendar$Builder.build(Calendar.java:1493) 01:41:44 at java.base/sun.util.locale.provider.HostLocaleProviderAdapterImpl$7.getInstance(HostLocaleProviderAdapterImpl.java:435) 01:41:44 at java.base/java.util.Calendar.createCalendar(Calendar.java:1696) 01:41:44 at java.base/java.util.Calendar.getInstance(Calendar.java:1660) 01:41:44 at java.base/java.text.SimpleDateFormat.initializeCalendar(SimpleDateFormat.java:676) 01:41:44 at java.base/java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:620) 01:41:44 at java.base/sun.util.locale.provider.HostLocaleProviderAdapterImpl$1.getDateInstance(HostLocaleProviderAdapterImpl.java:156) 01:41:44 at java.base/java.text.DateFormat.get(DateFormat.java:838) 01:41:44 at java.base/java.text.DateFormat.get(DateFormat.java:827) 01:41:44 at java.base/java.text.DateFormat.getDateInstance(DateFormat.java:566) 01:41:44 at LocaleProviders.bug7198834Test(LocaleProviders.java:106) 01:41:44 at LocaleProviders.main(LocaleProviders.java:48) 01:41:44 rerun:
27-06-2019