changeset 19430:13a7d45fdf76

jlink generated release file should not contain the date/timestamp
author mchung
date Wed, 29 Mar 2017 10:30:38 -0700
parents d14d350af115
children 415d9fa6fe82
files src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
diffstat 1 files changed, 16 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Wed Mar 29 15:04:40 2017 +0100
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Wed Mar 29 10:30:38 2017 -0700
@@ -27,6 +27,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.io.UncheckedIOException;
 import java.lang.module.ModuleDescriptor;
 import java.util.EnumSet;
@@ -43,8 +44,6 @@
 import jdk.tools.jlink.plugin.ResourcePoolBuilder;
 import jdk.tools.jlink.plugin.ResourcePoolEntry;
 import jdk.tools.jlink.plugin.ResourcePoolModule;
-import jdk.tools.jlink.plugin.Plugin.Category;
-import jdk.tools.jlink.plugin.Plugin.State;
 import jdk.tools.jlink.plugin.Plugin;
 
 /**
@@ -101,9 +100,9 @@
                 //     --release-info add:build_type=fastdebug,source=openjdk,java_version=9
                 // and put whatever value that was passed in command line.
 
-                config.keySet().stream().
-                    filter(s -> !NAME.equals(s)).
-                    forEach(s -> release.put(s, config.get(s)));
+                config.keySet().stream()
+                      .filter(s -> !NAME.equals(s))
+                      .forEach(s -> release.put(s, config.get(s)));
             }
             break;
 
@@ -148,8 +147,8 @@
 
         // put topological sorted module names separated by space
         release.put("MODULES",  new ModuleSorter(in.moduleView())
-                .sorted().map(ResourcePoolModule::name)
-                .collect(Collectors.joining(" ", "\"", "\"")));
+               .sorted().map(ResourcePoolModule::name)
+               .collect(Collectors.joining(" ", "\"", "\"")));
 
         // create a TOP level ResourcePoolEntry for "release" file.
         out.add(ResourcePoolEntry.create("/java.base/release",
@@ -160,11 +159,11 @@
     // Parse version string and return a string that includes only version part
     // leaving "pre", "build" information. See also: java.lang.Runtime.Version.
     private static String parseVersion(String str) {
-        return Runtime.Version.parse(str).
-            version().
-            stream().
-            map(Object::toString).
-            collect(Collectors.joining("."));
+        return Runtime.Version.parse(str)
+                      .version()
+                      .stream()
+                      .map(Object::toString)
+                      .collect(Collectors.joining("."));
     }
 
     private static String quote(String str) {
@@ -172,14 +171,12 @@
     }
 
     private byte[] releaseFileContent() {
-        Properties props = new Properties();
-        props.putAll(release);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        try {
-            props.store(baos, "");
-            return baos.toByteArray();
-        } catch (IOException ex) {
-            throw new UncheckedIOException(ex);
+        try (PrintWriter pw = new PrintWriter(baos)) {
+            release.entrySet().stream()
+                   .sorted(Map.Entry.comparingByKey())
+                   .forEach(e -> pw.format("%s=%s%n", e.getKey(), e.getValue()));
         }
+        return baos.toByteArray();
     }
 }