< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page




 817                                                Handle protection_domain,
 818                                                TRAPS) {
 819   // Allocate a simple java object for a lock.
 820   // This needs to be a java object because during class initialization
 821   // it can be held across a java call.
 822   typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK);
 823   set_init_lock(mirror(), r);
 824 
 825   // Set protection domain also
 826   set_protection_domain(mirror(), protection_domain());
 827 
 828   // Initialize static fields
 829   InstanceKlass::cast(k)->do_local_static_fields(&initialize_static_field, mirror, CHECK);
 830 }
 831 
 832 // Set the java.lang.Module module field in the java_lang_Class mirror
 833 void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle module, TRAPS) {
 834   if (module.is_null()) {
 835     // During startup, the module may be NULL only if java.base has not been defined yet.
 836     // Put the class on the fixup_module_list to patch later when the java.lang.Module
 837     // for java.base is known.
 838     assert(!Universe::is_module_initialized(), "Incorrect java.lang.Module pre module system initialization");
 839 
 840     bool javabase_was_defined = false;
 841     {
 842       MutexLocker m1(Module_lock, THREAD);
 843       // Keep list of classes needing java.base module fixup
 844       if (!ModuleEntryTable::javabase_defined()) {
 845         assert(k->java_mirror() != NULL, "Class's mirror is null");
 846         k->class_loader_data()->inc_keep_alive();
 847         assert(fixup_module_field_list() != NULL, "fixup_module_field_list not initialized");
 848         fixup_module_field_list()->push(k);
 849       } else {
 850         javabase_was_defined = true;
 851       }
 852     }
 853 
 854     // If java.base was already defined then patch this particular class with java.base.
 855     if (javabase_was_defined) {
 856       ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry();
 857       assert(javabase_entry != NULL && javabase_entry->module() != NULL,
 858              "Setting class module field, " JAVA_BASE_NAME " should be defined");




 817                                                Handle protection_domain,
 818                                                TRAPS) {
 819   // Allocate a simple java object for a lock.
 820   // This needs to be a java object because during class initialization
 821   // it can be held across a java call.
 822   typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK);
 823   set_init_lock(mirror(), r);
 824 
 825   // Set protection domain also
 826   set_protection_domain(mirror(), protection_domain());
 827 
 828   // Initialize static fields
 829   InstanceKlass::cast(k)->do_local_static_fields(&initialize_static_field, mirror, CHECK);
 830 }
 831 
 832 // Set the java.lang.Module module field in the java_lang_Class mirror
 833 void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle module, TRAPS) {
 834   if (module.is_null()) {
 835     // During startup, the module may be NULL only if java.base has not been defined yet.
 836     // Put the class on the fixup_module_list to patch later when the java.lang.Module
 837     // for java.base is known. But note that since we captured the NULL module another
 838     // thread may have completed that initialization.
 839 
 840     bool javabase_was_defined = false;
 841     {
 842       MutexLocker m1(Module_lock, THREAD);
 843       // Keep list of classes needing java.base module fixup
 844       if (!ModuleEntryTable::javabase_defined()) {
 845         assert(k->java_mirror() != NULL, "Class's mirror is null");
 846         k->class_loader_data()->inc_keep_alive();
 847         assert(fixup_module_field_list() != NULL, "fixup_module_field_list not initialized");
 848         fixup_module_field_list()->push(k);
 849       } else {
 850         javabase_was_defined = true;
 851       }
 852     }
 853 
 854     // If java.base was already defined then patch this particular class with java.base.
 855     if (javabase_was_defined) {
 856       ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry();
 857       assert(javabase_entry != NULL && javabase_entry->module() != NULL,
 858              "Setting class module field, " JAVA_BASE_NAME " should be defined");


< prev index next >