Java Code Examples for java.lang.module.ModuleDescriptor#isAutomatic()
The following examples show how to use
java.lang.module.ModuleDescriptor#isAutomatic() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Module.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Creates a new named Module. The resulting Module will be defined to the * VM but will not read any other modules, will not have any exports setup * and will not be registered in the service catalog. */ Module(ModuleLayer layer, ClassLoader loader, ModuleDescriptor descriptor, URI uri) { this.layer = layer; this.name = descriptor.name(); this.loader = loader; this.descriptor = descriptor; // define module to VM boolean isOpen = descriptor.isOpen() || descriptor.isAutomatic(); Version version = descriptor.version().orElse(null); String vs = Objects.toString(version, null); String loc = Objects.toString(uri, null); String[] packages = descriptor.packages().toArray(new String[0]); defineModule0(this, isOpen, vs, loc, packages); }
Example 2
Source File: Loader.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Returns true if the given module opens the given package * unconditionally. * * @implNote This method currently iterates over each of the open * packages. This will be replaced once the ModuleDescriptor.Opens * API is updated. */ private boolean isOpen(ModuleReference mref, String pn) { ModuleDescriptor descriptor = mref.descriptor(); if (descriptor.isOpen() || descriptor.isAutomatic()) return true; for (ModuleDescriptor.Opens opens : descriptor.opens()) { String source = opens.source(); if (!opens.isQualified() && source.equals(pn)) { return true; } } return false; }
Example 3
Source File: BuiltinClassLoader.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Returns true if the given module opens the given package * unconditionally. * * @implNote This method currently iterates over each of the open * packages. This will be replaced once the ModuleDescriptor.Opens * API is updated. */ private boolean isOpen(ModuleReference mref, String pn) { ModuleDescriptor descriptor = mref.descriptor(); if (descriptor.isOpen() || descriptor.isAutomatic()) return true; for (ModuleDescriptor.Opens opens : descriptor.opens()) { String source = opens.source(); if (!opens.isQualified() && source.equals(pn)) { return true; } } return false; }
Example 4
Source File: ModulePathValidator.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Prints the module location and name. */ private void printModule(ModuleReference mref) { mref.location() .filter(uri -> !isJrt(uri)) .ifPresent(uri -> out.print(uri + " ")); ModuleDescriptor descriptor = mref.descriptor(); out.print(descriptor.name()); if (descriptor.isAutomatic()) out.print(" automatic"); out.println(); }
Example 5
Source File: LauncherHelper.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Prints a single line with the module name, version and modifiers */ private static void showModule(ModuleReference mref) { ModuleDescriptor md = mref.descriptor(); ostream.print(md.toNameAndVersion()); mref.location() .filter(uri -> !isJrt(uri)) .ifPresent(uri -> ostream.format(" %s", uri)); if (md.isOpen()) ostream.print(" open"); if (md.isAutomatic()) ostream.print(" automatic"); ostream.println(); }
Example 6
Source File: Loader.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns true if the given module opens the given package * unconditionally. * * @implNote This method currently iterates over each of the open * packages. This will be replaced once the ModuleDescriptor.Opens * API is updated. */ private boolean isOpen(ModuleReference mref, String pn) { ModuleDescriptor descriptor = mref.descriptor(); if (descriptor.isOpen() || descriptor.isAutomatic()) return true; for (ModuleDescriptor.Opens opens : descriptor.opens()) { String source = opens.source(); if (!opens.isQualified() && source.equals(pn)) { return true; } } return false; }
Example 7
Source File: BuiltinClassLoader.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns true if the given module opens the given package * unconditionally. * * @implNote This method currently iterates over each of the open * packages. This will be replaced once the ModuleDescriptor.Opens * API is updated. */ private boolean isOpen(ModuleReference mref, String pn) { ModuleDescriptor descriptor = mref.descriptor(); if (descriptor.isOpen() || descriptor.isAutomatic()) return true; for (ModuleDescriptor.Opens opens : descriptor.opens()) { String source = opens.source(); if (!opens.isQualified() && source.equals(pn)) { return true; } } return false; }
Example 8
Source File: LauncherHelper.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Prints a single line with the module name, version and modifiers */ private static void showModule(ModuleReference mref) { ModuleDescriptor md = mref.descriptor(); ostream.print(md.toNameAndVersion()); mref.location() .filter(uri -> !isJrt(uri)) .ifPresent(uri -> ostream.format(" %s", uri)); if (md.isOpen()) ostream.print(" open"); if (md.isAutomatic()) ostream.print(" automatic"); ostream.println(); }
Example 9
Source File: LauncherHelper.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Prints the module location and name. */ private void printModule(ModuleReference mref) { mref.location() .filter(uri -> !isJrt(uri)) .ifPresent(uri -> ostream.print(uri + " ")); ModuleDescriptor descriptor = mref.descriptor(); ostream.print(descriptor.name()); if (descriptor.isAutomatic()) ostream.print(" automatic"); ostream.println(); }
Example 10
Source File: SystemModulesPlugin.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
ModuleDescriptorBuilder(ModuleDescriptor md, Set<String> packages, int index) { if (md.isAutomatic()) { throw new InternalError("linking automatic module is not supported"); } this.md = md; this.packages = packages; this.index = index; }
Example 11
Source File: Main.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void describeModule(ModuleDescriptor md, ModuleTarget target, ModuleHashes hashes, String uriString) throws IOException { StringBuilder sb = new StringBuilder(); sb.append(md.toNameAndVersion()); if (!uriString.equals("")) sb.append(" ").append(uriString); if (md.isOpen()) sb.append(" open"); if (md.isAutomatic()) sb.append(" automatic"); sb.append("\n"); // unqualified exports (sorted by package) md.exports().stream() .sorted(Comparator.comparing(Exports::source)) .filter(e -> !e.isQualified()) .forEach(e -> sb.append("exports ").append(e.source()) .append(toString(e.modifiers())).append("\n")); // dependences md.requires().stream().sorted() .forEach(r -> sb.append("requires ").append(r.name()) .append(toString(r.modifiers())).append("\n")); // service use and provides md.uses().stream().sorted() .forEach(s -> sb.append("uses ").append(s).append("\n")); md.provides().stream() .sorted(Comparator.comparing(Provides::service)) .forEach(p -> sb.append("provides ").append(p.service()) .append(" with") .append(toString(p.providers())) .append("\n")); // qualified exports md.exports().stream() .sorted(Comparator.comparing(Exports::source)) .filter(Exports::isQualified) .forEach(e -> sb.append("qualified exports ").append(e.source()) .append(" to").append(toString(e.targets())) .append("\n")); // open packages md.opens().stream() .sorted(Comparator.comparing(Opens::source)) .filter(o -> !o.isQualified()) .forEach(o -> sb.append("opens ").append(o.source()) .append(toString(o.modifiers())) .append("\n")); md.opens().stream() .sorted(Comparator.comparing(Opens::source)) .filter(Opens::isQualified) .forEach(o -> sb.append("qualified opens ").append(o.source()) .append(toString(o.modifiers())) .append(" to").append(toString(o.targets())) .append("\n")); // non-exported/non-open packages Set<String> concealed = new TreeSet<>(md.packages()); md.exports().stream().map(Exports::source).forEach(concealed::remove); md.opens().stream().map(Opens::source).forEach(concealed::remove); concealed.forEach(p -> sb.append("contains ").append(p).append("\n")); md.mainClass().ifPresent(v -> sb.append("main-class ").append(v).append("\n")); if (target != null) { String targetPlatform = target.targetPlatform(); if (!targetPlatform.isEmpty()) sb.append("platform ").append(targetPlatform).append("\n"); } if (hashes != null) { hashes.names().stream().sorted().forEach( mod -> sb.append("hashes ").append(mod).append(" ") .append(hashes.algorithm()).append(" ") .append(toHex(hashes.hashFor(mod))) .append("\n")); } output(sb.toString()); }
Example 12
Source File: JmodTask.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void describeModule(ModuleDescriptor md, ModuleTarget target, ModuleHashes hashes) throws IOException { StringBuilder sb = new StringBuilder(); sb.append(md.toNameAndVersion()); if (md.isOpen()) sb.append(" open"); if (md.isAutomatic()) sb.append(" automatic"); sb.append("\n"); // unqualified exports (sorted by package) md.exports().stream() .sorted(Comparator.comparing(Exports::source)) .filter(e -> !e.isQualified()) .forEach(e -> sb.append("exports ").append(e.source()) .append(toString(e.modifiers())).append("\n")); // dependences md.requires().stream().sorted() .forEach(r -> sb.append("requires ").append(r.name()) .append(toString(r.modifiers())).append("\n")); // service use and provides md.uses().stream().sorted() .forEach(s -> sb.append("uses ").append(s).append("\n")); md.provides().stream() .sorted(Comparator.comparing(Provides::service)) .forEach(p -> sb.append("provides ").append(p.service()) .append(" with") .append(toString(p.providers())) .append("\n")); // qualified exports md.exports().stream() .sorted(Comparator.comparing(Exports::source)) .filter(Exports::isQualified) .forEach(e -> sb.append("qualified exports ").append(e.source()) .append(" to").append(toString(e.targets())) .append("\n")); // open packages md.opens().stream() .sorted(Comparator.comparing(Opens::source)) .filter(o -> !o.isQualified()) .forEach(o -> sb.append("opens ").append(o.source()) .append(toString(o.modifiers())) .append("\n")); md.opens().stream() .sorted(Comparator.comparing(Opens::source)) .filter(Opens::isQualified) .forEach(o -> sb.append("qualified opens ").append(o.source()) .append(toString(o.modifiers())) .append(" to").append(toString(o.targets())) .append("\n")); // non-exported/non-open packages Set<String> concealed = new TreeSet<>(md.packages()); md.exports().stream().map(Exports::source).forEach(concealed::remove); md.opens().stream().map(Opens::source).forEach(concealed::remove); concealed.forEach(p -> sb.append("contains ").append(p).append("\n")); md.mainClass().ifPresent(v -> sb.append("main-class ").append(v).append("\n")); if (target != null) { String targetPlatform = target.targetPlatform(); if (!targetPlatform.isEmpty()) sb.append("platform ").append(targetPlatform).append("\n"); } if (hashes != null) { hashes.names().stream().sorted().forEach( mod -> sb.append("hashes ").append(mod).append(" ") .append(hashes.algorithm()).append(" ") .append(toHex(hashes.hashFor(mod))) .append("\n")); } out.println(sb.toString()); }