RFR (XS) 8241500: FieldLayout/OldLayoutCheck.java fails in 32-bit VMs
David Holmes
david.holmes at oracle.com
Tue Mar 24 13:51:51 UTC 2020
On 24/03/2020 11:19 pm, Frederic Parain wrote:
> Aleksey,
>
> Looks good to me, thank you for fixing this.
I'm somewhat surprised that it has taken 4 weeks for this problem on
32-bit to be noticed! :(
A comment as to why INT_OFFSET and LONG_OFFSET have those values would
be good. Otherwise fix is fine by me too.
Thanks,
David
> Fred
>
>
>> On Mar 24, 2020, at 06:54, Aleksey Shipilev <shade at redhat.com> wrote:
>>
>> Test bug:
>> https://bugs.openjdk.java.net/browse/JDK-8241500
>>
>> See the brief discussion and JOL dump in the bug.
>>
>> Fix:
>>
>> diff -r cc739b0abc44 test/hotspot/jtreg/runtime/FieldLayout/OldLayoutCheck.java
>> --- a/test/hotspot/jtreg/runtime/FieldLayout/OldLayoutCheck.java Tue Mar 24 06:13:39 2020 +0100
>> +++ b/test/hotspot/jtreg/runtime/FieldLayout/OldLayoutCheck.java Tue Mar 24 11:52:36 2020 +0100
>> @@ -45,28 +45,32 @@
>> import java.util.Arrays;
>> import java.util.Comparator;
>> import jdk.internal.misc.Unsafe;
>>
>> import jdk.test.lib.Asserts;
>> +import jdk.test.lib.Platform;
>>
>> public class OldLayoutCheck {
>>
>> static class LIClass {
>> public long l;
>> public int i;
>> }
>>
>> + 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;
>> Field[] fields = c.getFields();
>> 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");
>> }
>> }
>> }
>>
>> Testing: affected test on Linux {x86_64, x86_32}
>>
>> --
>> Thanks,
>> -Aleksey
>>
>
More information about the hotspot-runtime-dev
mailing list