< prev index next >

src/java.base/share/classes/java/security/SecureClassLoader.java

Print this page
*** 27,10 ***
--- 27,11 ---
  
  import java.util.Map;
  import java.util.Objects;
  import java.util.concurrent.ConcurrentHashMap;
  import java.util.function.Function;
+ import jdk.internal.misc.CDS;
  
  /**
   * This class extends {@code ClassLoader} with additional support for defining
   * classes with an associated code source and permissions.
   *

*** 241,8 ***
  
      /**
       * Called by the VM, during -Xshare:dump
       */
      private void resetArchivedStates() {
!         pdcache.clear();
      }
  }
--- 242,22 ---
  
      /**
       * Called by the VM, during -Xshare:dump
       */
      private void resetArchivedStates() {
!         if (CDS.isDumpingProtectionDomains()) {
+             for (CodeSourceKey key : pdcache.keySet()) {
+                 if (key.cs.getCodeSigners() != null) {
+                     // We don't archive any signed classes, so we don't need to cache their ProtectionDomains.
+                     pdcache.remove(key);
+                 }
+             }
+             if (System.getProperty("cds.debug.archived.protection.domains") != null) {
+                 for (CodeSourceKey key : pdcache.keySet()) {
+                     System.out.println("Archiving ProtectionDomain " + key.cs + " for " + this);
+                 }
+             }
+         } else {
+             pdcache.clear();
+         }
      }
  }
< prev index next >