On Wed, 9 Feb 2022 20:17:22 GMT, Chris Plummer <cjplum...@openjdk.org> wrote:
>> ClassLoaderDataGraph::classes_do description says: >> // Walking classes through the ClassLoaderDataGraph include array classes. >> So do_load_class callback should not dump arrays for the classes and dumper >> doesn't need to call Universe::basic_type_classes_do (array classes for >> primitive types are also reported by ClassLoaderDataGraph::classes_do) > > src/hotspot/share/services/heapDumper.cpp line 2293: > >> 2291: // Writes HPROF_GC_CLASS_DUMP records >> 2292: // For array classes we need signers and protection domain from >> their bottom classes >> 2293: // so do_class_dump skips array classes and dumps array classes >> with corresponding instance class. > > I'm having trouble parsing this comment. Can you clarify? HPROF_GC_CLASS_DUMP records contain references to signers and protection domain objects. But this is properties of InstanceKlass, for array classes the properties from their element classes are written (or NULL for arrays of primitive types). do_class_dump callback skips array classes: if (k->is_instance_klass()) { DumperSupport::dump_class_and_array_classes(writer(), k); } dump_class_and_array_classes dumps the class and then iterate over array classes (k->array_klass_or_null()) and writes records for them (using signer and protection domain from the instance class specified). This approach also skips primitive type arrays (they don't have corresponding InstanceKlass) - they are dumped separately. I added the comment to explain why do_class_dump goes this tricky way. Do you have any suggestions how to rephrase it to make clearer? ------------- PR: https://git.openjdk.java.net/jdk/pull/7384