author | coleenp |
Thu, 17 Jan 2008 13:38:17 -0800 | |
changeset 195 | 9193828514c4 |
parent 1 | 489c9b5090e2 |
child 360 | 21d113ecbf6a |
permissions | -rw-r--r-- |
1 | 1 |
/* |
2 |
* Copyright 1997-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 |
* have any questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
// Interface for manipulating the basic Java classes. |
|
26 |
// |
|
27 |
// All dependencies on layout of actual Java classes should be kept here. |
|
28 |
// If the layout of any of the classes above changes the offsets must be adjusted. |
|
29 |
// |
|
30 |
// For most classes we hardwire the offsets for performance reasons. In certain |
|
31 |
// cases (e.g. java.security.AccessControlContext) we compute the offsets at |
|
32 |
// startup since the layout here differs between JDK1.2 and JDK1.3. |
|
33 |
// |
|
34 |
// Note that fields (static and non-static) are arranged with oops before non-oops |
|
35 |
// on a per class basis. The offsets below have to reflect this ordering. |
|
36 |
// |
|
37 |
// When editing the layouts please update the check_offset verification code |
|
38 |
// correspondingly. The names in the enums must be identical to the actual field |
|
39 |
// names in order for the verification code to work. |
|
40 |
||
41 |
||
42 |
// Interface to java.lang.String objects |
|
43 |
||
44 |
class java_lang_String : AllStatic { |
|
45 |
private: |
|
46 |
enum { |
|
47 |
hc_value_offset = 0, |
|
48 |
hc_offset_offset = 1, |
|
49 |
hc_count_offset = 2, |
|
50 |
hc_hash_offset = 3 |
|
51 |
}; |
|
52 |
||
53 |
static int value_offset; |
|
54 |
static int offset_offset; |
|
55 |
static int count_offset; |
|
56 |
static int hash_offset; |
|
57 |
||
58 |
static Handle basic_create(int length, bool tenured, TRAPS); |
|
59 |
static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS); |
|
60 |
||
61 |
static void set_value( oop string, typeArrayOop buffer) { string->obj_field_put(value_offset, (oop)buffer); } |
|
62 |
static void set_offset(oop string, int offset) { string->int_field_put(offset_offset, offset); } |
|
63 |
static void set_count( oop string, int count) { string->int_field_put(count_offset, count); } |
|
64 |
||
65 |
public: |
|
66 |
// Instance creation |
|
67 |
static Handle create_from_unicode(jchar* unicode, int len, TRAPS); |
|
68 |
static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS); |
|
69 |
static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS); |
|
70 |
static Handle create_from_str(const char* utf8_str, TRAPS); |
|
71 |
static oop create_oop_from_str(const char* utf8_str, TRAPS); |
|
72 |
static Handle create_from_symbol(symbolHandle symbol, TRAPS); |
|
73 |
static Handle create_from_platform_dependent_str(const char* str, TRAPS); |
|
74 |
static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS); |
|
75 |
||
76 |
static int value_offset_in_bytes() { return value_offset; } |
|
77 |
static int count_offset_in_bytes() { return count_offset; } |
|
78 |
static int offset_offset_in_bytes() { return offset_offset; } |
|
79 |
static int hash_offset_in_bytes() { return hash_offset; } |
|
80 |
||
81 |
// Accessors |
|
82 |
static typeArrayOop value(oop java_string) { |
|
83 |
assert(is_instance(java_string), "must be java_string"); |
|
84 |
return (typeArrayOop) java_string->obj_field(value_offset); |
|
85 |
} |
|
86 |
static int offset(oop java_string) { |
|
87 |
assert(is_instance(java_string), "must be java_string"); |
|
88 |
return java_string->int_field(offset_offset); |
|
89 |
} |
|
90 |
static int length(oop java_string) { |
|
91 |
assert(is_instance(java_string), "must be java_string"); |
|
92 |
return java_string->int_field(count_offset); |
|
93 |
} |
|
94 |
static int utf8_length(oop java_string); |
|
95 |
||
96 |
// String converters |
|
97 |
static char* as_utf8_string(oop java_string); |
|
98 |
static char* as_utf8_string(oop java_string, int start, int len); |
|
195
9193828514c4
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
1
diff
changeset
|
99 |
static char* as_platform_dependent_str(Handle java_string, TRAPS); |
1 | 100 |
static jchar* as_unicode_string(oop java_string, int& length); |
101 |
||
102 |
static bool equals(oop java_string, jchar* chars, int len); |
|
103 |
||
104 |
// Conversion between '.' and '/' formats |
|
105 |
static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); } |
|
106 |
static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); } |
|
107 |
||
108 |
// Conversion |
|
109 |
static symbolHandle as_symbol(Handle java_string, TRAPS); |
|
110 |
||
111 |
// Testers |
|
112 |
static bool is_instance(oop obj) { |
|
113 |
return obj != NULL && obj->klass() == SystemDictionary::string_klass(); |
|
114 |
} |
|
115 |
||
116 |
// Debugging |
|
117 |
static void print(Handle java_string, outputStream* st); |
|
118 |
friend class JavaClasses; |
|
119 |
}; |
|
120 |
||
121 |
||
122 |
// Interface to java.lang.Class objects |
|
123 |
||
124 |
class java_lang_Class : AllStatic { |
|
125 |
friend class VMStructs; |
|
126 |
private: |
|
127 |
// The fake offsets are added by the class loader when java.lang.Class is loaded |
|
128 |
||
129 |
enum { |
|
130 |
hc_klass_offset = 0, |
|
131 |
hc_array_klass_offset = 1, |
|
132 |
hc_resolved_constructor_offset = 2, |
|
133 |
hc_number_of_fake_oop_fields = 3 |
|
134 |
}; |
|
135 |
||
136 |
static int klass_offset; |
|
137 |
static int resolved_constructor_offset; |
|
138 |
static int array_klass_offset; |
|
139 |
static int number_of_fake_oop_fields; |
|
140 |
||
141 |
static void compute_offsets(); |
|
142 |
static bool offsets_computed; |
|
143 |
static int classRedefinedCount_offset; |
|
144 |
||
145 |
public: |
|
146 |
// Instance creation |
|
147 |
static oop create_mirror(KlassHandle k, TRAPS); |
|
148 |
static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); |
|
149 |
// Conversion |
|
150 |
static klassOop as_klassOop(oop java_class); |
|
151 |
// Testing |
|
152 |
static bool is_primitive(oop java_class); |
|
153 |
static BasicType primitive_type(oop java_class); |
|
154 |
static oop primitive_mirror(BasicType t); |
|
155 |
// JVM_NewInstance support |
|
156 |
static methodOop resolved_constructor(oop java_class); |
|
157 |
static void set_resolved_constructor(oop java_class, methodOop constructor); |
|
158 |
// JVM_NewArray support |
|
159 |
static klassOop array_klass(oop java_class); |
|
160 |
static void set_array_klass(oop java_class, klassOop klass); |
|
161 |
// compiler support for class operations |
|
162 |
static int klass_offset_in_bytes() { return klass_offset; } |
|
163 |
static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; } |
|
164 |
static int array_klass_offset_in_bytes() { return array_klass_offset; } |
|
165 |
// Support for classRedefinedCount field |
|
166 |
static int classRedefinedCount(oop the_class_mirror); |
|
167 |
static void set_classRedefinedCount(oop the_class_mirror, int value); |
|
168 |
// Debugging |
|
169 |
friend class JavaClasses; |
|
170 |
friend class instanceKlass; // verification code accesses offsets |
|
171 |
friend class ClassFileParser; // access to number_of_fake_fields |
|
172 |
}; |
|
173 |
||
174 |
// Interface to java.lang.Thread objects |
|
175 |
||
176 |
class java_lang_Thread : AllStatic { |
|
177 |
private: |
|
178 |
// Note that for this class the layout changed between JDK1.2 and JDK1.3, |
|
179 |
// so we compute the offsets at startup rather than hard-wiring them. |
|
180 |
static int _name_offset; |
|
181 |
static int _group_offset; |
|
182 |
static int _contextClassLoader_offset; |
|
183 |
static int _inheritedAccessControlContext_offset; |
|
184 |
static int _priority_offset; |
|
185 |
static int _eetop_offset; |
|
186 |
static int _daemon_offset; |
|
187 |
static int _stillborn_offset; |
|
188 |
static int _stackSize_offset; |
|
189 |
static int _tid_offset; |
|
190 |
static int _thread_status_offset; |
|
191 |
static int _park_blocker_offset; |
|
192 |
static int _park_event_offset ; |
|
193 |
||
194 |
static void compute_offsets(); |
|
195 |
||
196 |
public: |
|
197 |
// Instance creation |
|
198 |
static oop create(); |
|
199 |
// Returns the JavaThread associated with the thread obj |
|
200 |
static JavaThread* thread(oop java_thread); |
|
201 |
// Set JavaThread for instance |
|
202 |
static void set_thread(oop java_thread, JavaThread* thread); |
|
203 |
// Name |
|
204 |
static typeArrayOop name(oop java_thread); |
|
205 |
static void set_name(oop java_thread, typeArrayOop name); |
|
206 |
// Priority |
|
207 |
static ThreadPriority priority(oop java_thread); |
|
208 |
static void set_priority(oop java_thread, ThreadPriority priority); |
|
209 |
// Thread group |
|
210 |
static oop threadGroup(oop java_thread); |
|
211 |
// Stillborn |
|
212 |
static bool is_stillborn(oop java_thread); |
|
213 |
static void set_stillborn(oop java_thread); |
|
214 |
// Alive (NOTE: this is not really a field, but provides the correct |
|
215 |
// definition without doing a Java call) |
|
216 |
static bool is_alive(oop java_thread); |
|
217 |
// Daemon |
|
218 |
static bool is_daemon(oop java_thread); |
|
219 |
static void set_daemon(oop java_thread); |
|
220 |
// Context ClassLoader |
|
221 |
static oop context_class_loader(oop java_thread); |
|
222 |
// Control context |
|
223 |
static oop inherited_access_control_context(oop java_thread); |
|
224 |
// Stack size hint |
|
225 |
static jlong stackSize(oop java_thread); |
|
226 |
// Thread ID |
|
227 |
static jlong thread_id(oop java_thread); |
|
228 |
||
229 |
// Blocker object responsible for thread parking |
|
230 |
static oop park_blocker(oop java_thread); |
|
231 |
||
232 |
// Pointer to type-stable park handler, encoded as jlong. |
|
233 |
// Should be set when apparently null |
|
234 |
// For details, see unsafe.cpp Unsafe_Unpark |
|
235 |
static jlong park_event(oop java_thread); |
|
236 |
static bool set_park_event(oop java_thread, jlong ptr); |
|
237 |
||
238 |
// Java Thread Status for JVMTI and M&M use. |
|
239 |
// This thread status info is saved in threadStatus field of |
|
240 |
// java.lang.Thread java class. |
|
241 |
enum ThreadStatus { |
|
242 |
NEW = 0, |
|
243 |
RUNNABLE = JVMTI_THREAD_STATE_ALIVE + // runnable / running |
|
244 |
JVMTI_THREAD_STATE_RUNNABLE, |
|
245 |
SLEEPING = JVMTI_THREAD_STATE_ALIVE + // Thread.sleep() |
|
246 |
JVMTI_THREAD_STATE_WAITING + |
|
247 |
JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + |
|
248 |
JVMTI_THREAD_STATE_SLEEPING, |
|
249 |
IN_OBJECT_WAIT = JVMTI_THREAD_STATE_ALIVE + // Object.wait() |
|
250 |
JVMTI_THREAD_STATE_WAITING + |
|
251 |
JVMTI_THREAD_STATE_WAITING_INDEFINITELY + |
|
252 |
JVMTI_THREAD_STATE_IN_OBJECT_WAIT, |
|
253 |
IN_OBJECT_WAIT_TIMED = JVMTI_THREAD_STATE_ALIVE + // Object.wait(long) |
|
254 |
JVMTI_THREAD_STATE_WAITING + |
|
255 |
JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + |
|
256 |
JVMTI_THREAD_STATE_IN_OBJECT_WAIT, |
|
257 |
PARKED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park() |
|
258 |
JVMTI_THREAD_STATE_WAITING + |
|
259 |
JVMTI_THREAD_STATE_WAITING_INDEFINITELY + |
|
260 |
JVMTI_THREAD_STATE_PARKED, |
|
261 |
PARKED_TIMED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park(long) |
|
262 |
JVMTI_THREAD_STATE_WAITING + |
|
263 |
JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + |
|
264 |
JVMTI_THREAD_STATE_PARKED, |
|
265 |
BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE + // (re-)entering a synchronization block |
|
266 |
JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, |
|
267 |
TERMINATED = JVMTI_THREAD_STATE_TERMINATED |
|
268 |
}; |
|
269 |
// Write thread status info to threadStatus field of java.lang.Thread. |
|
270 |
static void set_thread_status(oop java_thread_oop, ThreadStatus status); |
|
271 |
// Read thread status info from threadStatus field of java.lang.Thread. |
|
272 |
static ThreadStatus get_thread_status(oop java_thread_oop); |
|
273 |
||
274 |
static const char* thread_status_name(oop java_thread_oop); |
|
275 |
||
276 |
// Debugging |
|
277 |
friend class JavaClasses; |
|
278 |
}; |
|
279 |
||
280 |
// Interface to java.lang.ThreadGroup objects |
|
281 |
||
282 |
class java_lang_ThreadGroup : AllStatic { |
|
283 |
private: |
|
284 |
static int _parent_offset; |
|
285 |
static int _name_offset; |
|
286 |
static int _threads_offset; |
|
287 |
static int _groups_offset; |
|
288 |
static int _maxPriority_offset; |
|
289 |
static int _destroyed_offset; |
|
290 |
static int _daemon_offset; |
|
291 |
static int _vmAllowSuspension_offset; |
|
292 |
static int _nthreads_offset; |
|
293 |
static int _ngroups_offset; |
|
294 |
||
295 |
static void compute_offsets(); |
|
296 |
||
297 |
public: |
|
298 |
// parent ThreadGroup |
|
299 |
static oop parent(oop java_thread_group); |
|
300 |
// name |
|
301 |
static typeArrayOop name(oop java_thread_group); |
|
302 |
// ("name as oop" accessor is not necessary) |
|
303 |
// Number of threads in group |
|
304 |
static int nthreads(oop java_thread_group); |
|
305 |
// threads |
|
306 |
static objArrayOop threads(oop java_thread_group); |
|
307 |
// Number of threads in group |
|
308 |
static int ngroups(oop java_thread_group); |
|
309 |
// groups |
|
310 |
static objArrayOop groups(oop java_thread_group); |
|
311 |
// maxPriority in group |
|
312 |
static ThreadPriority maxPriority(oop java_thread_group); |
|
313 |
// Destroyed |
|
314 |
static bool is_destroyed(oop java_thread_group); |
|
315 |
// Daemon |
|
316 |
static bool is_daemon(oop java_thread_group); |
|
317 |
// vmAllowSuspension |
|
318 |
static bool is_vmAllowSuspension(oop java_thread_group); |
|
319 |
// Debugging |
|
320 |
friend class JavaClasses; |
|
321 |
}; |
|
322 |
||
323 |
||
324 |
||
325 |
// Interface to java.lang.Throwable objects |
|
326 |
||
327 |
class java_lang_Throwable: AllStatic { |
|
328 |
friend class BacktraceBuilder; |
|
329 |
||
330 |
private: |
|
331 |
// Offsets |
|
332 |
enum { |
|
333 |
hc_backtrace_offset = 0, |
|
334 |
hc_detailMessage_offset = 1, |
|
335 |
hc_cause_offset = 2, // New since 1.4 |
|
336 |
hc_stackTrace_offset = 3 // New since 1.4 |
|
337 |
}; |
|
338 |
// Trace constants |
|
339 |
enum { |
|
340 |
trace_methods_offset = 0, |
|
341 |
trace_bcis_offset = 1, |
|
342 |
trace_next_offset = 2, |
|
343 |
trace_size = 3, |
|
344 |
trace_chunk_size = 32 |
|
345 |
}; |
|
346 |
||
347 |
static int backtrace_offset; |
|
348 |
static int detailMessage_offset; |
|
349 |
static int cause_offset; |
|
350 |
static int stackTrace_offset; |
|
351 |
||
352 |
// Printing |
|
353 |
static char* print_stack_element_to_buffer(methodOop method, int bci); |
|
354 |
static void print_to_stream(Handle stream, const char* str); |
|
355 |
// StackTrace (programmatic access, new since 1.4) |
|
356 |
static void clear_stacktrace(oop throwable); |
|
357 |
// No stack trace available |
|
358 |
static const char* no_stack_trace_message(); |
|
359 |
||
360 |
public: |
|
361 |
// Backtrace |
|
362 |
static oop backtrace(oop throwable); |
|
363 |
static void set_backtrace(oop throwable, oop value); |
|
364 |
// Needed by JVMTI to filter out this internal field. |
|
365 |
static int get_backtrace_offset() { return backtrace_offset;} |
|
366 |
static int get_detailMessage_offset() { return detailMessage_offset;} |
|
367 |
// Message |
|
368 |
static oop message(oop throwable); |
|
369 |
static oop message(Handle throwable); |
|
370 |
static void set_message(oop throwable, oop value); |
|
371 |
// Print stack trace stored in exception by call-back to Java |
|
372 |
// Note: this is no longer used in Merlin, but we still suppport |
|
373 |
// it for compatibility. |
|
374 |
static void print_stack_trace(oop throwable, oop print_stream); |
|
375 |
static void print_stack_element(Handle stream, methodOop method, int bci); |
|
376 |
static void print_stack_element(outputStream *st, methodOop method, int bci); |
|
377 |
static void print_stack_usage(Handle stream); |
|
378 |
||
379 |
// Allocate space for backtrace (created but stack trace not filled in) |
|
380 |
static void allocate_backtrace(Handle throwable, TRAPS); |
|
381 |
// Fill in current stack trace for throwable with preallocated backtrace (no GC) |
|
382 |
static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable); |
|
383 |
||
384 |
// Fill in current stack trace, can cause GC |
|
385 |
static void fill_in_stack_trace(Handle throwable, TRAPS); |
|
386 |
static void fill_in_stack_trace(Handle throwable); |
|
387 |
// Programmatic access to stack trace |
|
388 |
static oop get_stack_trace_element(oop throwable, int index, TRAPS); |
|
389 |
static int get_stack_trace_depth(oop throwable, TRAPS); |
|
390 |
// Printing |
|
391 |
static void print(oop throwable, outputStream* st); |
|
392 |
static void print(Handle throwable, outputStream* st); |
|
393 |
static void print_stack_trace(oop throwable, outputStream* st); |
|
394 |
// Debugging |
|
395 |
friend class JavaClasses; |
|
396 |
}; |
|
397 |
||
398 |
||
399 |
// Interface to java.lang.reflect.AccessibleObject objects |
|
400 |
||
401 |
class java_lang_reflect_AccessibleObject: AllStatic { |
|
402 |
private: |
|
403 |
// Note that to reduce dependencies on the JDK we compute these |
|
404 |
// offsets at run-time. |
|
405 |
static int override_offset; |
|
406 |
||
407 |
static void compute_offsets(); |
|
408 |
||
409 |
public: |
|
410 |
// Accessors |
|
411 |
static jboolean override(oop reflect); |
|
412 |
static void set_override(oop reflect, jboolean value); |
|
413 |
||
414 |
// Debugging |
|
415 |
friend class JavaClasses; |
|
416 |
}; |
|
417 |
||
418 |
||
419 |
// Interface to java.lang.reflect.Method objects |
|
420 |
||
421 |
class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject { |
|
422 |
private: |
|
423 |
// Note that to reduce dependencies on the JDK we compute these |
|
424 |
// offsets at run-time. |
|
425 |
static int clazz_offset; |
|
426 |
static int name_offset; |
|
427 |
static int returnType_offset; |
|
428 |
static int parameterTypes_offset; |
|
429 |
static int exceptionTypes_offset; |
|
430 |
static int slot_offset; |
|
431 |
static int modifiers_offset; |
|
432 |
static int signature_offset; |
|
433 |
static int annotations_offset; |
|
434 |
static int parameter_annotations_offset; |
|
435 |
static int annotation_default_offset; |
|
436 |
||
437 |
static void compute_offsets(); |
|
438 |
||
439 |
public: |
|
440 |
// Allocation |
|
441 |
static Handle create(TRAPS); |
|
442 |
||
443 |
// Accessors |
|
444 |
static oop clazz(oop reflect); |
|
445 |
static void set_clazz(oop reflect, oop value); |
|
446 |
||
447 |
static oop name(oop method); |
|
448 |
static void set_name(oop method, oop value); |
|
449 |
||
450 |
static oop return_type(oop method); |
|
451 |
static void set_return_type(oop method, oop value); |
|
452 |
||
453 |
static oop parameter_types(oop method); |
|
454 |
static void set_parameter_types(oop method, oop value); |
|
455 |
||
456 |
static oop exception_types(oop method); |
|
457 |
static void set_exception_types(oop method, oop value); |
|
458 |
||
459 |
static int slot(oop reflect); |
|
460 |
static void set_slot(oop reflect, int value); |
|
461 |
||
462 |
static int modifiers(oop method); |
|
463 |
static void set_modifiers(oop method, int value); |
|
464 |
||
465 |
static bool has_signature_field(); |
|
466 |
static oop signature(oop method); |
|
467 |
static void set_signature(oop method, oop value); |
|
468 |
||
469 |
static bool has_annotations_field(); |
|
470 |
static oop annotations(oop method); |
|
471 |
static void set_annotations(oop method, oop value); |
|
472 |
||
473 |
static bool has_parameter_annotations_field(); |
|
474 |
static oop parameter_annotations(oop method); |
|
475 |
static void set_parameter_annotations(oop method, oop value); |
|
476 |
||
477 |
static bool has_annotation_default_field(); |
|
478 |
static oop annotation_default(oop method); |
|
479 |
static void set_annotation_default(oop method, oop value); |
|
480 |
||
481 |
// Debugging |
|
482 |
friend class JavaClasses; |
|
483 |
}; |
|
484 |
||
485 |
||
486 |
// Interface to java.lang.reflect.Constructor objects |
|
487 |
||
488 |
class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject { |
|
489 |
private: |
|
490 |
// Note that to reduce dependencies on the JDK we compute these |
|
491 |
// offsets at run-time. |
|
492 |
static int clazz_offset; |
|
493 |
static int parameterTypes_offset; |
|
494 |
static int exceptionTypes_offset; |
|
495 |
static int slot_offset; |
|
496 |
static int modifiers_offset; |
|
497 |
static int signature_offset; |
|
498 |
static int annotations_offset; |
|
499 |
static int parameter_annotations_offset; |
|
500 |
||
501 |
static void compute_offsets(); |
|
502 |
||
503 |
public: |
|
504 |
// Allocation |
|
505 |
static Handle create(TRAPS); |
|
506 |
||
507 |
// Accessors |
|
508 |
static oop clazz(oop reflect); |
|
509 |
static void set_clazz(oop reflect, oop value); |
|
510 |
||
511 |
static oop parameter_types(oop constructor); |
|
512 |
static void set_parameter_types(oop constructor, oop value); |
|
513 |
||
514 |
static oop exception_types(oop constructor); |
|
515 |
static void set_exception_types(oop constructor, oop value); |
|
516 |
||
517 |
static int slot(oop reflect); |
|
518 |
static void set_slot(oop reflect, int value); |
|
519 |
||
520 |
static int modifiers(oop constructor); |
|
521 |
static void set_modifiers(oop constructor, int value); |
|
522 |
||
523 |
static bool has_signature_field(); |
|
524 |
static oop signature(oop constructor); |
|
525 |
static void set_signature(oop constructor, oop value); |
|
526 |
||
527 |
static bool has_annotations_field(); |
|
528 |
static oop annotations(oop constructor); |
|
529 |
static void set_annotations(oop constructor, oop value); |
|
530 |
||
531 |
static bool has_parameter_annotations_field(); |
|
532 |
static oop parameter_annotations(oop method); |
|
533 |
static void set_parameter_annotations(oop method, oop value); |
|
534 |
||
535 |
// Debugging |
|
536 |
friend class JavaClasses; |
|
537 |
}; |
|
538 |
||
539 |
||
540 |
// Interface to java.lang.reflect.Field objects |
|
541 |
||
542 |
class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject { |
|
543 |
private: |
|
544 |
// Note that to reduce dependencies on the JDK we compute these |
|
545 |
// offsets at run-time. |
|
546 |
static int clazz_offset; |
|
547 |
static int name_offset; |
|
548 |
static int type_offset; |
|
549 |
static int slot_offset; |
|
550 |
static int modifiers_offset; |
|
551 |
static int signature_offset; |
|
552 |
static int annotations_offset; |
|
553 |
||
554 |
static void compute_offsets(); |
|
555 |
||
556 |
public: |
|
557 |
// Allocation |
|
558 |
static Handle create(TRAPS); |
|
559 |
||
560 |
// Accessors |
|
561 |
static oop clazz(oop reflect); |
|
562 |
static void set_clazz(oop reflect, oop value); |
|
563 |
||
564 |
static oop name(oop field); |
|
565 |
static void set_name(oop field, oop value); |
|
566 |
||
567 |
static oop type(oop field); |
|
568 |
static void set_type(oop field, oop value); |
|
569 |
||
570 |
static int slot(oop reflect); |
|
571 |
static void set_slot(oop reflect, int value); |
|
572 |
||
573 |
static int modifiers(oop field); |
|
574 |
static void set_modifiers(oop field, int value); |
|
575 |
||
576 |
static bool has_signature_field(); |
|
577 |
static oop signature(oop constructor); |
|
578 |
static void set_signature(oop constructor, oop value); |
|
579 |
||
580 |
static bool has_annotations_field(); |
|
581 |
static oop annotations(oop constructor); |
|
582 |
static void set_annotations(oop constructor, oop value); |
|
583 |
||
584 |
static bool has_parameter_annotations_field(); |
|
585 |
static oop parameter_annotations(oop method); |
|
586 |
static void set_parameter_annotations(oop method, oop value); |
|
587 |
||
588 |
static bool has_annotation_default_field(); |
|
589 |
static oop annotation_default(oop method); |
|
590 |
static void set_annotation_default(oop method, oop value); |
|
591 |
||
592 |
// Debugging |
|
593 |
friend class JavaClasses; |
|
594 |
}; |
|
595 |
||
596 |
// Interface to sun.reflect.ConstantPool objects |
|
597 |
class sun_reflect_ConstantPool { |
|
598 |
private: |
|
599 |
// Note that to reduce dependencies on the JDK we compute these |
|
600 |
// offsets at run-time. |
|
601 |
static int _cp_oop_offset; |
|
602 |
||
603 |
static void compute_offsets(); |
|
604 |
||
605 |
public: |
|
606 |
// Allocation |
|
607 |
static Handle create(TRAPS); |
|
608 |
||
609 |
// Accessors |
|
610 |
static oop cp_oop(oop reflect); |
|
611 |
static void set_cp_oop(oop reflect, oop value); |
|
612 |
static int cp_oop_offset() { |
|
613 |
return _cp_oop_offset; |
|
614 |
} |
|
615 |
||
616 |
// Debugging |
|
617 |
friend class JavaClasses; |
|
618 |
}; |
|
619 |
||
620 |
// Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects |
|
621 |
class sun_reflect_UnsafeStaticFieldAccessorImpl { |
|
622 |
private: |
|
623 |
static int _base_offset; |
|
624 |
static void compute_offsets(); |
|
625 |
||
626 |
public: |
|
627 |
static int base_offset() { |
|
628 |
return _base_offset; |
|
629 |
} |
|
630 |
||
631 |
// Debugging |
|
632 |
friend class JavaClasses; |
|
633 |
}; |
|
634 |
||
635 |
// Interface to java.lang primitive type boxing objects: |
|
636 |
// - java.lang.Boolean |
|
637 |
// - java.lang.Character |
|
638 |
// - java.lang.Float |
|
639 |
// - java.lang.Double |
|
640 |
// - java.lang.Byte |
|
641 |
// - java.lang.Short |
|
642 |
// - java.lang.Integer |
|
643 |
// - java.lang.Long |
|
644 |
||
645 |
// This could be separated out into 8 individual classes. |
|
646 |
||
647 |
class java_lang_boxing_object: AllStatic { |
|
648 |
private: |
|
649 |
enum { |
|
650 |
hc_value_offset = 0 |
|
651 |
}; |
|
652 |
static int value_offset; |
|
653 |
||
654 |
static oop initialize_and_allocate(klassOop klass, TRAPS); |
|
655 |
public: |
|
656 |
// Allocation. Returns a boxed value, or NULL for invalid type. |
|
657 |
static oop create(BasicType type, jvalue* value, TRAPS); |
|
658 |
// Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop. |
|
659 |
static BasicType get_value(oop box, jvalue* value); |
|
660 |
static BasicType set_value(oop box, jvalue* value); |
|
661 |
||
662 |
static int value_offset_in_bytes() { return value_offset; } |
|
663 |
||
664 |
// Debugging |
|
665 |
friend class JavaClasses; |
|
666 |
}; |
|
667 |
||
668 |
||
669 |
||
670 |
// Interface to java.lang.ref.Reference objects |
|
671 |
||
672 |
class java_lang_ref_Reference: AllStatic { |
|
673 |
public: |
|
674 |
enum { |
|
675 |
hc_referent_offset = 0, |
|
676 |
hc_queue_offset = 1, |
|
677 |
hc_next_offset = 2, |
|
678 |
hc_discovered_offset = 3 // Is not last, see SoftRefs. |
|
679 |
}; |
|
680 |
enum { |
|
681 |
hc_static_lock_offset = 0, |
|
682 |
hc_static_pending_offset = 1 |
|
683 |
}; |
|
684 |
||
685 |
static int referent_offset; |
|
686 |
static int queue_offset; |
|
687 |
static int next_offset; |
|
688 |
static int discovered_offset; |
|
689 |
static int static_lock_offset; |
|
690 |
static int static_pending_offset; |
|
691 |
static int number_of_fake_oop_fields; |
|
692 |
||
693 |
// Accessors |
|
694 |
static oop referent(oop ref) { return *referent_addr(ref); } |
|
695 |
static void set_referent(oop ref, oop value); |
|
696 |
static oop* referent_addr(oop ref); |
|
697 |
||
698 |
static oop next(oop ref) { return *next_addr(ref); } |
|
699 |
static void set_next(oop ref, oop value); |
|
700 |
static oop* next_addr(oop ref); |
|
701 |
||
702 |
static oop discovered(oop ref) { return *discovered_addr(ref); } |
|
703 |
static void set_discovered(oop ref, oop value); |
|
704 |
static oop* discovered_addr(oop ref); |
|
705 |
||
706 |
// Accessors for statics |
|
707 |
static oop pending_list_lock() { return *pending_list_lock_addr(); } |
|
708 |
static oop pending_list() { return *pending_list_addr(); } |
|
709 |
||
710 |
static oop* pending_list_lock_addr(); |
|
711 |
static oop* pending_list_addr(); |
|
712 |
}; |
|
713 |
||
714 |
||
715 |
// Interface to java.lang.ref.SoftReference objects |
|
716 |
||
717 |
class java_lang_ref_SoftReference: public java_lang_ref_Reference { |
|
718 |
public: |
|
719 |
enum { |
|
720 |
// The timestamp is a long field and may need to be adjusted for alignment. |
|
721 |
hc_timestamp_offset = align_object_offset_(hc_discovered_offset + 1) |
|
722 |
}; |
|
723 |
enum { |
|
724 |
hc_static_clock_offset = 0 |
|
725 |
}; |
|
726 |
||
727 |
static int timestamp_offset; |
|
728 |
static int static_clock_offset; |
|
729 |
||
730 |
// Accessors |
|
731 |
static jlong timestamp(oop ref); |
|
732 |
||
733 |
// Accessors for statics |
|
734 |
static jlong clock(); |
|
735 |
static void set_clock(jlong value); |
|
736 |
}; |
|
737 |
||
738 |
||
739 |
// Interface to java.security.AccessControlContext objects |
|
740 |
||
741 |
class java_security_AccessControlContext: AllStatic { |
|
742 |
private: |
|
743 |
// Note that for this class the layout changed between JDK1.2 and JDK1.3, |
|
744 |
// so we compute the offsets at startup rather than hard-wiring them. |
|
745 |
static int _context_offset; |
|
746 |
static int _privilegedContext_offset; |
|
747 |
static int _isPrivileged_offset; |
|
748 |
||
749 |
static void compute_offsets(); |
|
750 |
public: |
|
751 |
static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS); |
|
752 |
||
753 |
// Debugging/initialization |
|
754 |
friend class JavaClasses; |
|
755 |
}; |
|
756 |
||
757 |
||
758 |
// Interface to java.lang.ClassLoader objects |
|
759 |
||
760 |
class java_lang_ClassLoader : AllStatic { |
|
761 |
private: |
|
762 |
enum { |
|
763 |
hc_parent_offset = 0 |
|
764 |
}; |
|
765 |
||
766 |
static int parent_offset; |
|
767 |
||
768 |
public: |
|
769 |
static oop parent(oop loader); |
|
770 |
||
771 |
static bool is_trusted_loader(oop loader); |
|
772 |
||
773 |
// Fix for 4474172 |
|
774 |
static oop non_reflection_class_loader(oop loader); |
|
775 |
||
776 |
// Debugging |
|
777 |
friend class JavaClasses; |
|
778 |
}; |
|
779 |
||
780 |
||
781 |
// Interface to java.lang.System objects |
|
782 |
||
783 |
class java_lang_System : AllStatic { |
|
784 |
private: |
|
785 |
enum { |
|
786 |
hc_static_in_offset = 0, |
|
787 |
hc_static_out_offset = 1, |
|
788 |
hc_static_err_offset = 2 |
|
789 |
}; |
|
790 |
||
791 |
static int offset_of_static_fields; |
|
792 |
static int static_in_offset; |
|
793 |
static int static_out_offset; |
|
794 |
static int static_err_offset; |
|
795 |
||
796 |
static void compute_offsets(); |
|
797 |
||
798 |
public: |
|
799 |
static int in_offset_in_bytes(); |
|
800 |
static int out_offset_in_bytes(); |
|
801 |
static int err_offset_in_bytes(); |
|
802 |
||
803 |
// Debugging |
|
804 |
friend class JavaClasses; |
|
805 |
}; |
|
806 |
||
807 |
||
808 |
// Interface to java.lang.StackTraceElement objects |
|
809 |
||
810 |
class java_lang_StackTraceElement: AllStatic { |
|
811 |
private: |
|
812 |
enum { |
|
813 |
hc_declaringClass_offset = 0, |
|
814 |
hc_methodName_offset = 1, |
|
815 |
hc_fileName_offset = 2, |
|
816 |
hc_lineNumber_offset = 3 |
|
817 |
}; |
|
818 |
||
819 |
static int declaringClass_offset; |
|
820 |
static int methodName_offset; |
|
821 |
static int fileName_offset; |
|
822 |
static int lineNumber_offset; |
|
823 |
||
824 |
public: |
|
825 |
// Setters |
|
826 |
static void set_declaringClass(oop element, oop value); |
|
827 |
static void set_methodName(oop element, oop value); |
|
828 |
static void set_fileName(oop element, oop value); |
|
829 |
static void set_lineNumber(oop element, int value); |
|
830 |
||
831 |
// Create an instance of StackTraceElement |
|
832 |
static oop create(methodHandle m, int bci, TRAPS); |
|
833 |
||
834 |
// Debugging |
|
835 |
friend class JavaClasses; |
|
836 |
}; |
|
837 |
||
838 |
||
839 |
// Interface to java.lang.AssertionStatusDirectives objects |
|
840 |
||
841 |
class java_lang_AssertionStatusDirectives: AllStatic { |
|
842 |
private: |
|
843 |
enum { |
|
844 |
hc_classes_offset, |
|
845 |
hc_classEnabled_offset, |
|
846 |
hc_packages_offset, |
|
847 |
hc_packageEnabled_offset, |
|
848 |
hc_deflt_offset |
|
849 |
}; |
|
850 |
||
851 |
static int classes_offset; |
|
852 |
static int classEnabled_offset; |
|
853 |
static int packages_offset; |
|
854 |
static int packageEnabled_offset; |
|
855 |
static int deflt_offset; |
|
856 |
||
857 |
public: |
|
858 |
// Setters |
|
859 |
static void set_classes(oop obj, oop val); |
|
860 |
static void set_classEnabled(oop obj, oop val); |
|
861 |
static void set_packages(oop obj, oop val); |
|
862 |
static void set_packageEnabled(oop obj, oop val); |
|
863 |
static void set_deflt(oop obj, bool val); |
|
864 |
// Debugging |
|
865 |
friend class JavaClasses; |
|
866 |
}; |
|
867 |
||
868 |
||
869 |
class java_nio_Buffer: AllStatic { |
|
870 |
private: |
|
871 |
static int _limit_offset; |
|
872 |
||
873 |
public: |
|
874 |
static int limit_offset(); |
|
875 |
static void compute_offsets(); |
|
876 |
}; |
|
877 |
||
878 |
class sun_misc_AtomicLongCSImpl: AllStatic { |
|
879 |
private: |
|
880 |
static int _value_offset; |
|
881 |
||
882 |
public: |
|
883 |
static int value_offset(); |
|
884 |
static void compute_offsets(); |
|
885 |
}; |
|
886 |
||
887 |
class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic { |
|
888 |
private: |
|
889 |
static int _owner_offset; |
|
890 |
public: |
|
891 |
static void initialize(TRAPS); |
|
892 |
static oop get_owner_threadObj(oop obj); |
|
893 |
}; |
|
894 |
||
895 |
// Interface to hard-coded offset checking |
|
896 |
||
897 |
class JavaClasses : AllStatic { |
|
898 |
private: |
|
899 |
static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
|
900 |
static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
|
901 |
public: |
|
902 |
static void compute_hard_coded_offsets(); |
|
903 |
static void compute_offsets(); |
|
904 |
static void check_offsets() PRODUCT_RETURN; |
|
905 |
}; |