comparison src/share/vm/classfile/dictionary.cpp @ 20350:c3990b8c710e hs25.40-b07

8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes Summary: 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
author thartmann
date Mon, 25 Aug 2014 08:20:17 +0200
parents 2c6ef90f030a
children 6e0cb14ce59b
comparison
equal deleted inserted replaced
20349:7fa57b65c27f 20350:c3990b8c710e
128 print(); 128 print();
129 } 129 }
130 } 130 }
131 131
132 132
133 bool Dictionary::do_unloading() { 133 void Dictionary::do_unloading() {
134 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); 134 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
135 bool class_was_unloaded = false;
136 int index = 0; // Defined here for portability! Do not move
137 135
138 // Remove unloadable entries and classes from system dictionary 136 // Remove unloadable entries and classes from system dictionary
139 // The placeholder array has been handled in always_strong_oops_do. 137 // The placeholder array has been handled in always_strong_oops_do.
140 DictionaryEntry* probe = NULL; 138 DictionaryEntry* probe = NULL;
141 for (index = 0; index < table_size(); index++) { 139 for (int index = 0; index < table_size(); index++) {
142 for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) { 140 for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
143 probe = *p; 141 probe = *p;
144 Klass* e = probe->klass(); 142 Klass* e = probe->klass();
145 ClassLoaderData* loader_data = probe->loader_data(); 143 ClassLoaderData* loader_data = probe->loader_data();
146 144
156 bool purge_entry = false; 154 bool purge_entry = false;
157 155
158 // Do we need to delete this system dictionary entry? 156 // Do we need to delete this system dictionary entry?
159 if (loader_data->is_unloading()) { 157 if (loader_data->is_unloading()) {
160 // If the loader is not live this entry should always be 158 // If the loader is not live this entry should always be
161 // removed (will never be looked up again). Note that this is 159 // removed (will never be looked up again).
162 // not the same as unloading the referred class.
163 if (k_def_class_loader_data == loader_data) {
164 // This is the defining entry, so the referred class is about
165 // to be unloaded.
166 class_was_unloaded = true;
167 }
168 // Also remove this system dictionary entry.
169 purge_entry = true; 160 purge_entry = true;
170
171 } else { 161 } else {
172 // The loader in this entry is alive. If the klass is dead, 162 // The loader in this entry is alive. If the klass is dead,
173 // (determined by checking the defining class loader) 163 // (determined by checking the defining class loader)
174 // the loader must be an initiating loader (rather than the 164 // the loader must be an initiating loader (rather than the
175 // defining loader). Remove this entry. 165 // defining loader). Remove this entry.
194 } 184 }
195 } 185 }
196 p = probe->next_addr(); 186 p = probe->next_addr();
197 } 187 }
198 } 188 }
199 return class_was_unloaded;
200 } 189 }
201 190
202 void Dictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) { 191 void Dictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
203 // Skip the strong roots probe marking if the closures are the same. 192 // Skip the strong roots probe marking if the closures are the same.
204 if (strong == weak) { 193 if (strong == weak) {