1401 } 1402 seen_dead_loader = true; 1403 loaders_removed++; 1404 ClassLoaderData* dead = data; 1405 dead->unload(); 1406 data = data->next(); 1407 // Remove from loader list. 1408 // This class loader data will no longer be found 1409 // in the ClassLoaderDataGraph. 1410 if (prev != NULL) { 1411 prev->set_next(data); 1412 } else { 1413 assert(dead == _head, "sanity check"); 1414 _head = data; 1415 } 1416 dead->set_next(_unloading); 1417 _unloading = dead; 1418 } 1419 1420 if (seen_dead_loader) { 1421 data = _head; 1422 while (data != NULL) { 1423 // Remove entries in the dictionary of live class loader that have 1424 // initiated loading classes in a dead class loader. 1425 if (data->dictionary() != NULL) { 1426 data->dictionary()->do_unloading(); 1427 } 1428 // Walk a ModuleEntry's reads, and a PackageEntry's exports 1429 // lists to determine if there are modules on those lists that are now 1430 // dead and should be removed. A module's life cycle is equivalent 1431 // to its defining class loader's life cycle. Since a module is 1432 // considered dead if its class loader is dead, these walks must 1433 // occur after each class loader's aliveness is determined. 1434 if (data->packages() != NULL) { 1435 data->packages()->purge_all_package_exports(); 1436 } 1437 if (data->modules_defined()) { 1438 data->modules()->purge_all_module_reads(); 1439 } 1440 data = data->next(); 1441 } 1442 SymbolTable::do_check_concurrent_work(); 1443 JFR_ONLY(post_class_unload_events();) 1444 } 1445 1446 log_debug(class, loader, data)("do_unloading: loaders processed %u, loaders removed %u", loaders_processed, loaders_removed); 1447 1448 return seen_dead_loader; 1449 } 1450 1451 // There's at least one dead class loader. Purge refererences of healthy module 1452 // reads lists and package export lists to modules belonging to dead loaders. 1453 void ClassLoaderDataGraph::clean_module_and_package_info() { 1454 ClassLoaderData* data = _head; 1455 while (data != NULL) { 1456 // Remove entries in the dictionary of live class loader that have 1457 // initiated loading classes in a dead class loader. 1458 if (data->dictionary() != NULL) { 1459 data->dictionary()->do_unloading(); 1460 } 1461 // Walk a ModuleEntry's reads, and a PackageEntry's exports 1462 // lists to determine if there are modules on those lists that are now | 1401 } 1402 seen_dead_loader = true; 1403 loaders_removed++; 1404 ClassLoaderData* dead = data; 1405 dead->unload(); 1406 data = data->next(); 1407 // Remove from loader list. 1408 // This class loader data will no longer be found 1409 // in the ClassLoaderDataGraph. 1410 if (prev != NULL) { 1411 prev->set_next(data); 1412 } else { 1413 assert(dead == _head, "sanity check"); 1414 _head = data; 1415 } 1416 dead->set_next(_unloading); 1417 _unloading = dead; 1418 } 1419 1420 if (seen_dead_loader) { 1421 JFR_ONLY(post_class_unload_events();) 1422 } 1423 1424 log_debug(class, loader, data)("do_unloading: loaders processed %u, loaders removed %u", loaders_processed, loaders_removed); 1425 1426 return seen_dead_loader; 1427 } 1428 1429 // There's at least one dead class loader. Purge refererences of healthy module 1430 // reads lists and package export lists to modules belonging to dead loaders. 1431 void ClassLoaderDataGraph::clean_module_and_package_info() { 1432 ClassLoaderData* data = _head; 1433 while (data != NULL) { 1434 // Remove entries in the dictionary of live class loader that have 1435 // initiated loading classes in a dead class loader. 1436 if (data->dictionary() != NULL) { 1437 data->dictionary()->do_unloading(); 1438 } 1439 // Walk a ModuleEntry's reads, and a PackageEntry's exports 1440 // lists to determine if there are modules on those lists that are now |