< prev index next >

hotspot/test/runtime/6981737/Test6981737.java

Print this page




  21  * questions.
  22  */
  23 
  24 /*
  25  * @test Test6981737.java
  26  * @bug 6981737
  27  * @summary check for correct vm properties
  28  * @run main Test6981737
  29  * @author kamg
  30 */
  31 
  32 public class Test6981737 {
  33 
  34     /**
  35      * Check the 'vendor' properties java.vm.specification.version
  36      * property.  Before jdk7, they should be "Sun Micro..." and "1.0".
  37      * In jdk7 onwards they should be "Oracle..." and "1.<major_version>"
  38      */
  39     public static void main(String[] args) throws Exception {
  40 
  41         String version = verifyProperty("java.version", "[0-9]+\\.[0-9]+\\..*");
  42         String major_version_spec = version.split("\\.")[1];

  43         int major_version = new Integer(major_version_spec).intValue();
  44 
  45         String vendor_re = "Oracle Corporation";
  46         String vm_spec_version_re = "1\\." + major_version_spec;
  47         if (major_version < 7) {
  48             vendor_re = "Sun Microsystems Inc\\.";
  49             vm_spec_version_re = "1\\.0";
  50         }
  51         verifyProperty("java.vendor", vendor_re);
  52         verifyProperty("java.vm.vendor", vendor_re);
  53         verifyProperty("java.vm.specification.vendor", vendor_re);
  54         verifyProperty("java.specification.vendor", vendor_re);
  55         verifyProperty("java.vm.specification.version", vm_spec_version_re);
  56         System.out.println("PASS");
  57     }
  58 
  59     public static String verifyProperty(String name, String expected_re) {
  60         String value = System.getProperty(name, "");
  61         System.out.print("Checking " + name + ": \"" + value +
  62           "\".matches(\"" + expected_re + "\")... ");
  63         if (!value.matches(expected_re)) {
  64             System.out.println("no.");
  65             throw new RuntimeException("FAIL: Wrong value for " + name +
  66                 " property, \"" + value + "\", expected to be of form: \"" +


  21  * questions.
  22  */
  23 
  24 /*
  25  * @test Test6981737.java
  26  * @bug 6981737
  27  * @summary check for correct vm properties
  28  * @run main Test6981737
  29  * @author kamg
  30 */
  31 
  32 public class Test6981737 {
  33 
  34     /**
  35      * Check the 'vendor' properties java.vm.specification.version
  36      * property.  Before jdk7, they should be "Sun Micro..." and "1.0".
  37      * In jdk7 onwards they should be "Oracle..." and "1.<major_version>"
  38      */
  39     public static void main(String[] args) throws Exception {
  40 
  41         String version = verifyProperty("java.version", "[0-9]+[\\\\.[0-9]+]*\\-.*");
  42         String version_tokens[] = version.split("-|\\.");
  43         String major_version_spec = version_tokens[0];
  44         int major_version = new Integer(major_version_spec).intValue();
  45 
  46         String vendor_re = "Oracle Corporation";
  47         String vm_spec_version_re = major_version_spec;
  48         if (major_version < 7) {
  49             vendor_re = "Sun Microsystems Inc\\.";
  50             vm_spec_version_re = "1\\.0";
  51         }
  52         verifyProperty("java.vendor", vendor_re);
  53         verifyProperty("java.vm.vendor", vendor_re);
  54         verifyProperty("java.vm.specification.vendor", vendor_re);
  55         verifyProperty("java.specification.vendor", vendor_re);
  56         verifyProperty("java.vm.specification.version", vm_spec_version_re);
  57         System.out.println("PASS");
  58     }
  59 
  60     public static String verifyProperty(String name, String expected_re) {
  61         String value = System.getProperty(name, "");
  62         System.out.print("Checking " + name + ": \"" + value +
  63           "\".matches(\"" + expected_re + "\")... ");
  64         if (!value.matches(expected_re)) {
  65             System.out.println("no.");
  66             throw new RuntimeException("FAIL: Wrong value for " + name +
  67                 " property, \"" + value + "\", expected to be of form: \"" +
< prev index next >