428 assert(module != NULL, "Boot classLoader package missing module"); 429 assert(module->is_named(), "Boot classLoader package is in unnamed module"); 430 const char* module_name = module->name()->as_C_string(); 431 if (module_name != NULL) { 432 location = (*JImageFindResource)(_jimage, module_name, get_jimage_version_string(), name, &size); 433 } 434 } 435 } 436 } 437 } 438 if (location != 0) { 439 if (UsePerfData) { 440 ClassLoader::perf_sys_classfile_bytes_read()->inc(size); 441 } 442 char* data = NEW_RESOURCE_ARRAY(char, size); 443 (*JImageGetResource)(_jimage, location, data, size); 444 // Resource allocated 445 return new ClassFileStream((u1*)data, 446 (int)size, 447 _name, 448 ClassFileStream::verify); 449 } 450 451 return NULL; 452 } 453 454 JImageLocationRef ClassLoader::jimage_find_resource(JImageFile* jf, 455 const char* module_name, 456 const char* file_name, 457 jlong &size) { 458 return ((*JImageFindResource)(jf, module_name, get_jimage_version_string(), file_name, &size)); 459 } 460 461 bool ClassPathImageEntry::is_modules_image() const { 462 return ClassLoader::is_modules_image(name()); 463 } 464 465 #if INCLUDE_CDS 466 void ClassLoader::exit_with_path_failure(const char* error, const char* message) { 467 assert(DumpSharedSpaces, "only called at dump time"); 468 tty->print_cr("Hint: enable -Xlog:class+path=info to diagnose the failure"); 469 vm_exit_during_initialization(error, message); 470 } 471 #endif 472 473 ModuleClassPathList::ModuleClassPathList(Symbol* module_name) { 474 _module_name = module_name; 475 _module_first_entry = NULL; 476 _module_last_entry = NULL; 477 } 478 479 ModuleClassPathList::~ModuleClassPathList() { 480 // Clean out each ClassPathEntry on list 481 ClassPathEntry* e = _module_first_entry; 482 while (e != NULL) { 483 ClassPathEntry* next_entry = e->next(); 484 delete e; 1481 // -Xbootclasspath/a and jvmti appended entries. 1482 assert(loader == NULL, "sanity"); 1483 classpath_index = i; 1484 break; 1485 } 1486 } 1487 } else { 1488 // A class from a named module from the --module-path. Ensure the index is 1489 // within the --module-path range before assigning to the classpath_index. 1490 if ((pkg_entry != NULL) && !(pkg_entry->in_unnamed_module()) && (i > 0)) { 1491 if (i >= ClassLoaderExt::app_module_paths_start_index() && 1492 i < FileMapInfo::get_number_of_shared_paths()) { 1493 classpath_index = i; 1494 break; 1495 } 1496 } 1497 } 1498 } 1499 // for index 0 and the stream->source() is the modules image or has the jrt: protocol. 1500 // The class must be from the runtime modules image. 1501 if (i == 0 && (is_modules_image(src) || string_starts_with(src, "jrt:"))) { 1502 classpath_index = i; 1503 break; 1504 } 1505 } 1506 1507 // No path entry found for this class. Must be a shared class loaded by the 1508 // user defined classloader. 1509 if (classpath_index < 0) { 1510 assert(ik->shared_classpath_index() < 0, "Sanity"); 1511 return; 1512 } 1513 } else { 1514 // The shared path table is set up after module system initialization. 1515 // The path table contains no entry before that. Any classes loaded prior 1516 // to the setup of the shared path table must be from the modules image. 1517 assert(is_modules_image(src), "stream must be from modules image"); 1518 assert(FileMapInfo::get_number_of_shared_paths() == 0, "shared path table must not have been setup"); 1519 classpath_index = 0; 1520 } 1521 1522 const char* const class_name = ik->name()->as_C_string(); 1523 const char* const file_name = file_name_for_class_name(class_name, 1524 ik->name()->utf8_length()); 1525 assert(file_name != NULL, "invariant"); 1526 1527 ClassLoaderExt::record_result(classpath_index, ik, THREAD); 1528 } 1529 #endif // INCLUDE_CDS 1530 1531 // Initialize the class loader's access to methods in libzip. Parse and 1532 // process the boot classpath into a list ClassPathEntry objects. Once 1533 // this list has been created, it must not change order (see class PackageInfo) 1534 // it can be appended to and is by jvmti and the kernel vm. 1535 1536 void ClassLoader::initialize() { 1537 EXCEPTION_MARK; | 428 assert(module != NULL, "Boot classLoader package missing module"); 429 assert(module->is_named(), "Boot classLoader package is in unnamed module"); 430 const char* module_name = module->name()->as_C_string(); 431 if (module_name != NULL) { 432 location = (*JImageFindResource)(_jimage, module_name, get_jimage_version_string(), name, &size); 433 } 434 } 435 } 436 } 437 } 438 if (location != 0) { 439 if (UsePerfData) { 440 ClassLoader::perf_sys_classfile_bytes_read()->inc(size); 441 } 442 char* data = NEW_RESOURCE_ARRAY(char, size); 443 (*JImageGetResource)(_jimage, location, data, size); 444 // Resource allocated 445 return new ClassFileStream((u1*)data, 446 (int)size, 447 _name, 448 ClassFileStream::verify, 449 true); // from_modules_image 450 } 451 452 return NULL; 453 } 454 455 JImageLocationRef ClassLoader::jimage_find_resource(JImageFile* jf, 456 const char* module_name, 457 const char* file_name, 458 jlong &size) { 459 return ((*JImageFindResource)(jf, module_name, get_jimage_version_string(), file_name, &size)); 460 } 461 462 #if INCLUDE_CDS 463 void ClassLoader::exit_with_path_failure(const char* error, const char* message) { 464 assert(DumpSharedSpaces, "only called at dump time"); 465 tty->print_cr("Hint: enable -Xlog:class+path=info to diagnose the failure"); 466 vm_exit_during_initialization(error, message); 467 } 468 #endif 469 470 ModuleClassPathList::ModuleClassPathList(Symbol* module_name) { 471 _module_name = module_name; 472 _module_first_entry = NULL; 473 _module_last_entry = NULL; 474 } 475 476 ModuleClassPathList::~ModuleClassPathList() { 477 // Clean out each ClassPathEntry on list 478 ClassPathEntry* e = _module_first_entry; 479 while (e != NULL) { 480 ClassPathEntry* next_entry = e->next(); 481 delete e; 1478 // -Xbootclasspath/a and jvmti appended entries. 1479 assert(loader == NULL, "sanity"); 1480 classpath_index = i; 1481 break; 1482 } 1483 } 1484 } else { 1485 // A class from a named module from the --module-path. Ensure the index is 1486 // within the --module-path range before assigning to the classpath_index. 1487 if ((pkg_entry != NULL) && !(pkg_entry->in_unnamed_module()) && (i > 0)) { 1488 if (i >= ClassLoaderExt::app_module_paths_start_index() && 1489 i < FileMapInfo::get_number_of_shared_paths()) { 1490 classpath_index = i; 1491 break; 1492 } 1493 } 1494 } 1495 } 1496 // for index 0 and the stream->source() is the modules image or has the jrt: protocol. 1497 // The class must be from the runtime modules image. 1498 if (i == 0 && (stream->from_modules_image() || string_starts_with(src, "jrt:"))) { 1499 classpath_index = i; 1500 break; 1501 } 1502 } 1503 1504 // No path entry found for this class. Must be a shared class loaded by the 1505 // user defined classloader. 1506 if (classpath_index < 0) { 1507 assert(ik->shared_classpath_index() < 0, "Sanity"); 1508 return; 1509 } 1510 } else { 1511 // The shared path table is set up after module system initialization. 1512 // The path table contains no entry before that. Any classes loaded prior 1513 // to the setup of the shared path table must be from the modules image. 1514 assert(stream->from_modules_image(), "stream must be from modules image"); 1515 assert(FileMapInfo::get_number_of_shared_paths() == 0, "shared path table must not have been setup"); 1516 classpath_index = 0; 1517 } 1518 1519 const char* const class_name = ik->name()->as_C_string(); 1520 const char* const file_name = file_name_for_class_name(class_name, 1521 ik->name()->utf8_length()); 1522 assert(file_name != NULL, "invariant"); 1523 1524 ClassLoaderExt::record_result(classpath_index, ik, THREAD); 1525 } 1526 #endif // INCLUDE_CDS 1527 1528 // Initialize the class loader's access to methods in libzip. Parse and 1529 // process the boot classpath into a list ClassPathEntry objects. Once 1530 // this list has been created, it must not change order (see class PackageInfo) 1531 // it can be appended to and is by jvmti and the kernel vm. 1532 1533 void ClassLoader::initialize() { 1534 EXCEPTION_MARK; |