comparison src/share/vm/memory/filemap.cpp @ 7461:561148896559

8005076: Creating a CDS archive with one alignment and running another causes a crash. Summary: Save the alignment when writing the CDS and compare it when reading the CDS. Reviewed-by: kvn, coleenp
author hseigel
date Tue, 08 Jan 2013 13:38:11 -0500
parents 6c3f47d964f3
children c4ef3380a70b
comparison
equal deleted inserted replaced
7460:6c3f47d964f3 7461:561148896559
117 117
118 void FileMapInfo::populate_header(size_t alignment) { 118 void FileMapInfo::populate_header(size_t alignment) {
119 _header._magic = 0xf00baba2; 119 _header._magic = 0xf00baba2;
120 _header._version = _current_version; 120 _header._version = _current_version;
121 _header._alignment = alignment; 121 _header._alignment = alignment;
122 _header._obj_alignment = ObjectAlignmentInBytes;
122 123
123 // The following fields are for sanity checks for whether this archive 124 // The following fields are for sanity checks for whether this archive
124 // will function correctly with this JVM and the bootclasspath it's 125 // will function correctly with this JVM and the bootclasspath it's
125 // invoked with. 126 // invoked with.
126 127
469 char header_version[JVM_IDENT_MAX]; 470 char header_version[JVM_IDENT_MAX];
470 get_header_version(header_version); 471 get_header_version(header_version);
471 if (strncmp(_header._jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) { 472 if (strncmp(_header._jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) {
472 fail_continue("The shared archive file was created by a different" 473 fail_continue("The shared archive file was created by a different"
473 " version or build of HotSpot."); 474 " version or build of HotSpot.");
475 return false;
476 }
477 if (_header._obj_alignment != ObjectAlignmentInBytes) {
478 fail_continue("The shared archive file's ObjectAlignmentInBytes of %d"
479 " does not equal the current ObjectAlignmentInBytes of %d.",
480 _header._obj_alignment, ObjectAlignmentInBytes);
474 return false; 481 return false;
475 } 482 }
476 483
477 // Cannot verify interpreter yet, as it can only be created after the GC 484 // Cannot verify interpreter yet, as it can only be created after the GC
478 // heap has been initialized. 485 // heap has been initialized.