JDK-8180325 : Use ClassLoaderData::classes_do for CDS classes
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-05-12
  • Updated: 2019-05-22
  • Resolved: 2017-05-17
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 10
10 b21Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
ClassDataSharing classes should be dumped using the ClassLoaderData::_classes list.  Currently the code uses SystemDictionary::dictionary() which also contains classes that are initiated by different loaders than owning loaders.   Practically this doesn't affect CDS, since only the boot loader is present, but it necessitates calling the SystemDictionary::classes_do() function that passed the ClassLoaderData because some loaders in the table are NULL for CDS.

The list of loaded classes is found on the ClassLoaderData and includes array classes, anonymous classes, redefined classes, and unloaded classes.  For CDS the closure filters these out.
Comments
From earlier call chasing of SystemDictionary::classes_do memory/metaspaceShared.cpp: SystemDictionary::classes_do(collect_classes2); which? This is a special case for a bug that calls the classes_do function with ClassLoaderData argument that returns the initiating loader because the system dictionary may have NULL ClassLoaderData (or so the comment says). So this creates a GrowableArray with duplicate class entries which are filtered out. This would be more correct to walk the CLDG loaded classes, and filter out array and anonymous classes tested by? CDS -Xshare:dump memory/metaspaceShared.cpp: SystemDictionary::classes_do(link_one_shared_class, THREAD); memory/metaspaceShared.cpp: SystemDictionary::classes_do(check_one_shared_class); which? loaded instanceKlasses but not anonymous classes. tested by? CDS -Xshare:dump
12-05-2017