test/jdk/java/lang/System/Versions.java
changeset 50531 aeb7fb702890
parent 47216 71c04702a3d5
equal deleted inserted replaced
50530:7e3aa681a484 50531:aeb7fb702890
     1 /*
     1 /*
     2  * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /**
    24 /**
    25  * @test
    25  * @test
    26  * @bug 4989690 6259855 6706299
    26  * @bug 4989690 6259855 6706299 8204565
    27  * @summary Check that version-related system property invariants hold.
    27  * @summary Check that version-related system property invariants hold.
    28  * @author Martin Buchholz
    28  * @author Martin Buchholz
    29  */
    29  */
    30 
    30 
    31 import java.io.*;
    31 import java.io.*;
    70     }
    70     }
    71 
    71 
    72     public static void main(String [] args) throws Exception {
    72     public static void main(String [] args) throws Exception {
    73         String classVersion   = getProperty("java.class.version");
    73         String classVersion   = getProperty("java.class.version");
    74         String javaVersion    = getProperty("java.version");
    74         String javaVersion    = getProperty("java.version");
    75         String VMVersion      = getProperty("java.vm.version");
       
    76         String runtimeVersion = getProperty("java.runtime.version");
    75         String runtimeVersion = getProperty("java.runtime.version");
    77         String specVersion    = getProperty("java.specification.version");
    76         String specVersion    = getProperty("java.specification.version");
       
    77         String vmSpecVersion  = getProperty("java.vm.specification.version");
       
    78         String featureVersion = Integer.toString(Runtime.version().feature());
    78 
    79 
    79         if (! (javaVersion.startsWith(specVersion) &&
    80         if (! (javaVersion.startsWith(specVersion) &&
    80                runtimeVersion.startsWith(specVersion)))
    81                runtimeVersion.startsWith(specVersion) &&
       
    82                specVersion.equals(featureVersion) &&
       
    83                vmSpecVersion.equals(featureVersion))) {
    81             throw new Exception("Invalid version-related system properties");
    84             throw new Exception("Invalid version-related system properties");
       
    85         }
    82 
    86 
    83         //----------------------------------------------------------------
    87         //----------------------------------------------------------------
    84         // Check that java.class.version is correct.
    88         // Check that java.class.version is correct.
    85         // Injecting a larger major or minor version number into a
    89         // Injecting a larger major or minor version number into a
    86         // .class file should result in UnsupportedClassVersionError.
    90         // .class file should result in UnsupportedClassVersionError.