When working on some metaspace-related cleanup tasks, I saw that ClassLoaderDataGraph::unload_list_contains() seems wrong:
for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) {
if (cld->metaspace_or_null() != NULL && cld->metaspace_or_null()->contains(x)) {
return true;
}
}
There is no non-static Metaspace::contains. There are only two variants of static Metaspace::contains(), which test if the given pointer is somewhere in the metaspace, disregarding the classloader in question.
In this case, this static function is called via an instance, which unfortunately is valid C++.
This effects HeapRegion::verify:
bool is_metaspace_object = Metaspace::contains(klass) ||
(vo == VerifyOption_G1UsePrevMarking &&
ClassLoaderDataGraph::unload_list_contains(klass));
because ClassLoaderDataGraph::unload_list_contains(klass) returns true for any klass living in metaspace, not just klass objects which are part of this class loaders unload list.
Although I am not sure I even understand the conditions: "Metaspace::contains(klass)" should always encompass "ClassLoaderDataGraph::unload_list_contains(klass)", or?
for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) {
if (cld->metaspace_or_null() != NULL && cld->metaspace_or_null()->contains(x)) {
return true;
}
}
There is no non-static Metaspace::contains. There are only two variants of static Metaspace::contains(), which test if the given pointer is somewhere in the metaspace, disregarding the classloader in question.
In this case, this static function is called via an instance, which unfortunately is valid C++.
This effects HeapRegion::verify:
bool is_metaspace_object = Metaspace::contains(klass) ||
(vo == VerifyOption_G1UsePrevMarking &&
ClassLoaderDataGraph::unload_list_contains(klass));
because ClassLoaderDataGraph::unload_list_contains(klass) returns true for any klass living in metaspace, not just klass objects which are part of this class loaders unload list.
Although I am not sure I even understand the conditions: "Metaspace::contains(klass)" should always encompass "ClassLoaderDataGraph::unload_list_contains(klass)", or?