< prev index next >

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

Print this page

        

*** 47,58 **** --- 47,60 ---- import java.util.Set; import java.util.function.Function; import jdk.internal.loader.BootLoader; import jdk.internal.loader.BuiltinClassLoader; + import jdk.internal.misc.JavaLangModuleAccess; import jdk.internal.misc.SharedSecrets; import jdk.internal.perf.PerfCounter; + import static jdk.internal.module.WarnIfResolvedReason.*; /** * Initializes/boots the module system. * * The {@link #boot() boot} method is called early in the startup to initialize
*** 65,74 **** --- 67,79 ---- */ public final class ModuleBootstrap { private ModuleBootstrap() { } + private static final JavaLangModuleAccess JLMA + = SharedSecrets.getJavaLangModuleAccess(); + private static final String JAVA_BASE = "java.base"; private static final String JAVA_SE = "java.se"; // the token for "all default modules"
*** 193,203 **** // If there is no initial module specified then assume that the initial // module is the unnamed module of the application class loader. This // is implemented by resolving "java.se" and all (non-java.*) modules // that export an API. If "java.se" is not observable then all java.* ! // modules are resolved. if (mainModule == null || addAllDefaultModules) { boolean hasJava = false; if (systemModules.find(JAVA_SE).isPresent()) { // java.se is a system module if (finder == systemModules || finder.find(JAVA_SE).isPresent()) { --- 198,210 ---- // If there is no initial module specified then assume that the initial // module is the unnamed module of the application class loader. This // is implemented by resolving "java.se" and all (non-java.*) modules // that export an API. If "java.se" is not observable then all java.* ! // modules are resolved. Modules that have the DO_NOT_RESOLVE_BY_DEFAULT ! // bit set in their ModuleResolution attribute flags are excluded from ! // the detault set of roots. if (mainModule == null || addAllDefaultModules) { boolean hasJava = false; if (systemModules.find(JAVA_SE).isPresent()) { // java.se is a system module if (finder == systemModules || finder.find(JAVA_SE).isPresent()) {
*** 206,222 **** roots.add(JAVA_SE); } } for (ModuleReference mref : systemModules.findAll()) { ! String mn = mref.descriptor().name(); if (hasJava && mn.startsWith("java.")) continue; // add as root if observable and exports at least one package if ((finder == systemModules || finder.find(mn).isPresent())) { - ModuleDescriptor descriptor = mref.descriptor(); for (ModuleDescriptor.Exports e : descriptor.exports()) { if (!e.isQualified()) { roots.add(mn); break; } --- 213,233 ---- roots.add(JAVA_SE); } } for (ModuleReference mref : systemModules.findAll()) { ! ModuleDescriptor descriptor = mref.descriptor(); ! String mn = descriptor.name(); if (hasJava && mn.startsWith("java.")) continue; + if (JLMA.doNotResolveByDefault(descriptor)) { + continue; + } + // add as root if observable and exports at least one package if ((finder == systemModules || finder.find(mn).isPresent())) { for (ModuleDescriptor.Exports e : descriptor.exports()) { if (!e.isQualified()) { roots.add(mn); break; }
*** 230,239 **** --- 241,251 ---- if (addAllSystemModules) { ModuleFinder f = finder; // observable modules systemModules.findAll() .stream() .map(ModuleReference::descriptor) + .filter(md -> !JLMA.doNotResolveByDefault(md)) .map(ModuleDescriptor::name) .filter(mn -> f.find(mn).isPresent()) // observable .forEach(mn -> roots.add(mn)); }
*** 275,284 **** --- 287,309 ---- traceOutput); // time to create configuration PerfCounters.resolveTime.addElapsedTimeFrom(t3); + // issue a warning for any incubator modules in the configuration + String incubating = null; + for (ResolvedModule rm : cf.modules()) { + ModuleDescriptor descriptor = rm.reference().descriptor(); + if (JLMA.warnIfResolvedReason(descriptor) == INCUBATING) + if (incubating == null) + incubating = descriptor.name(); + else + incubating += ", " + descriptor.name(); + } + + if (incubating != null) + warn("using incubating module(s): " + incubating); // mapping of modules to class loaders Function<String, ClassLoader> clf = ModuleLoaderMap.mappingFunction(cf); // check that all modules to be mapped to the boot loader will be
< prev index next >