< prev index next >

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

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 1997, 2024, 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
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

@@ -29,10 +29,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 which are
   * retrieved by the system policy by default.

@@ -258,8 +259,17 @@
  
      /**
       * Called by the VM, during -Xshare:dump
       */
      private void resetArchivedStates() {
-         pdcache.clear();
+         if (CDS.isDumpingProtectionDomains()) {
+             if (System.getProperty("cds.debug.archived.protection.domains") != null) {
+                 for (Map.Entry<CodeSourceKey, ProtectionDomain> entry : pdcache.entrySet()) {
+                     CodeSourceKey key = entry.getKey();
+                     System.out.println("Archiving ProtectionDomain " + key.cs + " for " + this);
+                 }
+             }            
+         } else {
+             pdcache.clear();
+         }
      }
  }
< prev index next >