1 /* 2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_CLASSFILE_JAVACLASSES_HPP 26 #define SHARE_VM_CLASSFILE_JAVACLASSES_HPP 27 28 #include "classfile/systemDictionary.hpp" 29 #include "jvmtifiles/jvmti.h" 30 #include "oops/oop.hpp" 31 #include "runtime/os.hpp" 32 #include "utilities/utf8.hpp" 33 34 // Interface for manipulating the basic Java classes. 35 // 36 // All dependencies on layout of actual Java classes should be kept here. 37 // If the layout of any of the classes above changes the offsets must be adjusted. 38 // 39 // For most classes we hardwire the offsets for performance reasons. In certain 40 // cases (e.g. java.security.AccessControlContext) we compute the offsets at 41 // startup since the layout here differs between JDK1.2 and JDK1.3. 42 // 43 // Note that fields (static and non-static) are arranged with oops before non-oops 44 // on a per class basis. The offsets below have to reflect this ordering. 45 // 46 // When editing the layouts please update the check_offset verification code 47 // correspondingly. The names in the enums must be identical to the actual field 48 // names in order for the verification code to work. 49 50 51 // Interface to java.lang.String objects 52 53 class java_lang_String : AllStatic { 54 private: 55 static int value_offset; 56 static int offset_offset; 57 static int count_offset; 58 static int hash_offset; 59 60 static bool initialized; 61 62 static Handle basic_create(int length, TRAPS); 63 64 static void set_offset(oop string, int offset) { 65 assert(initialized, "Must be initialized"); 66 if (offset_offset > 0) { 67 string->int_field_put(offset_offset, offset); 68 } 69 } 70 static void set_count( oop string, int count) { 71 assert(initialized, "Must be initialized"); 72 if (count_offset > 0) { 73 string->int_field_put(count_offset, count); 74 } 75 } 76 77 public: 78 static void compute_offsets(); 79 80 // Instance creation 81 static Handle create_from_unicode(jchar* unicode, int len, TRAPS); 82 static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS); 83 static Handle create_from_str(const char* utf8_str, TRAPS); 84 static oop create_oop_from_str(const char* utf8_str, TRAPS); 85 static Handle create_from_symbol(Symbol* symbol, TRAPS); 86 static Handle create_from_platform_dependent_str(const char* str, TRAPS); 87 static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS); 88 89 static bool has_offset_field() { 90 assert(initialized, "Must be initialized"); 91 return (offset_offset > 0); 92 } 93 94 static bool has_count_field() { 95 assert(initialized, "Must be initialized"); 96 return (count_offset > 0); 97 } 98 99 static bool has_hash_field() { 100 assert(initialized, "Must be initialized"); 101 return (hash_offset > 0); 102 } 103 104 static int value_offset_in_bytes() { 105 assert(initialized && (value_offset > 0), "Must be initialized"); 106 return value_offset; 107 } 108 static int count_offset_in_bytes() { 109 assert(initialized && (count_offset > 0), "Must be initialized"); 110 return count_offset; 111 } 112 static int offset_offset_in_bytes() { 113 assert(initialized && (offset_offset > 0), "Must be initialized"); 114 return offset_offset; 115 } 116 static int hash_offset_in_bytes() { 117 assert(initialized && (hash_offset > 0), "Must be initialized"); 118 return hash_offset; 119 } 120 121 static void set_value_raw(oop string, typeArrayOop buffer) { 122 assert(initialized, "Must be initialized"); 123 string->obj_field_put_raw(value_offset, buffer); 124 } 125 static void set_value(oop string, typeArrayOop buffer) { 126 assert(initialized && (value_offset > 0), "Must be initialized"); 127 string->obj_field_put(value_offset, (oop)buffer); 128 } 129 static void set_hash(oop string, unsigned int hash) { 130 assert(initialized && (hash_offset > 0), "Must be initialized"); 131 string->int_field_put(hash_offset, hash); 132 } 133 134 // Accessors 135 static typeArrayOop value(oop java_string) { 136 assert(initialized && (value_offset > 0), "Must be initialized"); 137 assert(is_instance(java_string), "must be java_string"); 138 return (typeArrayOop) java_string->obj_field(value_offset); 139 } 140 static unsigned int hash(oop java_string) { 141 assert(initialized && (hash_offset > 0), "Must be initialized"); 142 assert(is_instance(java_string), "must be java_string"); 143 return java_string->int_field(hash_offset); 144 } 145 static int offset(oop java_string) { 146 assert(initialized, "Must be initialized"); 147 assert(is_instance(java_string), "must be java_string"); 148 if (offset_offset > 0) { 149 return java_string->int_field(offset_offset); 150 } else { 151 return 0; 152 } 153 } 154 static int length(oop java_string) { 155 assert(initialized, "Must be initialized"); 156 assert(is_instance(java_string), "must be java_string"); 157 if (count_offset > 0) { 158 return java_string->int_field(count_offset); 159 } else { 160 oop value = java_string->obj_field(value_offset); 161 if (ShenandoahVerifyReadsToFromSpace) { 162 value = oopDesc::bs()->read_barrier(value); 163 } 164 return ((typeArrayOop) value)->length(); 165 } 166 } 167 static int utf8_length(oop java_string); 168 169 // String converters 170 static char* as_utf8_string(oop java_string); 171 static char* as_utf8_string(oop java_string, char* buf, int buflen); 172 static char* as_utf8_string(oop java_string, int start, int len); 173 static char* as_utf8_string(oop java_string, int start, int len, char* buf, int buflen); 174 static char* as_platform_dependent_str(Handle java_string, TRAPS); 175 static jchar* as_unicode_string(oop java_string, int& length, TRAPS); 176 // produce an ascii string with all other values quoted using \u#### 177 static char* as_quoted_ascii(oop java_string); 178 179 // Compute the hash value for a java.lang.String object which would 180 // contain the characters passed in. 181 // 182 // As the hash value used by the String object itself, in 183 // String.hashCode(). This value is normally calculated in Java code 184 // in the String.hashCode method(), but is precomputed for String 185 // objects in the shared archive file. 186 // hash P(31) from Kernighan & Ritchie 187 // 188 // For this reason, THIS ALGORITHM MUST MATCH String.hashCode(). 189 template <typename T> static unsigned int hash_code(T* s, int len) { 190 unsigned int h = 0; 191 while (len-- > 0) { 192 h = 31*h + (unsigned int) *s; 193 s++; 194 } 195 return h; 196 } 197 static unsigned int hash_code(oop java_string); 198 199 // This is the string hash code used by the StringTable, which may be 200 // the same as String.hashCode or an alternate hash code. 201 static unsigned int hash_string(oop java_string); 202 203 static bool equals(oop java_string, jchar* chars, int len); 204 static bool equals(oop str1, oop str2); 205 206 // Conversion between '.' and '/' formats 207 static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); } 208 static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); } 209 210 // Conversion 211 static Symbol* as_symbol(Handle java_string, TRAPS); 212 static Symbol* as_symbol_or_null(oop java_string); 213 214 // Testers 215 static bool is_instance(oop obj); 216 static bool is_instance_inlined(oop obj); 217 218 // Debugging 219 static void print(oop java_string, outputStream* st); 220 friend class JavaClasses; 221 friend class StringTable; 222 }; 223 224 225 // Interface to java.lang.Class objects 226 227 #define CLASS_INJECTED_FIELDS(macro) \ 228 macro(java_lang_Class, klass, intptr_signature, false) \ 229 macro(java_lang_Class, array_klass, intptr_signature, false) \ 230 macro(java_lang_Class, oop_size, int_signature, false) \ 231 macro(java_lang_Class, static_oop_field_count, int_signature, false) \ 232 macro(java_lang_Class, protection_domain, object_signature, false) \ 233 macro(java_lang_Class, signers, object_signature, false) 234 235 class java_lang_Class : AllStatic { 236 friend class VMStructs; 237 238 private: 239 // The fake offsets are added by the class loader when java.lang.Class is loaded 240 241 static int _klass_offset; 242 static int _array_klass_offset; 243 244 static int _oop_size_offset; 245 static int _static_oop_field_count_offset; 246 247 static int _protection_domain_offset; 248 static int _init_lock_offset; 249 static int _signers_offset; 250 static int _class_loader_offset; 251 static int _component_mirror_offset; 252 253 static bool offsets_computed; 254 static int classRedefinedCount_offset; 255 256 static GrowableArray<Klass*>* _fixup_mirror_list; 257 258 static void set_init_lock(oop java_class, oop init_lock); 259 static void set_protection_domain(oop java_class, oop protection_domain); 260 static void set_class_loader(oop java_class, oop class_loader); 261 static void set_component_mirror(oop java_class, oop comp_mirror); 262 static void initialize_mirror_fields(KlassHandle k, Handle mirror, Handle protection_domain, TRAPS); 263 public: 264 static void compute_offsets(); 265 266 // Instance creation 267 static void create_mirror(KlassHandle k, Handle class_loader, 268 Handle protection_domain, TRAPS); 269 static void fixup_mirror(KlassHandle k, TRAPS); 270 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); 271 // Conversion 272 static Klass* as_Klass(oop java_class); 273 static void set_klass(oop java_class, Klass* klass); 274 static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL); 275 static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) { 276 Klass* refk_oop = NULL; 277 BasicType result = as_BasicType(java_class, &refk_oop); 278 (*reference_klass) = KlassHandle(refk_oop); 279 return result; 280 } 281 static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS); 282 static void print_signature(oop java_class, outputStream *st); 283 static const char* as_external_name(oop java_class); 284 // Testing 285 static bool is_instance(oop obj); 286 287 static bool is_primitive(oop java_class); 288 static BasicType primitive_type(oop java_class); 289 static oop primitive_mirror(BasicType t); 290 // JVM_NewArray support 291 static Klass* array_klass(oop java_class); 292 static void set_array_klass(oop java_class, Klass* klass); 293 // compiler support for class operations 294 static int klass_offset_in_bytes() { return _klass_offset; } 295 static int array_klass_offset_in_bytes() { return _array_klass_offset; } 296 // Support for classRedefinedCount field 297 static int classRedefinedCount(oop the_class_mirror); 298 static void set_classRedefinedCount(oop the_class_mirror, int value); 299 300 // Support for embedded per-class oops 301 static oop protection_domain(oop java_class); 302 static oop init_lock(oop java_class); 303 static oop component_mirror(oop java_class); 304 static objArrayOop signers(oop java_class); 305 static void set_signers(oop java_class, objArrayOop signers); 306 307 static oop class_loader(oop java_class); 308 309 static int oop_size(oop java_class); 310 static void set_oop_size(oop java_class, int size); 311 static int static_oop_field_count(oop java_class); 312 static void set_static_oop_field_count(oop java_class, int size); 313 314 static GrowableArray<Klass*>* fixup_mirror_list() { 315 return _fixup_mirror_list; 316 } 317 static void set_fixup_mirror_list(GrowableArray<Klass*>* v) { 318 _fixup_mirror_list = v; 319 } 320 // Debugging 321 friend class JavaClasses; 322 friend class InstanceKlass; // verification code accesses offsets 323 friend class ClassFileParser; // access to number_of_fake_fields 324 }; 325 326 // Interface to java.lang.Thread objects 327 328 class java_lang_Thread : AllStatic { 329 private: 330 // Note that for this class the layout changed between JDK1.2 and JDK1.3, 331 // so we compute the offsets at startup rather than hard-wiring them. 332 static int _name_offset; 333 static int _group_offset; 334 static int _contextClassLoader_offset; 335 static int _inheritedAccessControlContext_offset; 336 static int _priority_offset; 337 static int _eetop_offset; 338 static int _daemon_offset; 339 static int _stillborn_offset; 340 static int _stackSize_offset; 341 static int _tid_offset; 342 static int _thread_status_offset; 343 static int _park_blocker_offset; 344 static int _park_event_offset ; 345 346 static void compute_offsets(); 347 348 public: 349 // Instance creation 350 static oop create(); 351 // Returns the JavaThread associated with the thread obj 352 static JavaThread* thread(oop java_thread); 353 // Set JavaThread for instance 354 static void set_thread(oop java_thread, JavaThread* thread); 355 // Name 356 static oop name(oop java_thread); 357 static void set_name(oop java_thread, oop name); 358 // Priority 359 static ThreadPriority priority(oop java_thread); 360 static void set_priority(oop java_thread, ThreadPriority priority); 361 // Thread group 362 static oop threadGroup(oop java_thread); 363 // Stillborn 364 static bool is_stillborn(oop java_thread); 365 static void set_stillborn(oop java_thread); 366 // Alive (NOTE: this is not really a field, but provides the correct 367 // definition without doing a Java call) 368 static bool is_alive(oop java_thread); 369 // Daemon 370 static bool is_daemon(oop java_thread); 371 static void set_daemon(oop java_thread); 372 // Context ClassLoader 373 static oop context_class_loader(oop java_thread); 374 // Control context 375 static oop inherited_access_control_context(oop java_thread); 376 // Stack size hint 377 static jlong stackSize(oop java_thread); 378 // Thread ID 379 static jlong thread_id(oop java_thread); 380 381 // Blocker object responsible for thread parking 382 static oop park_blocker(oop java_thread); 383 384 // Pointer to type-stable park handler, encoded as jlong. 385 // Should be set when apparently null 386 // For details, see unsafe.cpp Unsafe_Unpark 387 static jlong park_event(oop java_thread); 388 static bool set_park_event(oop java_thread, jlong ptr); 389 390 // Java Thread Status for JVMTI and M&M use. 391 // This thread status info is saved in threadStatus field of 392 // java.lang.Thread java class. 393 enum ThreadStatus { 394 NEW = 0, 395 RUNNABLE = JVMTI_THREAD_STATE_ALIVE + // runnable / running 396 JVMTI_THREAD_STATE_RUNNABLE, 397 SLEEPING = JVMTI_THREAD_STATE_ALIVE + // Thread.sleep() 398 JVMTI_THREAD_STATE_WAITING + 399 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + 400 JVMTI_THREAD_STATE_SLEEPING, 401 IN_OBJECT_WAIT = JVMTI_THREAD_STATE_ALIVE + // Object.wait() 402 JVMTI_THREAD_STATE_WAITING + 403 JVMTI_THREAD_STATE_WAITING_INDEFINITELY + 404 JVMTI_THREAD_STATE_IN_OBJECT_WAIT, 405 IN_OBJECT_WAIT_TIMED = JVMTI_THREAD_STATE_ALIVE + // Object.wait(long) 406 JVMTI_THREAD_STATE_WAITING + 407 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + 408 JVMTI_THREAD_STATE_IN_OBJECT_WAIT, 409 PARKED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park() 410 JVMTI_THREAD_STATE_WAITING + 411 JVMTI_THREAD_STATE_WAITING_INDEFINITELY + 412 JVMTI_THREAD_STATE_PARKED, 413 PARKED_TIMED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park(long) 414 JVMTI_THREAD_STATE_WAITING + 415 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + 416 JVMTI_THREAD_STATE_PARKED, 417 BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE + // (re-)entering a synchronization block 418 JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, 419 TERMINATED = JVMTI_THREAD_STATE_TERMINATED 420 }; 421 // Write thread status info to threadStatus field of java.lang.Thread. 422 static void set_thread_status(oop java_thread_oop, ThreadStatus status); 423 // Read thread status info from threadStatus field of java.lang.Thread. 424 static ThreadStatus get_thread_status(oop java_thread_oop); 425 426 static const char* thread_status_name(oop java_thread_oop); 427 428 // Debugging 429 friend class JavaClasses; 430 }; 431 432 // Interface to java.lang.ThreadGroup objects 433 434 class java_lang_ThreadGroup : AllStatic { 435 private: 436 static int _parent_offset; 437 static int _name_offset; 438 static int _threads_offset; 439 static int _groups_offset; 440 static int _maxPriority_offset; 441 static int _destroyed_offset; 442 static int _daemon_offset; 443 static int _vmAllowSuspension_offset; 444 static int _nthreads_offset; 445 static int _ngroups_offset; 446 447 static void compute_offsets(); 448 449 public: 450 // parent ThreadGroup 451 static oop parent(oop java_thread_group); 452 // name 453 static typeArrayOop name(oop java_thread_group); 454 // ("name as oop" accessor is not necessary) 455 // Number of threads in group 456 static int nthreads(oop java_thread_group); 457 // threads 458 static objArrayOop threads(oop java_thread_group); 459 // Number of threads in group 460 static int ngroups(oop java_thread_group); 461 // groups 462 static objArrayOop groups(oop java_thread_group); 463 // maxPriority in group 464 static ThreadPriority maxPriority(oop java_thread_group); 465 // Destroyed 466 static bool is_destroyed(oop java_thread_group); 467 // Daemon 468 static bool is_daemon(oop java_thread_group); 469 // vmAllowSuspension 470 static bool is_vmAllowSuspension(oop java_thread_group); 471 // Debugging 472 friend class JavaClasses; 473 }; 474 475 476 477 // Interface to java.lang.Throwable objects 478 479 class java_lang_Throwable: AllStatic { 480 friend class BacktraceBuilder; 481 482 private: 483 // Offsets 484 enum { 485 hc_backtrace_offset = 0, 486 hc_detailMessage_offset = 1, 487 hc_cause_offset = 2, // New since 1.4 488 hc_stackTrace_offset = 3 // New since 1.4 489 }; 490 enum { 491 hc_static_unassigned_stacktrace_offset = 0 // New since 1.7 492 }; 493 // Trace constants 494 enum { 495 trace_methods_offset = 0, 496 trace_bcis_offset = 1, 497 trace_mirrors_offset = 2, 498 trace_cprefs_offset = 3, 499 trace_next_offset = 4, 500 trace_size = 5, 501 trace_chunk_size = 32 502 }; 503 504 static int backtrace_offset; 505 static int detailMessage_offset; 506 static int cause_offset; 507 static int stackTrace_offset; 508 static int static_unassigned_stacktrace_offset; 509 510 // Printing 511 static char* print_stack_element_to_buffer(Handle mirror, int method, int version, int bci, int cpref); 512 // StackTrace (programmatic access, new since 1.4) 513 static void clear_stacktrace(oop throwable); 514 // No stack trace available 515 static const char* no_stack_trace_message(); 516 // Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed) 517 static void set_stacktrace(oop throwable, oop st_element_array); 518 static oop unassigned_stacktrace(); 519 520 public: 521 // Backtrace 522 static oop backtrace(oop throwable); 523 static void set_backtrace(oop throwable, oop value); 524 // Needed by JVMTI to filter out this internal field. 525 static int get_backtrace_offset() { return backtrace_offset;} 526 static int get_detailMessage_offset() { return detailMessage_offset;} 527 // Message 528 static oop message(oop throwable); 529 static oop message(Handle throwable); 530 static void set_message(oop throwable, oop value); 531 static Symbol* detail_message(oop throwable); 532 static void print_stack_element(outputStream *st, Handle mirror, int method, 533 int version, int bci, int cpref); 534 static void print_stack_element(outputStream *st, methodHandle method, int bci); 535 static void print_stack_usage(Handle stream); 536 537 // Allocate space for backtrace (created but stack trace not filled in) 538 static void allocate_backtrace(Handle throwable, TRAPS); 539 // Fill in current stack trace for throwable with preallocated backtrace (no GC) 540 static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable); 541 // Fill in current stack trace, can cause GC 542 static void fill_in_stack_trace(Handle throwable, methodHandle method, TRAPS); 543 static void fill_in_stack_trace(Handle throwable, methodHandle method = methodHandle()); 544 // Programmatic access to stack trace 545 static oop get_stack_trace_element(oop throwable, int index, TRAPS); 546 static int get_stack_trace_depth(oop throwable, TRAPS); 547 // Printing 548 static void print(oop throwable, outputStream* st); 549 static void print(Handle throwable, outputStream* st); 550 static void print_stack_trace(oop throwable, outputStream* st); 551 // Debugging 552 friend class JavaClasses; 553 }; 554 555 556 // Interface to java.lang.reflect.AccessibleObject objects 557 558 class java_lang_reflect_AccessibleObject: AllStatic { 559 private: 560 // Note that to reduce dependencies on the JDK we compute these 561 // offsets at run-time. 562 static int override_offset; 563 564 static void compute_offsets(); 565 566 public: 567 // Accessors 568 static jboolean override(oop reflect); 569 static void set_override(oop reflect, jboolean value); 570 571 // Debugging 572 friend class JavaClasses; 573 }; 574 575 576 // Interface to java.lang.reflect.Method objects 577 578 class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject { 579 private: 580 // Note that to reduce dependencies on the JDK we compute these 581 // offsets at run-time. 582 static int clazz_offset; 583 static int name_offset; 584 static int returnType_offset; 585 static int parameterTypes_offset; 586 static int exceptionTypes_offset; 587 static int slot_offset; 588 static int modifiers_offset; 589 static int signature_offset; 590 static int annotations_offset; 591 static int parameter_annotations_offset; 592 static int annotation_default_offset; 593 static int type_annotations_offset; 594 595 static void compute_offsets(); 596 597 public: 598 // Allocation 599 static Handle create(TRAPS); 600 601 // Accessors 602 static oop clazz(oop reflect); 603 static void set_clazz(oop reflect, oop value); 604 605 static oop name(oop method); 606 static void set_name(oop method, oop value); 607 608 static oop return_type(oop method); 609 static void set_return_type(oop method, oop value); 610 611 static oop parameter_types(oop method); 612 static void set_parameter_types(oop method, oop value); 613 614 static oop exception_types(oop method); 615 static void set_exception_types(oop method, oop value); 616 617 static int slot(oop reflect); 618 static void set_slot(oop reflect, int value); 619 620 static int modifiers(oop method); 621 static void set_modifiers(oop method, int value); 622 623 static bool has_signature_field(); 624 static oop signature(oop method); 625 static void set_signature(oop method, oop value); 626 627 static bool has_annotations_field(); 628 static oop annotations(oop method); 629 static void set_annotations(oop method, oop value); 630 631 static bool has_parameter_annotations_field(); 632 static oop parameter_annotations(oop method); 633 static void set_parameter_annotations(oop method, oop value); 634 635 static bool has_annotation_default_field(); 636 static oop annotation_default(oop method); 637 static void set_annotation_default(oop method, oop value); 638 639 static bool has_type_annotations_field(); 640 static oop type_annotations(oop method); 641 static void set_type_annotations(oop method, oop value); 642 643 // Debugging 644 friend class JavaClasses; 645 }; 646 647 648 // Interface to java.lang.reflect.Constructor objects 649 650 class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject { 651 private: 652 // Note that to reduce dependencies on the JDK we compute these 653 // offsets at run-time. 654 static int clazz_offset; 655 static int parameterTypes_offset; 656 static int exceptionTypes_offset; 657 static int slot_offset; 658 static int modifiers_offset; 659 static int signature_offset; 660 static int annotations_offset; 661 static int parameter_annotations_offset; 662 static int type_annotations_offset; 663 664 static void compute_offsets(); 665 666 public: 667 // Allocation 668 static Handle create(TRAPS); 669 670 // Accessors 671 static oop clazz(oop reflect); 672 static void set_clazz(oop reflect, oop value); 673 674 static oop parameter_types(oop constructor); 675 static void set_parameter_types(oop constructor, oop value); 676 677 static oop exception_types(oop constructor); 678 static void set_exception_types(oop constructor, oop value); 679 680 static int slot(oop reflect); 681 static void set_slot(oop reflect, int value); 682 683 static int modifiers(oop constructor); 684 static void set_modifiers(oop constructor, int value); 685 686 static bool has_signature_field(); 687 static oop signature(oop constructor); 688 static void set_signature(oop constructor, oop value); 689 690 static bool has_annotations_field(); 691 static oop annotations(oop constructor); 692 static void set_annotations(oop constructor, oop value); 693 694 static bool has_parameter_annotations_field(); 695 static oop parameter_annotations(oop method); 696 static void set_parameter_annotations(oop method, oop value); 697 698 static bool has_type_annotations_field(); 699 static oop type_annotations(oop constructor); 700 static void set_type_annotations(oop constructor, oop value); 701 702 // Debugging 703 friend class JavaClasses; 704 }; 705 706 707 // Interface to java.lang.reflect.Field objects 708 709 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject { 710 private: 711 // Note that to reduce dependencies on the JDK we compute these 712 // offsets at run-time. 713 static int clazz_offset; 714 static int name_offset; 715 static int type_offset; 716 static int slot_offset; 717 static int modifiers_offset; 718 static int signature_offset; 719 static int annotations_offset; 720 static int type_annotations_offset; 721 722 static void compute_offsets(); 723 724 public: 725 // Allocation 726 static Handle create(TRAPS); 727 728 // Accessors 729 static oop clazz(oop reflect); 730 static void set_clazz(oop reflect, oop value); 731 732 static oop name(oop field); 733 static void set_name(oop field, oop value); 734 735 static oop type(oop field); 736 static void set_type(oop field, oop value); 737 738 static int slot(oop reflect); 739 static void set_slot(oop reflect, int value); 740 741 static int modifiers(oop field); 742 static void set_modifiers(oop field, int value); 743 744 static bool has_signature_field(); 745 static oop signature(oop constructor); 746 static void set_signature(oop constructor, oop value); 747 748 static bool has_annotations_field(); 749 static oop annotations(oop constructor); 750 static void set_annotations(oop constructor, oop value); 751 752 static bool has_parameter_annotations_field(); 753 static oop parameter_annotations(oop method); 754 static void set_parameter_annotations(oop method, oop value); 755 756 static bool has_annotation_default_field(); 757 static oop annotation_default(oop method); 758 static void set_annotation_default(oop method, oop value); 759 760 static bool has_type_annotations_field(); 761 static oop type_annotations(oop field); 762 static void set_type_annotations(oop field, oop value); 763 764 // Debugging 765 friend class JavaClasses; 766 }; 767 768 class java_lang_reflect_Parameter { 769 private: 770 // Note that to reduce dependencies on the JDK we compute these 771 // offsets at run-time. 772 static int name_offset; 773 static int modifiers_offset; 774 static int index_offset; 775 static int executable_offset; 776 777 static void compute_offsets(); 778 779 public: 780 // Allocation 781 static Handle create(TRAPS); 782 783 // Accessors 784 static oop name(oop field); 785 static void set_name(oop field, oop value); 786 787 static int index(oop reflect); 788 static void set_index(oop reflect, int value); 789 790 static int modifiers(oop reflect); 791 static void set_modifiers(oop reflect, int value); 792 793 static oop executable(oop constructor); 794 static void set_executable(oop constructor, oop value); 795 796 friend class JavaClasses; 797 }; 798 799 // Interface to sun.reflect.ConstantPool objects 800 class sun_reflect_ConstantPool { 801 private: 802 // Note that to reduce dependencies on the JDK we compute these 803 // offsets at run-time. 804 static int _oop_offset; 805 806 static void compute_offsets(); 807 808 public: 809 // Allocation 810 static Handle create(TRAPS); 811 812 // Accessors 813 static void set_cp(oop reflect, ConstantPool* value); 814 static int oop_offset() { 815 return _oop_offset; 816 } 817 818 static ConstantPool* get_cp(oop reflect); 819 820 // Debugging 821 friend class JavaClasses; 822 }; 823 824 // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects 825 class sun_reflect_UnsafeStaticFieldAccessorImpl { 826 private: 827 static int _base_offset; 828 static void compute_offsets(); 829 830 public: 831 static int base_offset() { 832 return _base_offset; 833 } 834 835 // Debugging 836 friend class JavaClasses; 837 }; 838 839 // Interface to java.lang primitive type boxing objects: 840 // - java.lang.Boolean 841 // - java.lang.Character 842 // - java.lang.Float 843 // - java.lang.Double 844 // - java.lang.Byte 845 // - java.lang.Short 846 // - java.lang.Integer 847 // - java.lang.Long 848 849 // This could be separated out into 8 individual classes. 850 851 class java_lang_boxing_object: AllStatic { 852 private: 853 enum { 854 hc_value_offset = 0 855 }; 856 static int value_offset; 857 static int long_value_offset; 858 859 static oop initialize_and_allocate(BasicType type, TRAPS); 860 public: 861 // Allocation. Returns a boxed value, or NULL for invalid type. 862 static oop create(BasicType type, jvalue* value, TRAPS); 863 // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop. 864 static BasicType get_value(oop box, jvalue* value); 865 static BasicType set_value(oop box, jvalue* value); 866 static BasicType basic_type(oop box); 867 static bool is_instance(oop box) { return basic_type(box) != T_ILLEGAL; } 868 static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; } 869 static void print(oop box, outputStream* st) { jvalue value; print(get_value(box, &value), &value, st); } 870 static void print(BasicType type, jvalue* value, outputStream* st); 871 872 static int value_offset_in_bytes(BasicType type) { 873 return ( type == T_LONG || type == T_DOUBLE ) ? long_value_offset : 874 value_offset; 875 } 876 877 // Debugging 878 friend class JavaClasses; 879 }; 880 881 882 883 // Interface to java.lang.ref.Reference objects 884 885 class java_lang_ref_Reference: AllStatic { 886 public: 887 enum { 888 hc_referent_offset = 0, 889 hc_queue_offset = 1, 890 hc_next_offset = 2, 891 hc_discovered_offset = 3 // Is not last, see SoftRefs. 892 }; 893 enum { 894 hc_static_lock_offset = 0, 895 hc_static_pending_offset = 1 896 }; 897 898 static int referent_offset; 899 static int queue_offset; 900 static int next_offset; 901 static int discovered_offset; 902 static int static_lock_offset; 903 static int static_pending_offset; 904 static int number_of_fake_oop_fields; 905 906 // Accessors 907 static oop referent(oop ref) { 908 return ref->obj_field(referent_offset); 909 } 910 static void set_referent(oop ref, oop value) { 911 ref->obj_field_put(referent_offset, value); 912 } 913 static void set_referent_raw(oop ref, oop value) { 914 ref->obj_field_put_raw(referent_offset, value); 915 } 916 static HeapWord* referent_addr(oop ref) { 917 return ref->obj_field_addr<HeapWord>(referent_offset); 918 } 919 static oop next(oop ref) { 920 return ref->obj_field(next_offset); 921 } 922 static void set_next(oop ref, oop value) { 923 ref->obj_field_put(next_offset, value); 924 } 925 static void set_next_raw(oop ref, oop value) { 926 ref->obj_field_put_raw(next_offset, value); 927 } 928 static HeapWord* next_addr(oop ref) { 929 return ref->obj_field_addr<HeapWord>(next_offset); 930 } 931 static oop discovered(oop ref) { 932 return ref->obj_field(discovered_offset); 933 } 934 static void set_discovered(oop ref, oop value) { 935 ref->obj_field_put(discovered_offset, value); 936 } 937 static void set_discovered_raw(oop ref, oop value) { 938 ref->obj_field_put_raw(discovered_offset, value); 939 } 940 static HeapWord* discovered_addr(oop ref) { 941 return ref->obj_field_addr<HeapWord>(discovered_offset); 942 } 943 // Accessors for statics 944 static oop pending_list_lock(); 945 static oop pending_list(); 946 947 static HeapWord* pending_list_lock_addr(); 948 static HeapWord* pending_list_addr(); 949 }; 950 951 952 // Interface to java.lang.ref.SoftReference objects 953 954 class java_lang_ref_SoftReference: public java_lang_ref_Reference { 955 public: 956 enum { 957 // The timestamp is a long field and may need to be adjusted for alignment. 958 hc_timestamp_offset = hc_discovered_offset + 1 959 }; 960 enum { 961 hc_static_clock_offset = 0 962 }; 963 964 static int timestamp_offset; 965 static int static_clock_offset; 966 967 // Accessors 968 static jlong timestamp(oop ref); 969 970 // Accessors for statics 971 static jlong clock(); 972 static void set_clock(jlong value); 973 }; 974 975 // Interface to java.lang.invoke.MethodHandle objects 976 977 class MethodHandleEntry; 978 979 class java_lang_invoke_MethodHandle: AllStatic { 980 friend class JavaClasses; 981 982 private: 983 static int _type_offset; // the MethodType of this MH 984 static int _form_offset; // the LambdaForm of this MH 985 986 static void compute_offsets(); 987 988 public: 989 // Accessors 990 static oop type(oop mh); 991 static void set_type(oop mh, oop mtype); 992 993 static oop form(oop mh); 994 static void set_form(oop mh, oop lform); 995 996 // Testers 997 static bool is_subclass(Klass* klass) { 998 return klass->is_subclass_of(SystemDictionary::MethodHandle_klass()); 999 } 1000 static bool is_instance(oop obj); 1001 1002 // Accessors for code generation: 1003 static int type_offset_in_bytes() { return _type_offset; } 1004 static int form_offset_in_bytes() { return _form_offset; } 1005 }; 1006 1007 // Interface to java.lang.invoke.DirectMethodHandle objects 1008 1009 class java_lang_invoke_DirectMethodHandle: AllStatic { 1010 friend class JavaClasses; 1011 1012 private: 1013 static int _member_offset; // the MemberName of this DMH 1014 1015 static void compute_offsets(); 1016 1017 public: 1018 // Accessors 1019 static oop member(oop mh); 1020 1021 // Testers 1022 static bool is_subclass(Klass* klass) { 1023 return klass->is_subclass_of(SystemDictionary::DirectMethodHandle_klass()); 1024 } 1025 static bool is_instance(oop obj); 1026 1027 // Accessors for code generation: 1028 static int member_offset_in_bytes() { return _member_offset; } 1029 }; 1030 1031 // Interface to java.lang.invoke.LambdaForm objects 1032 // (These are a private interface for managing adapter code generation.) 1033 1034 class java_lang_invoke_LambdaForm: AllStatic { 1035 friend class JavaClasses; 1036 1037 private: 1038 static int _vmentry_offset; // type is MemberName 1039 1040 static void compute_offsets(); 1041 1042 public: 1043 // Accessors 1044 static oop vmentry(oop lform); 1045 static void set_vmentry(oop lform, oop invoker); 1046 1047 // Testers 1048 static bool is_subclass(Klass* klass) { 1049 return SystemDictionary::LambdaForm_klass() != NULL && 1050 klass->is_subclass_of(SystemDictionary::LambdaForm_klass()); 1051 } 1052 static bool is_instance(oop obj); 1053 1054 // Accessors for code generation: 1055 static int vmentry_offset_in_bytes() { return _vmentry_offset; } 1056 }; 1057 1058 1059 // Interface to java.lang.invoke.MemberName objects 1060 // (These are a private interface for Java code to query the class hierarchy.) 1061 1062 #define MEMBERNAME_INJECTED_FIELDS(macro) \ 1063 macro(java_lang_invoke_MemberName, vmloader, object_signature, false) \ 1064 macro(java_lang_invoke_MemberName, vmindex, intptr_signature, false) \ 1065 macro(java_lang_invoke_MemberName, vmtarget, intptr_signature, false) 1066 1067 class java_lang_invoke_MemberName: AllStatic { 1068 friend class JavaClasses; 1069 1070 private: 1071 // From java.lang.invoke.MemberName: 1072 // private Class<?> clazz; // class in which the method is defined 1073 // private String name; // may be null if not yet materialized 1074 // private Object type; // may be null if not yet materialized 1075 // private int flags; // modifier bits; see reflect.Modifier 1076 // private intptr vmtarget; // VM-specific target value 1077 // private intptr_t vmindex; // member index within class or interface 1078 static int _clazz_offset; 1079 static int _name_offset; 1080 static int _type_offset; 1081 static int _flags_offset; 1082 static int _vmtarget_offset; 1083 static int _vmloader_offset; 1084 static int _vmindex_offset; 1085 1086 static void compute_offsets(); 1087 1088 public: 1089 // Accessors 1090 static oop clazz(oop mname); 1091 static void set_clazz(oop mname, oop clazz); 1092 1093 static oop type(oop mname); 1094 static void set_type(oop mname, oop type); 1095 1096 static oop name(oop mname); 1097 static void set_name(oop mname, oop name); 1098 1099 static int flags(oop mname); 1100 static void set_flags(oop mname, int flags); 1101 1102 static Metadata* vmtarget(oop mname); 1103 static void set_vmtarget(oop mname, Metadata* target); 1104 1105 static intptr_t vmindex(oop mname); 1106 static void set_vmindex(oop mname, intptr_t index); 1107 1108 // Testers 1109 static bool is_subclass(Klass* klass) { 1110 return klass->is_subclass_of(SystemDictionary::MemberName_klass()); 1111 } 1112 static bool is_instance(oop obj); 1113 1114 static bool is_method(oop obj); 1115 1116 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): 1117 enum { 1118 MN_IS_METHOD = 0x00010000, // method (not constructor) 1119 MN_IS_CONSTRUCTOR = 0x00020000, // constructor 1120 MN_IS_FIELD = 0x00040000, // field 1121 MN_IS_TYPE = 0x00080000, // nested type 1122 MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected 1123 MN_REFERENCE_KIND_SHIFT = 24, // refKind 1124 MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT, 1125 // The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers: 1126 MN_SEARCH_SUPERCLASSES = 0x00100000, // walk super classes 1127 MN_SEARCH_INTERFACES = 0x00200000 // walk implemented interfaces 1128 }; 1129 1130 // Accessors for code generation: 1131 static int clazz_offset_in_bytes() { return _clazz_offset; } 1132 static int type_offset_in_bytes() { return _type_offset; } 1133 static int name_offset_in_bytes() { return _name_offset; } 1134 static int flags_offset_in_bytes() { return _flags_offset; } 1135 static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } 1136 static int vmindex_offset_in_bytes() { return _vmindex_offset; } 1137 }; 1138 1139 1140 // Interface to java.lang.invoke.MethodType objects 1141 1142 class java_lang_invoke_MethodType: AllStatic { 1143 friend class JavaClasses; 1144 1145 private: 1146 static int _rtype_offset; 1147 static int _ptypes_offset; 1148 1149 static void compute_offsets(); 1150 1151 public: 1152 // Accessors 1153 static oop rtype(oop mt); 1154 static objArrayOop ptypes(oop mt); 1155 1156 static oop ptype(oop mt, int index); 1157 static int ptype_count(oop mt); 1158 1159 static int ptype_slot_count(oop mt); // extra counts for long/double 1160 static int rtype_slot_count(oop mt); // extra counts for long/double 1161 1162 static Symbol* as_signature(oop mt, bool intern_if_not_found, TRAPS); 1163 static void print_signature(oop mt, outputStream* st); 1164 1165 static bool is_instance(oop obj); 1166 1167 static bool equals(oop mt1, oop mt2); 1168 1169 // Accessors for code generation: 1170 static int rtype_offset_in_bytes() { return _rtype_offset; } 1171 static int ptypes_offset_in_bytes() { return _ptypes_offset; } 1172 }; 1173 1174 1175 // Interface to java.lang.invoke.CallSite objects 1176 1177 class java_lang_invoke_CallSite: AllStatic { 1178 friend class JavaClasses; 1179 1180 private: 1181 static int _target_offset; 1182 static int _context_offset; 1183 1184 static void compute_offsets(); 1185 1186 public: 1187 // Accessors 1188 static oop target( oop site); 1189 static void set_target( oop site, oop target); 1190 static void set_target_volatile( oop site, oop target); 1191 1192 static oop context(oop site); 1193 1194 // Testers 1195 static bool is_subclass(Klass* klass) { 1196 return klass->is_subclass_of(SystemDictionary::CallSite_klass()); 1197 } 1198 static bool is_instance(oop obj); 1199 1200 // Accessors for code generation: 1201 static int target_offset_in_bytes() { return _target_offset; } 1202 }; 1203 1204 // Interface to java.lang.invoke.MethodHandleNatives$CallSiteContext objects 1205 1206 #define CALLSITECONTEXT_INJECTED_FIELDS(macro) \ 1207 macro(java_lang_invoke_MethodHandleNatives_CallSiteContext, vmdependencies, intptr_signature, false) 1208 1209 class java_lang_invoke_MethodHandleNatives_CallSiteContext : AllStatic { 1210 friend class JavaClasses; 1211 1212 private: 1213 static int _vmdependencies_offset; 1214 1215 static void compute_offsets(); 1216 1217 public: 1218 // Accessors 1219 static nmethodBucket* vmdependencies(oop context); 1220 static void set_vmdependencies(oop context, nmethodBucket* bucket); 1221 1222 // Testers 1223 static bool is_subclass(Klass* klass) { 1224 return klass->is_subclass_of(SystemDictionary::Context_klass()); 1225 } 1226 static bool is_instance(oop obj); 1227 }; 1228 1229 // Interface to java.security.AccessControlContext objects 1230 1231 class java_security_AccessControlContext: AllStatic { 1232 private: 1233 // Note that for this class the layout changed between JDK1.2 and JDK1.3, 1234 // so we compute the offsets at startup rather than hard-wiring them. 1235 static int _context_offset; 1236 static int _privilegedContext_offset; 1237 static int _isPrivileged_offset; 1238 static int _isAuthorized_offset; 1239 1240 static void compute_offsets(); 1241 public: 1242 static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS); 1243 1244 static bool is_authorized(Handle context); 1245 1246 // Debugging/initialization 1247 friend class JavaClasses; 1248 }; 1249 1250 1251 // Interface to java.lang.ClassLoader objects 1252 1253 #define CLASSLOADER_INJECTED_FIELDS(macro) \ 1254 macro(java_lang_ClassLoader, loader_data, intptr_signature, false) 1255 1256 class java_lang_ClassLoader : AllStatic { 1257 private: 1258 // The fake offsets are added by the class loader when java.lang.Class is loaded 1259 enum { 1260 hc_parent_offset = 0 1261 }; 1262 static int _loader_data_offset; 1263 static bool offsets_computed; 1264 static int parent_offset; 1265 static int parallelCapable_offset; 1266 1267 public: 1268 static void compute_offsets(); 1269 1270 static ClassLoaderData** loader_data_addr(oop loader); 1271 static ClassLoaderData* loader_data(oop loader); 1272 1273 static oop parent(oop loader); 1274 static bool isAncestor(oop loader, oop cl); 1275 1276 // Support for parallelCapable field 1277 static bool parallelCapable(oop the_class_mirror); 1278 1279 static bool is_trusted_loader(oop loader); 1280 1281 // Fix for 4474172 1282 static oop non_reflection_class_loader(oop loader); 1283 1284 // Testers 1285 static bool is_subclass(Klass* klass) { 1286 return klass->is_subclass_of(SystemDictionary::ClassLoader_klass()); 1287 } 1288 static bool is_instance(oop obj); 1289 1290 // Debugging 1291 friend class JavaClasses; 1292 friend class ClassFileParser; // access to number_of_fake_fields 1293 }; 1294 1295 1296 // Interface to java.lang.System objects 1297 1298 class java_lang_System : AllStatic { 1299 private: 1300 enum { 1301 hc_static_in_offset = 0, 1302 hc_static_out_offset = 1, 1303 hc_static_err_offset = 2, 1304 hc_static_security_offset = 3 1305 }; 1306 1307 static int static_in_offset; 1308 static int static_out_offset; 1309 static int static_err_offset; 1310 static int static_security_offset; 1311 1312 public: 1313 static int in_offset_in_bytes(); 1314 static int out_offset_in_bytes(); 1315 static int err_offset_in_bytes(); 1316 1317 static bool has_security_manager(); 1318 1319 // Debugging 1320 friend class JavaClasses; 1321 }; 1322 1323 1324 // Interface to java.lang.StackTraceElement objects 1325 1326 class java_lang_StackTraceElement: AllStatic { 1327 private: 1328 enum { 1329 hc_declaringClass_offset = 0, 1330 hc_methodName_offset = 1, 1331 hc_fileName_offset = 2, 1332 hc_lineNumber_offset = 3 1333 }; 1334 1335 static int declaringClass_offset; 1336 static int methodName_offset; 1337 static int fileName_offset; 1338 static int lineNumber_offset; 1339 1340 public: 1341 // Setters 1342 static void set_declaringClass(oop element, oop value); 1343 static void set_methodName(oop element, oop value); 1344 static void set_fileName(oop element, oop value); 1345 static void set_lineNumber(oop element, int value); 1346 1347 // Create an instance of StackTraceElement 1348 static oop create(Handle mirror, int method, int version, int bci, int cpref, TRAPS); 1349 static oop create(methodHandle method, int bci, TRAPS); 1350 1351 // Debugging 1352 friend class JavaClasses; 1353 }; 1354 1355 1356 // Interface to java.lang.AssertionStatusDirectives objects 1357 1358 class java_lang_AssertionStatusDirectives: AllStatic { 1359 private: 1360 enum { 1361 hc_classes_offset, 1362 hc_classEnabled_offset, 1363 hc_packages_offset, 1364 hc_packageEnabled_offset, 1365 hc_deflt_offset 1366 }; 1367 1368 static int classes_offset; 1369 static int classEnabled_offset; 1370 static int packages_offset; 1371 static int packageEnabled_offset; 1372 static int deflt_offset; 1373 1374 public: 1375 // Setters 1376 static void set_classes(oop obj, oop val); 1377 static void set_classEnabled(oop obj, oop val); 1378 static void set_packages(oop obj, oop val); 1379 static void set_packageEnabled(oop obj, oop val); 1380 static void set_deflt(oop obj, bool val); 1381 // Debugging 1382 friend class JavaClasses; 1383 }; 1384 1385 1386 class java_nio_Buffer: AllStatic { 1387 private: 1388 static int _limit_offset; 1389 1390 public: 1391 static int limit_offset(); 1392 static void compute_offsets(); 1393 }; 1394 1395 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic { 1396 private: 1397 static int _owner_offset; 1398 public: 1399 static void initialize(TRAPS); 1400 static oop get_owner_threadObj(oop obj); 1401 }; 1402 1403 // Use to declare fields that need to be injected into Java classes 1404 // for the JVM to use. The name_index and signature_index are 1405 // declared in vmSymbols. The may_be_java flag is used to declare 1406 // fields that might already exist in Java but should be injected if 1407 // they don't. Otherwise the field is unconditionally injected and 1408 // the JVM uses the injected one. This is to ensure that name 1409 // collisions don't occur. In general may_be_java should be false 1410 // unless there's a good reason. 1411 1412 class InjectedField { 1413 public: 1414 const SystemDictionary::WKID klass_id; 1415 const vmSymbols::SID name_index; 1416 const vmSymbols::SID signature_index; 1417 const bool may_be_java; 1418 1419 1420 Klass* klass() const { return SystemDictionary::well_known_klass(klass_id); } 1421 Symbol* name() const { return lookup_symbol(name_index); } 1422 Symbol* signature() const { return lookup_symbol(signature_index); } 1423 1424 int compute_offset(); 1425 1426 // Find the Symbol for this index 1427 static Symbol* lookup_symbol(int symbol_index) { 1428 return vmSymbols::symbol_at((vmSymbols::SID)symbol_index); 1429 } 1430 }; 1431 1432 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \ 1433 klass##_##name##_enum, 1434 1435 #define ALL_INJECTED_FIELDS(macro) \ 1436 CLASS_INJECTED_FIELDS(macro) \ 1437 CLASSLOADER_INJECTED_FIELDS(macro) \ 1438 MEMBERNAME_INJECTED_FIELDS(macro) \ 1439 CALLSITECONTEXT_INJECTED_FIELDS(macro) 1440 1441 // Interface to hard-coded offset checking 1442 1443 class JavaClasses : AllStatic { 1444 private: 1445 1446 static InjectedField _injected_fields[]; 1447 1448 static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; 1449 static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; 1450 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0; 1451 1452 public: 1453 enum InjectedFieldID { 1454 ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM) 1455 MAX_enum 1456 }; 1457 1458 static int compute_injected_offset(InjectedFieldID id); 1459 1460 static void compute_hard_coded_offsets(); 1461 static void compute_offsets(); 1462 static void check_offsets() PRODUCT_RETURN; 1463 1464 static InjectedField* get_injected(Symbol* class_name, int* field_count); 1465 }; 1466 1467 #undef DECLARE_INJECTED_FIELD_ENUM 1468 1469 #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP