< prev index next >

src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java

Print this page




 101         this.system = systemModulePath;
 102         this.finder = finder;
 103         this.version = version;
 104 
 105         // build root set for resolution
 106         Set<String> mods = new HashSet<>(roots);
 107 
 108         // add all system modules to the root set for unnamed module or set explicitly
 109         boolean unnamed = !initialArchives.isEmpty() || !classpaths.isEmpty();
 110         if (allSystemModules || (unnamed && !allDefaultModules)) {
 111             systemModulePath.findAll().stream()
 112                 .map(mref -> mref.descriptor().name())
 113                 .forEach(mods::add);
 114         }
 115 
 116         if (allDefaultModules) {
 117             mods.addAll(systemModulePath.defaultSystemRoots());
 118         }
 119 
 120         this.configuration = Configuration.empty()
 121                 .resolveRequires(finder, ModuleFinder.of(), mods);
 122 
 123         this.configuration.modules().stream()
 124                 .map(ResolvedModule::reference)
 125                 .forEach(this::addModuleReference);
 126 
 127         // packages in unnamed module
 128         initialArchives.forEach(archive -> {
 129             addPackagesInUnnamedModule(archive);
 130             this.initialArchives.add(archive);
 131         });
 132 
 133         // classpath archives
 134         for (Path p : classpaths) {
 135             if (Files.exists(p)) {
 136                 Archive archive = Archive.getInstance(p, version);
 137                 addPackagesInUnnamedModule(archive);
 138                 classpathArchives.add(archive);
 139             }
 140         }
 141 


 255             return packageToUnnamedModule.get(pn).stream()
 256                     .filter(a -> a.contains(name + ".class"))
 257                     .findFirst();
 258         }
 259         return Optional.empty();
 260     }
 261 
 262     /**
 263      * Returns the list of Modules that can be found in the specified
 264      * module paths.
 265      */
 266     public Map<String, Module> getModules() {
 267         return nameToModule;
 268     }
 269 
 270     public Stream<Module> resolve(Set<String> roots) {
 271         if (roots.isEmpty()) {
 272             return nameToModule.values().stream();
 273         } else {
 274             return Configuration.empty()
 275                     .resolveRequires(finder, ModuleFinder.of(), roots)
 276                     .modules().stream()
 277                     .map(ResolvedModule::name)
 278                     .map(nameToModule::get);
 279         }
 280     }
 281 
 282     public List<Archive> classPathArchives() {
 283         return classpathArchives;
 284     }
 285 
 286     public List<Archive> initialArchives() {
 287         return initialArchives;
 288     }
 289 
 290     public Set<Module> rootModules() {
 291         return rootModules;
 292     }
 293 
 294     public Module toModule(ModuleReference mref) {
 295         try {


 405                         return Stream.empty();
 406                     }
 407 
 408                     @Override
 409                     public void close() {
 410                     }
 411                 };
 412 
 413                 return new ModuleReference(descriptor, uri) {
 414                     @Override
 415                     public ModuleReader open() {
 416                         return readerSupplier.get();
 417                     }
 418                 };
 419             } catch (IOException e) {
 420                 throw new UncheckedIOException(e);
 421             }
 422         }
 423 
 424         private ModuleDescriptor dropHashes(ModuleDescriptor md) {
 425             ModuleDescriptor.Builder builder = ModuleDescriptor.module(md.name());
 426             md.requires().forEach(builder::requires);
 427             md.exports().forEach(builder::exports);
 428             md.opens().forEach(builder::opens);
 429             md.provides().stream().forEach(builder::provides);
 430             md.uses().stream().forEach(builder::uses);
 431 
 432             Set<String> concealed = new HashSet<>(md.packages());
 433             md.exports().stream().map(Exports::source).forEach(concealed::remove);
 434             md.opens().stream().map(Opens::source).forEach(concealed::remove);
 435             concealed.forEach(builder::contains);
 436 
 437             return builder.build();
 438         }
 439 
 440         @Override
 441         public Set<ModuleReference> findAll() {
 442             return systemModules.values().stream().collect(toSet());
 443         }
 444 
 445         @Override
 446         public Optional<ModuleReference> find(String mn) {
 447             return systemModules.containsKey(mn)
 448                     ? Optional.of(systemModules.get(mn)) : Optional.empty();
 449         }
 450 
 451         public Stream<String> moduleNames() {
 452             return systemModules.values().stream()
 453                 .map(mref -> mref.descriptor().name());
 454         }
 455 
 456         public ClassFileReader getClassReader(String modulename) throws IOException {




 101         this.system = systemModulePath;
 102         this.finder = finder;
 103         this.version = version;
 104 
 105         // build root set for resolution
 106         Set<String> mods = new HashSet<>(roots);
 107 
 108         // add all system modules to the root set for unnamed module or set explicitly
 109         boolean unnamed = !initialArchives.isEmpty() || !classpaths.isEmpty();
 110         if (allSystemModules || (unnamed && !allDefaultModules)) {
 111             systemModulePath.findAll().stream()
 112                 .map(mref -> mref.descriptor().name())
 113                 .forEach(mods::add);
 114         }
 115 
 116         if (allDefaultModules) {
 117             mods.addAll(systemModulePath.defaultSystemRoots());
 118         }
 119 
 120         this.configuration = Configuration.empty()
 121                 .resolve(finder, ModuleFinder.of(), mods);
 122 
 123         this.configuration.modules().stream()
 124                 .map(ResolvedModule::reference)
 125                 .forEach(this::addModuleReference);
 126 
 127         // packages in unnamed module
 128         initialArchives.forEach(archive -> {
 129             addPackagesInUnnamedModule(archive);
 130             this.initialArchives.add(archive);
 131         });
 132 
 133         // classpath archives
 134         for (Path p : classpaths) {
 135             if (Files.exists(p)) {
 136                 Archive archive = Archive.getInstance(p, version);
 137                 addPackagesInUnnamedModule(archive);
 138                 classpathArchives.add(archive);
 139             }
 140         }
 141 


 255             return packageToUnnamedModule.get(pn).stream()
 256                     .filter(a -> a.contains(name + ".class"))
 257                     .findFirst();
 258         }
 259         return Optional.empty();
 260     }
 261 
 262     /**
 263      * Returns the list of Modules that can be found in the specified
 264      * module paths.
 265      */
 266     public Map<String, Module> getModules() {
 267         return nameToModule;
 268     }
 269 
 270     public Stream<Module> resolve(Set<String> roots) {
 271         if (roots.isEmpty()) {
 272             return nameToModule.values().stream();
 273         } else {
 274             return Configuration.empty()
 275                     .resolve(finder, ModuleFinder.of(), roots)
 276                     .modules().stream()
 277                     .map(ResolvedModule::name)
 278                     .map(nameToModule::get);
 279         }
 280     }
 281 
 282     public List<Archive> classPathArchives() {
 283         return classpathArchives;
 284     }
 285 
 286     public List<Archive> initialArchives() {
 287         return initialArchives;
 288     }
 289 
 290     public Set<Module> rootModules() {
 291         return rootModules;
 292     }
 293 
 294     public Module toModule(ModuleReference mref) {
 295         try {


 405                         return Stream.empty();
 406                     }
 407 
 408                     @Override
 409                     public void close() {
 410                     }
 411                 };
 412 
 413                 return new ModuleReference(descriptor, uri) {
 414                     @Override
 415                     public ModuleReader open() {
 416                         return readerSupplier.get();
 417                     }
 418                 };
 419             } catch (IOException e) {
 420                 throw new UncheckedIOException(e);
 421             }
 422         }
 423 
 424         private ModuleDescriptor dropHashes(ModuleDescriptor md) {
 425             ModuleDescriptor.Builder builder = ModuleDescriptor.newModule(md.name());
 426             md.requires().forEach(builder::requires);
 427             md.exports().forEach(builder::exports);
 428             md.opens().forEach(builder::opens);
 429             md.provides().stream().forEach(builder::provides);
 430             md.uses().stream().forEach(builder::uses);
 431             builder.packages(md.packages());





 432             return builder.build();
 433         }
 434 
 435         @Override
 436         public Set<ModuleReference> findAll() {
 437             return systemModules.values().stream().collect(toSet());
 438         }
 439 
 440         @Override
 441         public Optional<ModuleReference> find(String mn) {
 442             return systemModules.containsKey(mn)
 443                     ? Optional.of(systemModules.get(mn)) : Optional.empty();
 444         }
 445 
 446         public Stream<String> moduleNames() {
 447             return systemModules.values().stream()
 448                 .map(mref -> mref.descriptor().name());
 449         }
 450 
 451         public ClassFileReader getClassReader(String modulename) throws IOException {


< prev index next >