Index: runtime/vm/object_reload.cc |
diff --git a/runtime/vm/object_reload.cc b/runtime/vm/object_reload.cc |
index ba5098a05b62c66449661e430a21bd44d7834d95..f9c5ad9869e4fffd1c825f305413977bfb0a8bb2 100644 |
--- a/runtime/vm/object_reload.cc |
+++ b/runtime/vm/object_reload.cc |
@@ -444,13 +444,22 @@ bool Class::CanReload(const Class& replacement) const { |
const Array& replacement_fields = |
Array::Handle(replacement.OffsetToFieldMap()); |
- // Check that we have the same number of fields. |
+ // Check that the size of the instance is the same. |
if (fields.Length() != replacement_fields.Length()) { |
IRC->ReportError(String::Handle(String::NewFormatted( |
"Number of instance fields changed in %s", ToCString()))); |
return false; |
} |
+ // Check that we have the same next field offset. This check is not |
+ // redundant with the one above because the instance OffsetToFieldMap |
+ // array length is based on the instance size (which may be aligned up). |
+ if (next_field_offset() != replacement.next_field_offset()) { |
+ IRC->ReportError(String::Handle(String::NewFormatted( |
+ "Number of instance fields changed in %s", ToCString()))); |
+ return false; |
+ } |
+ |
if (NumTypeArguments() != replacement.NumTypeArguments()) { |
IRC->ReportError(String::Handle(String::NewFormatted( |
"Number of type arguments changed in %s", ToCString()))); |
@@ -483,7 +492,8 @@ bool Class::CanReload(const Class& replacement) const { |
} else if (is_prefinalized()) { |
if (!replacement.is_prefinalized()) { |
IRC->ReportError(String::Handle(String::NewFormatted( |
- "Original class ('%s') is prefinalized and replacement class ('%s')", |
+ "Original class ('%s') is prefinalized and replacement class " |
+ "('%s') is not ", |
ToCString(), replacement.ToCString()))); |
return false; |
} |