8229791: Code clean up regressions JDK-8200758-branch
authorherrick
Fri, 16 Aug 2019 17:29:33 -0400
branchJDK-8200758-branch
changeset 57789 9280ca6669a2
parent 57788 370bae2d88fe
child 57790 1ea531646100
8229791: Code clean up regressions Reviewed-by: asemenyuk, almatvee
src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java
src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java
--- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java	Fri Aug 16 16:54:59 2019 -0400
+++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java	Fri Aug 16 17:29:33 2019 -0400
@@ -61,8 +61,6 @@
     private final Path binDir;
     private final Path mdir;
 
-    private final Map<String, ? super Object> params;
-
     public static final BundlerParamInfo<File> ICON_PNG =
             new StandardBundlerParam<>(
             "icon.png",
@@ -78,22 +76,19 @@
             },
             (s, p) -> new File(s));
 
-    public LinuxAppImageBuilder(Map<String, Object> config, Path imageOutDir)
+    public LinuxAppImageBuilder(Map<String, Object> params, Path imageOutDir)
             throws IOException {
-        super(config,
-                imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime"));
+        super(params,
+                imageOutDir.resolve(APP_NAME.fetchFrom(params) + "/runtime"));
 
         Objects.requireNonNull(imageOutDir);
 
-        this.root = imageOutDir.resolve(APP_NAME.fetchFrom(config));
+        this.root = imageOutDir.resolve(APP_NAME.fetchFrom(params));
         this.appDir = root.resolve("app");
         this.appModsDir = appDir.resolve("mods");
         this.runtimeDir = root.resolve("runtime");
         this.binDir = root.resolve("bin");
         this.mdir = runtimeDir.resolve("lib");
-        this.params = new HashMap<>();
-        config.entrySet().stream().forEach(e -> params.put(
-                e.getKey().toString(), e.getValue()));
         Files.createDirectories(appDir);
         Files.createDirectories(runtimeDir);
     }
@@ -110,7 +105,6 @@
         this.runtimeDir = null;
         this.binDir = null;
         this.mdir = null;
-        this.params = new HashMap<>();
     }
 
     private void writeEntry(InputStream in, Path dstFile) throws IOException {
@@ -150,7 +144,8 @@
     }
 
     @Override
-    public void prepareApplicationFiles() throws IOException {
+    public void prepareApplicationFiles(Map<String, ? super Object> params)
+            throws IOException {
         Map<String, ? super Object> originalParams = new HashMap<>(params);
 
         try {
@@ -177,14 +172,15 @@
         }
 
         // Copy class path entries to Java folder
-        copyApplication();
+        copyApplication(params);
 
         // Copy icon to Resources folder
-        copyIcon();
+        copyIcon(params);
     }
 
     @Override
-    public void prepareJreFiles() throws IOException {}
+    public void prepareJreFiles(Map<String, ? super Object> params)
+            throws IOException {}
 
     private void createLauncherForEntryPoint(
             Map<String, ? super Object> params) throws IOException {
@@ -201,7 +197,8 @@
         writeCfgFile(params, root.resolve(getLauncherCfgName(params)).toFile());
     }
 
-    private void copyIcon() throws IOException {
+    private void copyIcon(Map<String, ? super Object> params)
+            throws IOException {
         File icon = ICON_PNG.fetchFrom(params);
         if (icon != null) {
             File iconTarget = new File(binDir.toFile(),
@@ -210,7 +207,8 @@
         }
     }
 
-    private void copyApplication() throws IOException {
+    private void copyApplication(Map<String, ? super Object> params)
+            throws IOException {
         for (RelativeFileSet appResources :
                 APP_RESOURCES_LIST.fetchFrom(params)) {
             if (appResources == null) {
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java	Fri Aug 16 16:54:59 2019 -0400
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java	Fri Aug 16 17:29:33 2019 -0400
@@ -82,8 +82,6 @@
     private final Path runtimeRoot;
     private final Path mdir;
 
-    private final Map<String, ? super Object> params;
-
     private static List<String> keyChains;
 
     public static final BundlerParamInfo<Boolean>
@@ -163,14 +161,13 @@
                     null : Boolean.valueOf(s)
         );
 
-    public MacAppImageBuilder(Map<String, Object> config, Path imageOutDir)
+    public MacAppImageBuilder(Map<String, Object> params, Path imageOutDir)
             throws IOException {
-        super(config, imageOutDir.resolve(APP_NAME.fetchFrom(config)
+        super(params, imageOutDir.resolve(APP_NAME.fetchFrom(params)
                 + ".app/Contents/runtime/Contents/Home"));
 
         Objects.requireNonNull(imageOutDir);
 
-        this.params = config;
         this.root = imageOutDir.resolve(APP_NAME.fetchFrom(params) + ".app");
         this.contentsDir = root.resolve("Contents");
         this.javaDir = contentsDir.resolve("Java");
@@ -186,13 +183,12 @@
         Files.createDirectories(runtimeDir);
     }
 
-    public MacAppImageBuilder(Map<String, Object> config, String jreName,
+    public MacAppImageBuilder(Map<String, Object> params, String jreName,
             Path imageOutDir) throws IOException {
         super(null, imageOutDir.resolve(jreName + "/Contents/Home"));
 
         Objects.requireNonNull(imageOutDir);
 
-        this.params = config;
         this.root = imageOutDir.resolve(jreName );
         this.contentsDir = root.resolve("Contents");
         this.javaDir = null;
@@ -275,7 +271,8 @@
     }
 
     @Override
-    public void prepareApplicationFiles() throws IOException {
+    public void prepareApplicationFiles(Map<String, ? super Object> params)
+            throws IOException {
         Map<String, ? super Object> originalParams = new HashMap<>(params);
         // Generate PkgInfo
         File pkgInfoFile = new File(contentsDir.toFile(), "PkgInfo");
@@ -317,7 +314,7 @@
         }
 
         // Copy class path entries to Java folder
-        copyClassPathEntries(javaDir);
+        copyClassPathEntries(javaDir, params);
 
         /*********** Take care of "config" files *******/
         File icon = ICON_ICNS.fetchFrom(params);
@@ -345,14 +342,15 @@
             }
         }
 
-        copyRuntimeFiles();
-        sign();
+        copyRuntimeFiles(params);
+        sign(params);
     }
 
     @Override
-    public void prepareJreFiles() throws IOException {
-        copyRuntimeFiles();
-        sign();
+    public void prepareJreFiles(Map<String, ? super Object> params)
+            throws IOException {
+        copyRuntimeFiles(params);
+        sign(params);
     }
 
     @Override
@@ -361,13 +359,14 @@
         return (home.exists() ? home : runtimeImageTop);
     }
 
-    private void copyRuntimeFiles() throws IOException {
+    private void copyRuntimeFiles(Map<String, ? super Object> params)
+            throws IOException {
         // Generate Info.plist
-        writeInfoPlist(contentsDir.resolve("Info.plist").toFile());
+        writeInfoPlist(contentsDir.resolve("Info.plist").toFile(), params);
 
         // generate java runtime info.plist
         writeRuntimeInfoPlist(
-                runtimeDir.resolve("Contents/Info.plist").toFile());
+                runtimeDir.resolve("Contents/Info.plist").toFile(), params);
 
         // copy library
         Path runtimeMacOSDir = Files.createDirectories(
@@ -382,7 +381,7 @@
         Files.copy(jli, runtimeMacOSDir.resolve("libjli.dylib"));
     }
 
-    private void sign() throws IOException {
+    private void sign(Map<String, ? super Object> params) throws IOException {
         if (Optional.ofNullable(
                 SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.TRUE)) {
             try {
@@ -413,7 +412,8 @@
         return "Contents/Java/" + APP_NAME.fetchFrom(params) + ".cfg";
     }
 
-    private void copyClassPathEntries(Path javaDirectory) throws IOException {
+    private void copyClassPathEntries(Path javaDirectory,
+            Map<String, ? super Object> params) throws IOException {
         List<RelativeFileSet> resourcesList =
                 APP_RESOURCES_LIST.fetchFrom(params);
         if (resourcesList == null) {
@@ -449,7 +449,8 @@
         }
     }
 
-    private void writeRuntimeInfoPlist(File file) throws IOException {
+    private void writeRuntimeInfoPlist(File file,
+            Map<String, ? super Object> params) throws IOException {
         Map<String, String> data = new HashMap<>();
         String identifier = StandardBundlerParam.isRuntimeInstaller(params) ?
                 MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params) :
@@ -471,7 +472,8 @@
         }
     }
 
-    private void writeInfoPlist(File file) throws IOException {
+    private void writeInfoPlist(File file, Map<String, ? super Object> params)
+            throws IOException {
         Log.verbose(MessageFormat.format(I18N.getString(
                 "message.preparing-info-plist"), file.getAbsolutePath()));
 
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java	Fri Aug 16 16:54:59 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java	Fri Aug 16 17:29:33 2019 -0400
@@ -64,8 +64,10 @@
         return ResourceLocator.class.getResourceAsStream(name);
     }
 
-    public abstract void prepareApplicationFiles() throws IOException;
-    public abstract void prepareJreFiles() throws IOException;
+    public abstract void prepareApplicationFiles(
+            Map<String, ? super Object> params) throws IOException;
+    public abstract void prepareJreFiles(
+            Map<String, ? super Object> params) throws IOException;
     public abstract Path getAppDir();
     public abstract Path getAppModsDir();
 
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java	Fri Aug 16 16:54:59 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java	Fri Aug 16 17:29:33 2019 -0400
@@ -187,7 +187,7 @@
         runJLink(outputDir, modulePath, validModules, limitModules,
                 new HashMap<String,String>(), bindServices);
 
-        imageBuilder.prepareApplicationFiles();
+        imageBuilder.prepareApplicationFiles(params);
     }
 
 
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java	Fri Aug 16 16:54:59 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java	Fri Aug 16 17:29:33 2019 -0400
@@ -543,7 +543,7 @@
             }
         }
 
-        appBuilder.prepareApplicationFiles();
+        appBuilder.prepareApplicationFiles(params);
     }
 
     static void extractMainClassInfoFromAppResources(
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java	Fri Aug 16 16:54:59 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java	Fri Aug 16 17:29:33 2019 -0400
@@ -78,8 +78,6 @@
     private final Path mdir;
     private final Path binDir;
 
-    private final Map<String, ? super Object> params;
-
     public static final BundlerParamInfo<Boolean> REBRAND_EXECUTABLE =
             new WindowsBundlerParam<>(
             "win.launcher.rebrand",
@@ -112,15 +110,13 @@
             (s, p) -> (s == null
             || "null".equalsIgnoreCase(s)) ? true : Boolean.valueOf(s));
 
-    public WindowsAppImageBuilder(Map<String, Object> config, Path imageOutDir)
+    public WindowsAppImageBuilder(Map<String, Object> params, Path imageOutDir)
             throws IOException {
-        super(config,
-                imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime"));
+        super(params,
+                imageOutDir.resolve(APP_NAME.fetchFrom(params) + "/runtime"));
 
         Objects.requireNonNull(imageOutDir);
 
-        this.params = config;
-
         this.root = imageOutDir.resolve(APP_NAME.fetchFrom(params));
         this.appDir = root.resolve("app");
         this.appModsDir = appDir.resolve("mods");
@@ -137,7 +133,6 @@
 
         Objects.requireNonNull(imageOutDir);
 
-        this.params = null;
         this.root = imageOutDir.resolve(jreName);
         this.appDir = null;
         this.appModsDir = null;
@@ -197,7 +192,8 @@
     }
 
     @Override
-    public void prepareApplicationFiles() throws IOException {
+    public void prepareApplicationFiles(Map<String, ? super Object> params)
+            throws IOException {
         Map<String, ? super Object> originalParams = new HashMap<>(params);
 
         try {
@@ -230,7 +226,8 @@
     }
 
     @Override
-    public void prepareJreFiles() throws IOException {}
+    public void prepareJreFiles(Map<String, ? super Object> params)
+        throws IOException {}
 
     private void copyMSVCDLLs() throws IOException {
         AtomicReference<IOException> ioe = new AtomicReference<>();
@@ -269,6 +266,7 @@
 
     protected void prepareExecutableProperties(
            Map<String, ? super Object> params) throws IOException {
+
         Map<String, String> data = new HashMap<>();
 
         // mapping Java parameters in strings for version resource
@@ -297,9 +295,7 @@
     private void createLauncherForEntryPoint(
             Map<String, ? super Object> params) throws IOException {
 
-        File launcherIcon = ICON_ICO.fetchFrom(params);
-        File icon = launcherIcon != null ?
-                launcherIcon : ICON_ICO.fetchFrom(params);
+        File icon = ICON_ICO.fetchFrom(params);
         File iconTarget = getConfig_AppIcon(params);
 
         InputStream in = locateResource(