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