Fri, 27 Feb 2009 13:27:09 -0800
6810672: Comment typos
Summary: I have collected some typos I have found while looking at the code.
Reviewed-by: kvn, never
1 /*
2 * Copyright 1997-2008 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 */
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.
42 // Interface to java.lang.String objects
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 -- not a word-scaled offset
50 //hc_hash_offset = 3 -- not a word-scaled offset
51 };
53 static int value_offset;
54 static int offset_offset;
55 static int count_offset;
56 static int hash_offset;
58 static Handle basic_create(int length, bool tenured, TRAPS);
59 static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS);
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); }
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);
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; }
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);
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);
99 static char* as_platform_dependent_str(Handle java_string, TRAPS);
100 static jchar* as_unicode_string(oop java_string, int& length);
102 static bool equals(oop java_string, jchar* chars, int len);
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); }
108 // Conversion
109 static symbolHandle as_symbol(Handle java_string, TRAPS);
111 // Testers
112 static bool is_instance(oop obj) {
113 return obj != NULL && obj->klass() == SystemDictionary::string_klass();
114 }
116 // Debugging
117 static void print(Handle java_string, outputStream* st);
118 friend class JavaClasses;
119 };
122 // Interface to java.lang.Class objects
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
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 };
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;
141 static void compute_offsets();
142 static bool offsets_computed;
143 static int classRedefinedCount_offset;
144 static int parallelCapable_offset;
146 public:
147 // Instance creation
148 static oop create_mirror(KlassHandle k, TRAPS);
149 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
150 // Conversion
151 static klassOop as_klassOop(oop java_class);
152 // Testing
153 static bool is_instance(oop obj) {
154 return obj != NULL && obj->klass() == SystemDictionary::class_klass();
155 }
156 static bool is_primitive(oop java_class);
157 static BasicType primitive_type(oop java_class);
158 static oop primitive_mirror(BasicType t);
159 // JVM_NewInstance support
160 static methodOop resolved_constructor(oop java_class);
161 static void set_resolved_constructor(oop java_class, methodOop constructor);
162 // JVM_NewArray support
163 static klassOop array_klass(oop java_class);
164 static void set_array_klass(oop java_class, klassOop klass);
165 // compiler support for class operations
166 static int klass_offset_in_bytes() { return klass_offset; }
167 static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; }
168 static int array_klass_offset_in_bytes() { return array_klass_offset; }
169 // Support for classRedefinedCount field
170 static int classRedefinedCount(oop the_class_mirror);
171 static void set_classRedefinedCount(oop the_class_mirror, int value);
172 // Support for parallelCapable field
173 static bool parallelCapable(oop the_class_mirror);
174 // Debugging
175 friend class JavaClasses;
176 friend class instanceKlass; // verification code accesses offsets
177 friend class ClassFileParser; // access to number_of_fake_fields
178 };
180 // Interface to java.lang.Thread objects
182 class java_lang_Thread : AllStatic {
183 private:
184 // Note that for this class the layout changed between JDK1.2 and JDK1.3,
185 // so we compute the offsets at startup rather than hard-wiring them.
186 static int _name_offset;
187 static int _group_offset;
188 static int _contextClassLoader_offset;
189 static int _inheritedAccessControlContext_offset;
190 static int _priority_offset;
191 static int _eetop_offset;
192 static int _daemon_offset;
193 static int _stillborn_offset;
194 static int _stackSize_offset;
195 static int _tid_offset;
196 static int _thread_status_offset;
197 static int _park_blocker_offset;
198 static int _park_event_offset ;
200 static void compute_offsets();
202 public:
203 // Instance creation
204 static oop create();
205 // Returns the JavaThread associated with the thread obj
206 static JavaThread* thread(oop java_thread);
207 // Set JavaThread for instance
208 static void set_thread(oop java_thread, JavaThread* thread);
209 // Name
210 static typeArrayOop name(oop java_thread);
211 static void set_name(oop java_thread, typeArrayOop name);
212 // Priority
213 static ThreadPriority priority(oop java_thread);
214 static void set_priority(oop java_thread, ThreadPriority priority);
215 // Thread group
216 static oop threadGroup(oop java_thread);
217 // Stillborn
218 static bool is_stillborn(oop java_thread);
219 static void set_stillborn(oop java_thread);
220 // Alive (NOTE: this is not really a field, but provides the correct
221 // definition without doing a Java call)
222 static bool is_alive(oop java_thread);
223 // Daemon
224 static bool is_daemon(oop java_thread);
225 static void set_daemon(oop java_thread);
226 // Context ClassLoader
227 static oop context_class_loader(oop java_thread);
228 // Control context
229 static oop inherited_access_control_context(oop java_thread);
230 // Stack size hint
231 static jlong stackSize(oop java_thread);
232 // Thread ID
233 static jlong thread_id(oop java_thread);
235 // Blocker object responsible for thread parking
236 static oop park_blocker(oop java_thread);
238 // Pointer to type-stable park handler, encoded as jlong.
239 // Should be set when apparently null
240 // For details, see unsafe.cpp Unsafe_Unpark
241 static jlong park_event(oop java_thread);
242 static bool set_park_event(oop java_thread, jlong ptr);
244 // Java Thread Status for JVMTI and M&M use.
245 // This thread status info is saved in threadStatus field of
246 // java.lang.Thread java class.
247 enum ThreadStatus {
248 NEW = 0,
249 RUNNABLE = JVMTI_THREAD_STATE_ALIVE + // runnable / running
250 JVMTI_THREAD_STATE_RUNNABLE,
251 SLEEPING = JVMTI_THREAD_STATE_ALIVE + // Thread.sleep()
252 JVMTI_THREAD_STATE_WAITING +
253 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
254 JVMTI_THREAD_STATE_SLEEPING,
255 IN_OBJECT_WAIT = JVMTI_THREAD_STATE_ALIVE + // Object.wait()
256 JVMTI_THREAD_STATE_WAITING +
257 JVMTI_THREAD_STATE_WAITING_INDEFINITELY +
258 JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
259 IN_OBJECT_WAIT_TIMED = JVMTI_THREAD_STATE_ALIVE + // Object.wait(long)
260 JVMTI_THREAD_STATE_WAITING +
261 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
262 JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
263 PARKED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park()
264 JVMTI_THREAD_STATE_WAITING +
265 JVMTI_THREAD_STATE_WAITING_INDEFINITELY +
266 JVMTI_THREAD_STATE_PARKED,
267 PARKED_TIMED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park(long)
268 JVMTI_THREAD_STATE_WAITING +
269 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
270 JVMTI_THREAD_STATE_PARKED,
271 BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE + // (re-)entering a synchronization block
272 JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER,
273 TERMINATED = JVMTI_THREAD_STATE_TERMINATED
274 };
275 // Write thread status info to threadStatus field of java.lang.Thread.
276 static void set_thread_status(oop java_thread_oop, ThreadStatus status);
277 // Read thread status info from threadStatus field of java.lang.Thread.
278 static ThreadStatus get_thread_status(oop java_thread_oop);
280 static const char* thread_status_name(oop java_thread_oop);
282 // Debugging
283 friend class JavaClasses;
284 };
286 // Interface to java.lang.ThreadGroup objects
288 class java_lang_ThreadGroup : AllStatic {
289 private:
290 static int _parent_offset;
291 static int _name_offset;
292 static int _threads_offset;
293 static int _groups_offset;
294 static int _maxPriority_offset;
295 static int _destroyed_offset;
296 static int _daemon_offset;
297 static int _vmAllowSuspension_offset;
298 static int _nthreads_offset;
299 static int _ngroups_offset;
301 static void compute_offsets();
303 public:
304 // parent ThreadGroup
305 static oop parent(oop java_thread_group);
306 // name
307 static typeArrayOop name(oop java_thread_group);
308 // ("name as oop" accessor is not necessary)
309 // Number of threads in group
310 static int nthreads(oop java_thread_group);
311 // threads
312 static objArrayOop threads(oop java_thread_group);
313 // Number of threads in group
314 static int ngroups(oop java_thread_group);
315 // groups
316 static objArrayOop groups(oop java_thread_group);
317 // maxPriority in group
318 static ThreadPriority maxPriority(oop java_thread_group);
319 // Destroyed
320 static bool is_destroyed(oop java_thread_group);
321 // Daemon
322 static bool is_daemon(oop java_thread_group);
323 // vmAllowSuspension
324 static bool is_vmAllowSuspension(oop java_thread_group);
325 // Debugging
326 friend class JavaClasses;
327 };
331 // Interface to java.lang.Throwable objects
333 class java_lang_Throwable: AllStatic {
334 friend class BacktraceBuilder;
336 private:
337 // Offsets
338 enum {
339 hc_backtrace_offset = 0,
340 hc_detailMessage_offset = 1,
341 hc_cause_offset = 2, // New since 1.4
342 hc_stackTrace_offset = 3 // New since 1.4
343 };
344 // Trace constants
345 enum {
346 trace_methods_offset = 0,
347 trace_bcis_offset = 1,
348 trace_next_offset = 2,
349 trace_size = 3,
350 trace_chunk_size = 32
351 };
353 static int backtrace_offset;
354 static int detailMessage_offset;
355 static int cause_offset;
356 static int stackTrace_offset;
358 // Printing
359 static char* print_stack_element_to_buffer(methodOop method, int bci);
360 static void print_to_stream(Handle stream, const char* str);
361 // StackTrace (programmatic access, new since 1.4)
362 static void clear_stacktrace(oop throwable);
363 // No stack trace available
364 static const char* no_stack_trace_message();
366 public:
367 // Backtrace
368 static oop backtrace(oop throwable);
369 static void set_backtrace(oop throwable, oop value);
370 // Needed by JVMTI to filter out this internal field.
371 static int get_backtrace_offset() { return backtrace_offset;}
372 static int get_detailMessage_offset() { return detailMessage_offset;}
373 // Message
374 static oop message(oop throwable);
375 static oop message(Handle throwable);
376 static void set_message(oop throwable, oop value);
377 // Print stack trace stored in exception by call-back to Java
378 // Note: this is no longer used in Merlin, but we still suppport
379 // it for compatibility.
380 static void print_stack_trace(oop throwable, oop print_stream);
381 static void print_stack_element(Handle stream, methodOop method, int bci);
382 static void print_stack_element(outputStream *st, methodOop method, int bci);
383 static void print_stack_usage(Handle stream);
385 // Allocate space for backtrace (created but stack trace not filled in)
386 static void allocate_backtrace(Handle throwable, TRAPS);
387 // Fill in current stack trace for throwable with preallocated backtrace (no GC)
388 static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
390 // Fill in current stack trace, can cause GC
391 static void fill_in_stack_trace(Handle throwable, TRAPS);
392 static void fill_in_stack_trace(Handle throwable);
393 // Programmatic access to stack trace
394 static oop get_stack_trace_element(oop throwable, int index, TRAPS);
395 static int get_stack_trace_depth(oop throwable, TRAPS);
396 // Printing
397 static void print(oop throwable, outputStream* st);
398 static void print(Handle throwable, outputStream* st);
399 static void print_stack_trace(oop throwable, outputStream* st);
400 // Debugging
401 friend class JavaClasses;
402 };
405 // Interface to java.lang.reflect.AccessibleObject objects
407 class java_lang_reflect_AccessibleObject: AllStatic {
408 private:
409 // Note that to reduce dependencies on the JDK we compute these
410 // offsets at run-time.
411 static int override_offset;
413 static void compute_offsets();
415 public:
416 // Accessors
417 static jboolean override(oop reflect);
418 static void set_override(oop reflect, jboolean value);
420 // Debugging
421 friend class JavaClasses;
422 };
425 // Interface to java.lang.reflect.Method objects
427 class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject {
428 private:
429 // Note that to reduce dependencies on the JDK we compute these
430 // offsets at run-time.
431 static int clazz_offset;
432 static int name_offset;
433 static int returnType_offset;
434 static int parameterTypes_offset;
435 static int exceptionTypes_offset;
436 static int slot_offset;
437 static int modifiers_offset;
438 static int signature_offset;
439 static int annotations_offset;
440 static int parameter_annotations_offset;
441 static int annotation_default_offset;
443 static void compute_offsets();
445 public:
446 // Allocation
447 static Handle create(TRAPS);
449 // Accessors
450 static oop clazz(oop reflect);
451 static void set_clazz(oop reflect, oop value);
453 static oop name(oop method);
454 static void set_name(oop method, oop value);
456 static oop return_type(oop method);
457 static void set_return_type(oop method, oop value);
459 static oop parameter_types(oop method);
460 static void set_parameter_types(oop method, oop value);
462 static oop exception_types(oop method);
463 static void set_exception_types(oop method, oop value);
465 static int slot(oop reflect);
466 static void set_slot(oop reflect, int value);
468 static int modifiers(oop method);
469 static void set_modifiers(oop method, int value);
471 static bool has_signature_field();
472 static oop signature(oop method);
473 static void set_signature(oop method, oop value);
475 static bool has_annotations_field();
476 static oop annotations(oop method);
477 static void set_annotations(oop method, oop value);
479 static bool has_parameter_annotations_field();
480 static oop parameter_annotations(oop method);
481 static void set_parameter_annotations(oop method, oop value);
483 static bool has_annotation_default_field();
484 static oop annotation_default(oop method);
485 static void set_annotation_default(oop method, oop value);
487 // Debugging
488 friend class JavaClasses;
489 };
492 // Interface to java.lang.reflect.Constructor objects
494 class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject {
495 private:
496 // Note that to reduce dependencies on the JDK we compute these
497 // offsets at run-time.
498 static int clazz_offset;
499 static int parameterTypes_offset;
500 static int exceptionTypes_offset;
501 static int slot_offset;
502 static int modifiers_offset;
503 static int signature_offset;
504 static int annotations_offset;
505 static int parameter_annotations_offset;
507 static void compute_offsets();
509 public:
510 // Allocation
511 static Handle create(TRAPS);
513 // Accessors
514 static oop clazz(oop reflect);
515 static void set_clazz(oop reflect, oop value);
517 static oop parameter_types(oop constructor);
518 static void set_parameter_types(oop constructor, oop value);
520 static oop exception_types(oop constructor);
521 static void set_exception_types(oop constructor, oop value);
523 static int slot(oop reflect);
524 static void set_slot(oop reflect, int value);
526 static int modifiers(oop constructor);
527 static void set_modifiers(oop constructor, int value);
529 static bool has_signature_field();
530 static oop signature(oop constructor);
531 static void set_signature(oop constructor, oop value);
533 static bool has_annotations_field();
534 static oop annotations(oop constructor);
535 static void set_annotations(oop constructor, oop value);
537 static bool has_parameter_annotations_field();
538 static oop parameter_annotations(oop method);
539 static void set_parameter_annotations(oop method, oop value);
541 // Debugging
542 friend class JavaClasses;
543 };
546 // Interface to java.lang.reflect.Field objects
548 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
549 private:
550 // Note that to reduce dependencies on the JDK we compute these
551 // offsets at run-time.
552 static int clazz_offset;
553 static int name_offset;
554 static int type_offset;
555 static int slot_offset;
556 static int modifiers_offset;
557 static int signature_offset;
558 static int annotations_offset;
560 static void compute_offsets();
562 public:
563 // Allocation
564 static Handle create(TRAPS);
566 // Accessors
567 static oop clazz(oop reflect);
568 static void set_clazz(oop reflect, oop value);
570 static oop name(oop field);
571 static void set_name(oop field, oop value);
573 static oop type(oop field);
574 static void set_type(oop field, oop value);
576 static int slot(oop reflect);
577 static void set_slot(oop reflect, int value);
579 static int modifiers(oop field);
580 static void set_modifiers(oop field, int value);
582 static bool has_signature_field();
583 static oop signature(oop constructor);
584 static void set_signature(oop constructor, oop value);
586 static bool has_annotations_field();
587 static oop annotations(oop constructor);
588 static void set_annotations(oop constructor, oop value);
590 static bool has_parameter_annotations_field();
591 static oop parameter_annotations(oop method);
592 static void set_parameter_annotations(oop method, oop value);
594 static bool has_annotation_default_field();
595 static oop annotation_default(oop method);
596 static void set_annotation_default(oop method, oop value);
598 // Debugging
599 friend class JavaClasses;
600 };
602 // Interface to sun.reflect.ConstantPool objects
603 class sun_reflect_ConstantPool {
604 private:
605 // Note that to reduce dependencies on the JDK we compute these
606 // offsets at run-time.
607 static int _cp_oop_offset;
609 static void compute_offsets();
611 public:
612 // Allocation
613 static Handle create(TRAPS);
615 // Accessors
616 static oop cp_oop(oop reflect);
617 static void set_cp_oop(oop reflect, oop value);
618 static int cp_oop_offset() {
619 return _cp_oop_offset;
620 }
622 // Debugging
623 friend class JavaClasses;
624 };
626 // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects
627 class sun_reflect_UnsafeStaticFieldAccessorImpl {
628 private:
629 static int _base_offset;
630 static void compute_offsets();
632 public:
633 static int base_offset() {
634 return _base_offset;
635 }
637 // Debugging
638 friend class JavaClasses;
639 };
641 // Interface to java.lang primitive type boxing objects:
642 // - java.lang.Boolean
643 // - java.lang.Character
644 // - java.lang.Float
645 // - java.lang.Double
646 // - java.lang.Byte
647 // - java.lang.Short
648 // - java.lang.Integer
649 // - java.lang.Long
651 // This could be separated out into 8 individual classes.
653 class java_lang_boxing_object: AllStatic {
654 private:
655 enum {
656 hc_value_offset = 0
657 };
658 static int value_offset;
659 static int long_value_offset;
661 static oop initialize_and_allocate(BasicType type, TRAPS);
662 public:
663 // Allocation. Returns a boxed value, or NULL for invalid type.
664 static oop create(BasicType type, jvalue* value, TRAPS);
665 // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
666 static BasicType get_value(oop box, jvalue* value);
667 static BasicType set_value(oop box, jvalue* value);
668 static BasicType basic_type(oop box);
669 static bool is_instance(oop box) { return basic_type(box) != T_ILLEGAL; }
670 static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
672 static int value_offset_in_bytes(BasicType type) {
673 return ( type == T_LONG || type == T_DOUBLE ) ? long_value_offset :
674 value_offset;
675 }
677 // Debugging
678 friend class JavaClasses;
679 };
683 // Interface to java.lang.ref.Reference objects
685 class java_lang_ref_Reference: AllStatic {
686 public:
687 enum {
688 hc_referent_offset = 0,
689 hc_queue_offset = 1,
690 hc_next_offset = 2,
691 hc_discovered_offset = 3 // Is not last, see SoftRefs.
692 };
693 enum {
694 hc_static_lock_offset = 0,
695 hc_static_pending_offset = 1
696 };
698 static int referent_offset;
699 static int queue_offset;
700 static int next_offset;
701 static int discovered_offset;
702 static int static_lock_offset;
703 static int static_pending_offset;
704 static int number_of_fake_oop_fields;
706 // Accessors
707 static oop referent(oop ref) {
708 return ref->obj_field(referent_offset);
709 }
710 static void set_referent(oop ref, oop value) {
711 ref->obj_field_put(referent_offset, value);
712 }
713 static void set_referent_raw(oop ref, oop value) {
714 ref->obj_field_raw_put(referent_offset, value);
715 }
716 static HeapWord* referent_addr(oop ref) {
717 return ref->obj_field_addr<HeapWord>(referent_offset);
718 }
719 static oop next(oop ref) {
720 return ref->obj_field(next_offset);
721 }
722 static void set_next(oop ref, oop value) {
723 ref->obj_field_put(next_offset, value);
724 }
725 static void set_next_raw(oop ref, oop value) {
726 ref->obj_field_raw_put(next_offset, value);
727 }
728 static HeapWord* next_addr(oop ref) {
729 return ref->obj_field_addr<HeapWord>(next_offset);
730 }
731 static oop discovered(oop ref) {
732 return ref->obj_field(discovered_offset);
733 }
734 static void set_discovered(oop ref, oop value) {
735 ref->obj_field_put(discovered_offset, value);
736 }
737 static void set_discovered_raw(oop ref, oop value) {
738 ref->obj_field_raw_put(discovered_offset, value);
739 }
740 static HeapWord* discovered_addr(oop ref) {
741 return ref->obj_field_addr<HeapWord>(discovered_offset);
742 }
743 // Accessors for statics
744 static oop pending_list_lock();
745 static oop pending_list();
747 static HeapWord* pending_list_addr();
748 };
751 // Interface to java.lang.ref.SoftReference objects
753 class java_lang_ref_SoftReference: public java_lang_ref_Reference {
754 public:
755 enum {
756 // The timestamp is a long field and may need to be adjusted for alignment.
757 hc_timestamp_offset = hc_discovered_offset + 1
758 };
759 enum {
760 hc_static_clock_offset = 0
761 };
763 static int timestamp_offset;
764 static int static_clock_offset;
766 // Accessors
767 static jlong timestamp(oop ref);
769 // Accessors for statics
770 static jlong clock();
771 static void set_clock(jlong value);
772 };
775 // Interface to java.security.AccessControlContext objects
777 class java_security_AccessControlContext: AllStatic {
778 private:
779 // Note that for this class the layout changed between JDK1.2 and JDK1.3,
780 // so we compute the offsets at startup rather than hard-wiring them.
781 static int _context_offset;
782 static int _privilegedContext_offset;
783 static int _isPrivileged_offset;
785 static void compute_offsets();
786 public:
787 static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS);
789 // Debugging/initialization
790 friend class JavaClasses;
791 };
794 // Interface to java.lang.ClassLoader objects
796 class java_lang_ClassLoader : AllStatic {
797 private:
798 enum {
799 hc_parent_offset = 0
800 };
802 static int parent_offset;
804 public:
805 static oop parent(oop loader);
807 static bool is_trusted_loader(oop loader);
809 // Fix for 4474172
810 static oop non_reflection_class_loader(oop loader);
812 // Debugging
813 friend class JavaClasses;
814 };
817 // Interface to java.lang.System objects
819 class java_lang_System : AllStatic {
820 private:
821 enum {
822 hc_static_in_offset = 0,
823 hc_static_out_offset = 1,
824 hc_static_err_offset = 2
825 };
827 static int offset_of_static_fields;
828 static int static_in_offset;
829 static int static_out_offset;
830 static int static_err_offset;
832 static void compute_offsets();
834 public:
835 static int in_offset_in_bytes();
836 static int out_offset_in_bytes();
837 static int err_offset_in_bytes();
839 // Debugging
840 friend class JavaClasses;
841 };
844 // Interface to java.lang.StackTraceElement objects
846 class java_lang_StackTraceElement: AllStatic {
847 private:
848 enum {
849 hc_declaringClass_offset = 0,
850 hc_methodName_offset = 1,
851 hc_fileName_offset = 2,
852 hc_lineNumber_offset = 3
853 };
855 static int declaringClass_offset;
856 static int methodName_offset;
857 static int fileName_offset;
858 static int lineNumber_offset;
860 public:
861 // Setters
862 static void set_declaringClass(oop element, oop value);
863 static void set_methodName(oop element, oop value);
864 static void set_fileName(oop element, oop value);
865 static void set_lineNumber(oop element, int value);
867 // Create an instance of StackTraceElement
868 static oop create(methodHandle m, int bci, TRAPS);
870 // Debugging
871 friend class JavaClasses;
872 };
875 // Interface to java.lang.AssertionStatusDirectives objects
877 class java_lang_AssertionStatusDirectives: AllStatic {
878 private:
879 enum {
880 hc_classes_offset,
881 hc_classEnabled_offset,
882 hc_packages_offset,
883 hc_packageEnabled_offset,
884 hc_deflt_offset
885 };
887 static int classes_offset;
888 static int classEnabled_offset;
889 static int packages_offset;
890 static int packageEnabled_offset;
891 static int deflt_offset;
893 public:
894 // Setters
895 static void set_classes(oop obj, oop val);
896 static void set_classEnabled(oop obj, oop val);
897 static void set_packages(oop obj, oop val);
898 static void set_packageEnabled(oop obj, oop val);
899 static void set_deflt(oop obj, bool val);
900 // Debugging
901 friend class JavaClasses;
902 };
905 class java_nio_Buffer: AllStatic {
906 private:
907 static int _limit_offset;
909 public:
910 static int limit_offset();
911 static void compute_offsets();
912 };
914 class sun_misc_AtomicLongCSImpl: AllStatic {
915 private:
916 static int _value_offset;
918 public:
919 static int value_offset();
920 static void compute_offsets();
921 };
923 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
924 private:
925 static int _owner_offset;
926 public:
927 static void initialize(TRAPS);
928 static oop get_owner_threadObj(oop obj);
929 };
931 // Interface to hard-coded offset checking
933 class JavaClasses : AllStatic {
934 private:
935 static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
936 static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
937 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
938 public:
939 static void compute_hard_coded_offsets();
940 static void compute_offsets();
941 static void check_offsets() PRODUCT_RETURN;
942 };