diff -r d590cf6b4fac -r 9af672cab7cb src/java.base/share/classes/sun/security/rsa/SunRsaSign.java --- a/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java Thu Dec 13 08:23:56 2018 +0800 +++ b/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java Thu Dec 13 01:15:21 2018 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -29,7 +29,6 @@ import java.security.*; -import sun.security.action.PutAllAction; import static sun.security.util.SecurityConstants.PROVIDER_VER; /** @@ -46,17 +45,24 @@ public SunRsaSign() { super("SunRsaSign", PROVIDER_VER, "Sun RSA signature provider"); - // 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 + Provider p = this; + Iterator serviceIter = new SunRsaSignEntries(p).iterator(); + if (System.getSecurityManager() == null) { - SunRsaSignEntries.putEntries(this); + putEntries(serviceIter); } else { - // use LinkedHashMap to preserve the order of the PRNGs - Map map = new HashMap<>(); - SunRsaSignEntries.putEntries(map); - AccessController.doPrivileged(new PutAllAction(this, map)); + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + putEntries(serviceIter); + return null; + } + }); } } - + void putEntries(Iterator i) { + while (i.hasNext()) { + putService(i.next()); + } + } }