jdk/src/java.base/share/classes/java/security/ProtectionDomain.java
changeset 37882 e7f3cf12e739
parent 37880 60ec48925dc6
child 39747 2d542b973871
equal deleted inserted replaced
37881:fda31effa7b3 37882:e7f3cf12e739
   137     /*
   137     /*
   138      * An object used as a key when the ProtectionDomain is stored in a Map.
   138      * An object used as a key when the ProtectionDomain is stored in a Map.
   139      */
   139      */
   140     final Key key = new Key();
   140     final Key key = new Key();
   141 
   141 
   142     private static final Debug debug = Debug.getInstance("domain");
       
   143 
       
   144     /**
   142     /**
   145      * Creates a new ProtectionDomain with the given CodeSource and
   143      * Creates a new ProtectionDomain with the given CodeSource and
   146      * Permissions. If the permissions object is not null, then
   144      * Permissions. If the permissions object is not null, then
   147      *  {@code setReadOnly()} will be called on the passed in
   145      *  {@code setReadOnly()} will be called on the passed in
   148      * Permissions object. The only permissions granted to this domain
   146      * Permissions object. The only permissions granted to this domain
   336             " "+classloader+"\n"+
   334             " "+classloader+"\n"+
   337             " "+pals+"\n"+
   335             " "+pals+"\n"+
   338             " "+pc+"\n";
   336             " "+pc+"\n";
   339     }
   337     }
   340 
   338 
       
   339     /*
       
   340      * holder class for the static field "debug" to delay its initialization
       
   341      */
       
   342     private static class DebugHolder {
       
   343         private static final Debug debug = Debug.getInstance("domain");
       
   344     }
       
   345 
   341     /**
   346     /**
   342      * Return true (merge policy permissions) in the following cases:
   347      * Return true (merge policy permissions) in the following cases:
   343      *
   348      *
   344      * . SecurityManager is null
   349      * . SecurityManager is null
   345      *
   350      *
   357         SecurityManager sm = System.getSecurityManager();
   362         SecurityManager sm = System.getSecurityManager();
   358 
   363 
   359         if (sm == null) {
   364         if (sm == null) {
   360             return true;
   365             return true;
   361         } else {
   366         } else {
   362             if (debug != null) {
   367             if (DebugHolder.debug != null) {
   363                 if (sm.getClass().getClassLoader() == null &&
   368                 if (sm.getClass().getClassLoader() == null &&
   364                     Policy.getPolicyNoCheck().getClass().getClassLoader()
   369                     Policy.getPolicyNoCheck().getClass().getClassLoader()
   365                                                                 == null) {
   370                                                                 == null) {
   366                     return true;
   371                     return true;
   367                 }
   372                 }