Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/6981737/Test6981737.java
32284 views
/*1* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test Test6981737.java25* @bug 698173726* @summary check for correct vm properties27* @run main Test698173728* @author kamg29*/3031public class Test6981737 {3233/**34* Check the 'vendor' properties java.vm.specification.version35* property. Before jdk7, they should be "Sun Micro..." and "1.0".36* In jdk7 onwards they should be "Oracle..." and "1.<major_version>"37*/38public static void main(String[] args) throws Exception {3940String version = verifyProperty("java.version", "[0-9]+\\.[0-9]+\\..*");41String major_version_spec = version.split("\\.")[1];42int major_version = new Integer(major_version_spec).intValue();4344String vendor_re = "Oracle Corporation";45String vm_spec_version_re = "1\\." + major_version_spec;46if (major_version < 7) {47vendor_re = "Sun Microsystems Inc\\.";48vm_spec_version_re = "1\\.0";49}50verifyProperty("java.vm.specification.vendor", vendor_re);51verifyProperty("java.specification.vendor", vendor_re);52verifyProperty("java.vm.specification.version", vm_spec_version_re);53System.out.println("PASS");54}5556public static String verifyProperty(String name, String expected_re) {57String value = System.getProperty(name, "");58System.out.print("Checking " + name + ": \"" + value +59"\".matches(\"" + expected_re + "\")... ");60if (!value.matches(expected_re)) {61System.out.println("no.");62throw new RuntimeException("FAIL: Wrong value for " + name +63" property, \"" + value + "\", expected to be of form: \"" +64expected_re + "\"");65}66System.out.println("yes.");67return value;68}69}707172