< prev index next >

src/hotspot/share/memory/filemap.cpp

Print this page

*** 238,248 **** // invoked with. // JVM version string ... changes on each build. get_header_version(_jvm_ident); - ClassLoaderExt::finalize_shared_paths_misc_info(); _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index(); _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index(); _num_module_paths = ClassLoader::num_module_path_entries(); _max_used_path_index = ClassLoaderExt::max_used_path_index(); --- 238,247 ----
*** 285,314 **** // If we can't access a jar file in the boot path, then we can't // make assumptions about where classes get loaded from. FileMapInfo::fail_stop("Unable to open file %s.", cpe->name()); } ! size_t len = strlen(cpe->name()) + 1; _name = MetadataFactory::new_array<char>(ClassLoaderData::the_null_class_loader_data(), (int)len, THREAD); ! strcpy(_name->data(), cpe->name()); } ! bool SharedClassPathEntry::validate(bool is_class_path) { ! assert(UseSharedSpaces, "runtime only"); ! ! struct stat st; ! const char* name; ! // In order to validate the runtime modules image file size against the archived // size information, we need to obtain the runtime modules image path. The recorded // dump time modules image path in the archive may be different from the runtime path // if the JDK image has beed moved after generating the archive. ! if (is_modules_image()) { ! name = ClassLoader::get_jrt_entry()->name(); } else { ! name = this->name(); } bool ok = true; log_info(class, path)("checking shared classpath entry: %s", name); if (os::stat(name, &st) != 0 && is_class_path) { // If the archived module path entry does not exist at runtime, it is not fatal --- 284,318 ---- // If we can't access a jar file in the boot path, then we can't // make assumptions about where classes get loaded from. FileMapInfo::fail_stop("Unable to open file %s.", cpe->name()); } ! // No need to save the name of the module file, as it will be computed at run time ! // to allow relocation of the JDK directory. ! const char* name = is_modules_image ? "" : cpe->name(); ! size_t len = strlen(name) + 1; _name = MetadataFactory::new_array<char>(ClassLoaderData::the_null_class_loader_data(), (int)len, THREAD); ! strcpy(_name->data(), name); } ! const char* SharedClassPathEntry::name() const { ! if (UseSharedSpaces && is_modules_image()) { // In order to validate the runtime modules image file size against the archived // size information, we need to obtain the runtime modules image path. The recorded // dump time modules image path in the archive may be different from the runtime path // if the JDK image has beed moved after generating the archive. ! return ClassLoader::get_jrt_entry()->name(); } else { ! return _name->data(); } + } + + bool SharedClassPathEntry::validate(bool is_class_path) { + assert(UseSharedSpaces, "runtime only"); + + struct stat st; + const char* name = this->name(); bool ok = true; log_info(class, path)("checking shared classpath entry: %s", name); if (os::stat(name, &st) != 0 && is_class_path) { // If the archived module path entry does not exist at runtime, it is not fatal
*** 412,422 **** } // 3. module path ClassPathEntry *mpe = ClassLoader::module_path_entries(); while (mpe != NULL) { ! log_info(class, path)("add module path %s",mpe->name()); SharedClassPathEntry* ent = shared_path(i); ent->init(false, mpe, THREAD); EXCEPTION_MARK; update_shared_classpath(mpe, ent, THREAD); mpe = mpe->next(); --- 416,426 ---- } // 3. module path ClassPathEntry *mpe = ClassLoader::module_path_entries(); while (mpe != NULL) { ! log_info(class, path)("add module path %s", mpe->name()); SharedClassPathEntry* ent = shared_path(i); ent->init(false, mpe, THREAD); EXCEPTION_MARK; update_shared_classpath(mpe, ent, THREAD); mpe = mpe->next();
*** 702,711 **** --- 706,729 ---- } } return true; } + void FileMapInfo::log_paths(const char* msg, int start_idx, int end_idx) { + LogTarget(Info, class, path) lt; + if (lt.is_enabled()) { + LogStream ls(lt); + ls.print("%s", msg); + const char* prefix = ""; + for (int i = start_idx; i < end_idx; i++) { + ls.print("%s%s", prefix, shared_path(i)->name()); + prefix = os::path_separator(); + } + ls.cr(); + } + } + bool FileMapInfo::validate_shared_path_table() { assert(UseSharedSpaces, "runtime only"); _validating_shared_path_table = true;
*** 730,739 **** --- 748,760 ---- warning( "Dynamic archiving is disabled because base layer archive has module path"); } } + log_paths("Expecting BOOT path=", 0, _header->_app_class_paths_start_index); + log_paths("Expecting -Djava.class.path=", _header->_app_class_paths_start_index, _header->_app_module_paths_start_index); + int module_paths_start_index = _header->_app_module_paths_start_index; int shared_app_paths_len = 0; // validate the path entries up to the _max_used_path_index for (int i=0; i < _header->_max_used_path_index + 1; i++) {
*** 853,865 **** return false; } if (dynamic_header->_base_archive_is_default) { *base_archive_name = Arguments::get_default_shared_archive_path(); } else { - // skip over the _paths_misc_info - sz = dynamic_header->_paths_misc_info_size; - lseek(fd, (long)sz, SEEK_CUR); // read the base archive name size_t name_size = dynamic_header->_base_archive_name_size; if (name_size == 0) { os::free(dynamic_header); os::close(fd); --- 874,883 ----
*** 946,967 **** FileMapInfo::fail_continue("Header checksum verification failed."); return false; } } ! _file_offset = n; ! ! size_t info_size = _header->_paths_misc_info_size; ! _paths_misc_info = NEW_C_HEAP_ARRAY(char, info_size, mtClass); ! n = os::read(fd, _paths_misc_info, (unsigned int)info_size); ! if (n != info_size) { ! fail_continue("Unable to read the shared path info header."); ! FREE_C_HEAP_ARRAY(char, _paths_misc_info); ! _paths_misc_info = NULL; ! return false; ! } ! _file_offset += n + _header->_base_archive_name_size; // accounts for the size of _base_archive_name if (is_static) { // just checking the last region is sufficient since the archive is written // in sequential order size_t len = lseek(fd, 0, SEEK_END); --- 964,974 ---- FileMapInfo::fail_continue("Header checksum verification failed."); return false; } } ! _file_offset = n + _header->_base_archive_name_size; // accounts for the size of _base_archive_name if (is_static) { // just checking the last region is sufficient since the archive is written // in sequential order size_t len = lseek(fd, 0, SEEK_END);
*** 1039,1062 **** // Write the header to the file, seek to the next allocation boundary. void FileMapInfo::write_header() { - int info_size = ClassLoader::get_shared_paths_misc_info_size(); - - _header->_paths_misc_info_size = info_size; - char* base_archive_name = NULL; if (_header->_magic == CDS_DYNAMIC_ARCHIVE_MAGIC) { base_archive_name = (char*)Arguments::GetSharedArchivePath(); _header->_base_archive_name_size = (int)strlen(base_archive_name) + 1; _header->_base_archive_is_default = FLAG_IS_DEFAULT(SharedArchiveFile); } assert(is_file_position_aligned(), "must be"); write_bytes(_header, _header->_header_size); - write_bytes(ClassLoader::get_shared_paths_misc_info(), (size_t)info_size); if (base_archive_name != NULL) { write_bytes(base_archive_name, (size_t)_header->_base_archive_name_size); } align_file_position(); } --- 1046,1064 ----
*** 1749,1759 **** // fails, shared spaces are disabled and the file is closed. [See // fail_continue.] // // Validation of the archive is done in two steps: // ! // [1] validate_header() - done here. This checks the header, including _paths_misc_info. // [2] validate_shared_path_table - this is done later, because the table is in the RW // region of the archive, which is not mapped yet. bool FileMapInfo::initialize(bool is_static) { assert(UseSharedSpaces, "UseSharedSpaces expected."); --- 1751,1761 ---- // fails, shared spaces are disabled and the file is closed. [See // fail_continue.] // // Validation of the archive is done in two steps: // ! // [1] validate_header() - done here. // [2] validate_shared_path_table - this is done later, because the table is in the RW // region of the archive, which is not mapped yet. bool FileMapInfo::initialize(bool is_static) { assert(UseSharedSpaces, "UseSharedSpaces expected.");
*** 1853,1878 **** return true; } bool FileMapInfo::validate_header(bool is_static) { ! bool status = _header->validate(); ! ! if (status) { ! if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size, is_static)) { ! if (!PrintSharedArchiveAndExit) { ! fail_continue("shared class paths mismatch (hint: enable -Xlog:class+path=info to diagnose the failure)"); ! status = false; ! } ! } ! } ! ! if (_paths_misc_info != NULL) { ! FREE_C_HEAP_ARRAY(char, _paths_misc_info); ! _paths_misc_info = NULL; ! } ! return status; } // Check if a given address is within one of the shared regions bool FileMapInfo::is_in_shared_region(const void* p, int idx) { assert(idx == MetaspaceShared::ro || --- 1855,1865 ---- return true; } bool FileMapInfo::validate_header(bool is_static) { ! return _header->validate(); } // Check if a given address is within one of the shared regions bool FileMapInfo::is_in_shared_region(const void* p, int idx) { assert(idx == MetaspaceShared::ro ||
*** 1920,1930 **** ClassPathEntry* FileMapInfo::get_classpath_entry_for_jvmti(int i, TRAPS) { ClassPathEntry* ent = _classpath_entries_for_jvmti[i]; if (ent == NULL) { if (i == 0) { ! ent = ClassLoader:: get_jrt_entry(); assert(ent != NULL, "must be"); } else { SharedClassPathEntry* scpe = shared_path(i); assert(scpe->is_jar(), "must be"); // other types of scpe will not produce archived classes --- 1907,1917 ---- ClassPathEntry* FileMapInfo::get_classpath_entry_for_jvmti(int i, TRAPS) { ClassPathEntry* ent = _classpath_entries_for_jvmti[i]; if (ent == NULL) { if (i == 0) { ! ent = ClassLoader::get_jrt_entry(); assert(ent != NULL, "must be"); } else { SharedClassPathEntry* scpe = shared_path(i); assert(scpe->is_jar(), "must be"); // other types of scpe will not produce archived classes
< prev index next >