8038177: Eliminate unnecessary dependency to sun.security.action
authormchung
Wed, 26 Mar 2014 09:00:49 -0700
changeset 23582 d5fa3327ab3a
parent 23581 0ca496340112
child 23583 1bee92aa2f1f
8038177: Eliminate unnecessary dependency to sun.security.action Reviewed-by: chegar, alanb
jdk/src/share/classes/com/sun/java/browser/dom/DOMService.java
jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java
jdk/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java
jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java
jdk/src/share/classes/sun/security/smartcardio/ChannelImpl.java
jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java
jdk/src/solaris/classes/sun/nio/ch/sctp/SctpNet.java
jdk/src/windows/classes/sun/security/mscapi/KeyStore.java
jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.java
--- a/jdk/src/share/classes/com/sun/java/browser/dom/DOMService.java	Wed Mar 26 12:25:09 2014 +0000
+++ b/jdk/src/share/classes/com/sun/java/browser/dom/DOMService.java	Wed Mar 26 09:00:49 2014 -0700
@@ -25,6 +25,9 @@
 
 package com.sun.java.browser.dom;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 public abstract class DOMService
 {
     /**
@@ -43,8 +46,9 @@
     {
         try
         {
-            String provider = java.security.AccessController.doPrivileged(
-                   new sun.security.action.GetPropertyAction("com.sun.java.browser.dom.DOMServiceProvider"));
+            String provider = AccessController.doPrivileged(
+                (PrivilegedAction<String>) () ->
+                    System.getProperty("com.sun.java.browser.dom.DOMServiceProvider"));
 
             Class clazz = Class.forName("sun.plugin.dom.DOMService");
 
--- a/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java	Wed Mar 26 12:25:09 2014 +0000
+++ b/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java	Wed Mar 26 09:00:49 2014 -0700
@@ -30,8 +30,7 @@
 import java.nio.charset.spi.CharsetProvider;
 import sun.nio.cs.AbstractCharsetProvider;
 import java.security.AccessController;
-import sun.security.action.GetPropertyAction;
-
+import java.security.PrivilegedAction;
 
 /**
  * Provider for extended charsets.
@@ -1175,7 +1174,7 @@
             return;
 
         String map = AccessController.doPrivileged(
-            new GetPropertyAction("sun.nio.cs.map"));
+            (PrivilegedAction<String>) () -> System.getProperty("sun.nio.cs.map"));
         boolean sjisIsMS932 = false;
         boolean iso2022jpIsMS50221 = false;
         boolean iso2022jpIsMS50220 = false;
@@ -1296,7 +1295,7 @@
             }
         }
         String osName = AccessController.doPrivileged(
-            new GetPropertyAction("os.name"));
+            (PrivilegedAction<String>) () -> System.getProperty("os.name"));
         if ("SunOS".equals(osName) || "Linux".equals(osName) || "AIX".equals(osName)
                || osName.contains("OS X")) {
             charset("x-COMPOUND_TEXT", "COMPOUND_TEXT",
--- a/jdk/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java	Wed Mar 26 12:25:09 2014 +0000
+++ b/jdk/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java	Wed Mar 26 09:00:49 2014 -0700
@@ -35,7 +35,7 @@
 import java.nio.charset.MalformedInputException;
 import sun.nio.cs.HistoricallyNamedCharset;
 import java.security.AccessController;
-import sun.security.action.GetPropertyAction;
+import java.security.PrivilegedAction;
 import static java.lang.Character.UnicodeBlock;
 
 
@@ -239,12 +239,13 @@
             return ((CharsetDecoder) detectedDecoder).charset();
         }
 
+        private static final String osName = AccessController.doPrivileged(
+            (PrivilegedAction<String>) () -> System.getProperty("os.name"));
+
         /**
          * Returned Shift_JIS Charset name is OS dependent
          */
         private static String getSJISName() {
-            String osName = AccessController.doPrivileged(
-                new GetPropertyAction("os.name"));
             if (osName.equals("Solaris") || osName.equals("SunOS"))
                 return("PCK");
             else if (osName.startsWith("Windows"))
@@ -258,8 +259,6 @@
          */
 
         private static String getEUCJPName() {
-            String osName = AccessController.doPrivileged(
-                new GetPropertyAction("os.name"));
             if (osName.equals("Solaris") || osName.equals("SunOS"))
                 return("x-eucjp-open");
             else
--- a/jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java	Wed Mar 26 12:25:09 2014 +0000
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java	Wed Mar 26 09:00:49 2014 -0700
@@ -50,8 +50,6 @@
 import sun.security.util.Cache;
 import sun.security.util.Debug;
 import sun.security.x509.X500Name;
-import sun.security.action.GetBooleanAction;
-import sun.security.action.GetPropertyAction;
 
 /**
  * A <code>CertStore</code> that retrieves <code>Certificates</code> and
@@ -146,7 +144,7 @@
 
     static {
         String s = AccessController.doPrivileged(
-                                new GetPropertyAction(PROP_LIFETIME));
+            (PrivilegedAction<String>) () -> System.getProperty(PROP_LIFETIME));
         if (s != null) {
             LIFETIME = Integer.parseInt(s); // throws NumberFormatException
         } else {
@@ -249,7 +247,7 @@
 
         // If property is set to true, disable application resource file lookup.
         boolean disableAppResourceFiles = AccessController.doPrivileged(
-            new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
+            (PrivilegedAction<Boolean>) () -> Boolean.getBoolean(PROP_DISABLE_APP_RESOURCE_FILES));
         if (disableAppResourceFiles) {
             if (debug != null) {
                 debug.println("LDAPCertStore disabling app resource files");
--- a/jdk/src/share/classes/sun/security/smartcardio/ChannelImpl.java	Wed Mar 26 12:25:09 2014 +0000
+++ b/jdk/src/share/classes/sun/security/smartcardio/ChannelImpl.java	Wed Mar 26 09:00:49 2014 -0700
@@ -27,13 +27,12 @@
 
 import java.nio.*;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import javax.smartcardio.*;
 
 import static sun.security.smartcardio.PCSC.*;
 
-import sun.security.action.GetPropertyAction;
-
 /**
  * CardChannel implementation.
  *
@@ -125,7 +124,8 @@
         getBooleanProperty("sun.security.smartcardio.t1StripLe", false);
 
     private static boolean getBooleanProperty(String name, boolean def) {
-        String val = AccessController.doPrivileged(new GetPropertyAction(name));
+        String val = AccessController.doPrivileged(
+            (PrivilegedAction<String>) () -> System.getProperty(name));
         if (val == null) {
             return def;
         }
--- a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Wed Mar 26 12:25:09 2014 +0000
+++ b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Wed Mar 26 09:00:49 2014 -0700
@@ -61,10 +61,8 @@
      * Sync interval in seconds.
      */
     private static final int SYNC_INTERVAL = Math.max(1,
-        Integer.parseInt(
-            AccessController.doPrivileged(
-                new sun.security.action.GetPropertyAction(
-                    "java.util.prefs.syncInterval", "30"))));
+        AccessController.doPrivileged((PrivilegedAction<Integer>) () ->
+             Integer.getInteger("java.util.prefs.syncInterval", 30)));
 
     /**
      * Returns logger for error messages. Backing store exceptions are logged at
--- a/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpNet.java	Wed Mar 26 12:25:09 2014 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpNet.java	Wed Mar 26 09:00:49 2014 -0700
@@ -33,15 +33,15 @@
 import java.util.Set;
 import java.util.HashSet;
 import java.security.AccessController;
-import sun.security.action.GetPropertyAction;
+import java.security.PrivilegedAction;
 import sun.nio.ch.IOUtil;
 import sun.nio.ch.Net;
 import com.sun.nio.sctp.SctpSocketOption;
 import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
 
 public class SctpNet {
-    static final String osName = AccessController.doPrivileged(
-                    new GetPropertyAction("os.name"));
+    private static final String osName = AccessController.doPrivileged(
+        (PrivilegedAction<String>) () -> System.getProperty("os.name"));
 
     /* -- Miscellaneous SCTP utilities -- */
 
--- a/jdk/src/windows/classes/sun/security/mscapi/KeyStore.java	Wed Mar 26 12:25:09 2014 +0000
+++ b/jdk/src/windows/classes/sun/security/mscapi/KeyStore.java	Wed Mar 26 09:00:49 2014 -0700
@@ -33,6 +33,7 @@
 import java.security.InvalidKeyException;
 import java.security.KeyStoreSpi;
 import java.security.KeyStoreException;
+import java.security.PrivilegedAction;
 import java.security.UnrecoverableKeyException;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecurityPermission;
@@ -48,8 +49,6 @@
 import java.util.Iterator;
 import java.util.UUID;
 
-import sun.security.action.GetPropertyAction;
-
 /**
  * Implementation of key store for Windows using the Microsoft Crypto API.
  *
@@ -205,9 +204,8 @@
 
     KeyStore(String storeName) {
         // Get the compatibility mode
-        String prop =
-            AccessController.doPrivileged(
-                new GetPropertyAction(KEYSTORE_COMPATIBILITY_MODE_PROP));
+        String prop = AccessController.doPrivileged(
+            (PrivilegedAction<String>) () -> System.getProperty(KEYSTORE_COMPATIBILITY_MODE_PROP));
 
         if ("false".equalsIgnoreCase(prop)) {
             keyStoreCompatibilityMode = false;
--- a/jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.java	Wed Mar 26 12:25:09 2014 +0000
+++ b/jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.java	Wed Mar 26 09:00:49 2014 -0700
@@ -31,9 +31,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import sun.security.action.PutAllAction;
-
-
 /**
  * A Cryptographic Service Provider for the Microsoft Crypto API.
  *
@@ -140,7 +137,12 @@
         map.put("Cipher.RSA SupportedKeyClasses", "sun.security.mscapi.Key");
 
         if (map != this) {
-            AccessController.doPrivileged(new PutAllAction(this, map));
+            final Provider provider = this;
+            PrivilegedAction<Void> putAllAction = () -> {
+                provider.putAll(map);
+                return null;
+            };
+            AccessController.doPrivileged(putAllAction);
         }
     }
 }