src/hotspot/share/memory/metaspaceShared.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff src/hotspot/share/memory

src/hotspot/share/memory/metaspaceShared.cpp

Print this page




1610 int MetaspaceShared::preload_classes(const char* class_list_path, TRAPS) {
1611   ClassListParser parser(class_list_path);
1612   int class_count = 0;
1613 
1614     while (parser.parse_one_line()) {
1615       Klass* klass = ClassLoaderExt::load_one_class(&parser, THREAD);
1616       if (HAS_PENDING_EXCEPTION) {
1617         if (klass == NULL &&
1618              (PENDING_EXCEPTION->klass()->name() == vmSymbols::java_lang_ClassNotFoundException())) {
1619           // print a warning only when the pending exception is class not found
1620           tty->print_cr("Preload Warning: Cannot find %s", parser.current_class_name());
1621         }
1622         CLEAR_PENDING_EXCEPTION;
1623       }
1624       if (klass != NULL) {
1625         if (log_is_enabled(Trace, cds)) {
1626           ResourceMark rm;
1627           log_trace(cds)("Shared spaces preloaded: %s", klass->external_name());
1628         }
1629 

1630         InstanceKlass* ik = InstanceKlass::cast(klass);
1631 
1632         // Link the class to cause the bytecodes to be rewritten and the
1633         // cpcache to be created. The linking is done as soon as classes
1634         // are loaded in order that the related data structures (klass and
1635         // cpCache) are located together.
1636         try_link_class(ik, THREAD);
1637         guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class");

1638 
1639         class_count++;
1640       }
1641     }
1642 
1643   return class_count;
1644 }
1645 
1646 // Returns true if the class's status has changed
1647 bool MetaspaceShared::try_link_class(InstanceKlass* ik, TRAPS) {
1648   assert(DumpSharedSpaces, "should only be called during dumping");
1649   if (ik->init_state() < InstanceKlass::linked) {
1650     bool saved = BytecodeVerificationLocal;
1651     if (!(ik->is_shared_boot_class())) {
1652       // The verification decision is based on BytecodeVerificationRemote
1653       // for non-system classes. Since we are using the NULL classloader
1654       // to load non-system classes during dumping, we need to temporarily
1655       // change BytecodeVerificationLocal to be the same as
1656       // BytecodeVerificationRemote. Note this can cause the parent system
1657       // classes also being verified. The extra overhead is acceptable during




1610 int MetaspaceShared::preload_classes(const char* class_list_path, TRAPS) {
1611   ClassListParser parser(class_list_path);
1612   int class_count = 0;
1613 
1614     while (parser.parse_one_line()) {
1615       Klass* klass = ClassLoaderExt::load_one_class(&parser, THREAD);
1616       if (HAS_PENDING_EXCEPTION) {
1617         if (klass == NULL &&
1618              (PENDING_EXCEPTION->klass()->name() == vmSymbols::java_lang_ClassNotFoundException())) {
1619           // print a warning only when the pending exception is class not found
1620           tty->print_cr("Preload Warning: Cannot find %s", parser.current_class_name());
1621         }
1622         CLEAR_PENDING_EXCEPTION;
1623       }
1624       if (klass != NULL) {
1625         if (log_is_enabled(Trace, cds)) {
1626           ResourceMark rm;
1627           log_trace(cds)("Shared spaces preloaded: %s", klass->external_name());
1628         }
1629 
1630         if (klass->is_instance_klass()) {
1631           InstanceKlass* ik = InstanceKlass::cast(klass);
1632 
1633           // Link the class to cause the bytecodes to be rewritten and the
1634           // cpcache to be created. The linking is done as soon as classes
1635           // are loaded in order that the related data structures (klass and
1636           // cpCache) are located together.
1637           try_link_class(ik, THREAD);
1638           guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class");
1639         }
1640 
1641         class_count++;
1642       }
1643     }
1644 
1645   return class_count;
1646 }
1647 
1648 // Returns true if the class's status has changed
1649 bool MetaspaceShared::try_link_class(InstanceKlass* ik, TRAPS) {
1650   assert(DumpSharedSpaces, "should only be called during dumping");
1651   if (ik->init_state() < InstanceKlass::linked) {
1652     bool saved = BytecodeVerificationLocal;
1653     if (!(ik->is_shared_boot_class())) {
1654       // The verification decision is based on BytecodeVerificationRemote
1655       // for non-system classes. Since we are using the NULL classloader
1656       // to load non-system classes during dumping, we need to temporarily
1657       // change BytecodeVerificationLocal to be the same as
1658       // BytecodeVerificationRemote. Note this can cause the parent system
1659       // classes also being verified. The extra overhead is acceptable during


src/hotspot/share/memory/metaspaceShared.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File