From 6efa90da6be8187bdeba131701652c5fc2ea4105 Mon Sep 17 00:00:00 2001 From: aeriksso Date: Thu, 5 Nov 2015 11:42:42 +0100 Subject: [PATCH] 8134030: test/serviceability/dcmd/gc/HeapDumpTest fails to verify the dump Reviewed-by: dholmes --- src/share/vm/services/heapDumper.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/share/vm/services/heapDumper.cpp b/src/share/vm/services/heapDumper.cpp index a62ce9114..e5de80eae 100644 --- a/src/share/vm/services/heapDumper.cpp +++ b/src/share/vm/services/heapDumper.cpp @@ -941,8 +941,14 @@ void DumperSupport::dump_instance(DumpWriter* writer, oop o) { // its array classes void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) { Klass* klass = k; - assert(klass->oop_is_instance(), "not an InstanceKlass"); - InstanceKlass* ik = (InstanceKlass*)klass; + InstanceKlass* ik = InstanceKlass::cast(k); + + // We can safepoint and do a heap dump at a point where we have a Klass, + // but no java mirror class has been setup for it. So we need to check + // that the class is at least loaded, to avoid crash from a null mirror. + if (!ik->is_loaded()) { + return; + } writer->write_u1(HPROF_GC_CLASS_DUMP); -- GitLab