comparison src/share/vm/runtime/java.hpp @ 276:aa8f54688692

Merge
author trims
date Sun, 10 Aug 2008 21:31:42 -0700
parents d95b224e9f17
children c18cbe5936b8
comparison
equal deleted inserted replaced
240:585535ec8a14 276:aa8f54688692
46 extern void vm_exit_during_initialization(Handle exception); 46 extern void vm_exit_during_initialization(Handle exception);
47 extern void vm_exit_during_initialization(symbolHandle exception_name, const char* message); 47 extern void vm_exit_during_initialization(symbolHandle exception_name, const char* message);
48 extern void vm_exit_during_initialization(const char* error, const char* message = NULL); 48 extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
49 extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL); 49 extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
50 50
51 class JDK_Version : AllStatic { 51 /**
52 * Discovering the JDK_Version during initialization is tricky when the
53 * running JDK is less than JDK6. For JDK6 and greater, a "GetVersion"
54 * function exists in libjava.so and we simply call it during the
55 * 'initialize()' call to find the version. For JDKs with version < 6, no
56 * such call exists and we have to probe the JDK in order to determine
57 * the exact version. This probing cannot happen during late in
58 * the VM initialization process so there's a period of time during
59 * initialization when we don't know anything about the JDK version other than
60 * that it less than version 6. This is the "partially initialized" time,
61 * when we can answer only certain version queries (such as, is the JDK
62 * version greater than 5? Answer: no). Once the JDK probing occurs, we
63 * know the version and are considered fully initialized.
64 */
65 class JDK_Version VALUE_OBJ_CLASS_SPEC {
52 friend class VMStructs; 66 friend class VMStructs;
67 friend class Universe;
68 friend void JDK_Version_init();
53 private: 69 private:
54 static jdk_version_info _version_info; 70
55 static bool _pre_jdk16_version; 71 static JDK_Version _current;
56 static int _jdk_version; // JDK version number representing the release 72
57 // i.e. n in 1.n.x (= jdk_minor_version()) 73 // In this class, we promote the minor version of release to be the
74 // major version for releases >= 5 in anticipation of the JDK doing the
75 // same thing. For example, we represent "1.5.0" as major version 5 (we
76 // drop the leading 1 and use 5 as the 'major').
77
78 uint8_t _major;
79 uint8_t _minor;
80 uint8_t _micro;
81 uint8_t _update;
82 uint8_t _special;
83 uint8_t _build;
84
85 // If partially initialized, the above fields are invalid and we know
86 // that we're less than major version 6.
87 bool _partially_initialized;
88
89 bool _thread_park_blocker;
90
91 bool is_valid() const {
92 return (_major != 0 || _partially_initialized);
93 }
94
95 // initializes or partially initializes the _current static field
96 static void initialize();
97
98 // Completes initialization for a pre-JDK6 version.
99 static void fully_initialize(uint8_t major, uint8_t minor = 0,
100 uint8_t micro = 0, uint8_t update = 0);
58 101
59 public: 102 public:
60 static void initialize(); 103
61 static int jdk_major_version() { return JDK_VERSION_MAJOR(_version_info.jdk_version); } 104 // Returns true if the the current version has only been partially initialized
62 static int jdk_minor_version() { return JDK_VERSION_MINOR(_version_info.jdk_version); } 105 static bool is_partially_initialized() {
63 static int jdk_micro_version() { return JDK_VERSION_MICRO(_version_info.jdk_version); } 106 return _current._partially_initialized;
64 static int jdk_build_number() { return JDK_VERSION_BUILD(_version_info.jdk_version); } 107 }
65 108
66 static bool is_pre_jdk16_version() { return _pre_jdk16_version; } 109 JDK_Version() : _major(0), _minor(0), _micro(0), _update(0),
67 static bool is_jdk12x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 2; } 110 _special(0), _build(0), _partially_initialized(false),
68 static bool is_jdk13x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 3; } 111 _thread_park_blocker(false) {}
69 static bool is_jdk14x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 4; } 112
70 static bool is_jdk15x_version() { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 5; } 113 JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 0,
114 uint8_t update = 0, uint8_t special = 0, uint8_t build = 0,
115 bool thread_park_blocker = false) :
116 _major(major), _minor(minor), _micro(micro), _update(update),
117 _special(special), _build(build), _partially_initialized(false),
118 _thread_park_blocker(thread_park_blocker) {}
119
120 // Returns the current running JDK version
121 static JDK_Version current() { return _current; }
122
123 // Factory methods for convenience
124 static JDK_Version jdk(uint8_t m) {
125 return JDK_Version(m);
126 }
127
128 static JDK_Version jdk_update(uint8_t major, uint8_t update_number) {
129 return JDK_Version(major, 0, 0, update_number);
130 }
131
132 uint8_t major_version() const { return _major; }
133 uint8_t minor_version() const { return _minor; }
134 uint8_t micro_version() const { return _micro; }
135 uint8_t update_version() const { return _update; }
136 uint8_t special_update_version() const { return _special; }
137 uint8_t build_number() const { return _build; }
138
139 bool supports_thread_park_blocker() const {
140 return _thread_park_blocker;
141 }
142
143 // Performs a full ordering comparison using all fields (update, build, etc.)
144 int compare(const JDK_Version& other) const;
145
146 /**
147 * Performs comparison using only the major version, returning negative
148 * if the major version of 'this' is less than the parameter, 0 if it is
149 * equal, and a positive value if it is greater.
150 */
151 int compare_major(int version) const {
152 if (_partially_initialized) {
153 if (version >= 6) {
154 return -1;
155 } else {
156 assert(false, "Can't make this comparison during init time");
157 return -1; // conservative
158 }
159 } else {
160 return major_version() - version;
161 }
162 }
163
164 void to_string(char* buffer, size_t buflen) const;
165
166 // Convenience methods for queries on the current major/minor version
167 static bool is_jdk12x_version() {
168 return current().compare_major(2) == 0;
169 }
170
171 static bool is_jdk13x_version() {
172 return current().compare_major(3) == 0;
173 }
174
175 static bool is_jdk14x_version() {
176 return current().compare_major(4) == 0;
177 }
178
179 static bool is_jdk15x_version() {
180 return current().compare_major(5) == 0;
181 }
71 182
72 static bool is_jdk16x_version() { 183 static bool is_jdk16x_version() {
73 if (is_jdk_version_initialized()) { 184 return current().compare_major(6) == 0;
74 return _jdk_version == 6;
75 } else {
76 assert(is_pre_jdk16_version(), "must have been initialized");
77 return false;
78 }
79 } 185 }
80 186
81 static bool is_jdk17x_version() { 187 static bool is_jdk17x_version() {
82 if (is_jdk_version_initialized()) { 188 return current().compare_major(7) == 0;
83 return _jdk_version == 7; 189 }
84 } else { 190
85 assert(is_pre_jdk16_version(), "must have been initialized"); 191 static bool is_gte_jdk13x_version() {
86 return false; 192 return current().compare_major(3) >= 0;
87 } 193 }
88 }
89
90 static bool supports_thread_park_blocker() { return _version_info.thread_park_blocker; }
91 194
92 static bool is_gte_jdk14x_version() { 195 static bool is_gte_jdk14x_version() {
93 // Keep the semantics of this that the version number is >= 1.4 196 return current().compare_major(4) >= 0;
94 assert(is_jdk_version_initialized(), "Not initialized"); 197 }
95 return _jdk_version >= 4; 198
96 }
97 static bool is_gte_jdk15x_version() { 199 static bool is_gte_jdk15x_version() {
98 // Keep the semantics of this that the version number is >= 1.5 200 return current().compare_major(5) >= 0;
99 assert(is_jdk_version_initialized(), "Not initialized"); 201 }
100 return _jdk_version >= 5; 202
101 }
102 static bool is_gte_jdk16x_version() { 203 static bool is_gte_jdk16x_version() {
103 // Keep the semantics of this that the version number is >= 1.6 204 return current().compare_major(6) >= 0;
104 if (is_jdk_version_initialized()) {
105 return _jdk_version >= 6;
106 } else {
107 assert(is_pre_jdk16_version(), "Not initialized");
108 return false;
109 }
110 } 205 }
111 206
112 static bool is_gte_jdk17x_version() { 207 static bool is_gte_jdk17x_version() {
113 // Keep the semantics of this that the version number is >= 1.7 208 return current().compare_major(7) >= 0;
114 if (is_jdk_version_initialized()) {
115 return _jdk_version >= 7;
116 } else {
117 assert(is_pre_jdk16_version(), "Not initialized");
118 return false;
119 }
120 }
121
122 static bool is_jdk_version_initialized() {
123 return _jdk_version > 0;
124 }
125
126 // These methods are defined to deal with pre JDK 1.6 versions
127 static void set_jdk12x_version() {
128 assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize");
129 _jdk_version = 2;
130 _version_info.jdk_version = (1 << 24) | (2 << 16);
131 }
132 static void set_jdk13x_version() {
133 assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize");
134 _jdk_version = 3;
135 _version_info.jdk_version = (1 << 24) | (3 << 16);
136 }
137 static void set_jdk14x_version() {
138 assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize");
139 _jdk_version = 4;
140 _version_info.jdk_version = (1 << 24) | (4 << 16);
141 }
142 static void set_jdk15x_version() {
143 assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize");
144 _jdk_version = 5;
145 _version_info.jdk_version = (1 << 24) | (5 << 16);
146 } 209 }
147 }; 210 };