264 void ModuleEntryTable::create_unnamed_module(ClassLoaderData* loader_data) { |
264 void ModuleEntryTable::create_unnamed_module(ClassLoaderData* loader_data) { |
265 assert(Module_lock->owned_by_self(), "should have the Module_lock"); |
265 assert(Module_lock->owned_by_self(), "should have the Module_lock"); |
266 |
266 |
267 // Each ModuleEntryTable has exactly one unnamed module |
267 // Each ModuleEntryTable has exactly one unnamed module |
268 if (loader_data->is_the_null_class_loader_data()) { |
268 if (loader_data->is_the_null_class_loader_data()) { |
269 // For the boot loader, the java.lang.reflect.Module for the unnamed module |
269 // For the boot loader, the java.lang.Module for the unnamed module |
270 // is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At |
270 // is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At |
271 // this point initially create the ModuleEntry for the unnamed module. |
271 // this point initially create the ModuleEntry for the unnamed module. |
272 _unnamed_module = new_entry(0, Handle(NULL), NULL, NULL, NULL, loader_data); |
272 _unnamed_module = new_entry(0, Handle(NULL), NULL, NULL, NULL, loader_data); |
273 } else { |
273 } else { |
274 // For all other class loaders the java.lang.reflect.Module for their |
274 // For all other class loaders the java.lang.Module for their |
275 // corresponding unnamed module can be found in the java.lang.ClassLoader object. |
275 // corresponding unnamed module can be found in the java.lang.ClassLoader object. |
276 oop module = java_lang_ClassLoader::unnamedModule(loader_data->class_loader()); |
276 oop module = java_lang_ClassLoader::unnamedModule(loader_data->class_loader()); |
277 _unnamed_module = new_entry(0, Handle(module), NULL, NULL, NULL, loader_data); |
277 _unnamed_module = new_entry(0, Handle(module), NULL, NULL, NULL, loader_data); |
278 |
278 |
279 // Store pointer to the ModuleEntry in the unnamed module's java.lang.reflect.Module |
279 // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module |
280 // object. |
280 // object. |
281 java_lang_reflect_Module::set_module_entry(module, _unnamed_module); |
281 java_lang_Module::set_module_entry(module, _unnamed_module); |
282 } |
282 } |
283 |
283 |
284 // Add to bucket 0, no name to hash on |
284 // Add to bucket 0, no name to hash on |
285 add_entry(0, _unnamed_module); |
285 add_entry(0, _unnamed_module); |
286 } |
286 } |
386 |
386 |
387 if (module_handle.is_null()) { |
387 if (module_handle.is_null()) { |
388 fatal("Unable to finalize module definition for " JAVA_BASE_NAME); |
388 fatal("Unable to finalize module definition for " JAVA_BASE_NAME); |
389 } |
389 } |
390 |
390 |
391 // Set java.lang.reflect.Module, version and location for java.base |
391 // Set java.lang.Module, version and location for java.base |
392 ModuleEntry* jb_module = javabase_moduleEntry(); |
392 ModuleEntry* jb_module = javabase_moduleEntry(); |
393 assert(jb_module != NULL, JAVA_BASE_NAME " ModuleEntry not defined"); |
393 assert(jb_module != NULL, JAVA_BASE_NAME " ModuleEntry not defined"); |
394 jb_module->set_version(version); |
394 jb_module->set_version(version); |
395 jb_module->set_location(location); |
395 jb_module->set_location(location); |
396 // Once java.base's ModuleEntry _module field is set with the known |
396 // Once java.base's ModuleEntry _module field is set with the known |
397 // java.lang.reflect.Module, java.base is considered "defined" to the VM. |
397 // java.lang.Module, java.base is considered "defined" to the VM. |
398 jb_module->set_module(boot_loader_data->add_handle(module_handle)); |
398 jb_module->set_module(boot_loader_data->add_handle(module_handle)); |
399 |
399 |
400 // Store pointer to the ModuleEntry for java.base in the java.lang.reflect.Module object. |
400 // Store pointer to the ModuleEntry for java.base in the java.lang.Module object. |
401 java_lang_reflect_Module::set_module_entry(module_handle(), jb_module); |
401 java_lang_Module::set_module_entry(module_handle(), jb_module); |
402 } |
402 } |
403 |
403 |
404 // Within java.lang.Class instances there is a java.lang.reflect.Module field |
404 // Within java.lang.Class instances there is a java.lang.Module field that must |
405 // that must be set with the defining module. During startup, prior to java.base's |
405 // be set with the defining module. During startup, prior to java.base's definition, |
406 // definition, classes needing their module field set are added to the fixup_module_list. |
406 // classes needing their module field set are added to the fixup_module_list. |
407 // Their module field is set once java.base's java.lang.reflect.Module is known to the VM. |
407 // Their module field is set once java.base's java.lang.Module is known to the VM. |
408 void ModuleEntryTable::patch_javabase_entries(Handle module_handle) { |
408 void ModuleEntryTable::patch_javabase_entries(Handle module_handle) { |
409 if (module_handle.is_null()) { |
409 if (module_handle.is_null()) { |
410 fatal("Unable to patch the module field of classes loaded prior to " |
410 fatal("Unable to patch the module field of classes loaded prior to " |
411 JAVA_BASE_NAME "'s definition, invalid java.lang.reflect.Module"); |
411 JAVA_BASE_NAME "'s definition, invalid java.lang.Module"); |
412 } |
412 } |
413 |
413 |
414 // Do the fixups for the basic primitive types |
414 // Do the fixups for the basic primitive types |
415 java_lang_Class::set_module(Universe::int_mirror(), module_handle()); |
415 java_lang_Class::set_module(Universe::int_mirror(), module_handle()); |
416 java_lang_Class::set_module(Universe::float_mirror(), module_handle()); |
416 java_lang_Class::set_module(Universe::float_mirror(), module_handle()); |