Skip to content

Commit 734d3c3

Browse files
committed
8256862: Several java/foreign tests fail on x86_32 platforms
Reviewed-by: sundar
1 parent 7946c94 commit 734d3c3

21 files changed

+95
-11
lines changed

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CLinker.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@
9595
* {@link #asVarArg(MemoryLayout)} is used to create the memory layouts for each parameter corresponding to a variadic
9696
* argument in a specialized function descriptor.
9797
*
98+
* <p>On unsupported platforms this class will fail to initialize with an {@link ExceptionInInitializerError}.
99+
*
98100
* <p> Unless otherwise specified, passing a {@code null} argument, or an array argument containing one or more {@code null}
99101
* elements to a method in this class causes a {@link NullPointerException NullPointerException} to be thrown. </p>
100102
*

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/CABI.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
*/
2626
package jdk.internal.foreign;
2727

28+
import jdk.internal.foreign.abi.SharedUtils;
29+
30+
import static jdk.incubator.foreign.MemoryLayouts.ADDRESS;
31+
2832
public enum CABI {
2933
SysV,
3034
Win64,
@@ -35,7 +39,10 @@ public enum CABI {
3539
static {
3640
String arch = System.getProperty("os.arch");
3741
String os = System.getProperty("os.name");
38-
if (arch.equals("amd64") || arch.equals("x86_64")) {
42+
long addressSize = ADDRESS.bitSize();
43+
// might be running in a 32-bit VM on a 64-bit platform.
44+
// addressSize will be correctly 32
45+
if ((arch.equals("amd64") || arch.equals("x86_64")) && addressSize == 64) {
3946
if (os.startsWith("Windows")) {
4047
current = Win64;
4148
} else {
@@ -44,7 +51,8 @@ public enum CABI {
4451
} else if (arch.equals("aarch64")) {
4552
current = AArch64;
4653
} else {
47-
throw new ExceptionInInitializerError("Unsupported os or arch: " + os + ", " + arch);
54+
throw new ExceptionInInitializerError(
55+
"Unsupported os, arch, or address size: " + os + ", " + arch + ", " + addressSize);
4856
}
4957
}
5058

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/PlatformLayouts.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private SysV() {
141141
/**
142142
* The {@code T*} native type.
143143
*/
144-
public static final ValueLayout C_POINTER = ofPointer(LITTLE_ENDIAN, ADDRESS.bitSize());
144+
public static final ValueLayout C_POINTER = ofPointer(LITTLE_ENDIAN, 64);
145145

146146
/**
147147
* The {@code va_list} native type, as it is passed to a function.
@@ -201,7 +201,7 @@ private Win64() {
201201
/**
202202
* The {@code T*} native type.
203203
*/
204-
public static final ValueLayout C_POINTER = ofPointer(LITTLE_ENDIAN, ADDRESS.bitSize());
204+
public static final ValueLayout C_POINTER = ofPointer(LITTLE_ENDIAN, 64);
205205

206206
/**
207207
* The {@code va_list} native type, as it is passed to a function.
@@ -266,7 +266,7 @@ private AArch64() {
266266
/**
267267
* The {@code T*} native type.
268268
*/
269-
public static final ValueLayout C_POINTER = ofPointer(LITTLE_ENDIAN, ADDRESS.bitSize());
269+
public static final ValueLayout C_POINTER = ofPointer(LITTLE_ENDIAN, 64);
270270

271271
/**
272272
* The {@code va_list} native type, as it is passed to a function.

test/jdk/java/foreign/StdLibTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/*
2525
* @test
26+
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64"
2627
* @run testng/othervm -Dforeign.restricted=permit StdLibTest
2728
*/
2829

test/jdk/java/foreign/TestCircularInit1.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/*
2525
* @test
26+
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64"
2627
* @modules jdk.incubator.foreign/jdk.internal.foreign
2728
* @run testng/othervm TestCircularInit1
2829
*/

test/jdk/java/foreign/TestCircularInit2.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/*
2525
* @test
26+
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64"
2627
* @modules jdk.incubator.foreign/jdk.internal.foreign
2728
* @run testng/othervm TestCircularInit2
2829
*/

test/jdk/java/foreign/TestCondy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
*
26+
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64"
2727
* @run testng TestCondy
2828
*/
2929

test/jdk/java/foreign/TestDowncall.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
/*
2626
* @test
27+
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64"
2728
* @modules jdk.incubator.foreign/jdk.internal.foreign
2829
* @build NativeTestHelper CallGeneratorHelper TestDowncall
2930
*

test/jdk/java/foreign/TestFunctionDescriptor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
/*
2626
* @test
27+
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64"
2728
* @run testng TestFunctionDescriptor
2829
*/
2930

test/jdk/java/foreign/TestIllegalLink.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
/*
2626
* @test
27-
*
27+
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64"
2828
* @run testng/othervm -Dforeign.restricted=permit TestIllegalLink
2929
*/
3030

0 commit comments

Comments
 (0)