1 /*
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package jdk.test.lib;
25
26 import java.util.regex.Pattern;
27
28 public class Platform {
29 public static final String vmName = System.getProperty("java.vm.name");
30 public static final String vmInfo = System.getProperty("java.vm.info");
31 private static final String osName = System.getProperty("os.name");
32 private static final String dataModel = System.getProperty("sun.arch.data.model");
33 private static final String vmVersion = System.getProperty("java.vm.version");
34 private static final String javaVersion = System.getProperty("java.version");
35 private static final String osArch = System.getProperty("os.arch");
36 private static final String userName = System.getProperty("user.name");
37 private static final String compiler = System.getProperty("sun.management.compiler");
38
39 public static boolean isClient() {
40 return vmName.endsWith(" Client VM");
41 }
42
43 public static boolean isServer() {
44 return vmName.endsWith(" Server VM");
45 }
46
47 public static boolean isGraal() {
48 return vmName.endsWith(" Graal VM");
49 }
50
51 public static boolean isZero() {
52 return vmName.endsWith(" Zero VM");
53 }
54
96 return isOs("mac");
97 }
98
99 public static boolean isSolaris() {
100 return isOs("sunos");
101 }
102
103 public static boolean isWindows() {
104 return isOs("win");
105 }
106
107 private static boolean isOs(String osname) {
108 return osName.toLowerCase().startsWith(osname.toLowerCase());
109 }
110
111 public static String getOsName() {
112 return osName;
113 }
114
115 public static boolean isDebugBuild() {
116 return (vmVersion.toLowerCase().contains("debug") ||
117 javaVersion.toLowerCase().contains("debug"));
118 }
119
120 public static String getVMVersion() {
121 return vmVersion;
122 }
123
124 // Returns true for sparc and sparcv9.
125 public static boolean isSparc() {
126 return isArch("sparc.*");
127 }
128
129 public static boolean isARM() {
130 return isArch("arm.*");
131 }
132
133 public static boolean isPPC() {
134 return isArch("ppc.*");
135 }
136
137 public static boolean isX86() {
|
1 /*
2 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package jdk.test.lib;
25
26 import java.util.regex.Pattern;
27
28 public class Platform {
29 public static final String vmName = System.getProperty("java.vm.name");
30 public static final String vmInfo = System.getProperty("java.vm.info");
31 private static final String osName = System.getProperty("os.name");
32 private static final String dataModel = System.getProperty("sun.arch.data.model");
33 private static final String vmVersion = System.getProperty("java.vm.version");
34 private static final String jdkDebug = System.getProperty("jdk.debug");
35 private static final String osArch = System.getProperty("os.arch");
36 private static final String userName = System.getProperty("user.name");
37 private static final String compiler = System.getProperty("sun.management.compiler");
38
39 public static boolean isClient() {
40 return vmName.endsWith(" Client VM");
41 }
42
43 public static boolean isServer() {
44 return vmName.endsWith(" Server VM");
45 }
46
47 public static boolean isGraal() {
48 return vmName.endsWith(" Graal VM");
49 }
50
51 public static boolean isZero() {
52 return vmName.endsWith(" Zero VM");
53 }
54
96 return isOs("mac");
97 }
98
99 public static boolean isSolaris() {
100 return isOs("sunos");
101 }
102
103 public static boolean isWindows() {
104 return isOs("win");
105 }
106
107 private static boolean isOs(String osname) {
108 return osName.toLowerCase().startsWith(osname.toLowerCase());
109 }
110
111 public static String getOsName() {
112 return osName;
113 }
114
115 public static boolean isDebugBuild() {
116 return (jdkDebug.toLowerCase().contains("debug"));
117 }
118
119 public static String getVMVersion() {
120 return vmVersion;
121 }
122
123 // Returns true for sparc and sparcv9.
124 public static boolean isSparc() {
125 return isArch("sparc.*");
126 }
127
128 public static boolean isARM() {
129 return isArch("arm.*");
130 }
131
132 public static boolean isPPC() {
133 return isArch("ppc.*");
134 }
135
136 public static boolean isX86() {
|