< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page




1196 
1197   // The field at _array_klass_offset is pointing to the original one dimension
1198   // higher array klass if exists. Relocate the pointer.
1199   Klass *arr = array_klass_acquire(mirror);
1200   if (arr != NULL) {
1201     Klass *reloc_arr = MetaspaceShared::get_relocated_klass(arr);
1202     log_debug(cds, heap, mirror)(
1203       "Relocate mirror metadata field at _array_klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT,
1204       p2i(arr), p2i(reloc_arr));
1205     archived_mirror->metadata_field_put(_array_klass_offset, reloc_arr);
1206   }
1207   return archived_mirror;
1208 }
1209 
1210 // Returns true if the mirror is updated, false if no archived mirror
1211 // data is present. After the archived mirror object is restored, the
1212 // shared klass' _has_raw_archived_mirror flag is cleared.
1213 bool java_lang_Class::restore_archived_mirror(Klass *k,
1214                                               Handle class_loader, Handle module,
1215                                               Handle protection_domain, TRAPS) {








1216   oop m = MetaspaceShared::materialize_archived_object(k->archived_java_mirror_raw_narrow());
1217 
1218   if (m == NULL) {
1219     return false;
1220   }
1221 
1222   log_debug(cds, mirror)("Archived mirror is: " PTR_FORMAT, p2i(m));
1223 
1224   // mirror is archived, restore
1225   assert(MetaspaceShared::is_archive_object(m), "must be archived mirror object");
1226   Handle mirror(THREAD, m);
1227 
1228   // The java.lang.Class field offsets were archived and reloaded from archive.
1229   // No need to put classes on the fixup_mirror_list before java.lang.Class
1230   // is loaded.
1231 
1232   if (!k->is_array_klass()) {
1233     // - local static final fields with initial values were initialized at dump time
1234 
1235     // create the init_lock
1236     typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_(false));
1237     set_init_lock(mirror(), r);
1238 
1239     if (protection_domain.not_null()) {
1240       set_protection_domain(mirror(), protection_domain());
1241     }
1242   }
1243 
1244   assert(class_loader() == k->class_loader(), "should be same");
1245   if (class_loader.not_null()) {
1246     set_class_loader(mirror(), class_loader());
1247   }
1248 
1249   k->set_java_mirror(mirror);
1250   k->clear_has_raw_archived_mirror();




1196 
1197   // The field at _array_klass_offset is pointing to the original one dimension
1198   // higher array klass if exists. Relocate the pointer.
1199   Klass *arr = array_klass_acquire(mirror);
1200   if (arr != NULL) {
1201     Klass *reloc_arr = MetaspaceShared::get_relocated_klass(arr);
1202     log_debug(cds, heap, mirror)(
1203       "Relocate mirror metadata field at _array_klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT,
1204       p2i(arr), p2i(reloc_arr));
1205     archived_mirror->metadata_field_put(_array_klass_offset, reloc_arr);
1206   }
1207   return archived_mirror;
1208 }
1209 
1210 // Returns true if the mirror is updated, false if no archived mirror
1211 // data is present. After the archived mirror object is restored, the
1212 // shared klass' _has_raw_archived_mirror flag is cleared.
1213 bool java_lang_Class::restore_archived_mirror(Klass *k,
1214                                               Handle class_loader, Handle module,
1215                                               Handle protection_domain, TRAPS) {
1216   // Postpone restoring archived mirror until java.lang.Class is loaded. Please
1217   // see more details in SystemDictionary::resolve_preloaded_classes().
1218   if (!SystemDictionary::Class_klass_loaded()) {
1219     assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized");
1220     fixup_mirror_list()->push(k);
1221     return true;
1222   }
1223 
1224   oop m = MetaspaceShared::materialize_archived_object(k->archived_java_mirror_raw_narrow());
1225 
1226   if (m == NULL) {
1227     return false;
1228   }
1229 
1230   log_debug(cds, mirror)("Archived mirror is: " PTR_FORMAT, p2i(m));
1231 
1232   // mirror is archived, restore
1233   assert(MetaspaceShared::is_archive_object(m), "must be archived mirror object");
1234   Handle mirror(THREAD, m);




1235 
1236   if (!k->is_array_klass()) {
1237     // - local static final fields with initial values were initialized at dump time
1238 
1239     // create the init_lock
1240     typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_(false));
1241     set_init_lock(mirror(), r);
1242 
1243     if (protection_domain.not_null()) {
1244       set_protection_domain(mirror(), protection_domain());
1245     }
1246   }
1247 
1248   assert(class_loader() == k->class_loader(), "should be same");
1249   if (class_loader.not_null()) {
1250     set_class_loader(mirror(), class_loader());
1251   }
1252 
1253   k->set_java_mirror(mirror);
1254   k->clear_has_raw_archived_mirror();


< prev index next >