src/java.base/share/classes/sun/security/provider/Sun.java
changeset 52995 9af672cab7cb
parent 47216 71c04702a3d5
child 57950 4612a3cfb927
--- a/src/java.base/share/classes/sun/security/provider/Sun.java	Thu Dec 13 08:23:56 2018 +0800
+++ b/src/java.base/share/classes/sun/security/provider/Sun.java	Thu Dec 13 01:15:21 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2018, 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
@@ -28,7 +28,6 @@
 import java.util.*;
 import java.security.*;
 
-import sun.security.action.PutAllAction;
 import static sun.security.util.SecurityConstants.PROVIDER_VER;
 
 
@@ -51,17 +50,27 @@
         /* We are the SUN provider */
         super("SUN", PROVIDER_VER, INFO);
 
+        Provider p = this;
+        Iterator<Provider.Service> serviceIter = new SunEntries(p).iterator();
+
         // if there is no security manager installed, put directly into
-        // the provider. Otherwise, create a temporary map and use a
-        // doPrivileged() call at the end to transfer the contents
+        // the provider
         if (System.getSecurityManager() == null) {
-            SunEntries.putEntries(this);
+            putEntries(serviceIter);
         } else {
-            // use LinkedHashMap to preserve the order of the PRNGs
-            Map<Object, Object> map = new LinkedHashMap<>();
-            SunEntries.putEntries(map);
-            AccessController.doPrivileged(new PutAllAction(this, map));
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                @Override
+                public Void run() {
+                    putEntries(serviceIter);
+                    return null;
+                }
+            });
         }
     }
 
+    void putEntries(Iterator<Provider.Service> i) {
+        while (i.hasNext()) {
+            putService(i.next());
+        }
+    }
 }