[9] RFR (M) 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
Chris Plummer
chris.plummer at oracle.com
Wed Jan 7 23:29:22 UTC 2015
Hi,
Please review the following changes for the addition of the
VM.class_hierarchy DCMD. Please read the bug first for some background
information.
Webrev: http://cr.openjdk.java.net/~cjplummer/8054888/webrev.00/
Bug: https://bugs.openjdk.java.net/browse/JDK-8054888
I expect there will be further restructuring or additional feature work.
More discussion on that below. I'm not sure if that additional work will
be done later with a separately bug filed or with this initial commit.
That's one thing I want to work out with this review.
Currently the bulk of the DCMD is implemented in heapInspection.cpp.
The main purpose of this file is to implement the GC.class_stats and
GC.class_histogram DCMDs. Both of them require walking the java heap to
count live objects of each type, thus the name "heapInspection.cpp".
This new VM.class_hierarchy DCMD does not require walking the heap, but
is implemented in this file because it leverages the existing
KlassInfoTable and related classes (KlassInfoEntry, KlassInfoBucket, and
KlassClosure).
KlassInfoTable makes it easy to build a database of all loaded classes,
save additional info gathered for each class, iterate over them quickly,
and also do quick lookups. This exactly what I needed for this DCMD,
thus the reuse. There is some downside to this. For starters,
heapInspection.cpp is not the proper place for a DCMD that has nothing
to do with heap inspection. Also, KlassInfoEntry is being overloaded now
to support 3 different DCMDs, as is KlassInfoTable. As a result each has
a few fields and methods that are not used for all 3 DCMDs. Some
subclassing might be in order here, but I'm not sure if it's worth it.
Opinions welcomed. If I am going to refactor, I would prefer that be
done as a next step so I'm not disturbing the existing DCMDs with this
first implementation.
I added some comments to code only used for GC.class_stats and
GC.class_histogram. I did this when trying to figure them out so I could
better understand how to implement VM.class_hierarchy. I can take them
out if you think they are not appropriate for this commit.
One other item I like to discuss is whether it is worth adding a class
name argument to this DCMD. That would cause just the superclasses and
subclasses of the named class to be printed. If you think that is
useful, I think it can be added without too much trouble.
At the moment not much testing has been done other than running the DCMD
and looking at the output. I'll do more once it's clear the code has
"settled". I would like to know if there are any existing tests for
GC.class_stats and GC.class_histogram (there are none in the "test"
directory). If so, possibly one could serve as the basis for a new test
for VM.class_hierarchy.
thanks,
Chris
More information about the serviceability-dev
mailing list