8159487: Add JAVA_VERSION, OS_NAME, OS_ARCH properties in release file
authorsundar
Tue, 02 Aug 2016 17:33:50 +0530
changeset 40111 0fc6d1871da6
parent 39922 e613affb88d1
child 40112 fba684000cfc
8159487: Add JAVA_VERSION, OS_NAME, OS_ARCH properties in release file Reviewed-by: jlaskey
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
jdk/test/tools/jlink/IntegrationTest.java
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Wed Jul 05 22:01:28 2017 +0200
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Tue Aug 02 17:33:50 2016 +0530
@@ -228,6 +228,7 @@
             desc.osName().ifPresent(s -> props.setProperty("OS_NAME", s));
             desc.osVersion().ifPresent(s -> props.setProperty("OS_VERSION", s));
             desc.osArch().ifPresent(s -> props.setProperty("OS_ARCH", s));
+            props.setProperty("JAVA_VERSION", System.getProperty("java.version"));
         });
 
         Optional<ResourcePoolEntry> release = pool.findEntry("/java.base/release");
--- a/jdk/test/tools/jlink/IntegrationTest.java	Wed Jul 05 22:01:28 2017 +0200
+++ b/jdk/test/tools/jlink/IntegrationTest.java	Tue Aug 02 17:33:50 2016 +0530
@@ -22,6 +22,7 @@
  */
 
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.UncheckedIOException;
 import java.nio.file.Files;
@@ -33,6 +34,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 import java.util.function.Function;
 import jdk.tools.jlink.Jlink;
@@ -203,6 +205,27 @@
             throw new AssertionError("release not generated");
         }
 
+        Properties props = new Properties();
+        try (FileReader reader = new FileReader(release)) {
+            props.load(reader);
+        }
+
+        if (props.getProperty("JAVA_VERSION") == null) {
+            throw new AssertionError("release file does not contain JAVA_VERSION");
+        }
+
+        if (props.getProperty("OS_NAME") == null) {
+            throw new AssertionError("release file does not contain OS_NAME");
+        }
+
+        if (props.getProperty("OS_ARCH") == null) {
+            throw new AssertionError("release file does not contain OS_ARCH");
+        }
+
+        if (props.getProperty("OS_VERSION") == null) {
+            throw new AssertionError("release file does not contain OS_VERSION");
+        }
+
         if (!Files.exists(output.resolve("toto.txt"))) {
             throw new AssertionError("Post processing not called");
         }