changeset 11587:552953ba78bf

8138811: Construction of static protection domains Reviewed-by: valeriep
author igerasim
date Tue, 05 Jan 2016 19:30:06 +0300
parents 4c53be81bc7a
children dcacefa73649
files src/share/classes/java/security/ProtectionDomain.java src/share/classes/javax/security/auth/SubjectDomainCombiner.java src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java
diffstat 3 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/security/ProtectionDomain.java	Mon Dec 21 10:43:40 2015 -0800
+++ b/src/share/classes/java/security/ProtectionDomain.java	Tue Jan 05 19:30:06 2016 +0300
@@ -475,6 +475,11 @@
                         }
                     };
                 }
+
+                @Override
+                public boolean getStaticPermissionsField(ProtectionDomain pd) {
+                    return pd.staticPermissions;
+                }
             });
     }
 }
--- a/src/share/classes/javax/security/auth/SubjectDomainCombiner.java	Mon Dec 21 10:43:40 2015 -0800
+++ b/src/share/classes/javax/security/auth/SubjectDomainCombiner.java	Tue Jan 05 19:30:06 2016 +0300
@@ -37,6 +37,8 @@
 import java.util.Set;
 import java.util.WeakHashMap;
 import java.lang.ref.WeakReference;
+import sun.misc.SharedSecrets;
+import sun.misc.JavaSecurityProtectionDomainAccess;
 
 /**
  * A {@code SubjectDomainCombiner} updates ProtectionDomains
@@ -65,6 +67,9 @@
     private static final boolean allowCaching =
                                         (useJavaxPolicy && cachePolicy());
 
+    private static final JavaSecurityProtectionDomainAccess pdAccess =
+        SharedSecrets.getJavaSecurityProtectionDomainAccess();
+
     /**
      * Associate the provided {@code Subject} with this
      * {@code SubjectDomainCombiner}.
@@ -239,10 +244,15 @@
                 subjectPd = cachedPDs.getValue(pd);
 
                 if (subjectPd == null) {
-                    subjectPd = new ProtectionDomain(pd.getCodeSource(),
+                    if (pdAccess.getStaticPermissionsField(pd)) {
+                        // Need to keep static ProtectionDomain objects static
+                        subjectPd = pd;
+                    } else {
+                        subjectPd = new ProtectionDomain(pd.getCodeSource(),
                                                 pd.getPermissions(),
                                                 pd.getClassLoader(),
                                                 principals);
+                    }
                     cachedPDs.putValue(pd, subjectPd);
                 } else {
                     allNew = false;
--- a/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java	Mon Dec 21 10:43:40 2015 -0800
+++ b/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java	Tue Jan 05 19:30:06 2016 +0300
@@ -36,4 +36,9 @@
      * Returns the ProtectionDomainCache.
      */
     ProtectionDomainCache getProtectionDomainCache();
+
+    /**
+     * Returns the staticPermissions field of the specified object
+     */
+    boolean getStaticPermissionsField(ProtectionDomain pd);
 }