< 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 

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

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

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

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


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

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




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

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


















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

  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 

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

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

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

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