< prev index next >

hotspot/src/share/vm/runtime/java.hpp

Print this page




  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(Handle exception);
  49 extern void vm_exit_during_initialization(Symbol* exception_name, const char* message);
  50 extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
  51 extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
  52 
  53 /**
  54  * Discovering the JDK_Version during initialization is tricky when the
  55  * running JDK is less than JDK6.  For JDK6 and greater, a "GetVersion"
  56  * function exists in libjava.so and we simply call it during the
  57  * 'initialize()' call to find the version.  For JDKs with version < 6, no
  58  * such call exists and we have to probe the JDK in order to determine
  59  * the exact version.  This probing cannot happen during late in
  60  * the VM initialization process so there's a period of time during
  61  * initialization when we don't know anything about the JDK version other than
  62  * that it less than version 6.  This is the "partially initialized" time,
  63  * when we can answer only certain version queries (such as, is the JDK
  64  * version greater than 5?  Answer: no).  Once the JDK probing occurs, we
  65  * know the version and are considered fully initialized.
  66  */
  67 class JDK_Version VALUE_OBJ_CLASS_SPEC {
  68   friend class VMStructs;
  69   friend class Universe;
  70   friend void JDK_Version_init();
  71  private:
  72 
  73   static JDK_Version _current;
  74   static const char* _runtime_name;
  75   static const char* _runtime_version;
  76 
  77   // In this class, we promote the minor version of release to be the
  78   // major version for releases >= 5 in anticipation of the JDK doing the
  79   // same thing.  For example, we represent "1.5.0" as major version 5 (we
  80   // drop the leading 1 and use 5 as the 'major').
  81 
  82   uint8_t _major;
  83   uint8_t _minor;
  84   uint8_t _security;
  85   uint8_t _update;
  86   uint8_t _special;
  87   uint8_t _build;
  88 
  89   // If partially initialized, the above fields are invalid and we know
  90   // that we're less than major version 6.
  91   bool _partially_initialized;
  92 
  93   bool _thread_park_blocker;
  94   bool _post_vm_init_hook_enabled;
  95 
  96   bool is_valid() const {
  97     return (_major != 0 || _partially_initialized);
  98   }
  99 
 100   // initializes or partially initializes the _current static field
 101   static void initialize();
 102 
 103   // Completes initialization for a pre-JDK6 version.
 104   static void fully_initialize(uint8_t major, uint8_t minor = 0,
 105                                uint8_t security = 0, uint8_t update = 0);
 106 
 107  public:
 108 
 109   // Returns true if the the current version has only been partially initialized
 110   static bool is_partially_initialized() {
 111     return _current._partially_initialized;
 112   }
 113 
 114   JDK_Version() : _major(0), _minor(0), _security(0), _update(0),
 115                   _special(0), _build(0), _partially_initialized(false),
 116                   _thread_park_blocker(false), _post_vm_init_hook_enabled(false)
 117                   {}
 118 
 119   JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t security = 0,
 120               uint8_t update = 0, uint8_t special = 0, uint8_t build = 0,
 121               bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false) :
 122       _major(major), _minor(minor), _security(security), _update(update),
 123       _special(special), _build(build), _partially_initialized(false),
 124       _thread_park_blocker(thread_park_blocker),
 125       _post_vm_init_hook_enabled(post_vm_init_hook_enabled)
 126       {}
 127 
 128   // Returns the current running JDK version
 129   static JDK_Version current() { return _current; }
 130 
 131   // Factory methods for convenience
 132   static JDK_Version jdk(uint8_t m) {
 133     return JDK_Version(m);
 134   }
 135 
 136   static JDK_Version jdk_update(uint8_t major, uint8_t update_number) {
 137     return JDK_Version(major, 0, 0, update_number);
 138   }
 139 
 140   uint8_t major_version() const          { return _major; }
 141   uint8_t minor_version() const          { return _minor; }
 142   uint8_t security_version() const          { return _security; }
 143   uint8_t update_version() const         { return _update; }
 144   uint8_t special_update_version() const { return _special; }
 145   uint8_t build_number() const           { return _build; }
 146 
 147   bool supports_thread_park_blocker() const {
 148     return _thread_park_blocker;
 149   }
 150   bool post_vm_init_hook_enabled() const {
 151     return _post_vm_init_hook_enabled;
 152   }
 153 
 154   // Performs a full ordering comparison using all fields (update, build, etc.)
 155   int compare(const JDK_Version& other) const;
 156 
 157   /**
 158    * Performs comparison using only the major version, returning negative
 159    * if the major version of 'this' is less than the parameter, 0 if it is
 160    * equal, and a positive value if it is greater.
 161    */
 162   int compare_major(int version) const {
 163     if (_partially_initialized) {
 164       if (version >= 6) {
 165         return -1;
 166       } else {
 167         assert(false, "Can't make this comparison during init time");
 168         return -1; // conservative
 169       }
 170     } else {
 171       return major_version() - version;
 172     }
 173   }
 174 
 175   void to_string(char* buffer, size_t buflen) const;
 176 
 177   static const char* runtime_name() {
 178     return _runtime_name;
 179   }
 180   static void set_runtime_name(const char* name) {
 181     _runtime_name = name;
 182   }
 183 
 184   static const char* runtime_version() {
 185     return _runtime_version;
 186   }
 187   static void set_runtime_version(const char* version) {
 188     _runtime_version = version;
 189   }
 190 
 191 };
 192 
 193 #endif // SHARE_VM_RUNTIME_JAVA_HPP


  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(Handle exception);
  49 extern void vm_exit_during_initialization(Symbol* exception_name, const char* message);
  50 extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
  51 extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
  52 
  53 /**
  54  * With the integration of the changes to handle the version string
  55  * as defined by JEP-223, most of the code related to handle the version
  56  * string prior to JDK 1.6 was removed (partial initialization)









  57  */
  58 class JDK_Version VALUE_OBJ_CLASS_SPEC {
  59   friend class VMStructs;
  60   friend class Universe;
  61   friend void JDK_Version_init();
  62  private:
  63 
  64   static JDK_Version _current;
  65   static const char* _runtime_name;
  66   static const char* _runtime_version;
  67 





  68   uint8_t _major;
  69   uint8_t _minor;
  70   uint8_t _security;
  71   uint8_t _patch;

  72   uint8_t _build;
  73 




  74   bool _thread_park_blocker;
  75   bool _post_vm_init_hook_enabled;
  76 
  77   bool is_valid() const {
  78     return (_major != 0);
  79   }
  80 
  81   // initializes or partially initializes the _current static field
  82   static void initialize();
  83 




  84  public:
  85 
  86   JDK_Version() : _major(0), _minor(0), _security(0), _patch(0), _build(0),






  87                   _thread_park_blocker(false), _post_vm_init_hook_enabled(false)
  88                   {}
  89 
  90   JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t security = 0,
  91               uint8_t patch = 0, uint8_t build = 0,
  92               bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false) :
  93       _major(major), _minor(minor), _security(security), _patch(patch), _build(build),

  94       _thread_park_blocker(thread_park_blocker),
  95       _post_vm_init_hook_enabled(post_vm_init_hook_enabled)
  96       {}
  97 
  98   // Returns the current running JDK version
  99   static JDK_Version current() { return _current; }
 100 
 101   // Factory methods for convenience
 102   static JDK_Version jdk(uint8_t m) {
 103     return JDK_Version(m);
 104   }
 105 




 106   uint8_t major_version() const          { return _major; }
 107   uint8_t minor_version() const          { return _minor; }
 108   uint8_t security_version() const       { return _security; }
 109   uint8_t patch_version() const          { return _patch; }

 110   uint8_t build_number() const           { return _build; }
 111 
 112   bool supports_thread_park_blocker() const {
 113     return _thread_park_blocker;
 114   }
 115   bool post_vm_init_hook_enabled() const {
 116     return _post_vm_init_hook_enabled;
 117   }
 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    */
 127   int compare_major(int version) const {








 128       return major_version() - version;
 129   }

 130 
 131   void to_string(char* buffer, size_t buflen) const;
 132 
 133   static const char* runtime_name() {
 134     return _runtime_name;
 135   }
 136   static void set_runtime_name(const char* name) {
 137     _runtime_name = name;
 138   }
 139 
 140   static const char* runtime_version() {
 141     return _runtime_version;
 142   }
 143   static void set_runtime_version(const char* version) {
 144     _runtime_version = version;
 145   }
 146 
 147 };
 148 
 149 #endif // SHARE_VM_RUNTIME_JAVA_HPP
< prev index next >