785 bool javabase_was_defined = false; |
785 bool javabase_was_defined = false; |
786 { |
786 { |
787 MutexLocker m1(Module_lock, THREAD); |
787 MutexLocker m1(Module_lock, THREAD); |
788 // Keep list of classes needing java.base module fixup |
788 // Keep list of classes needing java.base module fixup |
789 if (!ModuleEntryTable::javabase_defined()) { |
789 if (!ModuleEntryTable::javabase_defined()) { |
790 if (fixup_module_field_list() == NULL) { |
790 assert(k->java_mirror() != NULL, "Class's mirror is null"); |
791 GrowableArray<Klass*>* list = |
|
792 new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true); |
|
793 set_fixup_module_field_list(list); |
|
794 } |
|
795 k->class_loader_data()->inc_keep_alive(); |
791 k->class_loader_data()->inc_keep_alive(); |
|
792 assert(fixup_module_field_list() != NULL, "fixup_module_field_list not initialized"); |
796 fixup_module_field_list()->push(k); |
793 fixup_module_field_list()->push(k); |
797 } else { |
794 } else { |
798 javabase_was_defined = true; |
795 javabase_was_defined = true; |
799 } |
796 } |
800 } |
797 } |
814 "Incorrect java.lang.Module specification while creating mirror"); |
811 "Incorrect java.lang.Module specification while creating mirror"); |
815 set_module(mirror(), module()); |
812 set_module(mirror(), module()); |
816 } |
813 } |
817 } |
814 } |
818 |
815 |
|
816 // Statically allocate fixup lists because they always get created. |
|
817 void java_lang_Class::allocate_fixup_lists() { |
|
818 GrowableArray<Klass*>* mirror_list = |
|
819 new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true); |
|
820 set_fixup_mirror_list(mirror_list); |
|
821 |
|
822 GrowableArray<Klass*>* module_list = |
|
823 new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true); |
|
824 set_fixup_module_field_list(module_list); |
|
825 } |
|
826 |
819 void java_lang_Class::create_mirror(Klass* k, Handle class_loader, |
827 void java_lang_Class::create_mirror(Klass* k, Handle class_loader, |
820 Handle module, Handle protection_domain, TRAPS) { |
828 Handle module, Handle protection_domain, TRAPS) { |
821 assert(k != NULL, "Use create_basic_type_mirror for primitive types"); |
829 assert(k != NULL, "Use create_basic_type_mirror for primitive types"); |
822 assert(k->java_mirror() == NULL, "should only assign mirror once"); |
830 assert(k->java_mirror() == NULL, "should only assign mirror once"); |
|
831 |
823 // Use this moment of initialization to cache modifier_flags also, |
832 // Use this moment of initialization to cache modifier_flags also, |
824 // to support Class.getModifiers(). Instance classes recalculate |
833 // to support Class.getModifiers(). Instance classes recalculate |
825 // the cached flags after the class file is parsed, but before the |
834 // the cached flags after the class file is parsed, but before the |
826 // class is put into the system dictionary. |
835 // class is put into the system dictionary. |
827 int computed_modifiers = k->compute_modifier_flags(CHECK); |
836 int computed_modifiers = k->compute_modifier_flags(CHECK); |
876 |
885 |
877 // set the classLoader field in the java_lang_Class instance |
886 // set the classLoader field in the java_lang_Class instance |
878 assert(class_loader() == k->class_loader(), "should be same"); |
887 assert(class_loader() == k->class_loader(), "should be same"); |
879 set_class_loader(mirror(), class_loader()); |
888 set_class_loader(mirror(), class_loader()); |
880 |
889 |
881 // set the module field in the java_lang_Class instance |
|
882 set_mirror_module_field(k, mirror, module, THREAD); |
|
883 |
|
884 // Setup indirection from klass->mirror |
890 // Setup indirection from klass->mirror |
885 // after any exceptions can happen during allocations. |
891 // after any exceptions can happen during allocations. |
886 k->set_java_mirror(mirror()); |
892 k->set_java_mirror(mirror()); |
|
893 |
|
894 // Set the module field in the java_lang_Class instance. This must be done |
|
895 // after the mirror is set. |
|
896 set_mirror_module_field(k, mirror, module, THREAD); |
|
897 |
887 if (comp_mirror() != NULL) { |
898 if (comp_mirror() != NULL) { |
888 // Set after k->java_mirror() is published, because compiled code running |
899 // Set after k->java_mirror() is published, because compiled code running |
889 // concurrently doesn't expect a k to have a null java_mirror. |
900 // concurrently doesn't expect a k to have a null java_mirror. |
890 release_set_array_klass(comp_mirror(), k); |
901 release_set_array_klass(comp_mirror(), k); |
891 } |
902 } |
892 } else { |
903 } else { |
893 if (fixup_mirror_list() == NULL) { |
904 assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized"); |
894 GrowableArray<Klass*>* list = |
|
895 new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true); |
|
896 set_fixup_mirror_list(list); |
|
897 } |
|
898 fixup_mirror_list()->push(k); |
905 fixup_mirror_list()->push(k); |
899 } |
906 } |
900 } |
907 } |
901 |
908 |
902 void java_lang_Class::fixup_module_field(Klass* k, Handle module) { |
909 void java_lang_Class::fixup_module_field(Klass* k, Handle module) { |