< prev index next >

src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java

Print this page

 68          * index value in the internal map. The index is stored as a boxed value
 69          * so that we can cheaply do identity comparisons during bootstrap.
 70          */
 71         Mapper(Configuration cf) {
 72             var map = new HashMap<String, Integer>();
 73             for (ResolvedModule resolvedModule : cf.modules()) {
 74                 String mn = resolvedModule.name();
 75                 if (!Modules.bootModules.contains(mn)) {
 76                     if (Modules.platformModules.contains(mn)) {
 77                         map.put(mn, PLATFORM_LOADER_INDEX);
 78                     } else {
 79                         map.put(mn, APP_LOADER_INDEX);
 80                     }
 81                 }
 82             }
 83             this.map = map;
 84         }
 85 
 86         @Override
 87         public ClassLoader apply(String name) {













 88             Integer loader = map.get(name);
 89             if (loader == APP_LOADER_INDEX) {
 90                 return APP_CLASSLOADER;
 91             } else if (loader == PLATFORM_LOADER_INDEX) {
 92                 return PLATFORM_CLASSLOADER;
 93             } else { // BOOT_LOADER_INDEX
 94                 return null;
 95             }
 96         }
 97     }
 98 
 99     /**
100      * Returns the names of the modules defined to the boot loader.
101      */
102     public static Set<String> bootModules() {
103         return Modules.bootModules;
104     }
105 
106     /**
107      * Returns the names of the modules defined to the platform loader.

 68          * index value in the internal map. The index is stored as a boxed value
 69          * so that we can cheaply do identity comparisons during bootstrap.
 70          */
 71         Mapper(Configuration cf) {
 72             var map = new HashMap<String, Integer>();
 73             for (ResolvedModule resolvedModule : cf.modules()) {
 74                 String mn = resolvedModule.name();
 75                 if (!Modules.bootModules.contains(mn)) {
 76                     if (Modules.platformModules.contains(mn)) {
 77                         map.put(mn, PLATFORM_LOADER_INDEX);
 78                     } else {
 79                         map.put(mn, APP_LOADER_INDEX);
 80                     }
 81                 }
 82             }
 83             this.map = map;
 84         }
 85 
 86         @Override
 87         public ClassLoader apply(String name) {
 88             // IOI hack -- force these two modules (if they exist) to be
 89             // loaded from the platform loader.
 90             //
 91             // Otherwise these two modules will be loaded by the app loader, but
 92             // jdk.internal.vm.compiler (loaded by the platform loader) will resolve
 93             // some classes in these two modules. This causes some complications with
 94             // -XX:+PreloadSharedClasses.
 95             if ("org.graalvm.sdk".equals(name)) {
 96                 return PLATFORM_CLASSLOADER;
 97             }
 98             if ("org.graalvm.truffle".equals(name)) {
 99                 return PLATFORM_CLASSLOADER;
100             }
101             Integer loader = map.get(name);
102             if (loader == APP_LOADER_INDEX) {
103                 return APP_CLASSLOADER;
104             } else if (loader == PLATFORM_LOADER_INDEX) {
105                 return PLATFORM_CLASSLOADER;
106             } else { // BOOT_LOADER_INDEX
107                 return null;
108             }
109         }
110     }
111 
112     /**
113      * Returns the names of the modules defined to the boot loader.
114      */
115     public static Set<String> bootModules() {
116         return Modules.bootModules;
117     }
118 
119     /**
120      * Returns the names of the modules defined to the platform loader.
< prev index next >