src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java
branchJDK-8200758-branch
changeset 58466 47f0d21c7e8d
parent 58360 fd45b7e2c027
child 58695 64adf683bc7b
equal deleted inserted replaced
58464:d82489644b15 58466:47f0d21c7e8d
   280                 .isPresent();
   280                 .isPresent();
   281     }
   281     }
   282 
   282 
   283     private static Set<String> removeInvalidModules(
   283     private static Set<String> removeInvalidModules(
   284             List<Path> modulePath, Set<String> modules) {
   284             List<Path> modulePath, Set<String> modules) {
   285         Set<String> result = new LinkedHashSet<String>();
   285         ModuleFinder moduleFinder = ModuleFinder.compose(
   286         ModuleManager mm = new ModuleManager(modulePath);
   286                 ModuleFinder.of(modulePath.toArray(Path[]::new)),
   287         List<ModFile> lmodfiles =
   287                 ModuleFinder.ofSystem());
   288                 mm.getModules(EnumSet.of(ModuleManager.SearchType.ModularJar,
   288         return modules.stream().filter(moduleName -> {
   289                         ModuleManager.SearchType.Jmod,
   289             if (moduleFinder.find(moduleName).isEmpty()) {
   290                         ModuleManager.SearchType.ExplodedModule));
   290                 Log.error(MessageFormat.format(I18N.getString(
   291 
   291                         "warning.module.does.not.exist"), moduleName));
   292         HashMap<String, ModFile> validModules = new HashMap<>();
   292                 return false;
   293 
   293             }
   294         for (ModFile modFile : lmodfiles) {
   294             return true;
   295             validModules.put(modFile.getModName(), modFile);
   295         }).collect(Collectors.toSet());
   296         }
       
   297 
       
   298         for (String name : modules) {
       
   299             if (validModules.containsKey(name)) {
       
   300                 result.add(name);
       
   301             } else {
       
   302                 Log.error(MessageFormat.format(
       
   303                         I18N.getString("warning.module.does.not.exist"), name));
       
   304             }
       
   305         }
       
   306 
       
   307         return result;
       
   308     }
   296     }
   309 
   297 
   310     private static class ModuleHelper {
   298     private static class ModuleHelper {
   311         // The token for "all modules on the module path".
   299         // The token for "all modules on the module path".
   312         private static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
   300         private static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
   349 
   337 
   350         Set<String> modules() {
   338         Set<String> modules() {
   351             return modules;
   339             return modules;
   352         }
   340         }
   353 
   341 
   354         private static Set<String> getModuleNamesFromPath(List<Path> Value) {
   342         private static Set<String> getModuleNamesFromPath(List<Path> paths) {
   355             Set<String> result = new LinkedHashSet<String>();
   343 
   356             ModuleManager mm = new ModuleManager(Value);
   344             return ModuleFinder.compose(
   357             List<ModFile> modFiles = mm.getModules(
   345                     ModuleFinder.of(paths.toArray(Path[]::new)),
   358                     EnumSet.of(ModuleManager.SearchType.ModularJar,
   346                     ModuleFinder.ofSystem())
   359                     ModuleManager.SearchType.Jmod,
   347                     .findAll()
   360                     ModuleManager.SearchType.ExplodedModule));
   348                     .stream()
   361 
   349                     .map(ModuleReference::descriptor)
   362             for (ModFile modFile : modFiles) {
   350                     .map(ModuleDescriptor::name)
   363                 result.add(modFile.getModName());
   351                     .collect(Collectors.toSet());
   364             }
       
   365             return result;
       
   366         }
   352         }
   367     }
   353     }
   368 
   354 
   369     private static void runJLink(Path output, List<Path> modulePath,
   355     private static void runJLink(Path output, List<Path> modulePath,
   370             Set<String> modules, Set<String> limitModules,
   356             Set<String> modules, Set<String> limitModules,