< prev index next > test/hotspot/jtreg/runtime/FieldLayout/OldLayoutCheck.java
Print this page
/*
* @test
* @bug 8239014
* @summary -XX:-UseEmptySlotsInSupers sometime fails to reproduce the layout of the old code
- * @library /test/lib
+ * @library /test/lib /
* @modules java.base/jdk.internal.misc
* java.management
* @requires vm.bits == "64" & vm.opt.final.UseCompressedOops == true & vm.gc != "Z"
- * @run main/othervm -XX:+UseCompressedClassPointers -XX:-UseEmptySlotsInSupers OldLayoutCheck
+ * @build jdk.test.whitebox.WhiteBox
+ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseCompressedClassPointers -XX:-UseEmptySlotsInSupers OldLayoutCheck
*/
/*
* @test
* @requires vm.bits == "32"
- * @library /test/lib
+ * @library /test/lib /
* @modules java.base/jdk.internal.misc
* java.management
- * @run main/othervm -XX:-UseEmptySlotsInSupers OldLayoutCheck
+ * @build jdk.test.whitebox.WhiteBox
+ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseEmptySlotsInSupers OldLayoutCheck
*/
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Comparator;
import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts;
import jdk.test.lib.Platform;
+ import jdk.test.whitebox.WhiteBox;
public class OldLayoutCheck {
static class LIClass {
public long l;
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;
-
+ private static final long INT_OFFSET;
+ private static final long LONG_OFFSET;
+ static {
+ WhiteBox WB = WhiteBox.getWhiteBox();
+ if (!Platform.is64bit() || WB.getBooleanVMFlag("UseCompactObjectHeaders")) {
+ INT_OFFSET = 16L;
+ LONG_OFFSET = 8L;
+ } else {
+ INT_OFFSET = 12L;
+ LONG_OFFSET = 16L;
+ }
+ }
static public void main(String[] args) {
Unsafe unsafe = Unsafe.getUnsafe();
Class c = LIClass.class;
Field[] fields = c.getFields();
for (int i = 0; i < fields.length; i++) {
< prev index next >