< prev index next >

jdk/test/sun/misc/Version/Version.java

Print this page




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 6994413
  26  * @summary Check the JDK and JVM version returned by sun.misc.Version
  27  *          matches the versions defined in the system properties
  28  * @modules java.base/sun.misc
  29  * @compile -XDignore.symbol.file Version.java
  30  * @run main Version
  31  */
  32 
  33 import static sun.misc.Version.*;
  34 public class Version {
  35 
  36     public static void main(String[] args) throws Exception {
  37         VersionInfo jdk = newVersionInfo(System.getProperty("java.runtime.version"));
  38         VersionInfo v1 = new VersionInfo(jdkMajorVersion(),
  39                                          jdkMinorVersion(),
  40                                          jdkMicroVersion(),
  41                                          jdkUpdateVersion(),
  42                                          jdkSpecialVersion(),
  43                                          jdkBuildNumber());
  44         System.out.println("JDK version = " + jdk + "  " + v1);
  45         if (!jdk.equals(v1)) {
  46             throw new RuntimeException("Unmatched version: " + jdk + " vs " + v1);
  47         }
  48         VersionInfo jvm = newVersionInfo(System.getProperty("java.vm.version"));
  49         VersionInfo v2 = new VersionInfo(jvmMajorVersion(),
  50                                          jvmMinorVersion(),
  51                                          jvmMicroVersion(),
  52                                          jvmUpdateVersion(),
  53                                          jvmSpecialVersion(),
  54                                          jvmBuildNumber());
  55         System.out.println("JVM version = " + jvm + " " + v2);
  56         if (!jvm.equals(v2)) {
  57             throw new RuntimeException("Unmatched version: " + jvm + " vs " + v2);
  58         }
  59     }
  60 
  61     static class VersionInfo {
  62         final int major;
  63         final int minor;
  64         final int micro;
  65         final int update;
  66         final String special;
  67         final int build;
  68         VersionInfo(int major, int minor, int micro,
  69                     int update, String special, int build) {
  70             this.major = major;
  71             this.minor = minor;




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 6994413
  26  * @summary Check the JDK and JVM version returned by sun.misc.Version
  27  *          matches the versions defined in the system properties
  28  * @modules java.base/sun.misc
  29  * @compile -XDignore.symbol.file Version.java
  30  * @run main Version
  31  */
  32 
  33 import static sun.misc.Version.*;
  34 public class Version {
  35 
  36     public static void main(String[] args) throws Exception {
  37         VersionInfo jdk = newVersionInfo(System.getProperty("java.runtime.version"));
  38         VersionInfo v1 = new VersionInfo(jdkMajorVersion(),
  39                                          jdkMinorVersion(),
  40                                          jdkSecurityVersion(),
  41                                          jdkUpdateVersion(),
  42                                          jdkSpecialVersion(),
  43                                          jdkBuildNumber());
  44         System.out.println("JDK version = " + jdk + "  " + v1);
  45         if (!jdk.equals(v1)) {
  46             throw new RuntimeException("Unmatched version: " + jdk + " vs " + v1);
  47         }
  48         VersionInfo jvm = newVersionInfo(System.getProperty("java.vm.version"));
  49         VersionInfo v2 = new VersionInfo(jvmMajorVersion(),
  50                                          jvmMinorVersion(),
  51                                          jvmSecurityVersion(),
  52                                          jvmUpdateVersion(),
  53                                          jvmSpecialVersion(),
  54                                          jvmBuildNumber());
  55         System.out.println("JVM version = " + jvm + " " + v2);
  56         if (!jvm.equals(v2)) {
  57             throw new RuntimeException("Unmatched version: " + jvm + " vs " + v2);
  58         }
  59     }
  60 
  61     static class VersionInfo {
  62         final int major;
  63         final int minor;
  64         final int micro;
  65         final int update;
  66         final String special;
  67         final int build;
  68         VersionInfo(int major, int minor, int micro,
  69                     int update, String special, int build) {
  70             this.major = major;
  71             this.minor = minor;


< prev index next >