1 /* 2 * Copyright (c) 1997, 2018, 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 */ 24 25 #ifndef SHARE_VM_RUNTIME_JAVA_HPP 26 #define SHARE_VM_RUNTIME_JAVA_HPP 27 28 #include "runtime/os.hpp" 29 30 // Execute code before all handles are released and thread is killed; prologue to vm_exit 31 extern void before_exit(JavaThread * thread); 32 33 // Forced VM exit (i.e, internal error or JVM_Exit) 34 extern void vm_exit(int code); 35 36 // Wrapper for ::exit() 37 extern void vm_direct_exit(int code); 38 39 // Shutdown the VM but do not exit the process 40 extern void vm_shutdown(); 41 // Shutdown the VM and abort the process 42 extern void vm_abort(bool dump_core=true); 43 44 // Trigger any necessary notification of the VM being shutdown 45 extern void notify_vm_shutdown(); 46 47 // VM exit if error occurs during initialization of VM 48 extern void vm_exit_during_initialization(); 49 extern void vm_exit_during_initialization(Handle exception); 50 extern void vm_exit_during_initialization(Symbol* exception_name, const char* message); 51 extern void vm_exit_during_initialization(const char* error, const char* message = NULL); 52 extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL); 53 54 /** 55 * With the integration of the changes to handle the version string 56 * as defined by JEP-223, most of the code related to handle the version 57 * string prior to JDK 1.6 was removed (partial initialization) 58 */ 59 class JDK_Version { 60 friend class VMStructs; 61 friend class Universe; 62 friend void JDK_Version_init(); 63 private: 64 65 static JDK_Version _current; 66 static const char* _runtime_name; 67 static const char* _runtime_version; 68 static const char* _runtime_vendor_version; 69 static const char* _runtime_vendor_vm_bug_url; 70 71 uint8_t _major; 72 uint8_t _minor; 73 uint8_t _security; 74 uint8_t _patch; 75 uint8_t _build; 76 77 bool _thread_park_blocker; 78 bool _post_vm_init_hook_enabled; 79 is_valid() const80 bool is_valid() const { 81 return (_major != 0); 82 } 83 84 // initializes or partially initializes the _current static field 85 static void initialize(); 86 87 public: 88 JDK_Version()89 JDK_Version() : _major(0), _minor(0), _security(0), _patch(0), _build(0), 90 _thread_park_blocker(false), _post_vm_init_hook_enabled(false) 91 {} 92 JDK_Version(uint8_t major,uint8_t minor=0,uint8_t security=0,uint8_t patch=0,uint8_t build=0,bool thread_park_blocker=false,bool post_vm_init_hook_enabled=false)93 JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t security = 0, 94 uint8_t patch = 0, uint8_t build = 0, 95 bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false) : 96 _major(major), _minor(minor), _security(security), _patch(patch), _build(build), 97 _thread_park_blocker(thread_park_blocker), 98 _post_vm_init_hook_enabled(post_vm_init_hook_enabled) 99 {} 100 101 // Returns the current running JDK version current()102 static JDK_Version current() { return _current; } 103 104 // Factory methods for convenience jdk(uint8_t m)105 static JDK_Version jdk(uint8_t m) { 106 return JDK_Version(m); 107 } 108 undefined()109 static JDK_Version undefined() { 110 return JDK_Version(0); 111 } 112 is_undefined() const113 bool is_undefined() const { 114 return _major == 0; 115 } 116 major_version() const117 uint8_t major_version() const { return _major; } minor_version() const118 uint8_t minor_version() const { return _minor; } security_version() const119 uint8_t security_version() const { return _security; } patch_version() const120 uint8_t patch_version() const { return _patch; } build_number() const121 uint8_t build_number() const { return _build; } 122 supports_thread_park_blocker() const123 bool supports_thread_park_blocker() const { 124 return _thread_park_blocker; 125 } post_vm_init_hook_enabled() const126 bool post_vm_init_hook_enabled() const { 127 return _post_vm_init_hook_enabled; 128 } 129 130 // Performs a full ordering comparison using all fields (patch, build, etc.) 131 int compare(const JDK_Version& other) const; 132 133 /** 134 * Performs comparison using only the major version, returning negative 135 * if the major version of 'this' is less than the parameter, 0 if it is 136 * equal, and a positive value if it is greater. 137 */ compare_major(int version) const138 int compare_major(int version) const { 139 return major_version() - version; 140 } 141 142 void to_string(char* buffer, size_t buflen) const; 143 runtime_name()144 static const char* runtime_name() { 145 return _runtime_name; 146 } set_runtime_name(const char * name)147 static void set_runtime_name(const char* name) { 148 _runtime_name = name; 149 } 150 runtime_version()151 static const char* runtime_version() { 152 return _runtime_version; 153 } set_runtime_version(const char * version)154 static void set_runtime_version(const char* version) { 155 _runtime_version = version; 156 } 157 runtime_vendor_version()158 static const char* runtime_vendor_version() { 159 return _runtime_vendor_version; 160 } set_runtime_vendor_version(const char * vendor_version)161 static void set_runtime_vendor_version(const char* vendor_version) { 162 _runtime_vendor_version = vendor_version; 163 } 164 runtime_vendor_vm_bug_url()165 static const char* runtime_vendor_vm_bug_url() { 166 return _runtime_vendor_vm_bug_url; 167 } set_runtime_vendor_vm_bug_url(const char * vendor_vm_bug_url)168 static void set_runtime_vendor_vm_bug_url(const char* vendor_vm_bug_url) { 169 _runtime_vendor_vm_bug_url = vendor_vm_bug_url; 170 } 171 172 }; 173 174 #endif // SHARE_VM_RUNTIME_JAVA_HPP 175