98
99 // the URL class path or null if there is no class path
100 private final URLClassPath ucp;
101
102
103 /**
104 * A module defined/loaded by a built-in class loader.
105 *
106 * A LoadedModule encapsulates a ModuleReference along with its CodeSource
107 * URL to avoid needing to create this URL when define classes.
108 */
109 private static class LoadedModule {
110 private final BuiltinClassLoader loader;
111 private final ModuleReference mref;
112 private final URL codeSourceURL; // may be null
113
114 LoadedModule(BuiltinClassLoader loader, ModuleReference mref) {
115 URL url = null;
116 if (mref.location().isPresent()) {
117 try {
118 url = mref.location().get().toURL();
119 } catch (MalformedURLException e) { }
120 }
121 this.loader = loader;
122 this.mref = mref;
123 this.codeSourceURL = url;
124 }
125
126 BuiltinClassLoader loader() { return loader; }
127 ModuleReference mref() { return mref; }
128 String name() { return mref.descriptor().name(); }
129 URL codeSourceURL() { return codeSourceURL; }
130 }
131
132
133 // maps package name to loaded module for modules in the boot layer
134 private static final Map<String, LoadedModule> packageToModule
135 = new ConcurrentHashMap<>(1024);
136
137 // maps a module name to a module reference
138 private final Map<String, ModuleReference> nameToModule;
|
98
99 // the URL class path or null if there is no class path
100 private final URLClassPath ucp;
101
102
103 /**
104 * A module defined/loaded by a built-in class loader.
105 *
106 * A LoadedModule encapsulates a ModuleReference along with its CodeSource
107 * URL to avoid needing to create this URL when define classes.
108 */
109 private static class LoadedModule {
110 private final BuiltinClassLoader loader;
111 private final ModuleReference mref;
112 private final URL codeSourceURL; // may be null
113
114 LoadedModule(BuiltinClassLoader loader, ModuleReference mref) {
115 URL url = null;
116 if (mref.location().isPresent()) {
117 try {
118 url = mref.location().getWhenPresent().toURL();
119 } catch (MalformedURLException e) { }
120 }
121 this.loader = loader;
122 this.mref = mref;
123 this.codeSourceURL = url;
124 }
125
126 BuiltinClassLoader loader() { return loader; }
127 ModuleReference mref() { return mref; }
128 String name() { return mref.descriptor().name(); }
129 URL codeSourceURL() { return codeSourceURL; }
130 }
131
132
133 // maps package name to loaded module for modules in the boot layer
134 private static final Map<String, LoadedModule> packageToModule
135 = new ConcurrentHashMap<>(1024);
136
137 // maps a module name to a module reference
138 private final Map<String, ModuleReference> nameToModule;
|