JDK-8208061 : runtime/LoadClass/TestResize.java fails with "Load factor too high" when running in CDS mode
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 12
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-07-20
  • Updated: 2021-04-14
  • Resolved: 2018-08-24
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.0.12-oracleFixed 12 b09Fixed
Related Reports
Blocks :  
Relates :  
Description
The test fails with following error when running on a JDK binary with default CDS archive: 

java.lang.RuntimeException: Load factor too high, expected MAX 5.0, got 467.30841121495325 [table size 107, number of clases 50002]
	at TestResize.analyzeOutputOn(TestResize.java:99)
	at TestResize.main(TestResize.java:124)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.sun.javatest.regtest.agent.MainActionHelper$SameVMRunnable.run(MainActionHelper.java:229)
	at java.base/java.lang.Thread.run(Thread.java:834)
Comments
Fix request(11u): Patch applies cleanly and fixes the tier1 test case for 11u, if a CDS archive is used during testing. Tested tier1.
09-04-2021

'resizable' should be enabled for all non-shared dictionaries at runtime. The test passes with the following patch when running in CDS mode: diff --git a/src/hotspot/share/classfile/classLoaderData.cpp b/src/hotspot/share/classfile/classLoaderData.cpp --- a/src/hotspot/share/classfile/classLoaderData.cpp +++ b/src/hotspot/share/classfile/classLoaderData.cpp @@ -655,7 +655,7 @@ size = _default_loader_dictionary_size; resizable = true; } - if (!DynamicallyResizeSystemDictionaries || DumpSharedSpaces || UseSharedSpaces) { + if (!DynamicallyResizeSystemDictionaries || DumpSharedSpaces) { resizable = false; } return new Dictionary(this, size, resizable); diff --git a/src/hotspot/share/classfile/dictionary.cpp b/src/hotspot/share/classfile/dictionary.cpp --- a/src/hotspot/share/classfile/dictionary.cpp +++ b/src/hotspot/share/classfile/dictionary.cpp @@ -592,8 +592,8 @@ ResourceMark rm; assert(loader_data() != NULL, "loader data should not be null"); - st->print_cr("Java dictionary (table_size=%d, classes=%d)", - table_size(), number_of_entries()); + st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)", + table_size(), number_of_entries(), BOOL_TO_STR(_resizable)); st->print_cr("^ indicates that initiating loader is different from defining loader"); for (int index = 0; index < table_size(); index++) { diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -1163,7 +1163,8 @@ assert(length == _shared_dictionary_size * sizeof(HashtableBucket<mtClass>), "bad shared dictionary size."); _shared_dictionary = new Dictionary(ClassLoaderData::the_null_class_loader_data(), - _shared_dictionary_size, t, number_of_entries); + _shared_dictionary_size, t, number_of_entries, + false /* explicitly set _resizable to false */); } From -XX:+PrintSystemDictionaryAtExit output with CDS enabled at runtime, all system dictionaries except the shared dictionary are resizable: Shared Dictionary Java dictionary (table_size=1009, classes=1170, resizable=false) Dictionary for loader data: 0x00007f17d8612ba0 for instance a 'TriggerResize'{0x00000000a3888e50} Java dictionary (table_size=10103, classes=50002, resizable=true) Dictionary for loader data: 0x00007f17d8597190 for instance a 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x00000000a3812580} Java dictionary (table_size=1009, classes=6, resizable=true) Dictionary for loader data: 0x00007f17d858ef90 for instance a 'jdk/internal/loader/ClassLoaders$PlatformClassLoader'{0x00000000a38125f8} Java dictionary (table_size=107, classes=0, resizable=true) Dictionary for loader data: 0x00007f17d84950d0 of 'bootstrap' Java dictionary (table_size=1009, classes=461, resizable=true)
23-08-2018

Here are details for different dictionaries when the test fails with CDS enabled: Shared Dictionary Java dictionary (table_size=1009, classes=1170) Dictionary for loader data: 0x00007fe0a0611b10 for instance a 'TriggerResize'{0x0000000084892010} Java dictionary (table_size=107, classes=50002) Dictionary for loader data: 0x00007fe0a05981f0 for instance a 'jdk/internal/loader/ClassLoaders$PlatformClassLoader'{0x000000008482da78} Java dictionary (table_size=107, classes=0) Dictionary for loader data: 0x00007fe0a058e640 for instance a 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x000000008482da00} Java dictionary (table_size=1009, classes=6) Dictionary for loader data: 0x00007fe0a0494e00 of 'bootstrap' Java dictionary (table_size=1009, classes=461) In gdb, I set a break point on Dictionary::resize_if_needed(). The break point is never hit when running the test with CDS enabled. The following in ClassLoaderData::create_dictionary appears to be the cause. When UseSharedSpaces is enabled, resizable is disabled. Dictionary* ClassLoaderData::create_dictionary() { ... if (!DynamicallyResizeSystemDictionaries || DumpSharedSpaces || UseSharedSpaces) { resizable = false; } ... }
18-08-2018