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
93 }
94
95 public static boolean isOSX() {
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() {
|
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 osVersion = System.getProperty("os.version");
32 private static int osVersion_major = -1;
33 private static int osVersion_minor = -1;
34 private static final String osName = System.getProperty("os.name");
35 private static final String dataModel = System.getProperty("sun.arch.data.model");
36 private static final String vmVersion = System.getProperty("java.vm.version");
37 private static final String jdkDebug = System.getProperty("jdk.debug");
38 private static final String osArch = System.getProperty("os.arch");
39 private static final String userName = System.getProperty("user.name");
40 private static final String compiler = System.getProperty("sun.management.compiler");
41
42 public static boolean isClient() {
43 return vmName.endsWith(" Client VM");
44 }
45
46 public static boolean isServer() {
47 return vmName.endsWith(" Server VM");
48 }
49
50 public static boolean isGraal() {
51 return vmName.endsWith(" Graal VM");
52 }
53
96 }
97
98 public static boolean isOSX() {
99 return isOs("mac");
100 }
101
102 public static boolean isSolaris() {
103 return isOs("sunos");
104 }
105
106 public static boolean isWindows() {
107 return isOs("win");
108 }
109
110 private static boolean isOs(String osname) {
111 return osName.toLowerCase().startsWith(osname.toLowerCase());
112 }
113
114 public static String getOsName() {
115 return osName;
116 }
117
118 // Os version support.
119 private static void init_version() {
120 try {
121 final String[] tokens = osVersion.split("\\.");
122 if (tokens.length > 0) {
123 osVersion_major = Integer.parseInt(tokens[0]);
124 if (tokens.length > 1) {
125 osVersion_minor = Integer.parseInt(tokens[1]);
126 }
127 }
128 } catch (NumberFormatException e) {
129 osVersion_major = osVersion_minor = 0;
130 }
131 }
132
133 // Returns major version number from os.version system property.
134 // E.g. 5 on Solaris 10 and 3 on SLES 11.3 (for the linux kernel version).
135 public static int getOsVersionMajor() {
136 if (osVersion_major == -1) init_version();
137 return osVersion_major;
138 }
139
140 // Returns major version number from os.version system property.
141 // E.g. 10 on Solaris 10 and 0 on SLES 11.3 (for the linux kernel version).
142 public static int getOsVersionMinor() {
143 if (osVersion_minor == -1) init_version();
144 return osVersion_minor;
145 }
146
147 public static boolean isDebugBuild() {
148 return (jdkDebug.toLowerCase().contains("debug"));
149 }
150
151 public static String getVMVersion() {
152 return vmVersion;
153 }
154
155 // Returns true for sparc and sparcv9.
156 public static boolean isSparc() {
157 return isArch("sparc.*");
158 }
159
160 public static boolean isARM() {
161 return isArch("arm.*");
162 }
163
164 public static boolean isPPC() {
|