diff --git a/test/jdk/java/foreign/TestDowncall.java b/test/jdk/java/foreign/TestDowncall.java index 40cc6cb45fa9..9fd2e8cffbfb 100644 --- a/test/jdk/java/foreign/TestDowncall.java +++ b/test/jdk/java/foreign/TestDowncall.java @@ -28,7 +28,7 @@ * @modules jdk.incubator.foreign/jdk.internal.foreign * @build NativeTestHelper CallGeneratorHelper TestDowncall * - * @run testng/othervm + * @run testng/othervm/timeout=240 * --enable-native-access=ALL-UNNAMED * TestDowncall */ diff --git a/test/jdk/java/foreign/TestResourceScope.java b/test/jdk/java/foreign/TestResourceScope.java index 829859677bd7..7df9790668a0 100644 --- a/test/jdk/java/foreign/TestResourceScope.java +++ b/test/jdk/java/foreign/TestResourceScope.java @@ -127,7 +127,14 @@ public void testSharedMultiThread(Supplier cleanerSupplier) { // if no cleaner, close - not all segments might have been added to the scope! // if cleaner, don't unset the scope - after all, the scope is kept alive by threads if (cleaner == null) { - scope.close(); + while (true) { + try { + scope.close(); + break; + } catch (IllegalStateException ise) { + // scope is acquired (by add) - wait some more + } + } } threads.forEach(t -> { diff --git a/test/jdk/java/foreign/TestUpcall.java b/test/jdk/java/foreign/TestUpcall.java index c6e8835df6e7..229147c81f73 100644 --- a/test/jdk/java/foreign/TestUpcall.java +++ b/test/jdk/java/foreign/TestUpcall.java @@ -28,7 +28,7 @@ * @modules jdk.incubator.foreign/jdk.internal.foreign * @build NativeTestHelper CallGeneratorHelper TestUpcall * - * @run testng/othervm + * @run testng/othervm/timeout=240 * --enable-native-access=ALL-UNNAMED * TestUpcall */