From 0eef2f9998eedf7bd2b257a50410ec380fbd3cc5 Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Wed, 16 Sep 2015 10:52:10 -0700 Subject: [PATCH] 8134365: Test test/sun/misc/Version/Version.java should follow Verona rules for trailing zeros Reviewed-by: mchung, iris --- jdk/test/sun/misc/Version/Version.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/jdk/test/sun/misc/Version/Version.java b/jdk/test/sun/misc/Version/Version.java index 4b22307918b..7e4f72bcd67 100644 --- a/jdk/test/sun/misc/Version/Version.java +++ b/jdk/test/sun/misc/Version/Version.java @@ -22,9 +22,10 @@ */ /* @test - * @bug 6994413 + * @bug 6994413, 8134365 * @summary Check the JDK and JVM version returned by sun.misc.Version - * matches the versions defined in the system properties + * matches the versions defined in the system properties. + * Should use the API described in JDK-8136651 when available * @modules java.base/sun.misc * @compile -XDignore.symbol.file Version.java * @run main Version @@ -90,12 +91,21 @@ public class Version { public String toString() { StringBuilder sb = new StringBuilder(); - sb.append(major + "." + minor + "." + security); + // Do not include trailing zeros if (patch > 0) { - sb.append("." + patch); + sb.insert(0, "." + patch); } + if (security > 0 || sb.length() > 0) { + sb.insert(0, "." + security); + } + if (minor > 0 || sb.length() > 0) { + sb.insert(0, "." + minor); + } + sb.insert(0, major); + + if (build >= 0) + sb.append("+" + build); - sb.append("+" + build); return sb.toString(); } }