1540 } 1541 1542 oop loader = ik->class_loader(); 1543 char* src = (char*)stream->source(); 1544 if (src == NULL) { 1545 if (loader == NULL) { 1546 // JFR classes 1547 ik->set_shared_classpath_index(0); 1548 ik->set_class_loader_type(ClassLoader::BOOT_LOADER); 1549 } 1550 return; 1551 } 1552 1553 assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build"); 1554 1555 ResourceMark rm(THREAD); 1556 int classpath_index = -1; 1557 PackageEntry* pkg_entry = ik->package(); 1558 1559 if (FileMapInfo::get_number_of_shared_paths() > 0) { 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_shared_paths(); i++) { 1566 SharedClassPathEntry* ent = FileMapInfo::shared_path(i); 1567 if (get_canonical_path(ent->name(), canonical_path, JVM_MAXPATHLEN)) { 1568 // If the path (from the class stream source) is the same as the shared 1569 // class or module path, then we have a match. 1570 if (strcmp(canonical_path, os::native_path((char*)path)) == 0) { 1571 // NULL pkg_entry and pkg_entry in an unnamed module implies the class 1572 // is from the -cp or boot loader append path which consists of -Xbootclasspath/a 1573 // and jvmti appended entries. 1574 if ((pkg_entry == NULL) || (pkg_entry->in_unnamed_module())) { 1575 // Ensure the index is within the -cp range before assigning 1576 // to the classpath_index. 1577 if (SystemDictionary::is_system_class_loader(loader) && 1578 (i >= ClassLoaderExt::app_class_paths_start_index()) && 1579 (i < ClassLoaderExt::app_module_paths_start_index())) { 1580 classpath_index = i; 1581 break; 1582 } else { 1583 if ((i >= 1) && 1584 (i < ClassLoaderExt::app_class_paths_start_index())) { 1585 // The class must be from boot loader append path which consists of 1586 // -Xbootclasspath/a and jvmti appended entries. 1587 assert(loader == NULL, "sanity"); 1588 classpath_index = i; 1589 break; 1590 } | 1540 } 1541 1542 oop loader = ik->class_loader(); 1543 char* src = (char*)stream->source(); 1544 if (src == NULL) { 1545 if (loader == NULL) { 1546 // JFR classes 1547 ik->set_shared_classpath_index(0); 1548 ik->set_class_loader_type(ClassLoader::BOOT_LOADER); 1549 } 1550 return; 1551 } 1552 1553 assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build"); 1554 1555 ResourceMark rm(THREAD); 1556 int classpath_index = -1; 1557 PackageEntry* pkg_entry = ik->package(); 1558 1559 if (FileMapInfo::get_number_of_shared_paths() > 0) { 1560 char* canonical_path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, 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 char* canonical_src_path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN); 1566 for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) { 1567 SharedClassPathEntry* ent = FileMapInfo::shared_path(i); 1568 if (get_canonical_path(ent->name(), canonical_path, JVM_MAXPATHLEN) && 1569 get_canonical_path(path, canonical_src_path, JVM_MAXPATHLEN)) { 1570 // If the path (from the class stream source) is the same as the shared 1571 // class or module path, then we have a match. 1572 if (strcmp(canonical_path, canonical_src_path) == 0) { 1573 // NULL pkg_entry and pkg_entry in an unnamed module implies the class 1574 // is from the -cp or boot loader append path which consists of -Xbootclasspath/a 1575 // and jvmti appended entries. 1576 if ((pkg_entry == NULL) || (pkg_entry->in_unnamed_module())) { 1577 // Ensure the index is within the -cp range before assigning 1578 // to the classpath_index. 1579 if (SystemDictionary::is_system_class_loader(loader) && 1580 (i >= ClassLoaderExt::app_class_paths_start_index()) && 1581 (i < ClassLoaderExt::app_module_paths_start_index())) { 1582 classpath_index = i; 1583 break; 1584 } else { 1585 if ((i >= 1) && 1586 (i < ClassLoaderExt::app_class_paths_start_index())) { 1587 // The class must be from boot loader append path which consists of 1588 // -Xbootclasspath/a and jvmti appended entries. 1589 assert(loader == NULL, "sanity"); 1590 classpath_index = i; 1591 break; 1592 } |