# HG changeset patch # User shurailine # Date 1398111392 25200 # Node ID 49aa856e6f38485643b5c6e8da56c020b6c41a33 # Parent 16da2a111dd39e2e1eca6ea541d597bbac5b1cfd 8039816: Some tests depend on internal API sun.security.action.GetPropertyAction Summary: Replace sun.security.action.GetPropertyAction usages with lambda expressions creating java.security.PrivilegedAction. Reviewed-by: alanb, mchung, chegar Contributed-by: Alexandre Iline diff -r 16da2a111dd3 -r 49aa856e6f38 jdk/test/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java --- a/jdk/test/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java Mon Apr 21 13:12:22 2014 -0700 +++ b/jdk/test/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java Mon Apr 21 13:16:32 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, 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 @@ -39,13 +39,13 @@ import com.sun.nio.sctp.SctpServerChannel; import com.sun.nio.sctp.SctpSocketOption; import java.security.AccessController; -import sun.security.action.GetPropertyAction; +import java.security.PrivilegedAction; import static com.sun.nio.sctp.SctpStandardSocketOptions.*; import static java.lang.System.out; public class SocketOptionTests { final String osName = AccessController.doPrivileged( - new GetPropertyAction("os.name")); + (PrivilegedAction)() -> System.getProperty("os.name")); void checkOption(SctpChannel sc, SctpSocketOption name, T expectedValue) throws IOException { diff -r 16da2a111dd3 -r 49aa856e6f38 jdk/test/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java --- a/jdk/test/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java Mon Apr 21 13:12:22 2014 -0700 +++ b/jdk/test/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java Mon Apr 21 13:16:32 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, 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 @@ -47,13 +47,13 @@ import com.sun.nio.sctp.SctpServerChannel; import com.sun.nio.sctp.SctpSocketOption; import java.security.AccessController; -import sun.security.action.GetPropertyAction; +import java.security.PrivilegedAction; import static com.sun.nio.sctp.SctpStandardSocketOptions.*; import static java.lang.System.out; public class SocketOptionTests { final String osName = AccessController.doPrivileged( - new GetPropertyAction("os.name")); + (PrivilegedAction)() -> System.getProperty("os.name")); void checkOption(SctpMultiChannel smc, SctpSocketOption name, T expectedValue) throws IOException { diff -r 16da2a111dd3 -r 49aa856e6f38 jdk/test/java/nio/charset/Charset/NIOCharsetAvailabilityTest.java --- a/jdk/test/java/nio/charset/Charset/NIOCharsetAvailabilityTest.java Mon Apr 21 13:12:22 2014 -0700 +++ b/jdk/test/java/nio/charset/Charset/NIOCharsetAvailabilityTest.java Mon Apr 21 13:16:32 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, 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 @@ -36,6 +36,8 @@ import java.net.URL; import java.net.URLClassLoader; import java.nio.charset.Charset; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; @@ -89,12 +91,10 @@ private static void addCharsets(Set charsets, final String packageName) throws Exception { - String classPath = - (String) java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("sun.boot.class.path")); - String s = - (String) java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("java.class.path")); + String classPath = AccessController.doPrivileged( + (PrivilegedAction)() -> System.getProperty("sun.boot.class.path")); + String s = AccessController.doPrivileged( + (PrivilegedAction)() -> System.getProperty("java.class.path")); // Search combined system and application class path if (s != null && s.length() != 0) { diff -r 16da2a111dd3 -r 49aa856e6f38 jdk/test/sun/security/tools/jarsigner/CertChainUnclosed.java --- a/jdk/test/sun/security/tools/jarsigner/CertChainUnclosed.java Mon Apr 21 13:12:22 2014 -0700 +++ b/jdk/test/sun/security/tools/jarsigner/CertChainUnclosed.java Mon Apr 21 13:16:32 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, 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,13 +30,15 @@ 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 = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("os.name")); + String os = AccessController.doPrivileged( + (PrivilegedAction)() -> System.getProperty("os.name")); if (!os.toUpperCase(Locale.US).contains("WINDOWS")) { System.out.println("Not Windows. Skip test."); return;