test/hotspot/jtreg/runtime/6981737/Test6981737.java
author bchristi
Tue, 12 Jun 2018 14:08:24 -0700
changeset 50531 aeb7fb702890
parent 48553 fe2950b07f1e
permissions -rw-r--r--
8204565: (spec) Document java.{vm.}?specification.version system properties' relation to $FEATURE Reviewed-by: mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7381
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
     1
/*
50531
aeb7fb702890 8204565: (spec) Document java.{vm.}?specification.version system properties' relation to $FEATURE
bchristi
parents: 48553
diff changeset
     2
 * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
7381
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
     4
 *
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
     8
 *
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    13
 * accompanied this code).
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    14
 *
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    18
 *
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    21
 * questions.
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    22
 */
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    23
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    24
/*
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    25
 * @test Test6981737.java
50531
aeb7fb702890 8204565: (spec) Document java.{vm.}?specification.version system properties' relation to $FEATURE
bchristi
parents: 48553
diff changeset
    26
 * @bug 6981737 8204565
7381
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    27
 * @summary check for correct vm properties
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    28
 * @run main Test6981737
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    29
 * @author kamg
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    30
*/
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    31
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    32
public class Test6981737 {
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    33
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    34
    /**
46639
c6618ddbe993 8183400: runtime/6981737/Test6981737.java fails with java.lang.RuntimeException: FAIL: Wrong value for java.version property, "9", expected to be of form: "[0-9]+[\\.[0-9]+]*\-.*"
hseigel
parents: 33957
diff changeset
    35
     * Check the 'vendor' properties and java.vm.specification.version property.
7381
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    36
     */
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    37
    public static void main(String[] args) throws Exception {
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    38
46639
c6618ddbe993 8183400: runtime/6981737/Test6981737.java fails with java.lang.RuntimeException: FAIL: Wrong value for java.version property, "9", expected to be of form: "[0-9]+[\\.[0-9]+]*\-.*"
hseigel
parents: 33957
diff changeset
    39
        String vendor_re = "Oracle Corporation";
50531
aeb7fb702890 8204565: (spec) Document java.{vm.}?specification.version system properties' relation to $FEATURE
bchristi
parents: 48553
diff changeset
    40
        int feature_version = Runtime.version().feature();
aeb7fb702890 8204565: (spec) Document java.{vm.}?specification.version system properties' relation to $FEATURE
bchristi
parents: 48553
diff changeset
    41
        String vm_spec_version_re = Integer.toString(feature_version);
7381
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    42
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    43
        verifyProperty("java.vm.specification.vendor", vendor_re);
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    44
        verifyProperty("java.specification.vendor", vendor_re);
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    45
        verifyProperty("java.vm.specification.version", vm_spec_version_re);
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    46
        System.out.println("PASS");
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    47
    }
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    48
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    49
    public static String verifyProperty(String name, String expected_re) {
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    50
        String value = System.getProperty(name, "");
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    51
        System.out.print("Checking " + name + ": \"" + value +
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    52
          "\".matches(\"" + expected_re + "\")... ");
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    53
        if (!value.matches(expected_re)) {
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    54
            System.out.println("no.");
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    55
            throw new RuntimeException("FAIL: Wrong value for " + name +
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    56
                " property, \"" + value + "\", expected to be of form: \"" +
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    57
                expected_re + "\"");
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    58
        }
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    59
        System.out.println("yes.");
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    60
        return value;
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    61
    }
5d924959cd81 6981737: The java.vm.specification.version property is 1.0, seems like it should be 2.0
kamg
parents:
diff changeset
    62
}