< prev index next >

src/hotspot/share/cds/filemap.cpp

Print this page

  70 #include "runtime/mutexLocker.hpp"
  71 #include "runtime/os.hpp"
  72 #include "runtime/vm_version.hpp"
  73 #include "utilities/align.hpp"
  74 #include "utilities/bitMap.inline.hpp"
  75 #include "utilities/classpathStream.hpp"
  76 #include "utilities/defaultStream.hpp"
  77 #include "utilities/ostream.hpp"
  78 #if INCLUDE_G1GC
  79 #include "gc/g1/g1CollectedHeap.hpp"
  80 #include "gc/g1/g1HeapRegion.hpp"
  81 #endif
  82 
  83 #include <errno.h>
  84 #include <sys/stat.h>
  85 
  86 #ifndef O_BINARY       // if defined (Win32) use binary files.
  87 #define O_BINARY 0     // otherwise do nothing.
  88 #endif
  89 

































































  90 // Fill in the fileMapInfo structure with data about this VM instance.
  91 
  92 // This method copies the vm version info into header_version.  If the version is too
  93 // long then a truncated version, which has a hash code appended to it, is copied.
  94 //
  95 // Using a template enables this method to verify that header_version is an array of
  96 // length JVM_IDENT_MAX.  This ensures that the code that writes to the CDS file and
  97 // the code that reads the CDS file will both use the same size buffer.  Hence, will
  98 // use identical truncation.  This is necessary for matching of truncated versions.
  99 template <int N> static void get_header_version(char (&header_version) [N]) {
 100   assert(N == JVM_IDENT_MAX, "Bad header_version size");
 101 
 102   const char *vm_version = VM_Version::internal_vm_info_string();
 103   const int version_len = (int)strlen(vm_version);
 104 
 105   memset(header_version, 0, JVM_IDENT_MAX);
 106 
 107   if (version_len < (JVM_IDENT_MAX-1)) {
 108     strcpy(header_version, vm_version);
 109 

 228     _narrow_klass_pointer_bits = CompressedKlassPointers::narrow_klass_pointer_bits();
 229     _narrow_klass_shift = ArchiveBuilder::precomputed_narrow_klass_shift();
 230 #endif
 231   } else {
 232     _narrow_klass_pointer_bits = _narrow_klass_shift = -1;
 233   }
 234   // Which JIT compier is used
 235   _compiler_type = (u1)CompilerConfig::compiler_type();
 236   _type_profile_level = TypeProfileLevel;
 237   _type_profile_args_limit = TypeProfileArgsLimit;
 238   _type_profile_parms_limit = TypeProfileParmsLimit;
 239   _type_profile_width = TypeProfileWidth;
 240   _bci_profile_width = BciProfileWidth;
 241   _profile_traps = ProfileTraps;
 242   _type_profile_casts = TypeProfileCasts;
 243   _spec_trap_limit_extra_entries = SpecTrapLimitExtraEntries;
 244   _max_heap_size = MaxHeapSize;
 245   _use_optimized_module_handling = CDSConfig::is_using_optimized_module_handling();
 246   _has_aot_linked_classes = CDSConfig::is_dumping_aot_linked_classes();
 247   _has_full_module_graph = CDSConfig::is_dumping_full_module_graph();

 248 
 249   // The following fields are for sanity checks for whether this archive
 250   // will function correctly with this JVM and the bootclasspath it's
 251   // invoked with.
 252 
 253   // JVM version string ... changes on each build.
 254   get_header_version(_jvm_ident);
 255 
 256   _verify_local = BytecodeVerificationLocal;
 257   _verify_remote = BytecodeVerificationRemote;
 258   _has_platform_or_app_classes = AOTClassLocationConfig::dumptime()->has_platform_or_app_classes();
 259   _requested_base_address = (char*)SharedBaseAddress;
 260   _mapped_base_address = (char*)SharedBaseAddress;

 261 }
 262 
 263 void FileMapHeader::copy_base_archive_name(const char* archive) {
 264   assert(base_archive_name_size() != 0, "_base_archive_name_size not set");
 265   assert(base_archive_name_offset() != 0, "_base_archive_name_offset not set");
 266   assert(header_size() > sizeof(*this), "_base_archive_name_size not included in header size?");
 267   memcpy((char*)this + base_archive_name_offset(), archive, base_archive_name_size());
 268 }
 269 
 270 void FileMapHeader::print(outputStream* st) {
 271   ResourceMark rm;
 272 
 273   st->print_cr("- magic:                          0x%08x", magic());
 274   st->print_cr("- crc:                            0x%08x", crc());
 275   st->print_cr("- version:                        0x%x", version());
 276   st->print_cr("- header_size:                    " UINT32_FORMAT, header_size());
 277   st->print_cr("- base_archive_name_offset:       " UINT32_FORMAT, base_archive_name_offset());
 278   st->print_cr("- base_archive_name_size:         " UINT32_FORMAT, base_archive_name_size());
 279 
 280   for (int i = 0; i < NUM_CDS_REGIONS; i++) {

 299   st->print_cr("- early_serialized_data_offset:   0x%zx", _early_serialized_data_offset);
 300   st->print_cr("- serialized_data_offset:         0x%zx", _serialized_data_offset);
 301   st->print_cr("- jvm_ident:                      %s", _jvm_ident);
 302   st->print_cr("- class_location_config_offset:   0x%zx", _class_location_config_offset);
 303   st->print_cr("- verify_local:                   %d", _verify_local);
 304   st->print_cr("- verify_remote:                  %d", _verify_remote);
 305   st->print_cr("- has_platform_or_app_classes:    %d", _has_platform_or_app_classes);
 306   st->print_cr("- requested_base_address:         " INTPTR_FORMAT, p2i(_requested_base_address));
 307   st->print_cr("- mapped_base_address:            " INTPTR_FORMAT, p2i(_mapped_base_address));
 308   st->print_cr("- heap_root_segments.roots_count: %d" , _heap_root_segments.roots_count());
 309   st->print_cr("- heap_root_segments.base_offset: 0x%zx", _heap_root_segments.base_offset());
 310   st->print_cr("- heap_root_segments.count:       %zu", _heap_root_segments.count());
 311   st->print_cr("- heap_root_segments.max_size_elems: %d", _heap_root_segments.max_size_in_elems());
 312   st->print_cr("- heap_root_segments.max_size_bytes: %d", _heap_root_segments.max_size_in_bytes());
 313   st->print_cr("- _heap_oopmap_start_pos:         %zu", _heap_oopmap_start_pos);
 314   st->print_cr("- _heap_ptrmap_start_pos:         %zu", _heap_ptrmap_start_pos);
 315   st->print_cr("- _rw_ptrmap_start_pos:           %zu", _rw_ptrmap_start_pos);
 316   st->print_cr("- _ro_ptrmap_start_pos:           %zu", _ro_ptrmap_start_pos);
 317   st->print_cr("- use_optimized_module_handling:  %d", _use_optimized_module_handling);
 318   st->print_cr("- has_full_module_graph           %d", _has_full_module_graph);


 319   st->print_cr("- has_aot_linked_classes          %d", _has_aot_linked_classes);
 320 }
 321 
 322 bool FileMapInfo::validate_class_location() {
 323   assert(CDSConfig::is_using_archive(), "runtime only");
 324 
 325   AOTClassLocationConfig* config = header()->class_location_config();
 326   bool has_extra_module_paths = false;
 327   if (!config->validate(full_path(), header()->has_aot_linked_classes(), &has_extra_module_paths)) {
 328     if (PrintSharedArchiveAndExit) {
 329       AOTMetaspace::set_archive_loading_failed();
 330       return true;
 331     } else {
 332       return false;
 333     }
 334   }
 335 
 336   if (header()->has_full_module_graph() && has_extra_module_paths) {
 337     CDSConfig::stop_using_optimized_module_handling();
 338     AOTMetaspace::report_loading_error("optimized module handling: disabled because extra module path(s) are specified");

 682   if (strncmp(actual_ident, expected_ident, JVM_IDENT_MAX-1) != 0) {
 683     aot_log_info(aot)("_jvm_ident expected: %s", expected_ident);
 684     aot_log_info(aot)("             actual: %s", actual_ident);
 685     aot_log_warning(aot)("The %s was created by a different"
 686                   " version or build of HotSpot", file_type);
 687     return false;
 688   }
 689 
 690   _file_offset = header()->header_size(); // accounts for the size of _base_archive_name
 691 
 692   size_t len = os::lseek(fd, 0, SEEK_END);
 693 
 694   for (int i = 0; i < AOTMetaspace::n_regions; i++) {
 695     FileMapRegion* r = region_at(i);
 696     if (r->file_offset() > len || len - r->file_offset() < r->used()) {
 697       aot_log_warning(aot)("The %s has been truncated.", file_type);
 698       return false;
 699     }
 700   }
 701 




 702   return true;
 703 }
 704 
 705 void FileMapInfo::seek_to_position(size_t pos) {
 706   if (os::lseek(_fd, (long)pos, SEEK_SET) < 0) {
 707     aot_log_error(aot)("Unable to seek to position %zu", pos);
 708     AOTMetaspace::unrecoverable_loading_error();
 709   }
 710 }
 711 
 712 // Read the FileMapInfo information from the file.
 713 bool FileMapInfo::open_for_read() {
 714   if (_file_open) {
 715     return true;
 716   }
 717   const char* file_type = CDSConfig::type_of_archive_being_loaded();
 718   const char* info = CDSConfig::is_dumping_final_static_archive() ?
 719     "AOTConfiguration file " : "";
 720   aot_log_info(aot)("trying to map %s%s", info, _full_path);
 721   int fd = os::open(_full_path, O_RDONLY | O_BINARY, 0);

2039   // For backwards compatibility, we don't check the BytecodeVerificationRemote setting
2040   // if the archive only contains system classes.
2041   if (_has_platform_or_app_classes
2042       && !_verify_remote // we didn't verify the archived platform/app classes
2043       && BytecodeVerificationRemote) { // but we want to verify all loaded platform/app classes
2044     aot_log_info(aot)("The %s was created with less restrictive "
2045                                "verification setting than the current setting.", file_type);
2046     // Pretend that we didn't have any archived platform/app classes, so they won't be loaded
2047     // by SystemDictionaryShared.
2048     _has_platform_or_app_classes = false;
2049   }
2050 
2051   aot_log_info(aot)("The %s was created with UseCompressedOops = %d, UseCompressedClassPointers = %d, UseCompactObjectHeaders = %d",
2052                           file_type, compressed_oops(), compressed_class_pointers(), compact_headers());
2053   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2054     aot_log_warning(aot)("Unable to use %s.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2055                                "different from runtime, CDS will be disabled.", file_type);
2056     return false;
2057   }
2058 


















2059   if (compact_headers() != UseCompactObjectHeaders) {
2060     aot_log_warning(aot)("Unable to use %s.\nThe %s's UseCompactObjectHeaders setting (%s)"
2061                      " does not equal the current UseCompactObjectHeaders setting (%s).", file_type, file_type,
2062                      _compact_headers          ? "enabled" : "disabled",
2063                      UseCompactObjectHeaders   ? "enabled" : "disabled");
2064     return false;
2065   }
2066 
2067   if (!_use_optimized_module_handling && !CDSConfig::is_dumping_final_static_archive()) {
2068     CDSConfig::stop_using_optimized_module_handling();
2069     aot_log_info(aot)("optimized module handling: disabled because archive was created without optimized module handling");
2070   }
2071 
2072   if (is_static()) {
2073     // Only the static archive can contain the full module graph.
2074     if (!_has_full_module_graph) {
2075       CDSConfig::stop_using_full_module_graph("archive was created without full module graph");
2076     }
2077   }
2078 

  70 #include "runtime/mutexLocker.hpp"
  71 #include "runtime/os.hpp"
  72 #include "runtime/vm_version.hpp"
  73 #include "utilities/align.hpp"
  74 #include "utilities/bitMap.inline.hpp"
  75 #include "utilities/classpathStream.hpp"
  76 #include "utilities/defaultStream.hpp"
  77 #include "utilities/ostream.hpp"
  78 #if INCLUDE_G1GC
  79 #include "gc/g1/g1CollectedHeap.hpp"
  80 #include "gc/g1/g1HeapRegion.hpp"
  81 #endif
  82 
  83 #include <errno.h>
  84 #include <sys/stat.h>
  85 
  86 #ifndef O_BINARY       // if defined (Win32) use binary files.
  87 #define O_BINARY 0     // otherwise do nothing.
  88 #endif
  89 
  90 inline void CDSMustMatchFlags::do_print(outputStream* st, bool v) {
  91   st->print("%s", v ? "true" : "false");
  92 }
  93 
  94 inline void CDSMustMatchFlags::do_print(outputStream* st, intx v) {
  95   st->print("%zd", v);
  96 }
  97 
  98 inline void CDSMustMatchFlags::do_print(outputStream* st, uintx v) {
  99   st->print("%zu", v);
 100 }
 101 
 102 inline void CDSMustMatchFlags::do_print(outputStream* st, double v) {
 103   st->print("%f", v);
 104 }
 105 
 106 void CDSMustMatchFlags::init() {
 107   assert(CDSConfig::is_dumping_archive(), "sanity");
 108   _max_name_width = 0;
 109 
 110 #define INIT_CDS_MUST_MATCH_FLAG(n) \
 111   _v_##n = n; \
 112   _max_name_width = MAX2(_max_name_width,strlen(#n));
 113   CDS_MUST_MATCH_FLAGS_DO(INIT_CDS_MUST_MATCH_FLAG);
 114 #undef INIT_CDS_MUST_MATCH_FLAG
 115 }
 116 
 117 bool CDSMustMatchFlags::runtime_check() const {
 118 #define CHECK_CDS_MUST_MATCH_FLAG(n) \
 119   if (_v_##n != n) { \
 120     ResourceMark rm; \
 121     stringStream ss; \
 122     ss.print("VM option %s is different between dumptime (", #n);  \
 123     do_print(&ss, _v_ ## n); \
 124     ss.print(") and runtime ("); \
 125     do_print(&ss, n); \
 126     ss.print(")"); \
 127     log_info(cds)("%s", ss.as_string()); \
 128     return false; \
 129   }
 130   CDS_MUST_MATCH_FLAGS_DO(CHECK_CDS_MUST_MATCH_FLAG);
 131 #undef CHECK_CDS_MUST_MATCH_FLAG
 132 
 133   return true;
 134 }
 135 
 136 void CDSMustMatchFlags::print_info() const {
 137   LogTarget(Info, cds) lt;
 138   if (lt.is_enabled()) {
 139     LogStream ls(lt);
 140     ls.print_cr("Recorded VM flags during dumptime:");
 141     print(&ls);
 142   }
 143 }
 144 
 145 void CDSMustMatchFlags::print(outputStream* st) const {
 146 #define PRINT_CDS_MUST_MATCH_FLAG(n) \
 147   st->print("- %-s ", #n);                   \
 148   st->sp(int(_max_name_width - strlen(#n))); \
 149   do_print(st, _v_##n);                      \
 150   st->cr();
 151   CDS_MUST_MATCH_FLAGS_DO(PRINT_CDS_MUST_MATCH_FLAG);
 152 #undef PRINT_CDS_MUST_MATCH_FLAG
 153 }
 154 
 155 // Fill in the fileMapInfo structure with data about this VM instance.
 156 
 157 // This method copies the vm version info into header_version.  If the version is too
 158 // long then a truncated version, which has a hash code appended to it, is copied.
 159 //
 160 // Using a template enables this method to verify that header_version is an array of
 161 // length JVM_IDENT_MAX.  This ensures that the code that writes to the CDS file and
 162 // the code that reads the CDS file will both use the same size buffer.  Hence, will
 163 // use identical truncation.  This is necessary for matching of truncated versions.
 164 template <int N> static void get_header_version(char (&header_version) [N]) {
 165   assert(N == JVM_IDENT_MAX, "Bad header_version size");
 166 
 167   const char *vm_version = VM_Version::internal_vm_info_string();
 168   const int version_len = (int)strlen(vm_version);
 169 
 170   memset(header_version, 0, JVM_IDENT_MAX);
 171 
 172   if (version_len < (JVM_IDENT_MAX-1)) {
 173     strcpy(header_version, vm_version);
 174 

 293     _narrow_klass_pointer_bits = CompressedKlassPointers::narrow_klass_pointer_bits();
 294     _narrow_klass_shift = ArchiveBuilder::precomputed_narrow_klass_shift();
 295 #endif
 296   } else {
 297     _narrow_klass_pointer_bits = _narrow_klass_shift = -1;
 298   }
 299   // Which JIT compier is used
 300   _compiler_type = (u1)CompilerConfig::compiler_type();
 301   _type_profile_level = TypeProfileLevel;
 302   _type_profile_args_limit = TypeProfileArgsLimit;
 303   _type_profile_parms_limit = TypeProfileParmsLimit;
 304   _type_profile_width = TypeProfileWidth;
 305   _bci_profile_width = BciProfileWidth;
 306   _profile_traps = ProfileTraps;
 307   _type_profile_casts = TypeProfileCasts;
 308   _spec_trap_limit_extra_entries = SpecTrapLimitExtraEntries;
 309   _max_heap_size = MaxHeapSize;
 310   _use_optimized_module_handling = CDSConfig::is_using_optimized_module_handling();
 311   _has_aot_linked_classes = CDSConfig::is_dumping_aot_linked_classes();
 312   _has_full_module_graph = CDSConfig::is_dumping_full_module_graph();
 313   _has_valhalla_patched_classes = CDSConfig::is_valhalla_preview();
 314 
 315   // The following fields are for sanity checks for whether this archive
 316   // will function correctly with this JVM and the bootclasspath it's
 317   // invoked with.
 318 
 319   // JVM version string ... changes on each build.
 320   get_header_version(_jvm_ident);
 321 
 322   _verify_local = BytecodeVerificationLocal;
 323   _verify_remote = BytecodeVerificationRemote;
 324   _has_platform_or_app_classes = AOTClassLocationConfig::dumptime()->has_platform_or_app_classes();
 325   _requested_base_address = (char*)SharedBaseAddress;
 326   _mapped_base_address = (char*)SharedBaseAddress;
 327   _must_match.init();
 328 }
 329 
 330 void FileMapHeader::copy_base_archive_name(const char* archive) {
 331   assert(base_archive_name_size() != 0, "_base_archive_name_size not set");
 332   assert(base_archive_name_offset() != 0, "_base_archive_name_offset not set");
 333   assert(header_size() > sizeof(*this), "_base_archive_name_size not included in header size?");
 334   memcpy((char*)this + base_archive_name_offset(), archive, base_archive_name_size());
 335 }
 336 
 337 void FileMapHeader::print(outputStream* st) {
 338   ResourceMark rm;
 339 
 340   st->print_cr("- magic:                          0x%08x", magic());
 341   st->print_cr("- crc:                            0x%08x", crc());
 342   st->print_cr("- version:                        0x%x", version());
 343   st->print_cr("- header_size:                    " UINT32_FORMAT, header_size());
 344   st->print_cr("- base_archive_name_offset:       " UINT32_FORMAT, base_archive_name_offset());
 345   st->print_cr("- base_archive_name_size:         " UINT32_FORMAT, base_archive_name_size());
 346 
 347   for (int i = 0; i < NUM_CDS_REGIONS; i++) {

 366   st->print_cr("- early_serialized_data_offset:   0x%zx", _early_serialized_data_offset);
 367   st->print_cr("- serialized_data_offset:         0x%zx", _serialized_data_offset);
 368   st->print_cr("- jvm_ident:                      %s", _jvm_ident);
 369   st->print_cr("- class_location_config_offset:   0x%zx", _class_location_config_offset);
 370   st->print_cr("- verify_local:                   %d", _verify_local);
 371   st->print_cr("- verify_remote:                  %d", _verify_remote);
 372   st->print_cr("- has_platform_or_app_classes:    %d", _has_platform_or_app_classes);
 373   st->print_cr("- requested_base_address:         " INTPTR_FORMAT, p2i(_requested_base_address));
 374   st->print_cr("- mapped_base_address:            " INTPTR_FORMAT, p2i(_mapped_base_address));
 375   st->print_cr("- heap_root_segments.roots_count: %d" , _heap_root_segments.roots_count());
 376   st->print_cr("- heap_root_segments.base_offset: 0x%zx", _heap_root_segments.base_offset());
 377   st->print_cr("- heap_root_segments.count:       %zu", _heap_root_segments.count());
 378   st->print_cr("- heap_root_segments.max_size_elems: %d", _heap_root_segments.max_size_in_elems());
 379   st->print_cr("- heap_root_segments.max_size_bytes: %d", _heap_root_segments.max_size_in_bytes());
 380   st->print_cr("- _heap_oopmap_start_pos:         %zu", _heap_oopmap_start_pos);
 381   st->print_cr("- _heap_ptrmap_start_pos:         %zu", _heap_ptrmap_start_pos);
 382   st->print_cr("- _rw_ptrmap_start_pos:           %zu", _rw_ptrmap_start_pos);
 383   st->print_cr("- _ro_ptrmap_start_pos:           %zu", _ro_ptrmap_start_pos);
 384   st->print_cr("- use_optimized_module_handling:  %d", _use_optimized_module_handling);
 385   st->print_cr("- has_full_module_graph           %d", _has_full_module_graph);
 386   st->print_cr("- has_valhalla_patched_classes    %d", _has_valhalla_patched_classes);
 387   _must_match.print(st);
 388   st->print_cr("- has_aot_linked_classes          %d", _has_aot_linked_classes);
 389 }
 390 
 391 bool FileMapInfo::validate_class_location() {
 392   assert(CDSConfig::is_using_archive(), "runtime only");
 393 
 394   AOTClassLocationConfig* config = header()->class_location_config();
 395   bool has_extra_module_paths = false;
 396   if (!config->validate(full_path(), header()->has_aot_linked_classes(), &has_extra_module_paths)) {
 397     if (PrintSharedArchiveAndExit) {
 398       AOTMetaspace::set_archive_loading_failed();
 399       return true;
 400     } else {
 401       return false;
 402     }
 403   }
 404 
 405   if (header()->has_full_module_graph() && has_extra_module_paths) {
 406     CDSConfig::stop_using_optimized_module_handling();
 407     AOTMetaspace::report_loading_error("optimized module handling: disabled because extra module path(s) are specified");

 751   if (strncmp(actual_ident, expected_ident, JVM_IDENT_MAX-1) != 0) {
 752     aot_log_info(aot)("_jvm_ident expected: %s", expected_ident);
 753     aot_log_info(aot)("             actual: %s", actual_ident);
 754     aot_log_warning(aot)("The %s was created by a different"
 755                   " version or build of HotSpot", file_type);
 756     return false;
 757   }
 758 
 759   _file_offset = header()->header_size(); // accounts for the size of _base_archive_name
 760 
 761   size_t len = os::lseek(fd, 0, SEEK_END);
 762 
 763   for (int i = 0; i < AOTMetaspace::n_regions; i++) {
 764     FileMapRegion* r = region_at(i);
 765     if (r->file_offset() > len || len - r->file_offset() < r->used()) {
 766       aot_log_warning(aot)("The %s has been truncated.", file_type);
 767       return false;
 768     }
 769   }
 770 
 771   if (!header()->check_must_match_flags()) {
 772     return false;
 773   }
 774 
 775   return true;
 776 }
 777 
 778 void FileMapInfo::seek_to_position(size_t pos) {
 779   if (os::lseek(_fd, (long)pos, SEEK_SET) < 0) {
 780     aot_log_error(aot)("Unable to seek to position %zu", pos);
 781     AOTMetaspace::unrecoverable_loading_error();
 782   }
 783 }
 784 
 785 // Read the FileMapInfo information from the file.
 786 bool FileMapInfo::open_for_read() {
 787   if (_file_open) {
 788     return true;
 789   }
 790   const char* file_type = CDSConfig::type_of_archive_being_loaded();
 791   const char* info = CDSConfig::is_dumping_final_static_archive() ?
 792     "AOTConfiguration file " : "";
 793   aot_log_info(aot)("trying to map %s%s", info, _full_path);
 794   int fd = os::open(_full_path, O_RDONLY | O_BINARY, 0);

2112   // For backwards compatibility, we don't check the BytecodeVerificationRemote setting
2113   // if the archive only contains system classes.
2114   if (_has_platform_or_app_classes
2115       && !_verify_remote // we didn't verify the archived platform/app classes
2116       && BytecodeVerificationRemote) { // but we want to verify all loaded platform/app classes
2117     aot_log_info(aot)("The %s was created with less restrictive "
2118                                "verification setting than the current setting.", file_type);
2119     // Pretend that we didn't have any archived platform/app classes, so they won't be loaded
2120     // by SystemDictionaryShared.
2121     _has_platform_or_app_classes = false;
2122   }
2123 
2124   aot_log_info(aot)("The %s was created with UseCompressedOops = %d, UseCompressedClassPointers = %d, UseCompactObjectHeaders = %d",
2125                           file_type, compressed_oops(), compressed_class_pointers(), compact_headers());
2126   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2127     aot_log_warning(aot)("Unable to use %s.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2128                                "different from runtime, CDS will be disabled.", file_type);
2129     return false;
2130   }
2131 
2132   if (is_static()) {
2133     const char* err = nullptr;
2134     if (CDSConfig::is_valhalla_preview()) {
2135       if (!_has_valhalla_patched_classes) {
2136         err = "not created";
2137       }
2138     } else {
2139       if (_has_valhalla_patched_classes) {
2140         err = "created";
2141       }
2142     }
2143     if (err != nullptr) {
2144       log_warning(cds)("This archive was %s with --enable-preview -XX:+EnableValhalla. It is "
2145                          "incompatible with the current JVM setting", err);
2146       return false;
2147     }
2148   }
2149 
2150   if (compact_headers() != UseCompactObjectHeaders) {
2151     aot_log_warning(aot)("Unable to use %s.\nThe %s's UseCompactObjectHeaders setting (%s)"
2152                      " does not equal the current UseCompactObjectHeaders setting (%s).", file_type, file_type,
2153                      _compact_headers          ? "enabled" : "disabled",
2154                      UseCompactObjectHeaders   ? "enabled" : "disabled");
2155     return false;
2156   }
2157 
2158   if (!_use_optimized_module_handling && !CDSConfig::is_dumping_final_static_archive()) {
2159     CDSConfig::stop_using_optimized_module_handling();
2160     aot_log_info(aot)("optimized module handling: disabled because archive was created without optimized module handling");
2161   }
2162 
2163   if (is_static()) {
2164     // Only the static archive can contain the full module graph.
2165     if (!_has_full_module_graph) {
2166       CDSConfig::stop_using_full_module_graph("archive was created without full module graph");
2167     }
2168   }
2169 
< prev index next >