Path: blob/master/src/hotspot/share/runtime/java.hpp
40951 views
/*1* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_RUNTIME_JAVA_HPP25#define SHARE_RUNTIME_JAVA_HPP2627#include "runtime/os.hpp"28#include "utilities/globalDefinitions.hpp"2930class Handle;31class JavaThread;32class Symbol;3334// Execute code before all handles are released and thread is killed; prologue to vm_exit35extern void before_exit(JavaThread * thread);3637// Forced VM exit (i.e, internal error or JVM_Exit)38extern void vm_exit(int code);3940// Wrapper for ::exit()41extern void vm_direct_exit(int code);42extern void vm_direct_exit(int code, const char* message);4344// Shutdown the VM but do not exit the process45extern void vm_shutdown();46// Shutdown the VM and abort the process47extern void vm_abort(bool dump_core=true);4849// Trigger any necessary notification of the VM being shutdown50extern void notify_vm_shutdown();5152// VM exit if error occurs during initialization of VM53extern void vm_exit_during_initialization();54extern void vm_exit_during_initialization(Handle exception);55extern void vm_exit_during_initialization(Symbol* exception_name, const char* message);56extern void vm_exit_during_initialization(const char* error, const char* message = NULL);57extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);5859extern void vm_exit_during_cds_dumping(const char* error, const char* message = NULL);6061/**62* With the integration of the changes to handle the version string63* as defined by JEP-223, most of the code related to handle the version64* string prior to JDK 1.6 was removed (partial initialization)65*/66class JDK_Version {67friend class VMStructs;68friend class Universe;69friend void JDK_Version_init();70private:7172static JDK_Version _current;73static const char* _java_version;74static const char* _runtime_name;75static const char* _runtime_version;76static const char* _runtime_vendor_version;77static const char* _runtime_vendor_vm_bug_url;7879uint8_t _major;80uint8_t _minor;81uint8_t _security;82uint8_t _patch;83uint8_t _build;8485bool is_valid() const {86return (_major != 0);87}8889// initializes or partially initializes the _current static field90static void initialize();9192public:9394JDK_Version() :95_major(0), _minor(0), _security(0), _patch(0), _build(0)96{}9798JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t security = 0,99uint8_t patch = 0, uint8_t build = 0) :100_major(major), _minor(minor), _security(security), _patch(patch), _build(build)101{}102103// Returns the current running JDK version104static JDK_Version current() { return _current; }105106// Factory methods for convenience107static JDK_Version jdk(uint8_t m) {108return JDK_Version(m);109}110111static JDK_Version undefined() {112return JDK_Version(0);113}114115bool is_undefined() const {116return _major == 0;117}118119uint8_t major_version() const { return _major; }120uint8_t minor_version() const { return _minor; }121uint8_t security_version() const { return _security; }122uint8_t patch_version() const { return _patch; }123uint8_t build_number() const { return _build; }124125// Performs a full ordering comparison using all fields (patch, build, etc.)126int compare(const JDK_Version& other) const;127128/**129* Performs comparison using only the major version, returning negative130* if the major version of 'this' is less than the parameter, 0 if it is131* equal, and a positive value if it is greater.132*/133int compare_major(int version) const {134return major_version() - version;135}136137void to_string(char* buffer, size_t buflen) const;138139static const char* java_version() {140return _java_version;141}142static void set_java_version(const char* version) {143_java_version = os::strdup(version);144}145146static const char* runtime_name() {147return _runtime_name;148}149static void set_runtime_name(const char* name) {150_runtime_name = os::strdup(name);151}152153static const char* runtime_version() {154return _runtime_version;155}156static void set_runtime_version(const char* version) {157_runtime_version = os::strdup(version);158}159160static const char* runtime_vendor_version() {161return _runtime_vendor_version;162}163static void set_runtime_vendor_version(const char* vendor_version) {164_runtime_vendor_version = os::strdup(vendor_version);165}166167static const char* runtime_vendor_vm_bug_url() {168return _runtime_vendor_vm_bug_url;169}170static void set_runtime_vendor_vm_bug_url(const char* vendor_vm_bug_url) {171_runtime_vendor_vm_bug_url = os::strdup(vendor_vm_bug_url);172}173174};175176#endif // SHARE_RUNTIME_JAVA_HPP177178179