< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page


 535   // Null out class_loader_data because we don't share that yet.
 536   set_class_loader_data(NULL);
 537   set_is_shared();
 538 }
 539 
 540 void Klass::remove_java_mirror() {
 541   Arguments::assert_is_dumping_archive();
 542   if (log_is_enabled(Trace, cds, unshareable)) {
 543     ResourceMark rm;
 544     log_trace(cds, unshareable)("remove java_mirror: %s", external_name());
 545   }
 546   // Just null out the mirror.  The class_loader_data() no longer exists.
 547   _java_mirror = NULL;
 548 }
 549 
 550 void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
 551   assert(is_klass(), "ensure C++ vtable is restored");
 552   assert(is_shared(), "must be set");
 553   JFR_ONLY(RESTORE_ID(this);)
 554   if (log_is_enabled(Trace, cds, unshareable)) {
 555     ResourceMark rm;
 556     log_trace(cds, unshareable)("restore: %s", external_name());
 557   }
 558 
 559   // If an exception happened during CDS restore, some of these fields may already be
 560   // set.  We leave the class on the CLD list, even if incomplete so that we don't
 561   // modify the CLD list outside a safepoint.
 562   if (class_loader_data() == NULL) {
 563     // Restore class_loader_data to the null class loader data
 564     set_class_loader_data(loader_data);
 565 
 566     // Add to null class loader list first before creating the mirror
 567     // (same order as class file parsing)
 568     loader_data->add_class(this);
 569   }
 570 
 571   Handle loader(THREAD, loader_data->class_loader());
 572   ModuleEntry* module_entry = NULL;
 573   Klass* k = this;
 574   if (k->is_objArray_klass()) {
 575     k = ObjArrayKlass::cast(k)->bottom_klass();
 576   }
 577   // Obtain klass' module.
 578   if (k->is_instance_klass()) {
 579     InstanceKlass* ik = (InstanceKlass*) k;
 580     module_entry = ik->module();
 581   } else {
 582     module_entry = ModuleEntryTable::javabase_moduleEntry();
 583   }
 584   // Obtain java.lang.Module, if available
 585   Handle module_handle(THREAD, ((module_entry != NULL) ? module_entry->module() : (oop)NULL));
 586 
 587   if (this->has_raw_archived_mirror()) {
 588     ResourceMark rm;
 589     log_debug(cds, mirror)("%s has raw archived mirror", external_name());
 590     if (HeapShared::open_archive_heap_region_mapped()) {
 591       bool present = java_lang_Class::restore_archived_mirror(this, loader, module_handle,
 592                                                               protection_domain,
 593                                                               CHECK);
 594       if (present) {
 595         return;
 596       }
 597     }
 598 
 599     // No archived mirror data
 600     log_debug(cds, mirror)("No archived mirror data for %s", external_name());
 601     _java_mirror = NULL;
 602     this->clear_has_raw_archived_mirror();
 603   }
 604 
 605   // Only recreate it if not present.  A previous attempt to restore may have
 606   // gotten an OOM later but keep the mirror if it was created.
 607   if (java_mirror() == NULL) {
 608     log_trace(cds, mirror)("Recreate mirror for %s", external_name());




 535   // Null out class_loader_data because we don't share that yet.
 536   set_class_loader_data(NULL);
 537   set_is_shared();
 538 }
 539 
 540 void Klass::remove_java_mirror() {
 541   Arguments::assert_is_dumping_archive();
 542   if (log_is_enabled(Trace, cds, unshareable)) {
 543     ResourceMark rm;
 544     log_trace(cds, unshareable)("remove java_mirror: %s", external_name());
 545   }
 546   // Just null out the mirror.  The class_loader_data() no longer exists.
 547   _java_mirror = NULL;
 548 }
 549 
 550 void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
 551   assert(is_klass(), "ensure C++ vtable is restored");
 552   assert(is_shared(), "must be set");
 553   JFR_ONLY(RESTORE_ID(this);)
 554   if (log_is_enabled(Trace, cds, unshareable)) {
 555     ResourceMark rm(THREAD);
 556     log_trace(cds, unshareable)("restore: %s", external_name());
 557   }
 558 
 559   // If an exception happened during CDS restore, some of these fields may already be
 560   // set.  We leave the class on the CLD list, even if incomplete so that we don't
 561   // modify the CLD list outside a safepoint.
 562   if (class_loader_data() == NULL) {
 563     // Restore class_loader_data to the null class loader data
 564     set_class_loader_data(loader_data);
 565 
 566     // Add to null class loader list first before creating the mirror
 567     // (same order as class file parsing)
 568     loader_data->add_class(this);
 569   }
 570 
 571   Handle loader(THREAD, loader_data->class_loader());
 572   ModuleEntry* module_entry = NULL;
 573   Klass* k = this;
 574   if (k->is_objArray_klass()) {
 575     k = ObjArrayKlass::cast(k)->bottom_klass();
 576   }
 577   // Obtain klass' module.
 578   if (k->is_instance_klass()) {
 579     InstanceKlass* ik = (InstanceKlass*) k;
 580     module_entry = ik->module();
 581   } else {
 582     module_entry = ModuleEntryTable::javabase_moduleEntry();
 583   }
 584   // Obtain java.lang.Module, if available
 585   Handle module_handle(THREAD, ((module_entry != NULL) ? module_entry->module() : (oop)NULL));
 586 
 587   if (this->has_raw_archived_mirror()) {
 588     ResourceMark rm(THREAD);
 589     log_debug(cds, mirror)("%s has raw archived mirror", external_name());
 590     if (HeapShared::open_archive_heap_region_mapped()) {
 591       bool present = java_lang_Class::restore_archived_mirror(this, loader, module_handle,
 592                                                               protection_domain,
 593                                                               CHECK);
 594       if (present) {
 595         return;
 596       }
 597     }
 598 
 599     // No archived mirror data
 600     log_debug(cds, mirror)("No archived mirror data for %s", external_name());
 601     _java_mirror = NULL;
 602     this->clear_has_raw_archived_mirror();
 603   }
 604 
 605   // Only recreate it if not present.  A previous attempt to restore may have
 606   // gotten an OOM later but keep the mirror if it was created.
 607   if (java_mirror() == NULL) {
 608     log_trace(cds, mirror)("Recreate mirror for %s", external_name());


< prev index next >