changeset 8973:acb9351e3a29

8134030: test/serviceability/dcmd/gc/HeapDumpTest fails to verify the dump Reviewed-by: dholmes
author aeriksso
date Thu, 05 Nov 2015 11:42:42 +0100
parents 1a1aec8c87b7
children 32bc598624bd
files src/share/vm/services/heapDumper.cpp
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/services/heapDumper.cpp	Fri Jan 18 17:05:41 2019 +0100
+++ b/src/share/vm/services/heapDumper.cpp	Thu Nov 05 11:42:42 2015 +0100
@@ -941,8 +941,14 @@
 // 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);