8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes

Because anonymous classes are not in the system dictionary, we have to set 'unloading_occurred' based on 'CLDG::do_unloading()'. Added jtreg test.

Reviewed-by: kvn, coleenp
This commit is contained in:
Tobias Hartmann 2014-08-14 09:15:39 +02:00
parent 8ed4cb5a02
commit d50dfdb399
4 changed files with 136 additions and 21 deletions

View file

@ -130,15 +130,13 @@ void DictionaryEntry::add_protection_domain(Dictionary* dict, oop protection_dom
}
bool Dictionary::do_unloading() {
void Dictionary::do_unloading() {
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
bool class_was_unloaded = false;
int index = 0; // Defined here for portability! Do not move
// Remove unloadable entries and classes from system dictionary
// The placeholder array has been handled in always_strong_oops_do.
DictionaryEntry* probe = NULL;
for (index = 0; index < table_size(); index++) {
for (int index = 0; index < table_size(); index++) {
for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
probe = *p;
Klass* e = probe->klass();
@ -158,16 +156,8 @@ bool Dictionary::do_unloading() {
// Do we need to delete this system dictionary entry?
if (loader_data->is_unloading()) {
// If the loader is not live this entry should always be
// removed (will never be looked up again). Note that this is
// not the same as unloading the referred class.
if (k_def_class_loader_data == loader_data) {
// This is the defining entry, so the referred class is about
// to be unloaded.
class_was_unloaded = true;
}
// Also remove this system dictionary entry.
// removed (will never be looked up again).
purge_entry = true;
} else {
// The loader in this entry is alive. If the klass is dead,
// (determined by checking the defining class loader)
@ -196,7 +186,6 @@ bool Dictionary::do_unloading() {
p = probe->next_addr();
}
}
return class_was_unloaded;
}
void Dictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {