java.lang.module.ResolvedModule#reference ( )源码实例Demo

下面列出了java.lang.module.ResolvedModule#reference ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Bytecoder   文件: Loader.java
/**
 * Creates a {@code Loader} in a loader pool that loads classes/resources
 * from one module.
 */
public Loader(ResolvedModule resolvedModule,
              LoaderPool pool,
              ClassLoader parent)
{
    super("Loader-" + resolvedModule.name(), parent);

    this.pool = pool;
    this.parent = parent;

    ModuleReference mref = resolvedModule.reference();
    ModuleDescriptor descriptor = mref.descriptor();
    String mn = descriptor.name();
    this.nameToModule = Map.of(mn, mref);

    Map<String, LoadedModule> localPackageToModule = new HashMap<>();
    LoadedModule lm = new LoadedModule(mref);
    descriptor.packages().forEach(pn -> localPackageToModule.put(pn, lm));
    this.localPackageToModule = localPackageToModule;

    this.acc = AccessController.getContext();
}
 
源代码2 项目: Bytecoder   文件: Loader.java
/**
 * Creates a {@code Loader} that loads classes/resources from a collection
 * of modules.
 *
 * @throws IllegalArgumentException
 *         If two or more modules have the same package
 */
public Loader(Collection<ResolvedModule> modules, ClassLoader parent) {
    super(parent);

    this.pool = null;
    this.parent = parent;

    Map<String, ModuleReference> nameToModule = new HashMap<>();
    Map<String, LoadedModule> localPackageToModule = new HashMap<>();
    for (ResolvedModule resolvedModule : modules) {
        ModuleReference mref = resolvedModule.reference();
        ModuleDescriptor descriptor = mref.descriptor();
        nameToModule.put(descriptor.name(), mref);
        descriptor.packages().forEach(pn -> {
            LoadedModule lm = new LoadedModule(mref);
            if (localPackageToModule.put(pn, lm) != null)
                throw new IllegalArgumentException("Package "
                    + pn + " in more than one module");
        });
    }
    this.nameToModule = nameToModule;
    this.localPackageToModule = localPackageToModule;

    this.acc = AccessController.getContext();
}
 
源代码3 项目: Bytecoder   文件: ModuleBootstrap.java
/**
 * Load/register the modules to the built-in class loaders.
 */
private static void loadModules(Configuration cf,
                                Function<String, ClassLoader> clf) {
    for (ResolvedModule resolvedModule : cf.modules()) {
        ModuleReference mref = resolvedModule.reference();
        String name = resolvedModule.name();
        ClassLoader loader = clf.apply(name);
        if (loader == null) {
            // skip java.base as it is already loaded
            if (!name.equals(JAVA_BASE)) {
                BootLoader.loadModule(mref);
            }
        } else if (loader instanceof BuiltinClassLoader) {
            ((BuiltinClassLoader) loader).loadModule(mref);
        }
    }
}
 
源代码4 项目: Bytecoder   文件: ModuleBootstrap.java
/**
 * Checks incubating status of modules in the configuration
 */
private static void checkIncubatingStatus(Configuration cf) {
    String incubating = null;
    for (ResolvedModule resolvedModule : cf.modules()) {
        ModuleReference mref = resolvedModule.reference();

        // emit warning if the WARN_INCUBATING module resolution bit set
        if (ModuleResolution.hasIncubatingWarning(mref)) {
            String mn = mref.descriptor().name();
            if (incubating == null) {
                incubating = mn;
            } else {
                incubating += ", " + mn;
            }
        }
    }
    if (incubating != null)
        warn("Using incubator modules: " + incubating);
}
 
源代码5 项目: openjdk-jdk9   文件: Loader.java
/**
 * Creates a {@code Loader} in a loader pool that loads classes/resources
 * from one module.
 */
public Loader(ResolvedModule resolvedModule,
              LoaderPool pool,
              ClassLoader parent)
{
    super("Loader-" + resolvedModule.name(), parent);

    this.pool = pool;
    this.parent = parent;

    ModuleReference mref = resolvedModule.reference();
    ModuleDescriptor descriptor = mref.descriptor();
    String mn = descriptor.name();
    this.nameToModule = Map.of(mn, mref);

    Map<String, LoadedModule> localPackageToModule = new HashMap<>();
    LoadedModule lm = new LoadedModule(mref);
    descriptor.packages().forEach(pn -> localPackageToModule.put(pn, lm));
    this.localPackageToModule = localPackageToModule;

    this.acc = AccessController.getContext();
}
 
源代码6 项目: openjdk-jdk9   文件: Loader.java
/**
 * Creates a {@code Loader} that loads classes/resources from a collection
 * of modules.
 *
 * @throws IllegalArgumentException
 *         If two or more modules have the same package
 */
public Loader(Collection<ResolvedModule> modules, ClassLoader parent) {
    super(parent);

    this.pool = null;
    this.parent = parent;

    Map<String, ModuleReference> nameToModule = new HashMap<>();
    Map<String, LoadedModule> localPackageToModule = new HashMap<>();
    for (ResolvedModule resolvedModule : modules) {
        ModuleReference mref = resolvedModule.reference();
        ModuleDescriptor descriptor = mref.descriptor();
        nameToModule.put(descriptor.name(), mref);
        descriptor.packages().forEach(pn -> {
            LoadedModule lm = new LoadedModule(mref);
            if (localPackageToModule.put(pn, lm) != null)
                throw new IllegalArgumentException("Package "
                    + pn + " in more than one module");
        });
    }
    this.nameToModule = nameToModule;
    this.localPackageToModule = localPackageToModule;

    this.acc = AccessController.getContext();
}
 
源代码7 项目: openjdk-jdk9   文件: ModuleBootstrap.java
/**
 * Load/register the modules to the built-in class loaders.
 */
private static void loadModules(Configuration cf,
                                Function<String, ClassLoader> clf) {
    for (ResolvedModule resolvedModule : cf.modules()) {
        ModuleReference mref = resolvedModule.reference();
        String name = resolvedModule.name();
        ClassLoader loader = clf.apply(name);
        if (loader == null) {
            // skip java.base as it is already loaded
            if (!name.equals(JAVA_BASE)) {
                BootLoader.loadModule(mref);
            }
        } else if (loader instanceof BuiltinClassLoader) {
            ((BuiltinClassLoader) loader).loadModule(mref);
        }
    }
}
 
源代码8 项目: openjdk-jdk9   文件: ModuleBootstrap.java
/**
 * Checks incubating status of modules in the configuration
 */
private static void checkIncubatingStatus(Configuration cf) {
    String incubating = null;
    for (ResolvedModule resolvedModule : cf.modules()) {
        ModuleReference mref = resolvedModule.reference();

        // emit warning if the WARN_INCUBATING module resolution bit set
        if (ModuleResolution.hasIncubatingWarning(mref)) {
            String mn = mref.descriptor().name();
            if (incubating == null) {
                incubating = mn;
            } else {
                incubating += ", " + mn;
            }
        }
    }
    if (incubating != null)
        warn("Using incubator modules: " + incubating);
}
 
 同类方法