From ff538c7f5641bb24748243da44de5d964141ae31 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Sat, 13 Sep 2025 13:51:17 +0000 Subject: [PATCH] 8367583: sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java fails after JDK-8244336 Reviewed-by: weijun --- .../InvalidCryptoDisabledAlgos.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java b/test/jdk/sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java index 16c9bd65532..bc59c85bec1 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 { @@ -49,11 +45,19 @@ 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 - Utils.runAndCheckException(() -> CryptoAlgorithmConstraints.permits( - "x", "y"), - t -> Asserts.assertTrue( - t instanceof ExceptionInInitializerError && - t.getCause() instanceof IllegalArgumentException)); + 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)) { + // unexpected exception, propagate it + throw t; + } + // got expected + System.out.println("Received expected exception: " + t); + } } }