From d1bba53b3043aa20641b5678252b7c910cc89369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sladk=C3=BD?= Date: Wed, 3 Jun 2026 11:27:37 +0200 Subject: [PATCH 1/3] backport 35ad4d570f38830028d86cf0174463d4bace1da5 --- .../InvalidCryptoDisabledAlgos.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java b/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java index 16c9bd65532..98a59dc093c 100644 --- a/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java +++ b/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java @@ -27,7 +27,6 @@ * @modules java.base/sun.security.util * @summary Check that invalid property values for * "jdk.crypto.disabledAlgorithms" are rejected - * @library /test/lib * @run main/othervm InvalidCryptoDisabledAlgos "*" * @run main/othervm InvalidCryptoDisabledAlgos "." * @run main/othervm InvalidCryptoDisabledAlgos ".AES" @@ -38,10 +37,7 @@ * @run main/othervm InvalidCryptoDisabledAlgos "KeyStore.MY,Cipher." * @run main/othervm InvalidCryptoDisabledAlgos "KeyStore.MY,A.B" */ -import java.security.MessageDigest; import java.security.Security; -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; import sun.security.util.CryptoAlgorithmConstraints; public class InvalidCryptoDisabledAlgos { @@ -50,10 +46,19 @@ public static void main(String[] args) throws Exception { System.out.println("Invalid Property Value = " + args[0]); Security.setProperty("jdk.crypto.disabledAlgorithms", args[0]); // Trigger the check to parse and validate property value - Utils.runAndCheckException(() -> CryptoAlgorithmConstraints.permits( - "x", "y"), - t -> Asserts.assertTrue( - t instanceof ExceptionInInitializerError && - t.getCause() instanceof IllegalArgumentException)); + try { + CryptoAlgorithmConstraints.permits("x", "y"); + throw new AssertionError( + "CryptoAlgorithmConstraints.permits() did not generate expected exception"); + } catch (Throwable t) { + if (t instanceof ExceptionInInitializerError + && t.getCause() instanceof IllegalArgumentException) { + // got expected + System.out.println("Received expected exception: " + t); + return; + } else { + throw t; // propagate the original exception + } + } } } From 6c5a88ab86eac26fbe45157c8a060cc330985d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sladk=C3=BD?= Date: Fri, 5 Jun 2026 15:02:39 +0200 Subject: [PATCH 2/3] Actually do the backport instead of using the .diff in the relevant issue --- .../InvalidCryptoDisabledAlgos.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java b/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java index 98a59dc093c..8c930d162bd 100644 --- a/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java +++ b/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java @@ -45,20 +45,18 @@ public class InvalidCryptoDisabledAlgos { public static void main(String[] args) throws Exception { System.out.println("Invalid Property Value = " + args[0]); Security.setProperty("jdk.crypto.disabledAlgorithms", args[0]); - // Trigger the check to parse and validate property value try { + // Trigger the check to parse and validate property value CryptoAlgorithmConstraints.permits("x", "y"); throw new AssertionError( "CryptoAlgorithmConstraints.permits() did not generate expected exception"); } catch (Throwable t) { - if (t instanceof ExceptionInInitializerError - && t.getCause() instanceof IllegalArgumentException) { - // got expected - System.out.println("Received expected exception: " + t); - return; - } else { - throw t; // propagate the original exception + if (!(t instanceof ExceptionInInitializerError) + || !(t.getCause() instanceof IllegalArgumentException)) { + // unexpected exception, propagate it + throw t; } + System.out.println("Received expected exception: " + t); } } } From cff22124f45aff4d3398396646bed3e6fbdeb4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sladk=C3=BD?= Date: Fri, 5 Jun 2026 15:11:10 +0200 Subject: [PATCH 3/3] Add missing comment --- .../util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java b/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java index 8c930d162bd..bc59c85bec1 100644 --- a/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java +++ b/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java @@ -56,6 +56,7 @@ public static void main(String[] args) throws Exception { // unexpected exception, propagate it throw t; } + // got expected System.out.println("Received expected exception: " + t); } }