Tue, 09 Oct 2012 10:09:34 -0700
7197424: update copyright year to match last edit in jdk8 hotspot repository
Summary: Update copyright year to 2012 for relevant files
Reviewed-by: dholmes, coleenp
1 /*
2 * Copyright (c) 1997, 2012, 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 */
25 #ifndef SHARE_VM_RUNTIME_JAVA_HPP
26 #define SHARE_VM_RUNTIME_JAVA_HPP
28 #include "runtime/os.hpp"
30 // Register function to be called by before_exit
31 extern "C" { void register_on_exit_function(void (*func)(void)) ;}
33 // Execute code before all handles are released and thread is killed; prologue to vm_exit
34 extern void before_exit(JavaThread * thread);
36 // Forced VM exit (i.e, internal error or JVM_Exit)
37 extern void vm_exit(int code);
39 // Wrapper for ::exit()
40 extern void vm_direct_exit(int code);
42 // Shutdown the VM but do not exit the process
43 extern void vm_shutdown();
44 // Shutdown the VM and abort the process
45 extern void vm_abort(bool dump_core=true);
47 // Trigger any necessary notification of the VM being shutdown
48 extern void notify_vm_shutdown();
50 // VM exit if error occurs during initialization of VM
51 extern void vm_exit_during_initialization(Handle exception);
52 extern void vm_exit_during_initialization(Symbol* exception_name, const char* message);
53 extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
54 extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
56 /**
57 * Discovering the JDK_Version during initialization is tricky when the
58 * running JDK is less than JDK6. For JDK6 and greater, a "GetVersion"
59 * function exists in libjava.so and we simply call it during the
60 * 'initialize()' call to find the version. For JDKs with version < 6, no
61 * such call exists and we have to probe the JDK in order to determine
62 * the exact version. This probing cannot happen during late in
63 * the VM initialization process so there's a period of time during
64 * initialization when we don't know anything about the JDK version other than
65 * that it less than version 6. This is the "partially initialized" time,
66 * when we can answer only certain version queries (such as, is the JDK
67 * version greater than 5? Answer: no). Once the JDK probing occurs, we
68 * know the version and are considered fully initialized.
69 */
70 class JDK_Version VALUE_OBJ_CLASS_SPEC {
71 friend class VMStructs;
72 friend class Universe;
73 friend void JDK_Version_init();
74 private:
76 static JDK_Version _current;
77 static const char* _runtime_name;
79 // In this class, we promote the minor version of release to be the
80 // major version for releases >= 5 in anticipation of the JDK doing the
81 // same thing. For example, we represent "1.5.0" as major version 5 (we
82 // drop the leading 1 and use 5 as the 'major').
84 uint8_t _major;
85 uint8_t _minor;
86 uint8_t _micro;
87 uint8_t _update;
88 uint8_t _special;
89 uint8_t _build;
91 // If partially initialized, the above fields are invalid and we know
92 // that we're less than major version 6.
93 bool _partially_initialized;
95 bool _thread_park_blocker;
96 bool _pending_list_uses_discovered_field;
97 bool _post_vm_init_hook_enabled;
99 bool is_valid() const {
100 return (_major != 0 || _partially_initialized);
101 }
103 // initializes or partially initializes the _current static field
104 static void initialize();
106 // Completes initialization for a pre-JDK6 version.
107 static void fully_initialize(uint8_t major, uint8_t minor = 0,
108 uint8_t micro = 0, uint8_t update = 0);
110 public:
112 // Returns true if the the current version has only been partially initialized
113 static bool is_partially_initialized() {
114 return _current._partially_initialized;
115 }
117 JDK_Version() : _major(0), _minor(0), _micro(0), _update(0),
118 _special(0), _build(0), _partially_initialized(false),
119 _thread_park_blocker(false), _post_vm_init_hook_enabled(false),
120 _pending_list_uses_discovered_field(false) {}
122 JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 0,
123 uint8_t update = 0, uint8_t special = 0, uint8_t build = 0,
124 bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false,
125 bool pending_list_uses_discovered_field = false) :
126 _major(major), _minor(minor), _micro(micro), _update(update),
127 _special(special), _build(build), _partially_initialized(false),
128 _thread_park_blocker(thread_park_blocker),
129 _post_vm_init_hook_enabled(post_vm_init_hook_enabled),
130 _pending_list_uses_discovered_field(pending_list_uses_discovered_field) {}
132 // Returns the current running JDK version
133 static JDK_Version current() { return _current; }
135 // Factory methods for convenience
136 static JDK_Version jdk(uint8_t m) {
137 return JDK_Version(m);
138 }
140 static JDK_Version jdk_update(uint8_t major, uint8_t update_number) {
141 return JDK_Version(major, 0, 0, update_number);
142 }
144 uint8_t major_version() const { return _major; }
145 uint8_t minor_version() const { return _minor; }
146 uint8_t micro_version() const { return _micro; }
147 uint8_t update_version() const { return _update; }
148 uint8_t special_update_version() const { return _special; }
149 uint8_t build_number() const { return _build; }
151 bool supports_thread_park_blocker() const {
152 return _thread_park_blocker;
153 }
154 bool post_vm_init_hook_enabled() const {
155 return _post_vm_init_hook_enabled;
156 }
157 // For compatibility wrt pre-4965777 JDK's
158 bool pending_list_uses_discovered_field() const {
159 return _pending_list_uses_discovered_field;
160 }
162 // Performs a full ordering comparison using all fields (update, build, etc.)
163 int compare(const JDK_Version& other) const;
165 /**
166 * Performs comparison using only the major version, returning negative
167 * if the major version of 'this' is less than the parameter, 0 if it is
168 * equal, and a positive value if it is greater.
169 */
170 int compare_major(int version) const {
171 if (_partially_initialized) {
172 if (version >= 6) {
173 return -1;
174 } else {
175 assert(false, "Can't make this comparison during init time");
176 return -1; // conservative
177 }
178 } else {
179 return major_version() - version;
180 }
181 }
183 void to_string(char* buffer, size_t buflen) const;
185 static const char* runtime_name() {
186 return _runtime_name;
187 }
188 static void set_runtime_name(const char* name) {
189 _runtime_name = name;
190 }
192 // Convenience methods for queries on the current major/minor version
193 static bool is_jdk12x_version() {
194 return current().compare_major(2) == 0;
195 }
197 static bool is_jdk13x_version() {
198 return current().compare_major(3) == 0;
199 }
201 static bool is_jdk14x_version() {
202 return current().compare_major(4) == 0;
203 }
205 static bool is_jdk15x_version() {
206 return current().compare_major(5) == 0;
207 }
209 static bool is_jdk16x_version() {
210 return current().compare_major(6) == 0;
211 }
213 static bool is_jdk17x_version() {
214 return current().compare_major(7) == 0;
215 }
217 static bool is_jdk18x_version() {
218 return current().compare_major(8) == 0;
219 }
221 static bool is_gte_jdk13x_version() {
222 return current().compare_major(3) >= 0;
223 }
225 static bool is_gte_jdk14x_version() {
226 return current().compare_major(4) >= 0;
227 }
229 static bool is_gte_jdk15x_version() {
230 return current().compare_major(5) >= 0;
231 }
233 static bool is_gte_jdk16x_version() {
234 return current().compare_major(6) >= 0;
235 }
237 static bool is_gte_jdk17x_version() {
238 return current().compare_major(7) >= 0;
239 }
241 static bool is_gte_jdk18x_version() {
242 return current().compare_major(8) >= 0;
243 }
244 };
246 #endif // SHARE_VM_RUNTIME_JAVA_HPP