< prev index next >

jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java

Print this page




 128         ModuleReference mref() { return mref; }
 129         String name() { return mref.descriptor().name(); }
 130         URL codeSourceURL() { return codeSourceURL; }
 131     }
 132 
 133 
 134     // maps package name to loaded module for modules in the boot layer
 135     private static final Map<String, LoadedModule> packageToModule
 136         = new ConcurrentHashMap<>(1024);
 137 
 138     // maps a module name to a module reference
 139     private final Map<String, ModuleReference> nameToModule;
 140 
 141     // maps a module reference to a module reader
 142     private final Map<ModuleReference, ModuleReader> moduleToReader;
 143 
 144 
 145     /**
 146      * Create a new instance.
 147      */
 148     BuiltinClassLoader(BuiltinClassLoader parent, URLClassPath ucp) {
 149         // ensure getParent() returns null when the parent is the boot loader
 150         super(parent == null || parent == ClassLoaders.bootLoader() ? null : parent);
 151 
 152         this.parent = parent;
 153         this.ucp = ucp;
 154 
 155         this.nameToModule = new ConcurrentHashMap<>();
 156         this.moduleToReader = new ConcurrentHashMap<>();
 157     }
 158 
 159     /**
 160      * Register a module this this class loader. This has the effect of making
 161      * the types in the module visible.
 162      */
 163     public void loadModule(ModuleReference mref) {
 164         String mn = mref.descriptor().name();
 165         if (nameToModule.putIfAbsent(mn, mref) != null) {
 166             throw new InternalError(mn + " already defined to this loader");
 167         }
 168 
 169         LoadedModule loadedModule = new LoadedModule(this, mref);
 170         for (String pn : mref.descriptor().packages()) {




 128         ModuleReference mref() { return mref; }
 129         String name() { return mref.descriptor().name(); }
 130         URL codeSourceURL() { return codeSourceURL; }
 131     }
 132 
 133 
 134     // maps package name to loaded module for modules in the boot layer
 135     private static final Map<String, LoadedModule> packageToModule
 136         = new ConcurrentHashMap<>(1024);
 137 
 138     // maps a module name to a module reference
 139     private final Map<String, ModuleReference> nameToModule;
 140 
 141     // maps a module reference to a module reader
 142     private final Map<ModuleReference, ModuleReader> moduleToReader;
 143 
 144 
 145     /**
 146      * Create a new instance.
 147      */
 148     BuiltinClassLoader(String name, BuiltinClassLoader parent, URLClassPath ucp) {
 149         // ensure getParent() returns null when the parent is the boot loader
 150         super(name, parent == null || parent == ClassLoaders.bootLoader() ? null : parent);
 151 
 152         this.parent = parent;
 153         this.ucp = ucp;
 154 
 155         this.nameToModule = new ConcurrentHashMap<>();
 156         this.moduleToReader = new ConcurrentHashMap<>();
 157     }
 158 
 159     /**
 160      * Register a module this this class loader. This has the effect of making
 161      * the types in the module visible.
 162      */
 163     public void loadModule(ModuleReference mref) {
 164         String mn = mref.descriptor().name();
 165         if (nameToModule.putIfAbsent(mn, mref) != null) {
 166             throw new InternalError(mn + " already defined to this loader");
 167         }
 168 
 169         LoadedModule loadedModule = new LoadedModule(this, mref);
 170         for (String pn : mref.descriptor().packages()) {


< prev index next >