< prev index next >

src/hotspot/share/classfile/moduleEntry.cpp

Print this page




 243     }
 244   }
 245 }
 246 
 247 void ModuleEntry::delete_reads() {
 248   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 249   delete _reads;
 250   _reads = NULL;
 251 }
 252 
 253 ModuleEntry* ModuleEntry::create_unnamed_module(ClassLoaderData* cld) {
 254   // The java.lang.Module for this loader's
 255   // corresponding unnamed module can be found in the java.lang.ClassLoader object.
 256   oop module = java_lang_ClassLoader::unnamedModule(cld->class_loader());
 257 
 258   // Ensure that the unnamed module was correctly set when the class loader was constructed.
 259   // Guarantee will cause a recognizable crash if the user code has circumvented calling the ClassLoader constructor.
 260   ResourceMark rm;
 261   guarantee(java_lang_Module::is_instance(module),
 262             "The unnamed module for ClassLoader %s, is null or not an instance of java.lang.Module. The class loader has not been initialized correctly.",
 263             cld->loader_name());
 264 
 265   ModuleEntry* unnamed_module = new_unnamed_module_entry(Handle(Thread::current(), module), cld);
 266 
 267   // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
 268   java_lang_Module::set_module_entry(module, unnamed_module);
 269 
 270   return unnamed_module;
 271 }
 272 
 273 ModuleEntry* ModuleEntry::create_boot_unnamed_module(ClassLoaderData* cld) {
 274   // For the boot loader, the java.lang.Module for the unnamed module
 275   // is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At
 276   // this point initially create the ModuleEntry for the unnamed module.
 277   ModuleEntry* unnamed_module = new_unnamed_module_entry(Handle(), cld);
 278   assert(unnamed_module != NULL, "boot loader unnamed module should not be null");
 279   return unnamed_module;
 280 }
 281 
 282 // When creating an unnamed module, this is called without holding the Module_lock.
 283 // This is okay because the unnamed module gets created before the ClassLoaderData


 505 }
 506 
 507 void ModuleEntryTable::print(outputStream* st) {
 508   st->print_cr("Module Entry Table (table_size=%d, entries=%d)",
 509                table_size(), number_of_entries());
 510   for (int i = 0; i < table_size(); i++) {
 511     for (ModuleEntry* probe = bucket(i);
 512                               probe != NULL;
 513                               probe = probe->next()) {
 514       probe->print(st);
 515     }
 516   }
 517 }
 518 
 519 void ModuleEntry::print(outputStream* st) {
 520   ResourceMark rm;
 521   st->print_cr("entry " PTR_FORMAT " name %s module " PTR_FORMAT " loader %s version %s location %s strict %s next " PTR_FORMAT,
 522                p2i(this),
 523                name() == NULL ? UNNAMED_MODULE : name()->as_C_string(),
 524                p2i(module()),
 525                loader_data()->loader_name(),
 526                version() != NULL ? version()->as_C_string() : "NULL",
 527                location() != NULL ? location()->as_C_string() : "NULL",
 528                BOOL_TO_STR(!can_read_all_unnamed()), p2i(next()));
 529 }
 530 
 531 void ModuleEntryTable::verify() {
 532   verify_table<ModuleEntry>("Module Entry Table");
 533 }
 534 
 535 void ModuleEntry::verify() {
 536   guarantee(loader_data() != NULL, "A module entry must be associated with a loader.");
 537 }


 243     }
 244   }
 245 }
 246 
 247 void ModuleEntry::delete_reads() {
 248   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 249   delete _reads;
 250   _reads = NULL;
 251 }
 252 
 253 ModuleEntry* ModuleEntry::create_unnamed_module(ClassLoaderData* cld) {
 254   // The java.lang.Module for this loader's
 255   // corresponding unnamed module can be found in the java.lang.ClassLoader object.
 256   oop module = java_lang_ClassLoader::unnamedModule(cld->class_loader());
 257 
 258   // Ensure that the unnamed module was correctly set when the class loader was constructed.
 259   // Guarantee will cause a recognizable crash if the user code has circumvented calling the ClassLoader constructor.
 260   ResourceMark rm;
 261   guarantee(java_lang_Module::is_instance(module),
 262             "The unnamed module for ClassLoader %s, is null or not an instance of java.lang.Module. The class loader has not been initialized correctly.",
 263             cld->loader_name_and_id());
 264 
 265   ModuleEntry* unnamed_module = new_unnamed_module_entry(Handle(Thread::current(), module), cld);
 266 
 267   // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
 268   java_lang_Module::set_module_entry(module, unnamed_module);
 269 
 270   return unnamed_module;
 271 }
 272 
 273 ModuleEntry* ModuleEntry::create_boot_unnamed_module(ClassLoaderData* cld) {
 274   // For the boot loader, the java.lang.Module for the unnamed module
 275   // is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At
 276   // this point initially create the ModuleEntry for the unnamed module.
 277   ModuleEntry* unnamed_module = new_unnamed_module_entry(Handle(), cld);
 278   assert(unnamed_module != NULL, "boot loader unnamed module should not be null");
 279   return unnamed_module;
 280 }
 281 
 282 // When creating an unnamed module, this is called without holding the Module_lock.
 283 // This is okay because the unnamed module gets created before the ClassLoaderData


 505 }
 506 
 507 void ModuleEntryTable::print(outputStream* st) {
 508   st->print_cr("Module Entry Table (table_size=%d, entries=%d)",
 509                table_size(), number_of_entries());
 510   for (int i = 0; i < table_size(); i++) {
 511     for (ModuleEntry* probe = bucket(i);
 512                               probe != NULL;
 513                               probe = probe->next()) {
 514       probe->print(st);
 515     }
 516   }
 517 }
 518 
 519 void ModuleEntry::print(outputStream* st) {
 520   ResourceMark rm;
 521   st->print_cr("entry " PTR_FORMAT " name %s module " PTR_FORMAT " loader %s version %s location %s strict %s next " PTR_FORMAT,
 522                p2i(this),
 523                name() == NULL ? UNNAMED_MODULE : name()->as_C_string(),
 524                p2i(module()),
 525                loader_data()->loader_name_and_id(),
 526                version() != NULL ? version()->as_C_string() : "NULL",
 527                location() != NULL ? location()->as_C_string() : "NULL",
 528                BOOL_TO_STR(!can_read_all_unnamed()), p2i(next()));
 529 }
 530 
 531 void ModuleEntryTable::verify() {
 532   verify_table<ModuleEntry>("Module Entry Table");
 533 }
 534 
 535 void ModuleEntry::verify() {
 536   guarantee(loader_data() != NULL, "A module entry must be associated with a loader.");
 537 }
< prev index next >