diff 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
line wrap: on
line diff
--- a/src/share/vm/memory/filemap.cpp	Mon Jan 07 15:32:51 2013 -0500
+++ b/src/share/vm/memory/filemap.cpp	Tue Jan 08 13:38:11 2013 -0500
@@ -119,6 +119,7 @@
   _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 @@
                   " 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.