< prev index next >
src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java
Print this page
*** 104,117 ****
private final BuiltinClassLoader parent;
// 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.
*
* A LoadedModule encapsulates a ModuleReference along with its CodeSource
* URL to avoid needing to create this URL when defining classes.
--- 104,113 ----
*** 157,183 ****
}
return url;
}
}
- static class ArchivedData {
- static Map<String, LoadedModule> packageToModule;
- }
-
// maps package name to loaded module for modules in the boot layer
private static final Map<String, LoadedModule> packageToModule;
-
static {
! VM.initializeFromArchive(ArchivedData.class);
! if (ArchivedData.packageToModule != null) {
! packageToModule = ArchivedData.packageToModule;
} else {
packageToModule = new ConcurrentHashMap<>(1024);
- ArchivedData.packageToModule = packageToModule;
}
}
// maps a module name to a module reference
private final Map<String, ModuleReference> nameToModule;
// maps a module reference to a module reader
private final Map<ModuleReference, ModuleReader> moduleToReader;
--- 153,183 ----
}
return url;
}
}
// maps package name to loaded module for modules in the boot layer
private static final Map<String, LoadedModule> packageToModule;
static {
! ArchivedClassLoaders archivedClassLoaders = ArchivedClassLoaders.get();
! if (archivedClassLoaders != null) {
! @SuppressWarnings("unchecked")
! Map<String, LoadedModule> map
! = (Map<String, LoadedModule>) archivedClassLoaders.packageToModule();
! packageToModule = map;
} else {
packageToModule = new ConcurrentHashMap<>(1024);
}
}
+ /**
+ * Invoked by ArchivedClassLoaders to archive the package-to-module map.
+ */
+ static Map<String, ?> packageToModule() {
+ return packageToModule;
+ }
+
// maps a module name to a module reference
private final Map<String, ModuleReference> nameToModule;
// maps a module reference to a module reader
private final Map<ModuleReference, ModuleReader> moduleToReader;
*** 199,208 ****
--- 199,223 ----
this.nameToModule = new ConcurrentHashMap<>(32);
this.moduleToReader = new ConcurrentHashMap<>();
}
/**
+ * 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.
*/
boolean hasClassPath() {
return ucp != null;
< prev index next >