8224833: jpackages differences between platforms JDK-8200758-branch
authorherrick
Wed, 28 Aug 2019 11:52:20 -0400
branchJDK-8200758-branch
changeset 57911 f052c884af39
parent 57910 28412b313c6b
child 57912 2faaa38c86a4
8224833: jpackages differences between platforms Submitted-by: asemenyuk Reviewed-by: herrick, almatvee
src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java
--- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java	Wed Aug 28 11:41:49 2019 -0400
+++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java	Wed Aug 28 11:52:20 2019 -0400
@@ -26,24 +26,17 @@
 package jdk.jpackage.internal;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UncheckedIOException;
-import java.io.Writer;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.attribute.PosixFilePermission;
+import java.nio.file.StandardCopyOption;
 import java.text.MessageFormat;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.ResourceBundle;
-import java.util.Set;
 
 import static jdk.jpackage.internal.StandardBundlerParam.*;
 
@@ -53,6 +46,7 @@
         "jdk.jpackage.internal.resources.LinuxResources");
 
     private static final String LIBRARY_NAME = "libapplauncher.so";
+    private final static String DEFAULT_ICON = "java32.png";
 
     private final Path root;
     private final Path appDir;
@@ -199,12 +193,19 @@
 
     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(),
-                    APP_NAME.fetchFrom(params) + ".png");
-            IOUtils.copyFile(icon, iconTarget);
-        }
+        File iconTarget = binDir.resolve(APP_NAME.fetchFrom(params) + ".png").toFile();
+
+        InputStream in = locateResource(
+                iconTarget.getName(),
+                "icon",
+                DEFAULT_ICON,
+                icon,
+                VERBOSE.fetchFrom(params),
+                RESOURCE_DIR.fetchFrom(params));
+
+        Files.copy(in, iconTarget.toPath(), StandardCopyOption.REPLACE_EXISTING);
     }
 
     private void copyApplication(Map<String, ? super Object> params)
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java	Wed Aug 28 11:41:49 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java	Wed Aug 28 11:52:20 2019 -0400
@@ -299,7 +299,7 @@
         File iconTarget = getConfig_AppIcon(params);
 
         InputStream in = locateResource(
-                APP_NAME.fetchFrom(params) + ".ico",
+                iconTarget.getName(),
                 "icon",
                 TEMPLATE_APP_ICON,
                 icon,