--- old/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java 2020-08-12 15:04:54.749484219 -0700 +++ new/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java 2020-08-12 15:04:54.541476389 -0700 @@ -106,10 +106,6 @@ // the URL class path, or null if there is no class path private @Stable URLClassPath ucp; - void setClassPath(URLClassPath ucp) { - this.ucp = ucp; - } - /** * A module defined/loaded by a built-in class loader. * @@ -159,23 +155,27 @@ } } - static class ArchivedData { - static Map packageToModule; - } - // maps package name to loaded module for modules in the boot layer private static final Map packageToModule; - static { - VM.initializeFromArchive(ArchivedData.class); - if (ArchivedData.packageToModule != null) { - packageToModule = ArchivedData.packageToModule; + ArchivedClassLoaders archivedClassLoaders = ArchivedClassLoaders.get(); + if (archivedClassLoaders != null) { + @SuppressWarnings("unchecked") + Map map + = (Map) archivedClassLoaders.packageToModule(); + packageToModule = map; } else { packageToModule = new ConcurrentHashMap<>(1024); - ArchivedData.packageToModule = packageToModule; } } + /** + * 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; @@ -201,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. */