131 PerfCounter* ClassLoader::_perf_define_appclass_time = NULL; 132 PerfCounter* ClassLoader::_perf_define_appclass_selftime = NULL; 133 PerfCounter* ClassLoader::_perf_app_classfile_bytes_read = NULL; 134 PerfCounter* ClassLoader::_perf_sys_classfile_bytes_read = NULL; 135 PerfCounter* ClassLoader::_sync_systemLoaderLockContentionRate = NULL; 136 PerfCounter* ClassLoader::_sync_nonSystemLoaderLockContentionRate = NULL; 137 PerfCounter* ClassLoader::_sync_JVMFindLoadedClassLockFreeCounter = NULL; 138 PerfCounter* ClassLoader::_sync_JVMDefineClassLockFreeCounter = NULL; 139 PerfCounter* ClassLoader::_sync_JNIDefineClassLockFreeCounter = NULL; 140 PerfCounter* ClassLoader::_unsafe_defineClassCallCounter = NULL; 141 PerfCounter* ClassLoader::_load_instance_class_failCounter = NULL; 142 143 GrowableArray<ModuleClassPathList*>* ClassLoader::_patch_mod_entries = NULL; 144 GrowableArray<ModuleClassPathList*>* ClassLoader::_exploded_entries = NULL; 145 ClassPathEntry* ClassLoader::_jrt_entry = NULL; 146 ClassPathEntry* ClassLoader::_first_append_entry = NULL; 147 ClassPathEntry* ClassLoader::_last_append_entry = NULL; 148 #if INCLUDE_CDS 149 ClassPathEntry* ClassLoader::_app_classpath_entries = NULL; 150 ClassPathEntry* ClassLoader::_last_app_classpath_entry = NULL; 151 SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL; 152 #endif 153 154 // helper routines 155 bool string_starts_with(const char* str, const char* str_to_find) { 156 size_t str_len = strlen(str); 157 size_t str_to_find_len = strlen(str_to_find); 158 if (str_to_find_len > str_len) { 159 return false; 160 } 161 return (strncmp(str, str_to_find, str_to_find_len) == 0); 162 } 163 164 static const char* get_jimage_version_string() { 165 static char version_string[10] = ""; 166 if (version_string[0] == '\0') { 167 jio_snprintf(version_string, sizeof(version_string), "%d.%d", 168 Abstract_VM_Version::vm_major_version(), Abstract_VM_Version::vm_minor_version()); 169 } 170 return (const char*)version_string; 704 for (int start = 0; start < len; start = end) { 705 while (class_path[end] && class_path[end] != os::path_separator()[0]) { 706 end++; 707 } 708 EXCEPTION_MARK; 709 ResourceMark rm(THREAD); 710 char* path = NEW_RESOURCE_ARRAY(char, end - start + 1); 711 strncpy(path, &class_path[start], end - start); 712 path[end - start] = '\0'; 713 714 check_shared_classpath(path); 715 716 update_class_path_entry_list(path, false, false); 717 718 while (class_path[end] == os::path_separator()[0]) { 719 end++; 720 } 721 } 722 } 723 724 #endif 725 726 // Construct the array of module/path pairs as specified to --patch-module 727 // for the boot loader to search ahead of the jimage, if the class being 728 // loaded is defined to a module that has been specified to --patch-module. 729 void ClassLoader::setup_patch_mod_entries() { 730 Thread* THREAD = Thread::current(); 731 GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix(); 732 int num_of_entries = patch_mod_args->length(); 733 734 735 // Set up the boot loader's _patch_mod_entries list 736 _patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true); 737 738 for (int i = 0; i < num_of_entries; i++) { 739 const char* module_name = (patch_mod_args->at(i))->module_name(); 740 Symbol* const module_sym = SymbolTable::lookup(module_name, (int)strlen(module_name), CHECK); 741 assert(module_sym != NULL, "Failed to obtain Symbol for module name"); 742 ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym); 743 1071 } 1072 1073 // Do not reorder the bootclasspath which would break get_system_package(). 1074 // Add new entry to linked list 1075 if (is_boot_append) { 1076 add_to_boot_append_entries(new_entry); 1077 } else { 1078 add_to_app_classpath_entries(path, new_entry, check_for_duplicates); 1079 } 1080 return true; 1081 } else { 1082 #if INCLUDE_CDS 1083 if (DumpSharedSpaces) { 1084 _shared_paths_misc_info->add_nonexist_path(path); 1085 } 1086 #endif 1087 return false; 1088 } 1089 } 1090 1091 static void print_module_entry_table(const GrowableArray<ModuleClassPathList*>* const module_list) { 1092 ResourceMark rm; 1093 int num_of_entries = module_list->length(); 1094 for (int i = 0; i < num_of_entries; i++) { 1095 ClassPathEntry* e; 1096 ModuleClassPathList* mpl = module_list->at(i); 1097 tty->print("%s=", mpl->module_name()->as_C_string()); 1098 e = mpl->module_first_entry(); 1099 while (e != NULL) { 1100 tty->print("%s", e->name()); 1101 e = e->next(); 1102 if (e != NULL) { 1103 tty->print("%s", os::path_separator()); 1104 } 1105 } 1106 tty->print(" ;"); 1107 } 1108 } 1109 1110 void ClassLoader::print_bootclasspath() { 1495 loader_data, 1496 protection_domain, 1497 NULL, // host_klass 1498 NULL, // cp_patches 1499 THREAD); 1500 if (HAS_PENDING_EXCEPTION) { 1501 if (DumpSharedSpaces) { 1502 tty->print_cr("Preload Error: Failed to load %s", class_name); 1503 } 1504 return NULL; 1505 } 1506 1507 if (!add_package(file_name, classpath_index, THREAD)) { 1508 return NULL; 1509 } 1510 1511 return result; 1512 } 1513 1514 #if INCLUDE_CDS 1515 static char* skip_uri_protocol(char* source) { 1516 if (strncmp(source, "file:", 5) == 0) { 1517 // file: protocol path could start with file:/ or file:/// 1518 // locate the char after all the forward slashes 1519 int offset = 5; 1520 while (*(source + offset) == '/') { 1521 offset++; 1522 } 1523 source += offset; 1524 // for non-windows platforms, move back one char as the path begins with a '/' 1525 #ifndef _WINDOWS 1526 source -= 1; 1527 #endif 1528 } else if (strncmp(source, "jrt:/", 5) == 0) { 1529 source += 5; 1530 } 1531 return source; 1532 } 1533 1534 // Record the shared classpath index and loader type for classes loaded 1535 // by the builtin loaders at dump time. 1536 void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream) { 1537 assert(DumpSharedSpaces, "sanity"); 1538 assert(stream != NULL, "sanity"); 1539 1540 if (ik->is_anonymous()) { 1541 // We do not archive anonymous classes. 1542 return; 1543 } 1544 1545 char* src = (char*)stream->source(); 1546 if (src == NULL) { 1547 if (ik->class_loader() == NULL) { 1548 // JFR classes 1549 ik->set_shared_classpath_index(0); 1550 ik->set_class_loader_type(ClassLoader::BOOT_LOADER); 1551 } 1552 return; 1553 } 1554 1555 assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build"); 1556 1557 ModuleEntry* module = ik->module(); 1558 int classpath_index = -1; 1559 ResourceMark rm; 1560 char* canonical_path = NEW_RESOURCE_ARRAY(char, JVM_MAXPATHLEN); 1561 1562 // save the path from the file: protocol or the module name from the jrt: protocol 1563 // if no protocol prefix is found, path is the same as stream->source() 1564 char* path = skip_uri_protocol(src); 1565 for (int i = 0; i < FileMapInfo::get_number_of_share_classpaths(); i++) { 1566 SharedClassPathEntry* ent = FileMapInfo::shared_classpath(i); 1567 if (get_canonical_path(ent->name(), canonical_path, JVM_MAXPATHLEN)) { 1568 // If the path (from the class stream srouce) is the same as the shared 1569 // class path, then we have a match. For classes from module image loaded by the 1570 // PlatformClassLoader, the stream->source() is not the name of the module image. 1571 // Need to look for 'jrt:' explicitly. 1572 if (strcmp(canonical_path, os::native_path((char*)path)) == 0 || 1573 (i == 0 && string_starts_with(src, "jrt:"))) { 1574 classpath_index = i; 1575 break; 1576 } 1577 } 1578 } 1579 if (classpath_index < 0) { 1580 // Shared classpath entry table only contains boot class path and -cp path. 1581 // No path entry found for this class. Must be a shared class loaded by the 1582 // user defined classloader. 1583 assert(ik->shared_classpath_index() < 0, "Sanity"); 1584 return; 1585 } 1586 1587 const char* const class_name = ik->name()->as_C_string(); 1588 const char* const file_name = file_name_for_class_name(class_name, 1589 ik->name()->utf8_length()); 1590 assert(file_name != NULL, "invariant"); 1591 Thread* THREAD = Thread::current(); 1592 ClassLoaderExt::Context context(class_name, file_name, CATCH); 1593 context.record_result(ik->name(), classpath_index, ik, THREAD); 1594 } 1595 #endif // INCLUDE_CDS 1596 1597 // Initialize the class loader's access to methods in libzip. Parse and 1598 // process the boot classpath into a list ClassPathEntry objects. Once 1599 // this list has been created, it must not change order (see class PackageInfo) 1600 // it can be appended to and is by jvmti and the kernel vm. 1601 1602 void ClassLoader::initialize() { 1603 EXCEPTION_MARK; 1604 1605 if (UsePerfData) { 1606 // jvmstat performance counters 1607 NEWPERFTICKCOUNTER(_perf_accumulated_time, SUN_CLS, "time"); 1608 NEWPERFTICKCOUNTER(_perf_class_init_time, SUN_CLS, "classInitTime"); 1609 NEWPERFTICKCOUNTER(_perf_class_init_selftime, SUN_CLS, "classInitTime.self"); 1610 NEWPERFTICKCOUNTER(_perf_class_verify_time, SUN_CLS, "classVerifyTime"); 1611 NEWPERFTICKCOUNTER(_perf_class_verify_selftime, SUN_CLS, "classVerifyTime.self"); 1654 } 1655 1656 // lookup zip library entry points 1657 load_zip_library(); 1658 // lookup jimage library entry points 1659 load_jimage_library(); 1660 #if INCLUDE_CDS 1661 // initialize search path 1662 if (DumpSharedSpaces) { 1663 _shared_paths_misc_info = SharedClassUtil::allocate_shared_paths_misc_info(); 1664 } 1665 #endif 1666 setup_bootstrap_search_path(); 1667 } 1668 1669 #if INCLUDE_CDS 1670 void ClassLoader::initialize_shared_path() { 1671 if (DumpSharedSpaces) { 1672 ClassLoaderExt::setup_search_paths(); 1673 _shared_paths_misc_info->write_jint(0); // see comments in SharedPathsMiscInfo::check() 1674 } 1675 } 1676 #endif 1677 1678 jlong ClassLoader::classloader_time_ms() { 1679 return UsePerfData ? 1680 Management::ticks_to_ms(_perf_accumulated_time->get_value()) : -1; 1681 } 1682 1683 jlong ClassLoader::class_init_count() { 1684 return UsePerfData ? _perf_classes_inited->get_value() : -1; 1685 } 1686 1687 jlong ClassLoader::class_init_time_ms() { 1688 return UsePerfData ? 1689 Management::ticks_to_ms(_perf_class_init_time->get_value()) : -1; 1690 } 1691 1692 jlong ClassLoader::class_verify_time_ms() { 1693 return UsePerfData ? | 131 PerfCounter* ClassLoader::_perf_define_appclass_time = NULL; 132 PerfCounter* ClassLoader::_perf_define_appclass_selftime = NULL; 133 PerfCounter* ClassLoader::_perf_app_classfile_bytes_read = NULL; 134 PerfCounter* ClassLoader::_perf_sys_classfile_bytes_read = NULL; 135 PerfCounter* ClassLoader::_sync_systemLoaderLockContentionRate = NULL; 136 PerfCounter* ClassLoader::_sync_nonSystemLoaderLockContentionRate = NULL; 137 PerfCounter* ClassLoader::_sync_JVMFindLoadedClassLockFreeCounter = NULL; 138 PerfCounter* ClassLoader::_sync_JVMDefineClassLockFreeCounter = NULL; 139 PerfCounter* ClassLoader::_sync_JNIDefineClassLockFreeCounter = NULL; 140 PerfCounter* ClassLoader::_unsafe_defineClassCallCounter = NULL; 141 PerfCounter* ClassLoader::_load_instance_class_failCounter = NULL; 142 143 GrowableArray<ModuleClassPathList*>* ClassLoader::_patch_mod_entries = NULL; 144 GrowableArray<ModuleClassPathList*>* ClassLoader::_exploded_entries = NULL; 145 ClassPathEntry* ClassLoader::_jrt_entry = NULL; 146 ClassPathEntry* ClassLoader::_first_append_entry = NULL; 147 ClassPathEntry* ClassLoader::_last_append_entry = NULL; 148 #if INCLUDE_CDS 149 ClassPathEntry* ClassLoader::_app_classpath_entries = NULL; 150 ClassPathEntry* ClassLoader::_last_app_classpath_entry = NULL; 151 ClassPathEntry* ClassLoader::_module_path_entries = NULL; 152 ClassPathEntry* ClassLoader::_last_module_path_entry = NULL; 153 SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL; 154 #endif 155 156 // helper routines 157 bool string_starts_with(const char* str, const char* str_to_find) { 158 size_t str_len = strlen(str); 159 size_t str_to_find_len = strlen(str_to_find); 160 if (str_to_find_len > str_len) { 161 return false; 162 } 163 return (strncmp(str, str_to_find, str_to_find_len) == 0); 164 } 165 166 static const char* get_jimage_version_string() { 167 static char version_string[10] = ""; 168 if (version_string[0] == '\0') { 169 jio_snprintf(version_string, sizeof(version_string), "%d.%d", 170 Abstract_VM_Version::vm_major_version(), Abstract_VM_Version::vm_minor_version()); 171 } 172 return (const char*)version_string; 706 for (int start = 0; start < len; start = end) { 707 while (class_path[end] && class_path[end] != os::path_separator()[0]) { 708 end++; 709 } 710 EXCEPTION_MARK; 711 ResourceMark rm(THREAD); 712 char* path = NEW_RESOURCE_ARRAY(char, end - start + 1); 713 strncpy(path, &class_path[start], end - start); 714 path[end - start] = '\0'; 715 716 check_shared_classpath(path); 717 718 update_class_path_entry_list(path, false, false); 719 720 while (class_path[end] == os::path_separator()[0]) { 721 end++; 722 } 723 } 724 } 725 726 void ClassLoader::setup_module_search_path(const char* path) { 727 check_shared_classpath(path); 728 update_module_path_entry_list(path); 729 } 730 731 #endif 732 733 // Construct the array of module/path pairs as specified to --patch-module 734 // for the boot loader to search ahead of the jimage, if the class being 735 // loaded is defined to a module that has been specified to --patch-module. 736 void ClassLoader::setup_patch_mod_entries() { 737 Thread* THREAD = Thread::current(); 738 GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix(); 739 int num_of_entries = patch_mod_args->length(); 740 741 742 // Set up the boot loader's _patch_mod_entries list 743 _patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true); 744 745 for (int i = 0; i < num_of_entries; i++) { 746 const char* module_name = (patch_mod_args->at(i))->module_name(); 747 Symbol* const module_sym = SymbolTable::lookup(module_name, (int)strlen(module_name), CHECK); 748 assert(module_sym != NULL, "Failed to obtain Symbol for module name"); 749 ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym); 750 1078 } 1079 1080 // Do not reorder the bootclasspath which would break get_system_package(). 1081 // Add new entry to linked list 1082 if (is_boot_append) { 1083 add_to_boot_append_entries(new_entry); 1084 } else { 1085 add_to_app_classpath_entries(path, new_entry, check_for_duplicates); 1086 } 1087 return true; 1088 } else { 1089 #if INCLUDE_CDS 1090 if (DumpSharedSpaces) { 1091 _shared_paths_misc_info->add_nonexist_path(path); 1092 } 1093 #endif 1094 return false; 1095 } 1096 } 1097 1098 #if INCLUDE_CDS 1099 void ClassLoader::add_to_module_path_entries(const char* path, 1100 ClassPathEntry* entry) { 1101 assert(entry != NULL, "ClassPathEntry should not be NULL"); 1102 ClassPathEntry* e = _module_path_entries; 1103 1104 // The entry does not exist, add to the list 1105 if (_module_path_entries == NULL) { 1106 assert(_last_module_path_entry == NULL, "Sanity"); 1107 _module_path_entries = _last_module_path_entry = entry; 1108 } else { 1109 _last_module_path_entry->set_next(entry); 1110 _last_module_path_entry = entry; 1111 } 1112 } 1113 1114 // Add a module path to the _module_path_entries list. 1115 void ClassLoader::update_module_path_entry_list(const char *path, 1116 bool throw_exception) { 1117 struct stat st; 1118 assert(os::stat(path, &st) == 0, "module path must exist"); 1119 // File or directory found 1120 ClassPathEntry* new_entry = NULL; 1121 Thread* THREAD = Thread::current(); 1122 new_entry = create_class_path_entry(path, &st, throw_exception, 1123 false /*is_boot_append */, CHECK); 1124 if (new_entry == NULL) { 1125 return; 1126 } 1127 1128 add_to_module_path_entries(path, new_entry); 1129 return; 1130 } 1131 #endif // INCLUDE_CDS 1132 1133 static void print_module_entry_table(const GrowableArray<ModuleClassPathList*>* const module_list) { 1134 ResourceMark rm; 1135 int num_of_entries = module_list->length(); 1136 for (int i = 0; i < num_of_entries; i++) { 1137 ClassPathEntry* e; 1138 ModuleClassPathList* mpl = module_list->at(i); 1139 tty->print("%s=", mpl->module_name()->as_C_string()); 1140 e = mpl->module_first_entry(); 1141 while (e != NULL) { 1142 tty->print("%s", e->name()); 1143 e = e->next(); 1144 if (e != NULL) { 1145 tty->print("%s", os::path_separator()); 1146 } 1147 } 1148 tty->print(" ;"); 1149 } 1150 } 1151 1152 void ClassLoader::print_bootclasspath() { 1537 loader_data, 1538 protection_domain, 1539 NULL, // host_klass 1540 NULL, // cp_patches 1541 THREAD); 1542 if (HAS_PENDING_EXCEPTION) { 1543 if (DumpSharedSpaces) { 1544 tty->print_cr("Preload Error: Failed to load %s", class_name); 1545 } 1546 return NULL; 1547 } 1548 1549 if (!add_package(file_name, classpath_index, THREAD)) { 1550 return NULL; 1551 } 1552 1553 return result; 1554 } 1555 1556 #if INCLUDE_CDS 1557 char* ClassLoader::skip_uri_protocol(char* source) { 1558 if (strncmp(source, "file:", 5) == 0) { 1559 // file: protocol path could start with file:/ or file:/// 1560 // locate the char after all the forward slashes 1561 int offset = 5; 1562 while (*(source + offset) == '/') { 1563 offset++; 1564 } 1565 source += offset; 1566 // for non-windows platforms, move back one char as the path begins with a '/' 1567 #ifndef _WINDOWS 1568 source -= 1; 1569 #endif 1570 } else if (strncmp(source, "jrt:/", 5) == 0) { 1571 source += 5; 1572 } 1573 return source; 1574 } 1575 1576 // Record the shared classpath index and loader type for classes loaded 1577 // by the builtin loaders at dump time. 1578 void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream) { 1579 assert(DumpSharedSpaces, "sanity"); 1580 assert(stream != NULL, "sanity"); 1581 1582 if (ik->is_anonymous()) { 1583 // We do not archive anonymous classes. 1584 return; 1585 } 1586 1587 oop loader = ik->class_loader(); 1588 char* src = (char*)stream->source(); 1589 if (src == NULL) { 1590 if (loader == NULL) { 1591 // JFR classes 1592 ik->set_shared_classpath_index(0); 1593 ik->set_class_loader_type(ClassLoader::BOOT_LOADER); 1594 } 1595 return; 1596 } 1597 1598 assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build"); 1599 1600 ResourceMark rm; 1601 Thread* THREAD = Thread::current(); 1602 int classpath_index = -1; 1603 PackageEntry* pkg_entry = ik->package(); 1604 1605 if (FileMapInfo::get_number_of_shared_paths() > 0) { 1606 char* canonical_path = NEW_RESOURCE_ARRAY(char, JVM_MAXPATHLEN); 1607 1608 // save the path from the file: protocol or the module name from the jrt: protocol 1609 // if no protocol prefix is found, path is the same as stream->source() 1610 char* path = skip_uri_protocol(src); 1611 for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) { 1612 SharedClassPathEntry* ent = FileMapInfo::shared_path(i); 1613 if (get_canonical_path(ent->name(), canonical_path, JVM_MAXPATHLEN)) { 1614 // If the path (from the class stream source) is the same as the shared 1615 // class or module path, then we have a match. 1616 if (strcmp(canonical_path, os::native_path((char*)path)) == 0) { 1617 // NULL pkg_entry and pkg_entry in an unnamed module implies the class 1618 // is from the -cp. Ensure the index is within the -cp range before assigning 1619 // to the classpath_index. 1620 if ((pkg_entry == NULL) || (pkg_entry->in_unnamed_module())) { 1621 if (SystemDictionary::is_system_class_loader(loader) && 1622 (i >= ClassLoaderExt::app_class_paths_start_index()) && 1623 (i < ClassLoaderExt::app_module_paths_start_index())) { 1624 classpath_index = i; 1625 break; 1626 } else { 1627 if ((i >= 1) && 1628 (i < ClassLoaderExt::app_module_paths_start_index())) { 1629 classpath_index = i; 1630 break; 1631 } 1632 } 1633 } else { 1634 // non-NULL pkg_entry and is a named module implies the class is from the 1635 // --module-path. Ensure the index is within the --module-path range before 1636 // assigning to the classpath_index. 1637 if ((pkg_entry != NULL) && !(pkg_entry->in_unnamed_module()) && (i > 0)) { 1638 if (i >= ClassLoaderExt::app_module_paths_start_index() && 1639 i < FileMapInfo::get_number_of_shared_paths()) { 1640 classpath_index = i; 1641 break; 1642 } 1643 } 1644 } 1645 } 1646 // for index 0 and the stream->source() is the modules image or has the jrt: protocol. 1647 // The class must be from the runtime modules image. 1648 if (i == 0 && (is_modules_image(src) || string_starts_with(src, "jrt:"))) { 1649 classpath_index = i; 1650 break; 1651 } 1652 } 1653 } 1654 1655 // No path entry found for this class. Must be a shared class loaded by the 1656 // user defined classloader. 1657 if (classpath_index < 0) { 1658 assert(ik->shared_classpath_index() < 0, "Sanity"); 1659 return; 1660 } 1661 } else { 1662 assert(is_modules_image(src), "stream must be from modules image"); 1663 assert(FileMapInfo::get_number_of_shared_paths() == 0, "shared path table must not have been setup"); 1664 classpath_index = 0; 1665 } 1666 1667 const char* const class_name = ik->name()->as_C_string(); 1668 const char* const file_name = file_name_for_class_name(class_name, 1669 ik->name()->utf8_length()); 1670 assert(file_name != NULL, "invariant"); 1671 1672 ClassLoaderExt::Context context(class_name, file_name, CATCH); 1673 context.record_result(ik->name(), classpath_index, ik, THREAD); 1674 } 1675 #endif // INCLUDE_CDS 1676 1677 // Initialize the class loader's access to methods in libzip. Parse and 1678 // process the boot classpath into a list ClassPathEntry objects. Once 1679 // this list has been created, it must not change order (see class PackageInfo) 1680 // it can be appended to and is by jvmti and the kernel vm. 1681 1682 void ClassLoader::initialize() { 1683 EXCEPTION_MARK; 1684 1685 if (UsePerfData) { 1686 // jvmstat performance counters 1687 NEWPERFTICKCOUNTER(_perf_accumulated_time, SUN_CLS, "time"); 1688 NEWPERFTICKCOUNTER(_perf_class_init_time, SUN_CLS, "classInitTime"); 1689 NEWPERFTICKCOUNTER(_perf_class_init_selftime, SUN_CLS, "classInitTime.self"); 1690 NEWPERFTICKCOUNTER(_perf_class_verify_time, SUN_CLS, "classVerifyTime"); 1691 NEWPERFTICKCOUNTER(_perf_class_verify_selftime, SUN_CLS, "classVerifyTime.self"); 1734 } 1735 1736 // lookup zip library entry points 1737 load_zip_library(); 1738 // lookup jimage library entry points 1739 load_jimage_library(); 1740 #if INCLUDE_CDS 1741 // initialize search path 1742 if (DumpSharedSpaces) { 1743 _shared_paths_misc_info = SharedClassUtil::allocate_shared_paths_misc_info(); 1744 } 1745 #endif 1746 setup_bootstrap_search_path(); 1747 } 1748 1749 #if INCLUDE_CDS 1750 void ClassLoader::initialize_shared_path() { 1751 if (DumpSharedSpaces) { 1752 ClassLoaderExt::setup_search_paths(); 1753 _shared_paths_misc_info->write_jint(0); // see comments in SharedPathsMiscInfo::check() 1754 } 1755 } 1756 1757 void ClassLoader::initialize_module_path() { 1758 if (DumpSharedSpaces) { 1759 ClassLoaderExt::setup_module_paths(); 1760 FileMapInfo::allocate_shared_path_table(); 1761 } 1762 } 1763 #endif 1764 1765 jlong ClassLoader::classloader_time_ms() { 1766 return UsePerfData ? 1767 Management::ticks_to_ms(_perf_accumulated_time->get_value()) : -1; 1768 } 1769 1770 jlong ClassLoader::class_init_count() { 1771 return UsePerfData ? _perf_classes_inited->get_value() : -1; 1772 } 1773 1774 jlong ClassLoader::class_init_time_ms() { 1775 return UsePerfData ? 1776 Management::ticks_to_ms(_perf_class_init_time->get_value()) : -1; 1777 } 1778 1779 jlong ClassLoader::class_verify_time_ms() { 1780 return UsePerfData ? |