< prev index next >

modules/jdk.packager/src/main/java/jdk/packager/internal/JLinkBundlerHelper.java

Print this page

        

@@ -304,11 +304,12 @@
                 throw new Exception(MessageFormat.format(I18N.getString("error.srcfiles.contain.modules"), modularJars.toString()));
             }
         }
 
         ModuleHelper moduleHelper = new ModuleHelper(modulePath, addModules, limitModules);
-        addModules.addAll(moduleHelper.modules());
+        Set<String> redistModules = removeInvalidModules(modulePath, moduleHelper.modules());
+        addModules.addAll(redistModules);
 
         //--------------------------------------------------------------------
         // Jars
 
         // Bundle with minimum dependencies that unnamed jars depend on.

@@ -389,10 +390,35 @@
         }
 
         return files;
     }
 
+    private static Set<String> removeInvalidModules(List<Path> modulePath, Set<String> modules) {
+        Set<String> result = new LinkedHashSet();
+        ModuleManager mm = new ModuleManager(modulePath);
+        List<Module> lmodules = mm.getModules(EnumSet.of(ModuleManager.SearchType.ModularJar,
+                                             ModuleManager.SearchType.Jmod,
+                                             ModuleManager.SearchType.ExplodedModule));
+
+        HashMap<String, Module> validModules = new HashMap<>();
+
+        for (Module module : lmodules) {
+            validModules.put(module.getModuleName(), module);
+        }
+
+        for (String name : modules) {
+            if (validModules.containsKey(name)) {
+                result.add(name);
+            }
+            else {
+                Log.info(MessageFormat.format(I18N.getString("warning.module.does.not.exist"), name));
+            }
+        }
+
+        return result;
+    }
+
     private static class ModuleHelper {
         // The token for "all modules on the module path".
         private static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
 
         // The token for "all redistributable runtime modules".
< prev index next >