201 if (DynamicDumpSharedSpaces) {
202 _magic = CDS_DYNAMIC_ARCHIVE_MAGIC;
203 } else {
204 _magic = CDS_ARCHIVE_MAGIC;
205 }
206 _version = CURRENT_CDS_ARCHIVE_VERSION;
207 _alignment = alignment;
208 _obj_alignment = ObjectAlignmentInBytes;
209 _compact_strings = CompactStrings;
210 if (HeapShared::is_heap_object_archiving_allowed()) {
211 _narrow_oop_mode = CompressedOops::mode();
212 _narrow_oop_base = CompressedOops::base();
213 _narrow_oop_shift = CompressedOops::shift();
214 _heap_end = CompressedOops::end();
215 }
216 _compressed_oops = UseCompressedOops;
217 _compressed_class_ptrs = UseCompressedClassPointers;
218 _max_heap_size = MaxHeapSize;
219 _narrow_klass_shift = CompressedKlassPointers::shift();
220 _use_optimized_module_handling = MetaspaceShared::use_optimized_module_handling();
221
222 // The following fields are for sanity checks for whether this archive
223 // will function correctly with this JVM and the bootclasspath it's
224 // invoked with.
225
226 // JVM version string ... changes on each build.
227 get_header_version(_jvm_ident);
228
229 _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
230 _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
231 _num_module_paths = ClassLoader::num_module_path_entries();
232 _max_used_path_index = ClassLoaderExt::max_used_path_index();
233
234 _verify_local = BytecodeVerificationLocal;
235 _verify_remote = BytecodeVerificationRemote;
236 _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
237 _requested_base_address = (char*)SharedBaseAddress;
238 _mapped_base_address = (char*)SharedBaseAddress;
239 _allow_archiving_with_java_agent = AllowArchivingWithJavaAgent;
240 // the following 2 fields will be set in write_header for dynamic archive header
2162 FileMapInfo::fail_continue("The setting of the AllowArchivingWithJavaAgent is different "
2163 "from the setting in the shared archive.");
2164 return false;
2165 }
2166
2167 if (_allow_archiving_with_java_agent) {
2168 warning("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2169 "for testing purposes only and should not be used in a production environment");
2170 }
2171
2172 log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2173 compressed_oops(), compressed_class_pointers());
2174 if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2175 FileMapInfo::fail_continue("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2176 "different from runtime, CDS will be disabled.");
2177 return false;
2178 }
2179
2180 if (!_use_optimized_module_handling) {
2181 MetaspaceShared::disable_optimized_module_handling();
2182 log_info(cds)("use_optimized_module_handling disabled: archive was created without optimized module handling");
2183 }
2184
2185 return true;
2186 }
2187
2188 bool FileMapInfo::validate_header() {
2189 if (!header()->validate()) {
2190 return false;
2191 }
2192 if (_is_static) {
2193 return true;
2194 } else {
2195 return DynamicArchive::validate(this);
2196 }
2197 }
2198
2199 // Check if a given address is within one of the shared regions
2200 bool FileMapInfo::is_in_shared_region(const void* p, int idx) {
2201 assert(idx == MetaspaceShared::ro ||
2202 idx == MetaspaceShared::rw ||
|
201 if (DynamicDumpSharedSpaces) {
202 _magic = CDS_DYNAMIC_ARCHIVE_MAGIC;
203 } else {
204 _magic = CDS_ARCHIVE_MAGIC;
205 }
206 _version = CURRENT_CDS_ARCHIVE_VERSION;
207 _alignment = alignment;
208 _obj_alignment = ObjectAlignmentInBytes;
209 _compact_strings = CompactStrings;
210 if (HeapShared::is_heap_object_archiving_allowed()) {
211 _narrow_oop_mode = CompressedOops::mode();
212 _narrow_oop_base = CompressedOops::base();
213 _narrow_oop_shift = CompressedOops::shift();
214 _heap_end = CompressedOops::end();
215 }
216 _compressed_oops = UseCompressedOops;
217 _compressed_class_ptrs = UseCompressedClassPointers;
218 _max_heap_size = MaxHeapSize;
219 _narrow_klass_shift = CompressedKlassPointers::shift();
220 _use_optimized_module_handling = MetaspaceShared::use_optimized_module_handling();
221 _use_full_module_graph = MetaspaceShared::use_full_module_graph();
222
223 // The following fields are for sanity checks for whether this archive
224 // will function correctly with this JVM and the bootclasspath it's
225 // invoked with.
226
227 // JVM version string ... changes on each build.
228 get_header_version(_jvm_ident);
229
230 _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
231 _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
232 _num_module_paths = ClassLoader::num_module_path_entries();
233 _max_used_path_index = ClassLoaderExt::max_used_path_index();
234
235 _verify_local = BytecodeVerificationLocal;
236 _verify_remote = BytecodeVerificationRemote;
237 _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
238 _requested_base_address = (char*)SharedBaseAddress;
239 _mapped_base_address = (char*)SharedBaseAddress;
240 _allow_archiving_with_java_agent = AllowArchivingWithJavaAgent;
241 // the following 2 fields will be set in write_header for dynamic archive header
2163 FileMapInfo::fail_continue("The setting of the AllowArchivingWithJavaAgent is different "
2164 "from the setting in the shared archive.");
2165 return false;
2166 }
2167
2168 if (_allow_archiving_with_java_agent) {
2169 warning("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2170 "for testing purposes only and should not be used in a production environment");
2171 }
2172
2173 log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2174 compressed_oops(), compressed_class_pointers());
2175 if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2176 FileMapInfo::fail_continue("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2177 "different from runtime, CDS will be disabled.");
2178 return false;
2179 }
2180
2181 if (!_use_optimized_module_handling) {
2182 MetaspaceShared::disable_optimized_module_handling();
2183 log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2184 }
2185
2186 if (!_use_full_module_graph) {
2187 MetaspaceShared::disable_full_module_graph();
2188 log_info(cds)("full module graph: disabled because archive was created without full module graph");
2189 }
2190
2191 return true;
2192 }
2193
2194 bool FileMapInfo::validate_header() {
2195 if (!header()->validate()) {
2196 return false;
2197 }
2198 if (_is_static) {
2199 return true;
2200 } else {
2201 return DynamicArchive::validate(this);
2202 }
2203 }
2204
2205 // Check if a given address is within one of the shared regions
2206 bool FileMapInfo::is_in_shared_region(const void* p, int idx) {
2207 assert(idx == MetaspaceShared::ro ||
2208 idx == MetaspaceShared::rw ||
|