# HG changeset patch # User herrick # Date 1552352661 14400 # Node ID a84c657c713d9c5996c9e932b2f7ed9c0a137465 # Parent ea75e8d7e34f666ad44531cc3fd6f11593206c09 8171959: add-launcher is not working when normal jar is used for first launcher and module is used for second launcher Reviewed-by: almatvee diff -r ea75e8d7e34f -r a84c657c713d src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java Mon Mar 11 21:00:22 2019 -0400 +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java Mon Mar 11 21:04:21 2019 -0400 @@ -193,9 +193,8 @@ List> entryPoints = StandardBundlerParam.ADD_LAUNCHERS.fetchFrom(params); for (Map entryPoint : entryPoints) { - Map tmp = new HashMap<>(originalParams); - tmp.putAll(entryPoint); - createLauncherForEntryPoint(tmp, root); + createLauncherForEntryPoint( + AddLauncherArguments.merge(originalParams, entryPoint)); } // Copy class path entries to Java folder diff -r ea75e8d7e34f -r a84c657c713d src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java Mon Mar 11 21:00:22 2019 -0400 +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java Mon Mar 11 21:04:21 2019 -0400 @@ -323,8 +323,8 @@ List> entryPoints = StandardBundlerParam.ADD_LAUNCHERS.fetchFrom(params); for (Map entryPoint : entryPoints) { - Map tmp = new HashMap<>(originalParams); - tmp.putAll(entryPoint); + Map tmp = + AddLauncherArguments.merge(originalParams, entryPoint); // add executable for add launcher Path addExecutable = macOSDir.resolve(getLauncherName(tmp)); diff -r ea75e8d7e34f -r a84c657c713d src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java Mon Mar 11 21:00:22 2019 -0400 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java Mon Mar 11 21:04:21 2019 -0400 @@ -164,4 +164,22 @@ params.put(param, value); } } + + static Map merge( + Map original, + Map additional) { + Map tmp = new HashMap<>(original); + if (additional.containsKey("module")) { + tmp.remove("main-jar"); + tmp.remove("main-class"); + } else if (additional.containsKey("main-jar")) { + tmp.remove("module"); + // should we only remove add-modules when it wasn't actually passed + // but was inferred or empty ? + tmp.remove("add-modules"); + } + tmp.putAll(additional); + return tmp; + } + } diff -r ea75e8d7e34f -r a84c657c713d src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java Mon Mar 11 21:00:22 2019 -0400 +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java Mon Mar 11 21:04:21 2019 -0400 @@ -254,9 +254,8 @@ List> entryPoints = StandardBundlerParam.ADD_LAUNCHERS.fetchFrom(params); for (Map entryPoint : entryPoints) { - Map tmp = new HashMap<>(originalParams); - tmp.putAll(entryPoint); - createLauncherForEntryPoint(tmp); + createLauncherForEntryPoint( + AddLauncherArguments.merge(originalParams, entryPoint)); } }