author | xdono |
Wed, 02 Jul 2008 12:55:16 -0700 | |
changeset 670 | ddf3e9583f2f |
parent 602 | 92e03692ddd6 |
child 781 | e1baa9c8f16f |
permissions | -rw-r--r-- |
1 | 1 |
/* |
670 | 2 |
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
1 | 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 |
* have any questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
// Register function to be called by before_exit |
|
26 |
extern "C" { void register_on_exit_function(void (*func)(void)) ;} |
|
27 |
||
28 |
// Execute code before all handles are released and thread is killed; prologue to vm_exit |
|
29 |
extern void before_exit(JavaThread * thread); |
|
30 |
||
31 |
// Forced VM exit (i.e, internal error or JVM_Exit) |
|
32 |
extern void vm_exit(int code); |
|
33 |
||
34 |
// Wrapper for ::exit() |
|
35 |
extern void vm_direct_exit(int code); |
|
36 |
||
37 |
// Shutdown the VM but do not exit the process |
|
38 |
extern void vm_shutdown(); |
|
39 |
// Shutdown the VM and abort the process |
|
40 |
extern void vm_abort(); |
|
41 |
||
42 |
// Trigger any necessary notification of the VM being shutdown |
|
43 |
extern void notify_vm_shutdown(); |
|
44 |
||
45 |
// VM exit if error occurs during initialization of VM |
|
46 |
extern void vm_exit_during_initialization(Handle exception); |
|
47 |
extern void vm_exit_during_initialization(symbolHandle exception_name, const char* message); |
|
48 |
extern void vm_exit_during_initialization(const char* error, const char* message = NULL); |
|
49 |
extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL); |
|
50 |
||
51 |
class JDK_Version : AllStatic { |
|
52 |
friend class VMStructs; |
|
53 |
private: |
|
54 |
static jdk_version_info _version_info; |
|
55 |
static bool _pre_jdk16_version; |
|
56 |
static int _jdk_version; // JDK version number representing the release |
|
57 |
// i.e. n in 1.n.x (= jdk_minor_version()) |
|
58 |
||
59 |
public: |
|
60 |
static void initialize(); |
|
61 |
static int jdk_major_version() { return JDK_VERSION_MAJOR(_version_info.jdk_version); } |
|
62 |
static int jdk_minor_version() { return JDK_VERSION_MINOR(_version_info.jdk_version); } |
|
63 |
static int jdk_micro_version() { return JDK_VERSION_MICRO(_version_info.jdk_version); } |
|
64 |
static int jdk_build_number() { return JDK_VERSION_BUILD(_version_info.jdk_version); } |
|
65 |
||
66 |
static bool is_pre_jdk16_version() { return _pre_jdk16_version; } |
|
67 |
static bool is_jdk12x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 2; } |
|
68 |
static bool is_jdk13x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 3; } |
|
69 |
static bool is_jdk14x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 4; } |
|
70 |
static bool is_jdk15x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 5; } |
|
602
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
71 |
|
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
72 |
static bool is_jdk16x_version() { |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
73 |
if (is_jdk_version_initialized()) { |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
74 |
return _jdk_version == 6; |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
75 |
} else { |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
76 |
assert(is_pre_jdk16_version(), "must have been initialized"); |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
77 |
return false; |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
78 |
} |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
79 |
} |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
80 |
|
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
81 |
static bool is_jdk17x_version() { |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
82 |
if (is_jdk_version_initialized()) { |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
83 |
return _jdk_version == 7; |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
84 |
} else { |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
85 |
assert(is_pre_jdk16_version(), "must have been initialized"); |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
86 |
return false; |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
87 |
} |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
88 |
} |
1 | 89 |
|
90 |
static bool supports_thread_park_blocker() { return _version_info.thread_park_blocker; } |
|
91 |
||
92 |
static bool is_gte_jdk14x_version() { |
|
93 |
// Keep the semantics of this that the version number is >= 1.4 |
|
94 |
assert(is_jdk_version_initialized(), "Not initialized"); |
|
95 |
return _jdk_version >= 4; |
|
96 |
} |
|
97 |
static bool is_gte_jdk15x_version() { |
|
98 |
// Keep the semantics of this that the version number is >= 1.5 |
|
99 |
assert(is_jdk_version_initialized(), "Not initialized"); |
|
100 |
return _jdk_version >= 5; |
|
101 |
} |
|
102 |
static bool is_gte_jdk16x_version() { |
|
103 |
// Keep the semantics of this that the version number is >= 1.6 |
|
602
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
104 |
if (is_jdk_version_initialized()) { |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
105 |
return _jdk_version >= 6; |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
106 |
} else { |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
107 |
assert(is_pre_jdk16_version(), "Not initialized"); |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
108 |
return false; |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
109 |
} |
1 | 110 |
} |
111 |
||
112 |
static bool is_gte_jdk17x_version() { |
|
113 |
// Keep the semantics of this that the version number is >= 1.7 |
|
602
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
114 |
if (is_jdk_version_initialized()) { |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
115 |
return _jdk_version >= 7; |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
116 |
} else { |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
117 |
assert(is_pre_jdk16_version(), "Not initialized"); |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
118 |
return false; |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
119 |
} |
1 | 120 |
} |
121 |
||
122 |
static bool is_jdk_version_initialized() { |
|
123 |
return _jdk_version > 0; |
|
124 |
} |
|
125 |
||
126 |
// These methods are defined to deal with pre JDK 1.6 versions |
|
127 |
static void set_jdk12x_version() { |
|
128 |
assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize"); |
|
129 |
_jdk_version = 2; |
|
130 |
_version_info.jdk_version = (1 << 24) | (2 << 16); |
|
131 |
} |
|
132 |
static void set_jdk13x_version() { |
|
133 |
assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize"); |
|
134 |
_jdk_version = 3; |
|
135 |
_version_info.jdk_version = (1 << 24) | (3 << 16); |
|
136 |
} |
|
137 |
static void set_jdk14x_version() { |
|
138 |
assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize"); |
|
139 |
_jdk_version = 4; |
|
140 |
_version_info.jdk_version = (1 << 24) | (4 << 16); |
|
141 |
} |
|
142 |
static void set_jdk15x_version() { |
|
143 |
assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize"); |
|
144 |
_jdk_version = 5; |
|
145 |
_version_info.jdk_version = (1 << 24) | (5 << 16); |
|
146 |
} |
|
147 |
}; |