01: /* JVMs.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Wed Mar 21 20:29:16 2007, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.lang;
20:
21: import org.zkoss.util.Utils;
22:
23: /**
24: * Utilities of Java Virtual Machine.
25: *
26: * @author tomyeh
27: */
28: public class JVMs {
29: private JVMs() {
30: }
31:
32: private static final int _major, _minor;
33: private static final boolean _j5, _j6;
34: static {
35: final String s = System.getProperty("java.version");
36: _major = Utils.getSubversion(s, 0);
37: _minor = Utils.getSubversion(s, 1);
38: _j5 = (_major == 1 && _minor >= 5) || _major >= 5;
39: _j6 = (_major == 1 && _minor >= 6) || _major >= 6;
40: }
41:
42: /** Returns whether JVM is 5.0 or above.
43: *
44: * <p>Note: if {@link #isJava5} returns true, then {@link #isJava6}
45: * must return true.
46: */
47: public static final boolean isJava5() {
48: return _j5;
49: }
50:
51: /** Returns whether JVM is 6.0 or above.
52: */
53: public static final boolean isJava6() {
54: return _j6;
55: }
56:
57: /** Returns the major version.
58: */
59: public static final int getMajorVersion() {
60: return _major;
61: }
62:
63: /** Returns the minor version.
64: */
65: public static final int getMinorVersion() {
66: return _minor;
67: }
68: }
|