8005076: Creating a CDS archive with one alignment and running another causes a crash

Save the alignment when writing the CDS and compare it when reading the CDS.

Reviewed-by: kvn, coleenp
This commit is contained in:
Harold Seigel 2013-01-08 13:38:11 -05:00
parent 89e575df23
commit cfea76669a
4 changed files with 19 additions and 16 deletions

View file

@ -119,6 +119,7 @@ void FileMapInfo::populate_header(size_t alignment) {
_header._magic = 0xf00baba2;
_header._version = _current_version;
_header._alignment = alignment;
_header._obj_alignment = ObjectAlignmentInBytes;
// The following fields are for sanity checks for whether this archive
// will function correctly with this JVM and the bootclasspath it's
@ -473,6 +474,12 @@ bool FileMapInfo::validate() {
" version or build of HotSpot.");
return false;
}
if (_header._obj_alignment != ObjectAlignmentInBytes) {
fail_continue("The shared archive file's ObjectAlignmentInBytes of %d"
" does not equal the current ObjectAlignmentInBytes of %d.",
_header._obj_alignment, ObjectAlignmentInBytes);
return false;
}
// Cannot verify interpreter yet, as it can only be created after the GC
// heap has been initialized.