1 /* 2 * Copyright (c) 1997, 2019, 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_RUNTIME_JAVA_HPP 26 #define SHARE_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 extern void vm_exit_during_cds_dumping(const char* error, const char* message = NULL); 55 56 /** 57 * With the integration of the changes to handle the version string 58 * as defined by JEP-223, most of the code related to handle the version 59 * string prior to JDK 1.6 was removed (partial initialization) 60 */ 61 class JDK_Version { 62 friend class VMStructs; 63 friend class Universe; 64 friend void JDK_Version_init(); 65 private: 66 67 static JDK_Version _current; 68 static const char* _runtime_name; 69 static const char* _runtime_version; 70 static const char* _runtime_vendor_version; 71 static const char* _runtime_vendor_vm_bug_url; 72 73 uint8_t _major; 74 uint8_t _minor; 75 uint8_t _security; 76 uint8_t _patch; 77 uint8_t _build; 78 is_valid() const79 bool is_valid() const { 80 return (_major != 0); 81 } 82 83 // initializes or partially initializes the _current static field 84 static void initialize(); 85 86 public: 87 JDK_Version()88 JDK_Version() : 89 _major(0), _minor(0), _security(0), _patch(0), _build(0) 90 {} 91 JDK_Version(uint8_t major,uint8_t minor=0,uint8_t security=0,uint8_t patch=0,uint8_t build=0)92 JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t security = 0, 93 uint8_t patch = 0, uint8_t build = 0) : 94 _major(major), _minor(minor), _security(security), _patch(patch), _build(build) 95 {} 96 97 // Returns the current running JDK version current()98 static JDK_Version current() { return _current; } 99 100 // Factory methods for convenience jdk(uint8_t m)101 static JDK_Version jdk(uint8_t m) { 102 return JDK_Version(m); 103 } 104 undefined()105 static JDK_Version undefined() { 106 return JDK_Version(0); 107 } 108 is_undefined() const109 bool is_undefined() const { 110 return _major == 0; 111 } 112 major_version() const113 uint8_t major_version() const { return _major; } minor_version() const114 uint8_t minor_version() const { return _minor; } security_version() const115 uint8_t security_version() const { return _security; } patch_version() const116 uint8_t patch_version() const { return _patch; } build_number() const117 uint8_t build_number() const { return _build; } 118 119 // Performs a full ordering comparison using all fields (patch, build, etc.) 120 int compare(const JDK_Version& other) const; 121 122 /** 123 * Performs comparison using only the major version, returning negative 124 * if the major version of 'this' is less than the parameter, 0 if it is 125 * equal, and a positive value if it is greater. 126 */ compare_major(int version) const127 int compare_major(int version) const { 128 return major_version() - version; 129 } 130 131 void to_string(char* buffer, size_t buflen) const; 132 runtime_name()133 static const char* runtime_name() { 134 return _runtime_name; 135 } set_runtime_name(const char * name)136 static void set_runtime_name(const char* name) { 137 _runtime_name = name; 138 } 139 runtime_version()140 static const char* runtime_version() { 141 return _runtime_version; 142 } set_runtime_version(const char * version)143 static void set_runtime_version(const char* version) { 144 _runtime_version = version; 145 } 146 runtime_vendor_version()147 static const char* runtime_vendor_version() { 148 return _runtime_vendor_version; 149 } set_runtime_vendor_version(const char * vendor_version)150 static void set_runtime_vendor_version(const char* vendor_version) { 151 _runtime_vendor_version = vendor_version; 152 } 153 runtime_vendor_vm_bug_url()154 static const char* runtime_vendor_vm_bug_url() { 155 return _runtime_vendor_vm_bug_url; 156 } set_runtime_vendor_vm_bug_url(const char * vendor_vm_bug_url)157 static void set_runtime_vendor_vm_bug_url(const char* vendor_vm_bug_url) { 158 _runtime_vendor_vm_bug_url = vendor_vm_bug_url; 159 } 160 161 }; 162 163 #endif // SHARE_RUNTIME_JAVA_HPP 164