changeset 58542:9cff5368d25a

8241500: FieldLayout/OldLayoutCheck.java fails in 32-bit VMs Reviewed-by: fparain, dholmes
author shade
date Wed, 25 Mar 2020 07:58:17 +0100
parents 7bbf2c0efac8
children 4bb7d9ea608d
files test/hotspot/jtreg/runtime/FieldLayout/OldLayoutCheck.java
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test/hotspot/jtreg/runtime/FieldLayout/OldLayoutCheck.java	Wed Mar 25 00:10:22 2020 +0300
+++ b/test/hotspot/jtreg/runtime/FieldLayout/OldLayoutCheck.java	Wed Mar 25 07:58:17 2020 +0100
@@ -47,6 +47,7 @@
 import jdk.internal.misc.Unsafe;
 
 import jdk.test.lib.Asserts;
+import jdk.test.lib.Platform;
 
 public class OldLayoutCheck {
 
@@ -55,6 +56,11 @@
         public int i;
     }
 
+    // 32-bit VMs: @0:  8 byte header,  @8: long field, @16:  int field
+    // 64-bit VMs: @0: 12 byte header, @12:  int field, @16: long field
+    static final long INT_OFFSET  = Platform.is64bit() ? 12L : 16L;
+    static final long LONG_OFFSET = Platform.is64bit() ? 16L :  8L;
+
     static public void main(String[] args) {
         Unsafe unsafe = Unsafe.getUnsafe();
         Class c = LIClass.class;
@@ -62,9 +68,9 @@
         for (int i = 0; i < fields.length; i++) {
             long offset = unsafe.objectFieldOffset(fields[i]);
             if (fields[i].getType() == int.class) {
-                Asserts.assertEquals(offset, 12L, "Misplaced int field");
+                Asserts.assertEquals(offset, INT_OFFSET, "Misplaced int field");
             } else if (fields[i].getType() == long.class) {
-                Asserts.assertEquals(offset, 16L, "Misplaced long field");
+                Asserts.assertEquals(offset, LONG_OFFSET, "Misplaced long field");
             } else {
                 Asserts.fail("Unexpected field type");
             }