From c29242ebb0cfd3eaa56240664af607c02a11324e Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Fri, 22 Jul 2022 11:33:05 +0000 Subject: [PATCH 1/3] 8290460: Alpine: disable some panama tests that rely on std::thread Backport-of: d7f0de272c85ee8d0890c9d61e10065b618b69d7 --- test/jdk/java/foreign/TestUpcallAsync.java | 1 + .../java/foreign/enablenativeaccess/TestEnableNativeAccess.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/test/jdk/java/foreign/TestUpcallAsync.java b/test/jdk/java/foreign/TestUpcallAsync.java index 1ad94ec7c36..64573029588 100644 --- a/test/jdk/java/foreign/TestUpcallAsync.java +++ b/test/jdk/java/foreign/TestUpcallAsync.java @@ -25,6 +25,7 @@ * @test * @enablePreview * @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" + * @requires !vm.musl * @build NativeTestHelper CallGeneratorHelper TestUpcallBase * * @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies diff --git a/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccess.java b/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccess.java index e20de4186c4..0b4cbb1d4bf 100644 --- a/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccess.java +++ b/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccess.java @@ -25,6 +25,8 @@ * @test * @enablePreview * @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" + * @requires !vm.musl + * * @library /test/lib * @build TestEnableNativeAccess * panama_module/* From 8c9d5ad4f89e7af18f4ee3b8f236083491d7f6fa Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Mon, 25 Jul 2022 21:32:44 +0000 Subject: [PATCH 2/3] 8290455: jck test api/java_lang/foreign/VaList/Empty.html fails on some platforms Reviewed-by: jvernee, mbaesken --- .../classes/jdk/internal/foreign/CABI.java | 37 +++++++----- .../jdk/internal/foreign/PlatformLayouts.java | 7 --- .../java/foreign/TestUnsupportedLinker.java | 60 +++++++++++++++++++ 3 files changed, 82 insertions(+), 22 deletions(-) create mode 100644 test/jdk/java/foreign/TestUnsupportedLinker.java diff --git a/src/java.base/share/classes/jdk/internal/foreign/CABI.java b/src/java.base/share/classes/jdk/internal/foreign/CABI.java index 1ab38dbfa96..4b4d95149f8 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/CABI.java +++ b/src/java.base/share/classes/jdk/internal/foreign/CABI.java @@ -34,34 +34,41 @@ public enum CABI { LinuxAArch64, MacOsAArch64; - private static final CABI current; + private static final CABI ABI; + private static final String ARCH; + private static final String OS; + private static final long ADDRESS_SIZE; static { - String arch = privilegedGetProperty("os.arch"); - String os = privilegedGetProperty("os.name"); - long addressSize = ADDRESS.bitSize(); + ARCH = privilegedGetProperty("os.arch"); + OS = privilegedGetProperty("os.name"); + ADDRESS_SIZE = ADDRESS.bitSize(); // might be running in a 32-bit VM on a 64-bit platform. // addressSize will be correctly 32 - if ((arch.equals("amd64") || arch.equals("x86_64")) && addressSize == 64) { - if (os.startsWith("Windows")) { - current = Win64; + if ((ARCH.equals("amd64") || ARCH.equals("x86_64")) && ADDRESS_SIZE == 64) { + if (OS.startsWith("Windows")) { + ABI = Win64; } else { - current = SysV; + ABI = SysV; } - } else if (arch.equals("aarch64")) { - if (os.startsWith("Mac")) { - current = MacOsAArch64; + } else if (ARCH.equals("aarch64")) { + if (OS.startsWith("Mac")) { + ABI = MacOsAArch64; } else { // The Linux ABI follows the standard AAPCS ABI - current = LinuxAArch64; + ABI = LinuxAArch64; } } else { - throw new UnsupportedOperationException( - "Unsupported os, arch, or address size: " + os + ", " + arch + ", " + addressSize); + // unsupported + ABI = null; } } public static CABI current() { - return current; + if (ABI == null) { + throw new UnsupportedOperationException( + "Unsupported os, arch, or address size: " + OS + ", " + ARCH + ", " + ADDRESS_SIZE); + } + return ABI; } } diff --git a/src/java.base/share/classes/jdk/internal/foreign/PlatformLayouts.java b/src/java.base/share/classes/jdk/internal/foreign/PlatformLayouts.java index 4b7c33694df..ab99b1fabeb 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/PlatformLayouts.java +++ b/src/java.base/share/classes/jdk/internal/foreign/PlatformLayouts.java @@ -29,13 +29,6 @@ import java.lang.foreign.MemoryLayout; import java.lang.foreign.ValueLayout; public class PlatformLayouts { - public static Z pick(Z sysv, Z win64, Z aarch64) { - return switch (CABI.current()) { - case SysV -> sysv; - case Win64 -> win64; - case LinuxAArch64, MacOsAArch64 -> aarch64; - }; - } /** * This class defines layout constants modelling standard primitive types supported by the x64 SystemV ABI. diff --git a/test/jdk/java/foreign/TestUnsupportedLinker.java b/test/jdk/java/foreign/TestUnsupportedLinker.java new file mode 100644 index 00000000000..8d223919b97 --- /dev/null +++ b/test/jdk/java/foreign/TestUnsupportedLinker.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @enablePreview + * + * @run testng/othervm -Dos.arch=unknown -Dos.name=unknown --enable-native-access=ALL-UNNAMED TestUnsupportedLinker + */ + +import java.lang.foreign.Linker; +import java.lang.foreign.MemoryAddress; +import java.lang.foreign.MemorySession; +import java.lang.foreign.VaList; +import java.lang.foreign.ValueLayout; + +import org.testng.annotations.Test; + +public class TestUnsupportedLinker { + + @Test(expectedExceptions = UnsupportedOperationException.class) + public void testLinker() { + Linker.nativeLinker(); + } + + @Test(expectedExceptions = UnsupportedOperationException.class) + public void testEmptyVaList() { + VaList.empty(); + } + + @Test(expectedExceptions = UnsupportedOperationException.class) + public void testNonEmptyVaList() { + VaList.make(builder -> builder.addVarg(ValueLayout.JAVA_INT, 42), MemorySession.openImplicit()); + } + + @Test(expectedExceptions = UnsupportedOperationException.class) + public void testUnsafeVaList() { + VaList.ofAddress(MemoryAddress.NULL, MemorySession.openImplicit()); + } +} From 36c00fdd74692b85e63e57e192f42c14561efd01 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Wed, 27 Jul 2022 09:50:58 +0000 Subject: [PATCH 3/3] 8291006: java/foreign/TestUnsupportedPlatform fails after JDK-8290455 Reviewed-by: jvernee --- .../java/foreign/TestUnsupportedPlatform.java | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 test/jdk/java/foreign/TestUnsupportedPlatform.java diff --git a/test/jdk/java/foreign/TestUnsupportedPlatform.java b/test/jdk/java/foreign/TestUnsupportedPlatform.java deleted file mode 100644 index 7fd409ed3f5..00000000000 --- a/test/jdk/java/foreign/TestUnsupportedPlatform.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -/* - * @test - * @enablePreview - * @requires !(((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64") - * @run testng/othervm --enable-native-access=ALL-UNNAMED TestUnsupportedPlatform - */ - -import java.lang.foreign.Linker; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertNull; - -// tests run on 32-bit platforms, which are currently not supported -public class TestUnsupportedPlatform { - - @Test(expectedExceptions = ExceptionInInitializerError.class) - public void testNoInitialization() { - Linker.nativeLinker(); // trigger initialization - } - -}