< prev index next >

src/hotspot/share/classfile/classLoaderData.cpp

Print this page




  39 // The System Dictionary and related data structures (e.g., placeholder table,
  40 // loader constraints table) as well as the runtime representation of classes
  41 // only reference ClassLoaderData.
  42 //
  43 // Instances of java.lang.ClassLoader holds a pointer to a ClassLoaderData that
  44 // that represent the loader's "linking domain" in the JVM.
  45 //
  46 // The bootstrap loader (represented by NULL) also has a ClassLoaderData,
  47 // the singleton class the_null_class_loader_data().
  48 
  49 #include "precompiled.hpp"
  50 #include "classfile/classLoaderData.hpp"
  51 #include "classfile/classLoaderData.inline.hpp"
  52 #include "classfile/dictionary.hpp"
  53 #include "classfile/javaClasses.hpp"
  54 #include "classfile/metadataOnStackMark.hpp"
  55 #include "classfile/moduleEntry.hpp"
  56 #include "classfile/packageEntry.hpp"
  57 #include "classfile/systemDictionary.hpp"
  58 #include "code/codeCache.hpp"

  59 #include "logging/log.hpp"
  60 #include "logging/logStream.hpp"
  61 #include "memory/allocation.inline.hpp"
  62 #include "memory/metadataFactory.hpp"
  63 #include "memory/metaspaceShared.hpp"
  64 #include "memory/oopFactory.hpp"
  65 #include "memory/resourceArea.hpp"
  66 #include "oops/access.inline.hpp"
  67 #include "oops/objArrayOop.inline.hpp"
  68 #include "oops/oop.inline.hpp"
  69 #include "runtime/atomic.hpp"
  70 #include "runtime/handles.inline.hpp"
  71 #include "runtime/javaCalls.hpp"
  72 #include "runtime/jniHandles.hpp"
  73 #include "runtime/mutex.hpp"
  74 #include "runtime/orderAccess.hpp"
  75 #include "runtime/safepoint.hpp"
  76 #include "runtime/safepointVerifiers.hpp"
  77 #include "runtime/synchronizer.hpp"
  78 #include "utilities/growableArray.hpp"


 493       if (_current_loader_data != NULL) {
 494         _current_class_entry = _current_loader_data->klasses();
 495       }  // else try_get_next_class will start at the head
 496     }
 497   }
 498 
 499   void adjust_saved_class(Klass* klass) {
 500     if (_current_class_entry == klass) {
 501       _current_class_entry = klass->next_link();
 502     }
 503   }
 504 };
 505 
 506 static ClassLoaderDataGraphKlassIteratorStatic static_klass_iterator;
 507 
 508 InstanceKlass* ClassLoaderDataGraph::try_get_next_class() {
 509   return static_klass_iterator.try_get_next_class();
 510 }
 511 
 512 






 513 // Remove a klass from the _klasses list for scratch_class during redefinition
 514 // or parsed class in the case of an error.
 515 void ClassLoaderData::remove_class(Klass* scratch_class) {
 516   assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
 517 
 518   // Adjust global class iterator.
 519   static_klass_iterator.adjust_saved_class(scratch_class);
 520 
 521   Klass* prev = NULL;
 522   for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
 523     if (k == scratch_class) {
 524       if (prev == NULL) {
 525         _klasses = k->next_link();
 526       } else {
 527         Klass* next = k->next_link();
 528         prev->set_next_link(next);
 529       }
 530 
 531       if (k->is_array_klass()) {
 532         ClassLoaderDataGraph::dec_array_classes(1);


 600   } else if (is_system_class_loader_data()) {
 601     size = _boot_loader_dictionary_size;
 602     resizable = true;
 603   } else {
 604     size = _default_loader_dictionary_size;
 605     resizable = true;
 606   }
 607   if (!DynamicallyResizeSystemDictionaries || DumpSharedSpaces || UseSharedSpaces) {
 608     resizable = false;
 609   }
 610   return new Dictionary(this, size, resizable);
 611 }
 612 
 613 // Tell the GC to keep this klass alive while iterating ClassLoaderDataGraph
 614 oop ClassLoaderData::holder_phantom() {
 615   // A klass that was previously considered dead can be looked up in the
 616   // CLD/SD, and its _java_mirror or _class_loader can be stored in a root
 617   // or a reachable object making it alive again. The SATB part of G1 needs
 618   // to get notified about this potential resurrection, otherwise the marking
 619   // might not find the object.
 620   if (!keep_alive()) {
 621     oop* o = is_anonymous() ? _klasses->java_mirror_handle().ptr_raw() : &_class_loader;
 622     return RootAccess<ON_PHANTOM_OOP_REF>::oop_load(o);
 623   } else {
 624     return NULL;
 625   }
 626 }
 627 
 628 // Unloading support
 629 oop ClassLoaderData::keep_alive_object() const {
 630   assert_locked_or_safepoint(_metaspace_lock);
 631   assert(!keep_alive(), "Don't use with CLDs that are artificially kept alive");
 632   return is_anonymous() ? _klasses->java_mirror() : class_loader();
 633 }
 634 
 635 bool ClassLoaderData::is_alive(BoolObjectClosure* is_alive_closure) const {
 636   bool alive = keep_alive() // null class loader and incomplete anonymous klasses.
 637       || is_alive_closure->do_object_b(keep_alive_object());

 638 
 639   return alive;
 640 }
 641 
 642 class ReleaseKlassClosure: public KlassClosure {
 643 private:
 644   size_t  _instance_class_released;
 645   size_t  _array_class_released;
 646 public:
 647   ReleaseKlassClosure() : _instance_class_released(0), _array_class_released(0) { }
 648 
 649   size_t instance_class_released() const { return _instance_class_released; }
 650   size_t array_class_released()    const { return _array_class_released;    }
 651 
 652   void do_klass(Klass* k) {
 653     if (k->is_array_klass()) {
 654       _array_class_released ++;
 655     } else {
 656       assert(k->is_instance_klass(), "Must be");
 657       _instance_class_released ++;
 658       InstanceKlass::release_C_heap_structures(InstanceKlass::cast(k));
 659     }
 660   }
 661 };
 662 
 663 ClassLoaderData::~ClassLoaderData() {
 664   // Release C heap structures for all the classes.
 665   ReleaseKlassClosure cl;
 666   classes_do(&cl);
 667 
 668   ClassLoaderDataGraph::dec_array_classes(cl.array_class_released());
 669   ClassLoaderDataGraph::dec_instance_classes(cl.instance_class_released());
 670 





 671   // Release C heap allocated hashtable for all the packages.
 672   if (_packages != NULL) {
 673     // Destroy the table itself
 674     delete _packages;
 675     _packages = NULL;
 676   }
 677 
 678   // Release C heap allocated hashtable for all the modules.
 679   if (_modules != NULL) {
 680     // Destroy the table itself
 681     delete _modules;
 682     _modules = NULL;
 683   }
 684 
 685   // Release C heap allocated hashtable for the dictionary
 686   if (_dictionary != NULL) {
 687     // Destroy the table itself
 688     delete _dictionary;
 689     _dictionary = NULL;
 690   }


 952 
 953 
 954 // GC root of class loader data created.
 955 ClassLoaderData* ClassLoaderDataGraph::_head = NULL;
 956 ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL;
 957 ClassLoaderData* ClassLoaderDataGraph::_saved_unloading = NULL;
 958 ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL;
 959 
 960 bool ClassLoaderDataGraph::_should_purge = false;
 961 bool ClassLoaderDataGraph::_metaspace_oom = false;
 962 
 963 // Add a new class loader data node to the list.  Assign the newly created
 964 // ClassLoaderData into the java/lang/ClassLoader object as a hidden field
 965 ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_anonymous) {
 966   NoSafepointVerifier no_safepoints; // we mustn't GC until we've installed the
 967                                      // ClassLoaderData in the graph since the CLD
 968                                      // contains unhandled oops
 969 
 970   ClassLoaderData* cld = new ClassLoaderData(loader, is_anonymous);
 971 
 972 
 973   if (!is_anonymous) {
 974     // First, Atomically set it
 975     ClassLoaderData* old = java_lang_ClassLoader::cmpxchg_loader_data(cld, loader(), NULL);
 976     if (old != NULL) {
 977       delete cld;
 978       // Returns the data.
 979       return old;
 980     }




 981   }
 982 

 983   // We won the race, and therefore the task of adding the data to the list of
 984   // class loader data
 985   ClassLoaderData** list_head = &_head;
 986   ClassLoaderData* next = _head;
 987 
 988   do {
 989     cld->set_next(next);
 990     ClassLoaderData* exchanged = Atomic::cmpxchg(cld, list_head, next);
 991     if (exchanged == next) {
 992       LogTarget(Debug, class, loader, data) lt;
 993       if (lt.is_enabled()) {
 994         ResourceMark rm;
 995         LogStream ls(lt);
 996         ls.print("create ");
 997         cld->print_value_on(&ls);
 998         ls.cr();
 999       }
1000       return cld;
1001     }
1002     next = exchanged;


1227 bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) {
1228   for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
1229     if (loader_data == data) {
1230       return true;
1231     }
1232   }
1233 
1234   return false;
1235 }
1236 #endif // PRODUCT
1237 
1238 
1239 // Move class loader data from main list to the unloaded list for unloading
1240 // and deallocation later.
1241 bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure,
1242                                         bool clean_previous_versions) {
1243 
1244   ClassLoaderData* data = _head;
1245   ClassLoaderData* prev = NULL;
1246   bool seen_dead_loader = false;


1247 
1248   // Mark metadata seen on the stack only so we can delete unneeded entries.
1249   // Only walk all metadata, including the expensive code cache walk, for Full GC
1250   // and only if class redefinition and if there's previous versions of
1251   // Klasses to delete.
1252   bool walk_all_metadata = clean_previous_versions &&
1253                            JvmtiExport::has_redefined_a_class() &&
1254                            InstanceKlass::has_previous_versions_and_reset();
1255   MetadataOnStackMark md_on_stack(walk_all_metadata);
1256 
1257   // Save previous _unloading pointer for CMS which may add to unloading list before
1258   // purging and we don't want to rewalk the previously unloaded class loader data.
1259   _saved_unloading = _unloading;
1260 
1261   data = _head;
1262   while (data != NULL) {
1263     if (data->is_alive(is_alive_closure)) {
1264       // clean metaspace
1265       if (walk_all_metadata) {
1266         data->classes_do(InstanceKlass::purge_previous_versions);
1267       }
1268       data->free_deallocate_list();
1269       prev = data;
1270       data = data->next();

1271       continue;
1272     }
1273     seen_dead_loader = true;

1274     ClassLoaderData* dead = data;
1275     dead->unload();
1276     data = data->next();
1277     // Remove from loader list.
1278     // This class loader data will no longer be found
1279     // in the ClassLoaderDataGraph.
1280     if (prev != NULL) {
1281       prev->set_next(data);
1282     } else {
1283       assert(dead == _head, "sanity check");
1284       _head = data;
1285     }
1286     dead->set_next(_unloading);
1287     _unloading = dead;
1288   }
1289 
1290   if (seen_dead_loader) {
1291     data = _head;
1292     while (data != NULL) {
1293       // Remove entries in the dictionary of live class loader that have


1295       if (data->dictionary() != NULL) {
1296         data->dictionary()->do_unloading(is_alive_closure);
1297       }
1298       // Walk a ModuleEntry's reads, and a PackageEntry's exports
1299       // lists to determine if there are modules on those lists that are now
1300       // dead and should be removed.  A module's life cycle is equivalent
1301       // to its defining class loader's life cycle.  Since a module is
1302       // considered dead if its class loader is dead, these walks must
1303       // occur after each class loader's aliveness is determined.
1304       if (data->packages() != NULL) {
1305         data->packages()->purge_all_package_exports();
1306       }
1307       if (data->modules_defined()) {
1308         data->modules()->purge_all_module_reads();
1309       }
1310       data = data->next();
1311     }
1312 
1313     post_class_unload_events();
1314   }


1315 
1316   return seen_dead_loader;
1317 }
1318 
1319 void ClassLoaderDataGraph::purge() {
1320   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
1321   ClassLoaderData* list = _unloading;
1322   _unloading = NULL;
1323   ClassLoaderData* next = list;
1324   bool classes_unloaded = false;
1325   while (next != NULL) {
1326     ClassLoaderData* purge_me = next;
1327     next = purge_me->next();
1328     delete purge_me;
1329     classes_unloaded = true;
1330   }
1331   if (classes_unloaded) {
1332     Metaspace::purge();
1333     set_metaspace_oom(false);
1334   }




  39 // The System Dictionary and related data structures (e.g., placeholder table,
  40 // loader constraints table) as well as the runtime representation of classes
  41 // only reference ClassLoaderData.
  42 //
  43 // Instances of java.lang.ClassLoader holds a pointer to a ClassLoaderData that
  44 // that represent the loader's "linking domain" in the JVM.
  45 //
  46 // The bootstrap loader (represented by NULL) also has a ClassLoaderData,
  47 // the singleton class the_null_class_loader_data().
  48 
  49 #include "precompiled.hpp"
  50 #include "classfile/classLoaderData.hpp"
  51 #include "classfile/classLoaderData.inline.hpp"
  52 #include "classfile/dictionary.hpp"
  53 #include "classfile/javaClasses.hpp"
  54 #include "classfile/metadataOnStackMark.hpp"
  55 #include "classfile/moduleEntry.hpp"
  56 #include "classfile/packageEntry.hpp"
  57 #include "classfile/systemDictionary.hpp"
  58 #include "code/codeCache.hpp"
  59 #include "gc/shared/oopStorage.hpp"
  60 #include "logging/log.hpp"
  61 #include "logging/logStream.hpp"
  62 #include "memory/allocation.inline.hpp"
  63 #include "memory/metadataFactory.hpp"
  64 #include "memory/metaspaceShared.hpp"
  65 #include "memory/oopFactory.hpp"
  66 #include "memory/resourceArea.hpp"
  67 #include "oops/access.inline.hpp"
  68 #include "oops/objArrayOop.inline.hpp"
  69 #include "oops/oop.inline.hpp"
  70 #include "runtime/atomic.hpp"
  71 #include "runtime/handles.inline.hpp"
  72 #include "runtime/javaCalls.hpp"
  73 #include "runtime/jniHandles.hpp"
  74 #include "runtime/mutex.hpp"
  75 #include "runtime/orderAccess.hpp"
  76 #include "runtime/safepoint.hpp"
  77 #include "runtime/safepointVerifiers.hpp"
  78 #include "runtime/synchronizer.hpp"
  79 #include "utilities/growableArray.hpp"


 494       if (_current_loader_data != NULL) {
 495         _current_class_entry = _current_loader_data->klasses();
 496       }  // else try_get_next_class will start at the head
 497     }
 498   }
 499 
 500   void adjust_saved_class(Klass* klass) {
 501     if (_current_class_entry == klass) {
 502       _current_class_entry = klass->next_link();
 503     }
 504   }
 505 };
 506 
 507 static ClassLoaderDataGraphKlassIteratorStatic static_klass_iterator;
 508 
 509 InstanceKlass* ClassLoaderDataGraph::try_get_next_class() {
 510   return static_klass_iterator.try_get_next_class();
 511 }
 512 
 513 
 514 void ClassLoaderData::update_holder(Handle holder) {
 515   assert(holder() != NULL, "should be called with non-NULL loader");
 516   assert(_holder.peek() == NULL, "never replace holders");
 517   _holder = WeakHandle::create(holder);
 518 }
 519 
 520 // Remove a klass from the _klasses list for scratch_class during redefinition
 521 // or parsed class in the case of an error.
 522 void ClassLoaderData::remove_class(Klass* scratch_class) {
 523   assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
 524 
 525   // Adjust global class iterator.
 526   static_klass_iterator.adjust_saved_class(scratch_class);
 527 
 528   Klass* prev = NULL;
 529   for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
 530     if (k == scratch_class) {
 531       if (prev == NULL) {
 532         _klasses = k->next_link();
 533       } else {
 534         Klass* next = k->next_link();
 535         prev->set_next_link(next);
 536       }
 537 
 538       if (k->is_array_klass()) {
 539         ClassLoaderDataGraph::dec_array_classes(1);


 607   } else if (is_system_class_loader_data()) {
 608     size = _boot_loader_dictionary_size;
 609     resizable = true;
 610   } else {
 611     size = _default_loader_dictionary_size;
 612     resizable = true;
 613   }
 614   if (!DynamicallyResizeSystemDictionaries || DumpSharedSpaces || UseSharedSpaces) {
 615     resizable = false;
 616   }
 617   return new Dictionary(this, size, resizable);
 618 }
 619 
 620 // Tell the GC to keep this klass alive while iterating ClassLoaderDataGraph
 621 oop ClassLoaderData::holder_phantom() {
 622   // A klass that was previously considered dead can be looked up in the
 623   // CLD/SD, and its _java_mirror or _class_loader can be stored in a root
 624   // or a reachable object making it alive again. The SATB part of G1 needs
 625   // to get notified about this potential resurrection, otherwise the marking
 626   // might not find the object.
 627   return _holder.resolve();





 628 }
 629 
 630 // Unloading support
 631 bool ClassLoaderData::is_alive() const {






 632   bool alive = keep_alive()         // null class loader and incomplete anonymous klasses.
 633       || _holder.is_null()
 634       || (_holder.peek() != NULL);  // not cleaned by weak reference processing
 635 
 636   return alive;
 637 }
 638 
 639 class ReleaseKlassClosure: public KlassClosure {
 640 private:
 641   size_t  _instance_class_released;
 642   size_t  _array_class_released;
 643 public:
 644   ReleaseKlassClosure() : _instance_class_released(0), _array_class_released(0) { }
 645 
 646   size_t instance_class_released() const { return _instance_class_released; }
 647   size_t array_class_released()    const { return _array_class_released;    }
 648 
 649   void do_klass(Klass* k) {
 650     if (k->is_array_klass()) {
 651       _array_class_released ++;
 652     } else {
 653       assert(k->is_instance_klass(), "Must be");
 654       _instance_class_released ++;
 655       InstanceKlass::release_C_heap_structures(InstanceKlass::cast(k));
 656     }
 657   }
 658 };
 659 
 660 ClassLoaderData::~ClassLoaderData() {
 661   // Release C heap structures for all the classes.
 662   ReleaseKlassClosure cl;
 663   classes_do(&cl);
 664 
 665   ClassLoaderDataGraph::dec_array_classes(cl.array_class_released());
 666   ClassLoaderDataGraph::dec_instance_classes(cl.instance_class_released());
 667 
 668   // Release the WeakHandle, if already set
 669   if (!_holder.is_null()) {
 670     _holder.release();
 671   }
 672 
 673   // Release C heap allocated hashtable for all the packages.
 674   if (_packages != NULL) {
 675     // Destroy the table itself
 676     delete _packages;
 677     _packages = NULL;
 678   }
 679 
 680   // Release C heap allocated hashtable for all the modules.
 681   if (_modules != NULL) {
 682     // Destroy the table itself
 683     delete _modules;
 684     _modules = NULL;
 685   }
 686 
 687   // Release C heap allocated hashtable for the dictionary
 688   if (_dictionary != NULL) {
 689     // Destroy the table itself
 690     delete _dictionary;
 691     _dictionary = NULL;
 692   }


 954 
 955 
 956 // GC root of class loader data created.
 957 ClassLoaderData* ClassLoaderDataGraph::_head = NULL;
 958 ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL;
 959 ClassLoaderData* ClassLoaderDataGraph::_saved_unloading = NULL;
 960 ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL;
 961 
 962 bool ClassLoaderDataGraph::_should_purge = false;
 963 bool ClassLoaderDataGraph::_metaspace_oom = false;
 964 
 965 // Add a new class loader data node to the list.  Assign the newly created
 966 // ClassLoaderData into the java/lang/ClassLoader object as a hidden field
 967 ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_anonymous) {
 968   NoSafepointVerifier no_safepoints; // we mustn't GC until we've installed the
 969                                      // ClassLoaderData in the graph since the CLD
 970                                      // contains unhandled oops
 971 
 972   ClassLoaderData* cld = new ClassLoaderData(loader, is_anonymous);
 973 

 974   if (!is_anonymous) {
 975     // First, Atomically set it
 976     ClassLoaderData* old = java_lang_ClassLoader::cmpxchg_loader_data(cld, loader(), NULL);
 977     if (old != NULL) {
 978       delete cld;
 979       // Returns the data.
 980       return old;
 981     }
 982 
 983     // Update the holder if we've won the race
 984     // The holder of this class is the class_loader generically.
 985     cld->update_holder(loader);
 986   }
 987 
 988 
 989   // We won the race, and therefore the task of adding the data to the list of
 990   // class loader data
 991   ClassLoaderData** list_head = &_head;
 992   ClassLoaderData* next = _head;
 993 
 994   do {
 995     cld->set_next(next);
 996     ClassLoaderData* exchanged = Atomic::cmpxchg(cld, list_head, next);
 997     if (exchanged == next) {
 998       LogTarget(Debug, class, loader, data) lt;
 999       if (lt.is_enabled()) {
1000         ResourceMark rm;
1001         LogStream ls(lt);
1002         ls.print("create ");
1003         cld->print_value_on(&ls);
1004         ls.cr();
1005       }
1006       return cld;
1007     }
1008     next = exchanged;


1233 bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) {
1234   for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
1235     if (loader_data == data) {
1236       return true;
1237     }
1238   }
1239 
1240   return false;
1241 }
1242 #endif // PRODUCT
1243 
1244 
1245 // Move class loader data from main list to the unloaded list for unloading
1246 // and deallocation later.
1247 bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure,
1248                                         bool clean_previous_versions) {
1249 
1250   ClassLoaderData* data = _head;
1251   ClassLoaderData* prev = NULL;
1252   bool seen_dead_loader = false;
1253   int  loaders_processed = 0;
1254   int  loaders_removed = 0;
1255 
1256   // Mark metadata seen on the stack only so we can delete unneeded entries.
1257   // Only walk all metadata, including the expensive code cache walk, for Full GC
1258   // and only if class redefinition and if there's previous versions of
1259   // Klasses to delete.
1260   bool walk_all_metadata = clean_previous_versions &&
1261                            JvmtiExport::has_redefined_a_class() &&
1262                            InstanceKlass::has_previous_versions_and_reset();
1263   MetadataOnStackMark md_on_stack(walk_all_metadata);
1264 
1265   // Save previous _unloading pointer for CMS which may add to unloading list before
1266   // purging and we don't want to rewalk the previously unloaded class loader data.
1267   _saved_unloading = _unloading;
1268 
1269   data = _head;
1270   while (data != NULL) {
1271     if (data->is_alive()) {
1272       // clean metaspace
1273       if (walk_all_metadata) {
1274         data->classes_do(InstanceKlass::purge_previous_versions);
1275       }
1276       data->free_deallocate_list();
1277       prev = data;
1278       data = data->next();
1279       loaders_processed++;
1280       continue;
1281     }
1282     seen_dead_loader = true;
1283     loaders_removed++;
1284     ClassLoaderData* dead = data;
1285     dead->unload();
1286     data = data->next();
1287     // Remove from loader list.
1288     // This class loader data will no longer be found
1289     // in the ClassLoaderDataGraph.
1290     if (prev != NULL) {
1291       prev->set_next(data);
1292     } else {
1293       assert(dead == _head, "sanity check");
1294       _head = data;
1295     }
1296     dead->set_next(_unloading);
1297     _unloading = dead;
1298   }
1299 
1300   if (seen_dead_loader) {
1301     data = _head;
1302     while (data != NULL) {
1303       // Remove entries in the dictionary of live class loader that have


1305       if (data->dictionary() != NULL) {
1306         data->dictionary()->do_unloading(is_alive_closure);
1307       }
1308       // Walk a ModuleEntry's reads, and a PackageEntry's exports
1309       // lists to determine if there are modules on those lists that are now
1310       // dead and should be removed.  A module's life cycle is equivalent
1311       // to its defining class loader's life cycle.  Since a module is
1312       // considered dead if its class loader is dead, these walks must
1313       // occur after each class loader's aliveness is determined.
1314       if (data->packages() != NULL) {
1315         data->packages()->purge_all_package_exports();
1316       }
1317       if (data->modules_defined()) {
1318         data->modules()->purge_all_module_reads();
1319       }
1320       data = data->next();
1321     }
1322 
1323     post_class_unload_events();
1324   }
1325 
1326   log_debug(class, loader, data)("do_unloading: loaders processed %d, loaders removed %d", loaders_processed, loaders_removed);
1327 
1328   return seen_dead_loader;
1329 }
1330 
1331 void ClassLoaderDataGraph::purge() {
1332   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
1333   ClassLoaderData* list = _unloading;
1334   _unloading = NULL;
1335   ClassLoaderData* next = list;
1336   bool classes_unloaded = false;
1337   while (next != NULL) {
1338     ClassLoaderData* purge_me = next;
1339     next = purge_me->next();
1340     delete purge_me;
1341     classes_unloaded = true;
1342   }
1343   if (classes_unloaded) {
1344     Metaspace::purge();
1345     set_metaspace_oom(false);
1346   }


< prev index next >