267
268 // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
269 java_lang_Module::set_module_entry(module, unnamed_module);
270
271 return unnamed_module;
272 }
273
274 ModuleEntry* ModuleEntry::create_boot_unnamed_module(ClassLoaderData* cld) {
275 // For the boot loader, the java.lang.Module for the unnamed module
276 // is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At
277 // this point initially create the ModuleEntry for the unnamed module.
278 ModuleEntry* unnamed_module = new_unnamed_module_entry(Handle(), cld);
279 assert(unnamed_module != NULL, "boot loader unnamed module should not be null");
280 return unnamed_module;
281 }
282
283 // When creating an unnamed module, this is called without holding the Module_lock.
284 // This is okay because the unnamed module gets created before the ClassLoaderData
285 // is available to other threads.
286 ModuleEntry* ModuleEntry::new_unnamed_module_entry(Handle module_handle, ClassLoaderData* cld) {
287 ModuleEntry* entry = (ModuleEntry*) NEW_C_HEAP_ARRAY(char, sizeof(ModuleEntry), mtModule);
288
289 // Initialize everything BasicHashtable would
290 entry->set_next(NULL);
291 entry->set_hash(0);
292 entry->set_literal(NULL);
293
294 // Initialize fields specific to a ModuleEntry
295 entry->init();
296
297 // Unnamed modules can read all other unnamed modules.
298 entry->set_can_read_all_unnamed();
299
300 if (!module_handle.is_null()) {
301 entry->set_module(cld->add_handle(module_handle));
302 }
303
304 entry->set_loader_data(cld);
305 entry->_is_open = true;
306
307 JFR_ONLY(INIT_ID(entry);)
294 // Initialize fields specific to a ModuleEntry
295 entry->init();
296
297 // Unnamed modules can read all other unnamed modules.
298 entry->set_can_read_all_unnamed();
299
300 if (!module_handle.is_null()) {
301 entry->set_module(cld->add_handle(module_handle));
302 }
303
304 entry->set_loader_data(cld);
305 entry->_is_open = true;
306
307 JFR_ONLY(INIT_ID(entry);)
308
309 return entry;
310 }
311
312 void ModuleEntry::delete_unnamed_module() {
313 // Do not need unlink_entry() since the unnamed module is not in the hashtable
314 FREE_C_HEAP_ARRAY(char, this);
315 }
316
317 ModuleEntryTable::ModuleEntryTable(int table_size)
318 : Hashtable<Symbol*, mtModule>(table_size, sizeof(ModuleEntry))
319 {
320 }
321
322 ModuleEntryTable::~ModuleEntryTable() {
323 // Walk through all buckets and all entries in each bucket,
324 // freeing each entry.
325 for (int i = 0; i < table_size(); ++i) {
326 for (ModuleEntry* m = bucket(i); m != NULL;) {
327 ModuleEntry* to_remove = m;
328 // read next before freeing.
329 m = m->next();
330
331 ResourceMark rm;
332 if (to_remove->name() != NULL) {
333 log_info(module, unload)("unloading module %s", to_remove->name()->as_C_string());
334 }
|
267
268 // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
269 java_lang_Module::set_module_entry(module, unnamed_module);
270
271 return unnamed_module;
272 }
273
274 ModuleEntry* ModuleEntry::create_boot_unnamed_module(ClassLoaderData* cld) {
275 // For the boot loader, the java.lang.Module for the unnamed module
276 // is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At
277 // this point initially create the ModuleEntry for the unnamed module.
278 ModuleEntry* unnamed_module = new_unnamed_module_entry(Handle(), cld);
279 assert(unnamed_module != NULL, "boot loader unnamed module should not be null");
280 return unnamed_module;
281 }
282
283 // When creating an unnamed module, this is called without holding the Module_lock.
284 // This is okay because the unnamed module gets created before the ClassLoaderData
285 // is available to other threads.
286 ModuleEntry* ModuleEntry::new_unnamed_module_entry(Handle module_handle, ClassLoaderData* cld) {
287 ModuleEntry* entry = NEW_C_HEAP_OBJ(ModuleEntry, mtModule);
288
289 // Initialize everything BasicHashtable would
290 entry->set_next(NULL);
291 entry->set_hash(0);
292 entry->set_literal(NULL);
293
294 // Initialize fields specific to a ModuleEntry
295 entry->init();
296
297 // Unnamed modules can read all other unnamed modules.
298 entry->set_can_read_all_unnamed();
299
300 if (!module_handle.is_null()) {
301 entry->set_module(cld->add_handle(module_handle));
302 }
303
304 entry->set_loader_data(cld);
305 entry->_is_open = true;
306
307 JFR_ONLY(INIT_ID(entry);)
294 // Initialize fields specific to a ModuleEntry
295 entry->init();
296
297 // Unnamed modules can read all other unnamed modules.
298 entry->set_can_read_all_unnamed();
299
300 if (!module_handle.is_null()) {
301 entry->set_module(cld->add_handle(module_handle));
302 }
303
304 entry->set_loader_data(cld);
305 entry->_is_open = true;
306
307 JFR_ONLY(INIT_ID(entry);)
308
309 return entry;
310 }
311
312 void ModuleEntry::delete_unnamed_module() {
313 // Do not need unlink_entry() since the unnamed module is not in the hashtable
314 FREE_C_HEAP_OBJ(this);
315 }
316
317 ModuleEntryTable::ModuleEntryTable(int table_size)
318 : Hashtable<Symbol*, mtModule>(table_size, sizeof(ModuleEntry))
319 {
320 }
321
322 ModuleEntryTable::~ModuleEntryTable() {
323 // Walk through all buckets and all entries in each bucket,
324 // freeing each entry.
325 for (int i = 0; i < table_size(); ++i) {
326 for (ModuleEntry* m = bucket(i); m != NULL;) {
327 ModuleEntry* to_remove = m;
328 // read next before freeing.
329 m = m->next();
330
331 ResourceMark rm;
332 if (to_remove->name() != NULL) {
333 log_info(module, unload)("unloading module %s", to_remove->name()->as_C_string());
334 }
|