--- old/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java 2020-08-12 15:01:16.785279658 -0700 +++ new/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java 2020-08-12 15:01:16.177256771 -0700 @@ -104,8 +104,7 @@ private final BuiltinClassLoader parent; // the URL class path, or null if there is no class path - private final URLClassPath ucp; - + private @Stable URLClassPath ucp; /** * A module defined/loaded by a built-in class loader. @@ -156,10 +155,26 @@ } } - // maps package name to loaded module for modules in the boot layer - private static final Map packageToModule - = new ConcurrentHashMap<>(1024); + private static final Map packageToModule; + static { + ArchivedClassLoaders archivedClassLoaders = ArchivedClassLoaders.get(); + if (archivedClassLoaders != null) { + @SuppressWarnings("unchecked") + Map map + = (Map) archivedClassLoaders.packageToModule(); + packageToModule = map; + } else { + packageToModule = new ConcurrentHashMap<>(1024); + } + } + + /** + * Invoked by ArchivedClassLoaders to archive the package-to-module map. + */ + static Map packageToModule() { + return packageToModule; + } // maps a module name to a module reference private final Map nameToModule; @@ -186,6 +201,21 @@ } /** + * Appends to the given file path to the class path. + */ + void appendClassPath(String path) { + // assert ucp != null; + ucp.addFile(path); + } + + /** + * Sets the class path, called to reset the class path during -Xshare:dump + */ + void setClassPath(URLClassPath ucp) { + this.ucp = ucp; + } + + /** * Returns {@code true} if there is a class path associated with this * class loader. */ @@ -1042,4 +1072,9 @@ private static URL checkURL(URL url) { return URLClassPath.checkURL(url); } + + // Called from VM only, during -Xshare:dump + private void resetArchivedStates() { + ucp = null; + } }