duke@435: /* duke@435: * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: // Register function to be called by before_exit duke@435: extern "C" { void register_on_exit_function(void (*func)(void)) ;} duke@435: duke@435: // Execute code before all handles are released and thread is killed; prologue to vm_exit duke@435: extern void before_exit(JavaThread * thread); duke@435: duke@435: // Forced VM exit (i.e, internal error or JVM_Exit) duke@435: extern void vm_exit(int code); duke@435: duke@435: // Wrapper for ::exit() duke@435: extern void vm_direct_exit(int code); duke@435: duke@435: // Shutdown the VM but do not exit the process duke@435: extern void vm_shutdown(); duke@435: // Shutdown the VM and abort the process duke@435: extern void vm_abort(); duke@435: duke@435: // Trigger any necessary notification of the VM being shutdown duke@435: extern void notify_vm_shutdown(); duke@435: duke@435: // VM exit if error occurs during initialization of VM duke@435: extern void vm_exit_during_initialization(Handle exception); duke@435: extern void vm_exit_during_initialization(symbolHandle exception_name, const char* message); duke@435: extern void vm_exit_during_initialization(const char* error, const char* message = NULL); duke@435: extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL); duke@435: duke@435: class JDK_Version : AllStatic { duke@435: friend class VMStructs; duke@435: private: duke@435: static jdk_version_info _version_info; duke@435: static bool _pre_jdk16_version; duke@435: static int _jdk_version; // JDK version number representing the release duke@435: // i.e. n in 1.n.x (= jdk_minor_version()) duke@435: duke@435: public: duke@435: static void initialize(); duke@435: static int jdk_major_version() { return JDK_VERSION_MAJOR(_version_info.jdk_version); } duke@435: static int jdk_minor_version() { return JDK_VERSION_MINOR(_version_info.jdk_version); } duke@435: static int jdk_micro_version() { return JDK_VERSION_MICRO(_version_info.jdk_version); } duke@435: static int jdk_build_number() { return JDK_VERSION_BUILD(_version_info.jdk_version); } duke@435: duke@435: static bool is_pre_jdk16_version() { return _pre_jdk16_version; } duke@435: static bool is_jdk12x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 2; } duke@435: static bool is_jdk13x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 3; } duke@435: static bool is_jdk14x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 4; } duke@435: static bool is_jdk15x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 5; } duke@435: static bool is_jdk16x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 6; } duke@435: static bool is_jdk17x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 7; } duke@435: duke@435: static bool supports_thread_park_blocker() { return _version_info.thread_park_blocker; } duke@435: duke@435: static bool is_gte_jdk14x_version() { duke@435: // Keep the semantics of this that the version number is >= 1.4 duke@435: assert(is_jdk_version_initialized(), "Not initialized"); duke@435: return _jdk_version >= 4; duke@435: } duke@435: static bool is_gte_jdk15x_version() { duke@435: // Keep the semantics of this that the version number is >= 1.5 duke@435: assert(is_jdk_version_initialized(), "Not initialized"); duke@435: return _jdk_version >= 5; duke@435: } duke@435: static bool is_gte_jdk16x_version() { duke@435: // Keep the semantics of this that the version number is >= 1.6 duke@435: assert(is_jdk_version_initialized(), "Not initialized"); duke@435: return _jdk_version >= 6; duke@435: } duke@435: duke@435: static bool is_gte_jdk17x_version() { duke@435: // Keep the semantics of this that the version number is >= 1.7 duke@435: assert(is_jdk_version_initialized(), "Not initialized"); duke@435: return _jdk_version >= 7; duke@435: } duke@435: duke@435: static bool is_jdk_version_initialized() { duke@435: return _jdk_version > 0; duke@435: } duke@435: duke@435: // These methods are defined to deal with pre JDK 1.6 versions duke@435: static void set_jdk12x_version() { duke@435: assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize"); duke@435: _jdk_version = 2; duke@435: _version_info.jdk_version = (1 << 24) | (2 << 16); duke@435: } duke@435: static void set_jdk13x_version() { duke@435: assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize"); duke@435: _jdk_version = 3; duke@435: _version_info.jdk_version = (1 << 24) | (3 << 16); duke@435: } duke@435: static void set_jdk14x_version() { duke@435: assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize"); duke@435: _jdk_version = 4; duke@435: _version_info.jdk_version = (1 << 24) | (4 << 16); duke@435: } duke@435: static void set_jdk15x_version() { duke@435: assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize"); duke@435: _jdk_version = 5; duke@435: _version_info.jdk_version = (1 << 24) | (5 << 16); duke@435: } duke@435: };