diff --git a/test/jdk/java/security/AccessControlContext/FailureDebugOption.java b/test/jdk/java/security/AccessControlContext/FailureDebugOption.java deleted file mode 100644 index 2c0dd489c70de..0000000000000 --- a/test/jdk/java/security/AccessControlContext/FailureDebugOption.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2008, 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 - * @bug 6648816 - * @summary REGRESSION: setting -Djava.security.debug=failure result in NPE - * in ACC - * @run main/othervm -Djava.security.debug=failure FailureDebugOption - */ - -import java.security.ProtectionDomain; -import java.security.AccessController; -import java.security.AccessControlException; -import java.security.BasicPermission; - -public class FailureDebugOption { - - public static void main (String argv[]) throws Exception { - try { - AccessController.checkPermission( - new BasicPermission("no such permission"){}); - } catch (NullPointerException npe) { - throw new Exception("Unexpected NullPointerException for security" + - " debug option, -Djava.security.debug=failure"); - } catch (AccessControlException ace) { - } - } -} diff --git a/test/jdk/java/security/cert/CertPathBuilder/GetInstance.java b/test/jdk/java/security/cert/CertPathBuilder/GetInstance.java index 5ec4d6caa5a79..4289fcfaeced7 100644 --- a/test/jdk/java/security/cert/CertPathBuilder/GetInstance.java +++ b/test/jdk/java/security/cert/CertPathBuilder/GetInstance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -30,11 +30,7 @@ * The test passes if it returns. * The test fails if an exception is thrown. */ -import java.security.cert.CertPathParameters; -import java.security.cert.CertPathBuilderResult; -import java.security.cert.CertPathBuilderSpi; import java.security.Provider; -import java.security.AccessController; import java.security.cert.CertPathBuilder; import java.security.NoSuchAlgorithmException; diff --git a/test/jdk/sun/security/pkcs11/PKCS11Test.java b/test/jdk/sun/security/pkcs11/PKCS11Test.java index 237436094ac6e..b624afd69fb3c 100644 --- a/test/jdk/sun/security/pkcs11/PKCS11Test.java +++ b/test/jdk/sun/security/pkcs11/PKCS11Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, 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 @@ -37,7 +37,6 @@ import java.security.InvalidAlgorithmParameterException; import java.security.KeyPairGenerator; import java.security.NoSuchProviderException; -import java.security.Policy; import java.security.Provider; import java.security.ProviderException; import java.security.SecureRandom; diff --git a/test/jdk/sun/security/tools/jarsigner/CertChainUnclosed.java b/test/jdk/sun/security/tools/jarsigner/CertChainUnclosed.java index 7ec4d88d73a0f..d658dd9504c55 100644 --- a/test/jdk/sun/security/tools/jarsigner/CertChainUnclosed.java +++ b/test/jdk/sun/security/tools/jarsigner/CertChainUnclosed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, 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 @@ -32,15 +32,12 @@ import java.nio.file.Files; import java.nio.file.Paths; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Locale; public class CertChainUnclosed { public static void main(String[] args) throws Exception { - String os = AccessController.doPrivileged( - (PrivilegedAction)() -> System.getProperty("os.name")); + String os = System.getProperty("os.name"); if (!os.toUpperCase(Locale.US).contains("WINDOWS")) { System.out.println("Not Windows. Skip test."); return; diff --git a/test/jdk/sun/security/x509/AVA/AVAEqualsHashCode.java b/test/jdk/sun/security/x509/AVA/AVAEqualsHashCode.java index 20beb8db63922..60fe9775c82dd 100644 --- a/test/jdk/sun/security/x509/AVA/AVAEqualsHashCode.java +++ b/test/jdk/sun/security/x509/AVA/AVAEqualsHashCode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, 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 @@ -49,9 +49,7 @@ public static void main(String[] args) throws Exception { byte[] ba = deros.toByteArray(); DerValue dv = new DerValue(ba); - GetAVAConstructor a = new GetAVAConstructor(); - java.security.AccessController.doPrivileged(a); - Constructor c = a.getCons(); + Constructor c = getAVAConstructor(); Object[] objs = new Object[2]; objs[0] = oid; @@ -72,16 +70,10 @@ public static void main(String[] args) throws Exception { else throw new Exception("FAILED equals()/hashCode() contract"); } -} - -class GetAVAConstructor implements java.security.PrivilegedExceptionAction { - private Class avaClass = null; - private Constructor avaCons = null; - - public Object run() throws Exception { + static Constructor getAVAConstructor() throws Exception { try { - avaClass = Class.forName("sun.security.x509.AVA"); + Class avaClass = Class.forName("sun.security.x509.AVA"); Constructor[] cons = avaClass.getDeclaredConstructors(); int i; @@ -90,22 +82,16 @@ public Object run() throws Exception { if (parms.length == 2) { if (parms[0].getName().equalsIgnoreCase("sun.security.util.ObjectIdentifier") && parms[1].getName().equalsIgnoreCase("sun.security.util.DerValue")) { - avaCons = cons[i]; + Constructor avaCons = cons[i]; avaCons.setAccessible(true); - break; + return avaCons; } } } - + return null; } catch (Exception e) { System.out.println("Caught unexpected exception " + e); throw e; } - return avaCons; } - - public Constructor getCons(){ - return avaCons; - } - } diff --git a/test/lib/jdk/test/lib/net/SimpleSSLContext.java b/test/lib/jdk/test/lib/net/SimpleSSLContext.java index 85f31e524f93f..3c26809f1283e 100644 --- a/test/lib/jdk/test/lib/net/SimpleSSLContext.java +++ b/test/lib/jdk/test/lib/net/SimpleSSLContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, 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 @@ -48,8 +48,7 @@ public SimpleSSLContext() throws IOException { } private SimpleSSLContext(Supplier protocols) throws IOException { - final String proto = protocols.get(); - + String proto = protocols.get(); String paths = System.getProperty("test.src.path"); StringTokenizer st = new StringTokenizer(paths, File.pathSeparator); while (st.hasMoreTokens()) { @@ -58,6 +57,7 @@ private SimpleSSLContext(Supplier protocols) throws IOException { if (f.exists()) { try (FileInputStream fis = new FileInputStream(f)) { init(fis, proto); + break; } } }