75 76 static JDK_Version _current; 77 78 // In this class, we promote the minor version of release to be the 79 // major version for releases >= 5 in anticipation of the JDK doing the 80 // same thing. For example, we represent "1.5.0" as major version 5 (we 81 // drop the leading 1 and use 5 as the 'major'). 82 83 uint8_t _major; 84 uint8_t _minor; 85 uint8_t _micro; 86 uint8_t _update; 87 uint8_t _special; 88 uint8_t _build; 89 90 // If partially initialized, the above fields are invalid and we know 91 // that we're less than major version 6. 92 bool _partially_initialized; 93 94 bool _thread_park_blocker; 95 bool _post_vm_init_hook_enabled; 96 97 bool is_valid() const { 98 return (_major != 0 || _partially_initialized); 99 } 100 101 // initializes or partially initializes the _current static field 102 static void initialize(); 103 104 // Completes initialization for a pre-JDK6 version. 105 static void fully_initialize(uint8_t major, uint8_t minor = 0, 106 uint8_t micro = 0, uint8_t update = 0); 107 108 public: 109 110 // Returns true if the the current version has only been partially initialized 111 static bool is_partially_initialized() { 112 return _current._partially_initialized; 113 } 114 115 JDK_Version() : _major(0), _minor(0), _micro(0), _update(0), 116 _special(0), _build(0), _partially_initialized(false), 117 _thread_park_blocker(false), _post_vm_init_hook_enabled(false) {} 118 119 JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 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), _micro(micro), _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 // Returns the current running JDK version 128 static JDK_Version current() { return _current; } 129 130 // Factory methods for convenience 131 static JDK_Version jdk(uint8_t m) { 132 return JDK_Version(m); 133 } 134 135 static JDK_Version jdk_update(uint8_t major, uint8_t update_number) { 136 return JDK_Version(major, 0, 0, update_number); 137 } 138 139 uint8_t major_version() const { return _major; } 140 uint8_t minor_version() const { return _minor; } 141 uint8_t micro_version() const { return _micro; } 142 uint8_t update_version() const { return _update; } 143 uint8_t special_update_version() const { return _special; } 144 uint8_t build_number() const { return _build; } 145 146 bool supports_thread_park_blocker() const { 147 return _thread_park_blocker; 148 } 149 bool post_vm_init_hook_enabled() const { 150 return _post_vm_init_hook_enabled; 151 } 152 153 // Performs a full ordering comparison using all fields (update, build, etc.) 154 int compare(const JDK_Version& other) const; 155 156 /** 157 * Performs comparison using only the major version, returning negative 158 * if the major version of 'this' is less than the parameter, 0 if it is 159 * equal, and a positive value if it is greater. 160 */ 161 int compare_major(int version) const { 162 if (_partially_initialized) { 163 if (version >= 6) { 164 return -1; 165 } else { 166 assert(false, "Can't make this comparison during init time"); 167 return -1; // conservative 168 } 169 } else { 170 return major_version() - version; 171 } | 75 76 static JDK_Version _current; 77 78 // In this class, we promote the minor version of release to be the 79 // major version for releases >= 5 in anticipation of the JDK doing the 80 // same thing. For example, we represent "1.5.0" as major version 5 (we 81 // drop the leading 1 and use 5 as the 'major'). 82 83 uint8_t _major; 84 uint8_t _minor; 85 uint8_t _micro; 86 uint8_t _update; 87 uint8_t _special; 88 uint8_t _build; 89 90 // If partially initialized, the above fields are invalid and we know 91 // that we're less than major version 6. 92 bool _partially_initialized; 93 94 bool _thread_park_blocker; 95 bool _pending_list_uses_discovered_field; 96 bool _post_vm_init_hook_enabled; 97 98 bool is_valid() const { 99 return (_major != 0 || _partially_initialized); 100 } 101 102 // initializes or partially initializes the _current static field 103 static void initialize(); 104 105 // Completes initialization for a pre-JDK6 version. 106 static void fully_initialize(uint8_t major, uint8_t minor = 0, 107 uint8_t micro = 0, uint8_t update = 0); 108 109 public: 110 111 // Returns true if the the current version has only been partially initialized 112 static bool is_partially_initialized() { 113 return _current._partially_initialized; 114 } 115 116 JDK_Version() : _major(0), _minor(0), _micro(0), _update(0), 117 _special(0), _build(0), _partially_initialized(false), 118 _thread_park_blocker(false), _post_vm_init_hook_enabled(false), 119 _pending_list_uses_discovered_field(false) {} 120 121 JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 0, 122 uint8_t update = 0, uint8_t special = 0, uint8_t build = 0, 123 bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false, 124 bool pending_list_uses_discovered_field = false) : 125 _major(major), _minor(minor), _micro(micro), _update(update), 126 _special(special), _build(build), _partially_initialized(false), 127 _thread_park_blocker(thread_park_blocker), 128 _post_vm_init_hook_enabled(post_vm_init_hook_enabled), 129 _pending_list_uses_discovered_field(pending_list_uses_discovered_field) {} 130 131 // Returns the current running JDK version 132 static JDK_Version current() { return _current; } 133 134 // Factory methods for convenience 135 static JDK_Version jdk(uint8_t m) { 136 return JDK_Version(m); 137 } 138 139 static JDK_Version jdk_update(uint8_t major, uint8_t update_number) { 140 return JDK_Version(major, 0, 0, update_number); 141 } 142 143 uint8_t major_version() const { return _major; } 144 uint8_t minor_version() const { return _minor; } 145 uint8_t micro_version() const { return _micro; } 146 uint8_t update_version() const { return _update; } 147 uint8_t special_update_version() const { return _special; } 148 uint8_t build_number() const { return _build; } 149 150 bool supports_thread_park_blocker() const { 151 return _thread_park_blocker; 152 } 153 bool post_vm_init_hook_enabled() const { 154 return _post_vm_init_hook_enabled; 155 } 156 // For compatibility wrt pre-4965777 JDK's 157 bool pending_list_uses_discovered_field() const { 158 return _pending_list_uses_discovered_field; 159 } 160 161 // Performs a full ordering comparison using all fields (update, build, etc.) 162 int compare(const JDK_Version& other) const; 163 164 /** 165 * Performs comparison using only the major version, returning negative 166 * if the major version of 'this' is less than the parameter, 0 if it is 167 * equal, and a positive value if it is greater. 168 */ 169 int compare_major(int version) const { 170 if (_partially_initialized) { 171 if (version >= 6) { 172 return -1; 173 } else { 174 assert(false, "Can't make this comparison during init time"); 175 return -1; // conservative 176 } 177 } else { 178 return major_version() - version; 179 } |