open Sdiff src/hotspot/share/classfile (original) (raw)


1454 // JFR classes 1455 ik->set_shared_classpath_index(0); 1456 ik->set_class_loader_type(ClassLoader::BOOT_LOADER); 1457 } 1458 return; 1459 } 1460 1461 assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build"); 1462 1463 ResourceMark rm(THREAD); 1464 int classpath_index = -1; 1465 PackageEntry* pkg_entry = ik->package(); 1466 1467 if (FileMapInfo::get_number_of_shared_paths() > 0) { 1468 char* canonical_path_table_entry = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN); 1469 1470 // save the path from the file: protocol or the module name from the jrt: protocol 1471 // if no protocol prefix is found, path is the same as stream->source() 1472 char* path = skip_uri_protocol(src); 1473 char* canonical_class_src_path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN); 1474 if (!get_canonical_path(path, canonical_class_src_path, JVM_MAXPATHLEN)) { 1475 tty->print_cr("Bad pathname %s. CDS dump aborted.", path); 1476 vm_exit(1); 1477 } 1478 for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) { 1479 SharedClassPathEntry* ent = FileMapInfo::shared_path(i); 1480 if (!get_canonical_path(ent->name(), canonical_path_table_entry, JVM_MAXPATHLEN)) { 1481 tty->print_cr("Bad pathname %s. CDS dump aborted.", ent->name()); 1482 vm_exit(1); 1483 } 1484 // If the path (from the class stream source) is the same as the shared 1485 // class or module path, then we have a match. 1486 if (strcmp(canonical_path_table_entry, canonical_class_src_path) == 0) { 1487 // NULL pkg_entry and pkg_entry in an unnamed module implies the class 1488 // is from the -cp or boot loader append path which consists of -Xbootclasspath/a 1489 // and jvmti appended entries. 1490 if ((pkg_entry == NULL) || (pkg_entry->in_unnamed_module())) { 1491 // Ensure the index is within the -cp range before assigning 1492 // to the classpath_index. 1493 if (SystemDictionary::is_system_class_loader(loader) && 1494 (i >= ClassLoaderExt::app_class_paths_start_index()) && 1495 (i < ClassLoaderExt::app_module_paths_start_index())) { 1496 classpath_index = i; 1497 break; 1498 } else { 1499 if ((i >= 1) && 1500 (i < ClassLoaderExt::app_class_paths_start_index())) { 1501 // The class must be from boot loader append path which consists of 1502 // -Xbootclasspath/a and jvmti appended entries. 1503 assert(loader == NULL, "sanity");



1454 // JFR classes 1455 ik->set_shared_classpath_index(0); 1456 ik->set_class_loader_type(ClassLoader::BOOT_LOADER); 1457 } 1458 return; 1459 } 1460 1461 assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build"); 1462 1463 ResourceMark rm(THREAD); 1464 int classpath_index = -1; 1465 PackageEntry* pkg_entry = ik->package(); 1466 1467 if (FileMapInfo::get_number_of_shared_paths() > 0) { 1468 char* canonical_path_table_entry = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN); 1469 1470 // save the path from the file: protocol or the module name from the jrt: protocol 1471 // if no protocol prefix is found, path is the same as stream->source() 1472 char* path = skip_uri_protocol(src); 1473 char* canonical_class_src_path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN); 1474 bool success = get_canonical_path(path, canonical_class_src_path, JVM_MAXPATHLEN); 1475 // The path is from the ClassFileStream. Since a ClassFileStream has been created successfully in functions 1476 // such as ClassLoader::load_class(), its source path must be valid. 1477 assert(success, "must be valid path"); 1478 for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) { 1479 SharedClassPathEntry* ent = FileMapInfo::shared_path(i); 1480 success = get_canonical_path(ent->name(), canonical_path_table_entry, JVM_MAXPATHLEN); 1481 // A shared path has been validated during its creation in ClassLoader::create_class_path_entry(), 1482 // it must be valid here. 1483 assert(success, "must be valid path"); 1484 // If the path (from the class stream source) is the same as the shared 1485 // class or module path, then we have a match. 1486 if (strcmp(canonical_path_table_entry, canonical_class_src_path) == 0) { 1487 // NULL pkg_entry and pkg_entry in an unnamed module implies the class 1488 // is from the -cp or boot loader append path which consists of -Xbootclasspath/a 1489 // and jvmti appended entries. 1490 if ((pkg_entry == NULL) || (pkg_entry->in_unnamed_module())) { 1491 // Ensure the index is within the -cp range before assigning 1492 // to the classpath_index. 1493 if (SystemDictionary::is_system_class_loader(loader) && 1494 (i >= ClassLoaderExt::app_class_paths_start_index()) && 1495 (i < ClassLoaderExt::app_module_paths_start_index())) { 1496 classpath_index = i; 1497 break; 1498 } else { 1499 if ((i >= 1) && 1500 (i < ClassLoaderExt::app_class_paths_start_index())) { 1501 // The class must be from boot loader append path which consists of 1502 // -Xbootclasspath/a and jvmti appended entries. 1503 assert(loader == NULL, "sanity");