src/share/vm/classfile/classLoaderData.cpp

changeset 6974
556a06aec3fa
parent 6742
e4a6e7f1b90b
child 6992
2c6ef90f030a
equal deleted inserted replaced
6973:4af19b914f53 6974:556a06aec3fa
71 71
72 ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL; 72 ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
73 73
74 ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies) : 74 ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies) :
75 _class_loader(h_class_loader()), 75 _class_loader(h_class_loader()),
76 _is_anonymous(is_anonymous), _keep_alive(is_anonymous), // initially 76 _is_anonymous(is_anonymous),
77 // An anonymous class loader data doesn't have anything to keep
78 // it from being unloaded during parsing of the anonymous class.
79 // The null-class-loader should always be kept alive.
80 _keep_alive(is_anonymous || h_class_loader.is_null()),
77 _metaspace(NULL), _unloading(false), _klasses(NULL), 81 _metaspace(NULL), _unloading(false), _klasses(NULL),
78 _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL), 82 _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL),
79 _next(NULL), _dependencies(dependencies), 83 _next(NULL), _dependencies(dependencies),
80 _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true)) { 84 _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true)) {
81 // empty 85 // empty
315 } 319 }
316 tty->print_cr("]"); 320 tty->print_cr("]");
317 } 321 }
318 } 322 }
319 323
324 oop ClassLoaderData::keep_alive_object() const {
325 assert(!keep_alive(), "Don't use with CLDs that are artificially kept alive");
326 return is_anonymous() ? _klasses->java_mirror() : class_loader();
327 }
328
320 bool ClassLoaderData::is_alive(BoolObjectClosure* is_alive_closure) const { 329 bool ClassLoaderData::is_alive(BoolObjectClosure* is_alive_closure) const {
321 bool alive = 330 bool alive = keep_alive() // null class loader and incomplete anonymous klasses.
322 is_anonymous() ? 331 || is_alive_closure->do_object_b(keep_alive_object());
323 is_alive_closure->do_object_b(_klasses->java_mirror()) : 332
324 class_loader() == NULL || is_alive_closure->do_object_b(class_loader());
325 assert(!alive || claimed(), "must be claimed"); 333 assert(!alive || claimed(), "must be claimed");
326 return alive; 334 return alive;
327 } 335 }
328 336
329 337
599 } 607 }
600 } 608 }
601 609
602 void ClassLoaderDataGraph::always_strong_oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) { 610 void ClassLoaderDataGraph::always_strong_oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
603 if (ClassUnloading) { 611 if (ClassUnloading) {
604 ClassLoaderData::the_null_class_loader_data()->oops_do(f, klass_closure, must_claim);
605 // keep any special CLDs alive.
606 ClassLoaderDataGraph::keep_alive_oops_do(f, klass_closure, must_claim); 612 ClassLoaderDataGraph::keep_alive_oops_do(f, klass_closure, must_claim);
607 } else { 613 } else {
608 ClassLoaderDataGraph::oops_do(f, klass_closure, must_claim); 614 ClassLoaderDataGraph::oops_do(f, klass_closure, must_claim);
609 } 615 }
610 } 616 }
687 // mark metadata seen on the stack and code cache so we can delete 693 // mark metadata seen on the stack and code cache so we can delete
688 // unneeded entries. 694 // unneeded entries.
689 bool has_redefined_a_class = JvmtiExport::has_redefined_a_class(); 695 bool has_redefined_a_class = JvmtiExport::has_redefined_a_class();
690 MetadataOnStackMark md_on_stack; 696 MetadataOnStackMark md_on_stack;
691 while (data != NULL) { 697 while (data != NULL) {
692 if (data->keep_alive() || data->is_alive(is_alive_closure)) { 698 if (data->is_alive(is_alive_closure)) {
693 if (has_redefined_a_class) { 699 if (has_redefined_a_class) {
694 data->classes_do(InstanceKlass::purge_previous_versions); 700 data->classes_do(InstanceKlass::purge_previous_versions);
695 } 701 }
696 data->free_deallocate_list(); 702 data->free_deallocate_list();
697 prev = data; 703 prev = data;

mercurial