< prev index next >
src/hotspot/share/classfile/systemDictionary.cpp
Print this page
*** 2026,2035 ****
--- 2026,2052 ----
WKID scan = FIRST_WKID;
// first do Object, then String, Class
#if INCLUDE_CDS
if (UseSharedSpaces) {
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Object_klass), scan, CHECK);
+
+ // It's unsafe to access the archived heap regions before they
+ // are fixed up, so we must do the fixup as early as possible
+ // before the archived java objects are accessed by functions
+ // such as java_lang_Class::restore_archived_mirror and
+ // ConstantPool::restore_unshareable_info (restores the archived
+ // resolved_references array object).
+ //
+ // MetaspaceShared::fixup_mapped_heap_regions() fills the empty
+ // spaces in the archived heap regions and may use
+ // SystemDictionary::Object_klass(), so we can do this only after
+ // Object_klass is resolved.
+ // See the above resolve_wk_klasses_through() call. No mirror
+ // objects are accessed/restored in the above call. Mirrors are
+ // restored after java.lang.Class is loaded.
+ MetaspaceShared::fixup_mapped_heap_regions();
+
// Initialize the constant pool for the Object_class
Object_klass()->constants()->restore_unshareable_info(CHECK);
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
} else
#endif
< prev index next >