< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoaderData.inline.hpp"
  27 #include "classfile/dictionary.hpp"
  28 #include "classfile/javaClasses.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "classfile/vmSymbols.hpp"
  31 #include "gc/shared/collectedHeap.inline.hpp"
  32 #include "logging/log.hpp"
  33 #include "memory/heapInspection.hpp"

  34 #include "memory/metadataFactory.hpp"
  35 #include "memory/metaspaceClosure.hpp"
  36 #include "memory/metaspaceShared.hpp"
  37 #include "memory/oopFactory.hpp"
  38 #include "memory/resourceArea.hpp"
  39 #include "oops/compressedOops.inline.hpp"
  40 #include "oops/instanceKlass.hpp"
  41 #include "oops/klass.inline.hpp"
  42 #include "oops/oop.inline.hpp"
  43 #include "oops/oopHandle.inline.hpp"
  44 #include "runtime/atomic.hpp"
  45 #include "runtime/handles.inline.hpp"
  46 #include "runtime/orderAccess.hpp"
  47 #include "utilities/macros.hpp"
  48 #include "utilities/stack.inline.hpp"
  49 
  50 void Klass::set_java_mirror(Handle m) {
  51   assert(!m.is_null(), "New mirror should never be null.");
  52   assert(_java_mirror.resolve() == NULL, "should only be used to initialize mirror");
  53   _java_mirror = class_loader_data()->add_handle(m);


 524 
 525   Handle loader(THREAD, loader_data->class_loader());
 526   ModuleEntry* module_entry = NULL;
 527   Klass* k = this;
 528   if (k->is_objArray_klass()) {
 529     k = ObjArrayKlass::cast(k)->bottom_klass();
 530   }
 531   // Obtain klass' module.
 532   if (k->is_instance_klass()) {
 533     InstanceKlass* ik = (InstanceKlass*) k;
 534     module_entry = ik->module();
 535   } else {
 536     module_entry = ModuleEntryTable::javabase_moduleEntry();
 537   }
 538   // Obtain java.lang.Module, if available
 539   Handle module_handle(THREAD, ((module_entry != NULL) ? module_entry->module() : (oop)NULL));
 540 
 541   if (this->has_raw_archived_mirror()) {
 542     ResourceMark rm;
 543     log_debug(cds, mirror)("%s has raw archived mirror", external_name());
 544     if (MetaspaceShared::open_archive_heap_region_mapped()) {
 545       bool present = java_lang_Class::restore_archived_mirror(this, loader, module_handle,
 546                                                               protection_domain,
 547                                                               CHECK);
 548       if (present) {
 549         return;
 550       }
 551     }
 552 
 553     // No archived mirror data
 554     log_debug(cds, mirror)("No archived mirror data for %s", external_name());
 555     _java_mirror = NULL;
 556     this->clear_has_raw_archived_mirror();
 557   }
 558 
 559   // Only recreate it if not present.  A previous attempt to restore may have
 560   // gotten an OOM later but keep the mirror if it was created.
 561   if (java_mirror() == NULL) {
 562     log_trace(cds, mirror)("Recreate mirror for %s", external_name());
 563     java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, CHECK);
 564   }




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoaderData.inline.hpp"
  27 #include "classfile/dictionary.hpp"
  28 #include "classfile/javaClasses.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "classfile/vmSymbols.hpp"
  31 #include "gc/shared/collectedHeap.inline.hpp"
  32 #include "logging/log.hpp"
  33 #include "memory/heapInspection.hpp"
  34 #include "memory/heapShared.hpp"
  35 #include "memory/metadataFactory.hpp"
  36 #include "memory/metaspaceClosure.hpp"
  37 #include "memory/metaspaceShared.hpp"
  38 #include "memory/oopFactory.hpp"
  39 #include "memory/resourceArea.hpp"
  40 #include "oops/compressedOops.inline.hpp"
  41 #include "oops/instanceKlass.hpp"
  42 #include "oops/klass.inline.hpp"
  43 #include "oops/oop.inline.hpp"
  44 #include "oops/oopHandle.inline.hpp"
  45 #include "runtime/atomic.hpp"
  46 #include "runtime/handles.inline.hpp"
  47 #include "runtime/orderAccess.hpp"
  48 #include "utilities/macros.hpp"
  49 #include "utilities/stack.inline.hpp"
  50 
  51 void Klass::set_java_mirror(Handle m) {
  52   assert(!m.is_null(), "New mirror should never be null.");
  53   assert(_java_mirror.resolve() == NULL, "should only be used to initialize mirror");
  54   _java_mirror = class_loader_data()->add_handle(m);


 525 
 526   Handle loader(THREAD, loader_data->class_loader());
 527   ModuleEntry* module_entry = NULL;
 528   Klass* k = this;
 529   if (k->is_objArray_klass()) {
 530     k = ObjArrayKlass::cast(k)->bottom_klass();
 531   }
 532   // Obtain klass' module.
 533   if (k->is_instance_klass()) {
 534     InstanceKlass* ik = (InstanceKlass*) k;
 535     module_entry = ik->module();
 536   } else {
 537     module_entry = ModuleEntryTable::javabase_moduleEntry();
 538   }
 539   // Obtain java.lang.Module, if available
 540   Handle module_handle(THREAD, ((module_entry != NULL) ? module_entry->module() : (oop)NULL));
 541 
 542   if (this->has_raw_archived_mirror()) {
 543     ResourceMark rm;
 544     log_debug(cds, mirror)("%s has raw archived mirror", external_name());
 545     if (HeapShared::open_archive_heap_region_mapped()) {
 546       bool present = java_lang_Class::restore_archived_mirror(this, loader, module_handle,
 547                                                               protection_domain,
 548                                                               CHECK);
 549       if (present) {
 550         return;
 551       }
 552     }
 553 
 554     // No archived mirror data
 555     log_debug(cds, mirror)("No archived mirror data for %s", external_name());
 556     _java_mirror = NULL;
 557     this->clear_has_raw_archived_mirror();
 558   }
 559 
 560   // Only recreate it if not present.  A previous attempt to restore may have
 561   // gotten an OOM later but keep the mirror if it was created.
 562   if (java_mirror() == NULL) {
 563     log_trace(cds, mirror)("Recreate mirror for %s", external_name());
 564     java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, CHECK);
 565   }


< prev index next >