src/hotspot/share/runtime/java.hpp
changeset 47216 71c04702a3d5
parent 44326 6c59cca7ff07
child 49364 601146c66cad
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 /*
       
     2  * Copyright (c) 1997, 2017, 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 VALUE_OBJ_CLASS_SPEC {
       
    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 
       
    69   uint8_t _major;
       
    70   uint8_t _minor;
       
    71   uint8_t _security;
       
    72   uint8_t _patch;
       
    73   uint8_t _build;
       
    74 
       
    75   bool _thread_park_blocker;
       
    76   bool _post_vm_init_hook_enabled;
       
    77 
       
    78   bool is_valid() const {
       
    79     return (_major != 0);
       
    80   }
       
    81 
       
    82   // initializes or partially initializes the _current static field
       
    83   static void initialize();
       
    84 
       
    85  public:
       
    86 
       
    87   JDK_Version() : _major(0), _minor(0), _security(0), _patch(0), _build(0),
       
    88                   _thread_park_blocker(false), _post_vm_init_hook_enabled(false)
       
    89                   {}
       
    90 
       
    91   JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t security = 0,
       
    92               uint8_t patch = 0, uint8_t build = 0,
       
    93               bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false) :
       
    94       _major(major), _minor(minor), _security(security), _patch(patch), _build(build),
       
    95       _thread_park_blocker(thread_park_blocker),
       
    96       _post_vm_init_hook_enabled(post_vm_init_hook_enabled)
       
    97       {}
       
    98 
       
    99   // Returns the current running JDK version
       
   100   static JDK_Version current() { return _current; }
       
   101 
       
   102   // Factory methods for convenience
       
   103   static JDK_Version jdk(uint8_t m) {
       
   104     return JDK_Version(m);
       
   105   }
       
   106 
       
   107   static JDK_Version undefined() {
       
   108     return JDK_Version(0);
       
   109   }
       
   110 
       
   111   bool is_undefined() const {
       
   112     return _major == 0;
       
   113   }
       
   114 
       
   115   uint8_t major_version() const          { return _major; }
       
   116   uint8_t minor_version() const          { return _minor; }
       
   117   uint8_t security_version() const       { return _security; }
       
   118   uint8_t patch_version() const          { return _patch; }
       
   119   uint8_t build_number() const           { return _build; }
       
   120 
       
   121   bool supports_thread_park_blocker() const {
       
   122     return _thread_park_blocker;
       
   123   }
       
   124   bool post_vm_init_hook_enabled() const {
       
   125     return _post_vm_init_hook_enabled;
       
   126   }
       
   127 
       
   128   // Performs a full ordering comparison using all fields (patch, build, etc.)
       
   129   int compare(const JDK_Version& other) const;
       
   130 
       
   131   /**
       
   132    * Performs comparison using only the major version, returning negative
       
   133    * if the major version of 'this' is less than the parameter, 0 if it is
       
   134    * equal, and a positive value if it is greater.
       
   135    */
       
   136   int compare_major(int version) const {
       
   137       return major_version() - version;
       
   138   }
       
   139 
       
   140   void to_string(char* buffer, size_t buflen) const;
       
   141 
       
   142   static const char* runtime_name() {
       
   143     return _runtime_name;
       
   144   }
       
   145   static void set_runtime_name(const char* name) {
       
   146     _runtime_name = name;
       
   147   }
       
   148 
       
   149   static const char* runtime_version() {
       
   150     return _runtime_version;
       
   151   }
       
   152   static void set_runtime_version(const char* version) {
       
   153     _runtime_version = version;
       
   154   }
       
   155 
       
   156 };
       
   157 
       
   158 #endif // SHARE_VM_RUNTIME_JAVA_HPP