8220682: Heap dumping and inspection fails with JDK-8214712

Reviewed-by: jcbeyler, jiangli, sspitsyn
This commit is contained in:
Claes Redestad 2019-03-26 10:23:11 +01:00
parent 6ede0b6bb8
commit bf2d6a2838
2 changed files with 12 additions and 1 deletions

View File

@ -121,6 +121,11 @@ void KlassInfoEntry::print_on(outputStream* st) const {
}
KlassInfoEntry* KlassInfoBucket::lookup(Klass* const k) {
// Can happen if k is an archived class that we haven't loaded yet.
if (k->java_mirror() == NULL) {
return NULL;
}
KlassInfoEntry* elt = _list;
while (elt != NULL) {
if (elt->is_equal(k)) {
@ -202,7 +207,8 @@ KlassInfoEntry* KlassInfoTable::lookup(Klass* k) {
assert(_buckets != NULL, "Allocation failure should have been caught");
KlassInfoEntry* e = _buckets[idx].lookup(k);
// Lookup may fail if this is a new klass for which we
// could not allocate space for an new entry.
// could not allocate space for an new entry, or if it's
// an archived class that we haven't loaded yet.
assert(e == NULL || k == e->klass(), "must be equal");
return e;
}

View File

@ -958,6 +958,11 @@ void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, Klass* k
// creates HPROF_GC_INSTANCE_DUMP record for the given object
void DumperSupport::dump_instance(DumpWriter* writer, oop o) {
Klass* k = o->klass();
if (k->java_mirror() == NULL) {
// Ignoring this object since the corresponding java mirror is not loaded.
// Might be a dormant archive object.
return;
}
writer->write_u1(HPROF_GC_INSTANCE_DUMP);
writer->write_objectID(o);