--- old/src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java 2019-03-04 08:08:48.712270000 -0500 +++ new/src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java 2019-03-04 08:08:47.635856200 -0500 @@ -76,8 +76,6 @@ @SuppressWarnings("unchecked") static final BundlerParamInfo DEBUG = new StandardBundlerParam<>( - "", - "", "-J-Xdebug", Integer.class, p -> null, @@ -190,8 +188,6 @@ StandardBundlerParam.ADD_MODULES.fetchFrom(params); Set limitModules = StandardBundlerParam.LIMIT_MODULES.fetchFrom(params); - boolean stripNativeCommands = - StandardBundlerParam.STRIP_NATIVE_COMMANDS.fetchFrom(params); Path outputDir = imageBuilder.getRoot(); String excludeFileList = imageBuilder.getExcludeFileList(); File mainJar = getMainJar(params); @@ -206,18 +202,21 @@ // Modules String mainModule = getMainModule(params); - if (mainJarType == ModFile.ModType.UnnamedJar) { - // The default for an unnamed jar is ALL_DEFAULT - addModules.add(ModuleHelper.ALL_DEFAULT); - } else if (mainJarType == ModFile.ModType.Unknown || - mainJarType == ModFile.ModType.ModularJar) { - if (mainModule == null) { + if (mainModule == null) { + if (mainJarType == ModFile.ModType.UnnamedJar) { + if (addModules.isEmpty()) { + // The default for an unnamed jar is ALL_DEFAULT + addModules.add(ModuleHelper.ALL_DEFAULT); + } + } else if (mainJarType == ModFile.ModType.Unknown || + mainJarType == ModFile.ModType.ModularJar) { addModules.add(ModuleHelper.ALL_DEFAULT); } } Set validModules = getValidModules(modulePath, addModules, limitModules); + if (mainModule != null) { validModules.add(mainModule); } @@ -226,39 +225,12 @@ I18N.getString("message.modules"), validModules.toString())); runJLink(outputDir, modulePath, validModules, limitModules, - excludeFileList, stripNativeCommands, - new HashMap()); + excludeFileList, new HashMap()); imageBuilder.prepareApplicationFiles(); } - static void generateJre(Map params, - AbstractAppImageBuilder imageBuilder) - throws IOException, Exception { - List modulePath = - StandardBundlerParam.MODULE_PATH.fetchFrom(params); - Set addModules = - StandardBundlerParam.ADD_MODULES.fetchFrom(params); - Set limitModules = - StandardBundlerParam.LIMIT_MODULES.fetchFrom(params); - boolean stripNativeCommands = - StandardBundlerParam.STRIP_NATIVE_COMMANDS.fetchFrom(params); - Path outputDir = imageBuilder.getRoot(); - addModules.add(ModuleHelper.ALL_MODULE_PATH); - Set redistModules = getValidModules(modulePath, - addModules, limitModules); - addModules.addAll(redistModules); - - Log.verbose(MessageFormat.format( - I18N.getString("message.modules"), addModules.toString())); - - runJLink(outputDir, modulePath, addModules, limitModules, - null, stripNativeCommands, new HashMap()); - - imageBuilder.prepareJreFiles(); - } - // Returns the path to the JDK modules in the user defined module path. static Path findPathOfModule( List modulePath, String moduleName) { @@ -408,7 +380,7 @@ private static void runJLink(Path output, List modulePath, Set modules, Set limitModules, String excludes, - boolean strip, HashMap user) throws IOException { + HashMap user) throws IOException { // This is just to ensure jlink is given a non-existant directory // The passed in output path should be non-existant or empty directory @@ -433,16 +405,18 @@ args.add("--exclude-files"); args.add(excludes); } - if (strip) { + if (user != null && !user.isEmpty()) { + for (Map.Entry entry : user.entrySet()) { + args.add(entry.getKey()); + args.add(entry.getValue()); + } + } else { + args.add("--bind-services"); args.add("--strip-native-commands"); + args.add("--strip-debug"); + args.add("--no-man-pages"); + args.add("--no-header-files"); } - for (Map.Entry entry : user.entrySet()) { - args.add(entry.getKey()); - args.add(entry.getValue()); - } - args.add("--strip-debug"); - args.add("--no-header-files"); - args.add("--bind-services"); StringWriter writer = new StringWriter(); PrintWriter pw = new PrintWriter(writer);