939 |
939 |
940 // creates HPROF_GC_CLASS_DUMP record for the given class and each of |
940 // creates HPROF_GC_CLASS_DUMP record for the given class and each of |
941 // its array classes |
941 // its array classes |
942 void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) { |
942 void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) { |
943 Klass* klass = k; |
943 Klass* klass = k; |
944 assert(klass->oop_is_instance(), "not an InstanceKlass"); |
944 InstanceKlass* ik = InstanceKlass::cast(k); |
945 InstanceKlass* ik = (InstanceKlass*)klass; |
945 |
|
946 // We can safepoint and do a heap dump at a point where we have a Klass, |
|
947 // but no java mirror class has been setup for it. So we need to check |
|
948 // that the class is at least loaded, to avoid crash from a null mirror. |
|
949 if (!ik->is_loaded()) { |
|
950 return; |
|
951 } |
946 |
952 |
947 writer->write_u1(HPROF_GC_CLASS_DUMP); |
953 writer->write_u1(HPROF_GC_CLASS_DUMP); |
948 |
954 |
949 // class ID |
955 // class ID |
950 writer->write_classID(ik); |
956 writer->write_classID(ik); |