1 /*
   2  * Copyright (c) 1997, 2021, 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_CLASSFILE_JAVACLASSES_HPP
  26 #define SHARE_CLASSFILE_JAVACLASSES_HPP
  27 
  28 #include "classfile/vmClasses.hpp"
  29 #include "oops/oop.hpp"
  30 #include "oops/instanceKlass.hpp"
  31 #include "oops/stackChunkOop.hpp"
  32 #include "oops/symbol.hpp"
  33 #include "runtime/os.hpp"
  34 #include "utilities/vmEnums.hpp"
  35 
  36 class JvmtiThreadState;
  37 class RecordComponent;
  38 
  39 // Interface for manipulating the basic Java classes.
  40 
  41 #define BASIC_JAVA_CLASSES_DO_PART1(f) \
  42   f(java_lang_Class) \
  43   f(java_lang_String) \
  44   f(java_lang_ref_Reference) \
  45   //end
  46 
  47 #define BASIC_JAVA_CLASSES_DO_PART2(f) \
  48   f(java_lang_System) \
  49   f(java_lang_ClassLoader) \
  50   f(java_lang_Throwable) \
  51   f(java_lang_Thread) \
  52   f(java_lang_Thread_FieldHolder) \
  53   f(java_lang_Thread_VirtualThreads) \
  54   f(java_lang_Thread_ClassLoaders) \
  55   f(java_lang_ThreadGroup) \
  56   f(java_lang_VirtualThread) \
  57   f(java_lang_InternalError) \
  58   f(java_lang_AssertionStatusDirectives) \
  59   f(java_lang_ref_SoftReference) \
  60   f(java_lang_invoke_MethodHandle) \
  61   f(java_lang_invoke_DirectMethodHandle) \
  62   f(java_lang_invoke_MemberName) \
  63   f(java_lang_invoke_ResolvedMethodName) \
  64   f(java_lang_invoke_LambdaForm) \
  65   f(java_lang_invoke_MethodType) \
  66   f(java_lang_invoke_CallSite) \
  67   f(java_lang_invoke_ConstantCallSite) \
  68   f(java_lang_invoke_MethodHandleNatives_CallSiteContext) \
  69   f(java_security_AccessControlContext) \
  70   f(java_lang_reflect_AccessibleObject) \
  71   f(java_lang_reflect_Method) \
  72   f(java_lang_reflect_Constructor) \
  73   f(java_lang_reflect_Field) \
  74   f(java_lang_reflect_RecordComponent) \
  75   f(reflect_ConstantPool) \
  76   f(reflect_UnsafeStaticFieldAccessorImpl) \
  77   f(java_lang_reflect_Parameter) \
  78   f(java_lang_Module) \
  79   f(java_lang_StackTraceElement) \
  80   f(java_lang_StackFrameInfo) \
  81   f(java_lang_LiveStackFrameInfo) \
  82   f(jdk_internal_vm_ContinuationScope) \
  83   f(jdk_internal_vm_Continuation) \
  84   f(jdk_internal_vm_StackChunk) \
  85   f(java_util_concurrent_locks_AbstractOwnableSynchronizer) \
  86   f(jdk_internal_invoke_NativeEntryPoint) \
  87   f(jdk_internal_misc_UnsafeConstants) \
  88   f(java_lang_boxing_object) \
  89   f(vector_VectorPayload) \
  90   //end
  91 
  92 #define BASIC_JAVA_CLASSES_DO(f) \
  93         BASIC_JAVA_CLASSES_DO_PART1(f) \
  94         BASIC_JAVA_CLASSES_DO_PART2(f)
  95 
  96 #define CHECK_INIT(offset)  assert(offset != 0, "should be initialized"); return offset;
  97 
  98 // Interface to java.lang.Object objects
  99 
 100 class java_lang_Object : AllStatic {
 101  public:
 102   static void register_natives(TRAPS);
 103 };
 104 
 105 // Interface to java.lang.String objects
 106 
 107 // The flags field is a collection of bits representing boolean values used
 108 // internally by the VM.
 109 #define STRING_INJECTED_FIELDS(macro) \
 110   macro(java_lang_String, flags, byte_signature, false)
 111 
 112 class java_lang_String : AllStatic {
 113  private:
 114   static int _value_offset;
 115   static int _hash_offset;
 116   static int _hashIsZero_offset;
 117   static int _coder_offset;
 118   static int _flags_offset;
 119 
 120   static bool _initialized;
 121 
 122   static Handle basic_create(int length, bool byte_arr, TRAPS);
 123 
 124   static inline void set_coder(oop string, jbyte coder);
 125 
 126   // Bitmasks for values in the injected flags field.
 127   static const uint8_t _deduplication_forbidden_mask = 1 << 0;
 128   static const uint8_t _deduplication_requested_mask = 1 << 1;
 129 
 130   static int flags_offset() { CHECK_INIT(_flags_offset); }
 131   // Return the address of the injected flags field.
 132   static inline uint8_t* flags_addr(oop java_string);
 133   // Test whether the designated bit of the injected flags field is set.
 134   static inline bool is_flag_set(oop java_string, uint8_t flag_mask);
 135   // Atomically test and set the designated bit of the injected flags field,
 136   // returning true if the bit was already set.
 137   static bool test_and_set_flag(oop java_string, uint8_t flag_mask);
 138 
 139   static inline unsigned int hash_code_impl(oop java_string, bool update);
 140 
 141  public:
 142 
 143   // Coders
 144   enum Coder {
 145     CODER_LATIN1 =  0,
 146     CODER_UTF16  =  1
 147   };
 148 
 149   static void compute_offsets();
 150   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 151 
 152   // Instance creation
 153   static Handle create_from_unicode(const jchar* unicode, int len, TRAPS);
 154   static oop    create_oop_from_unicode(const jchar* unicode, int len, TRAPS);
 155   static Handle create_from_str(const char* utf8_str, TRAPS);
 156   static oop    create_oop_from_str(const char* utf8_str, TRAPS);
 157   static Handle create_from_symbol(Symbol* symbol, TRAPS);
 158   static Handle create_from_platform_dependent_str(const char* str, TRAPS);
 159 
 160   static void set_compact_strings(bool value);
 161 
 162   static int value_offset() { CHECK_INIT(_value_offset); }
 163   static int coder_offset() { CHECK_INIT(_coder_offset); }
 164 
 165   static inline void set_value_raw(oop string, typeArrayOop buffer);
 166   static inline void set_value(oop string, typeArrayOop buffer);
 167 
 168   // Set the deduplication_forbidden flag true.  This flag is sticky; once
 169   // set it never gets cleared.  This is set when a String is interned in
 170   // the StringTable, to prevent string deduplication from changing the
 171   // String's value array.
 172   static inline void set_deduplication_forbidden(oop java_string);
 173 
 174   // Test and set the deduplication_requested flag.  Returns the old value
 175   // of the flag.  This flag is sticky; once set it never gets cleared.
 176   // Some GCs may use this flag when deciding whether to request
 177   // deduplication of a String, to avoid multiple requests for the same
 178   // object.
 179   static inline bool test_and_set_deduplication_requested(oop java_string);
 180 
 181   // Accessors
 182   static inline typeArrayOop value(oop java_string);
 183   static inline typeArrayOop value_no_keepalive(oop java_string);
 184   static inline bool hash_is_set(oop string);
 185   static inline bool is_latin1(oop java_string);
 186   static inline bool deduplication_forbidden(oop java_string);
 187   static inline bool deduplication_requested(oop java_string);
 188   static inline int length(oop java_string);
 189   static inline int length(oop java_string, typeArrayOop string_value);
 190   static int utf8_length(oop java_string);
 191   static int utf8_length(oop java_string, typeArrayOop string_value);
 192 
 193   // String converters
 194   static char*  as_utf8_string(oop java_string);
 195   static char*  as_utf8_string(oop java_string, int& length);
 196   static char*  as_utf8_string_full(oop java_string, char* buf, int buflen, int& length);
 197   static char*  as_utf8_string(oop java_string, char* buf, int buflen);
 198   static char*  as_utf8_string(oop java_string, int start, int len);
 199   static char*  as_utf8_string(oop java_string, typeArrayOop value, char* buf, int buflen);
 200   static char*  as_utf8_string(oop java_string, typeArrayOop value, int start, int len, char* buf, int buflen);
 201   static char*  as_platform_dependent_str(Handle java_string, TRAPS);
 202   static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
 203   static jchar* as_unicode_string_or_null(oop java_string, int& length);
 204   // produce an ascii string with all other values quoted using \u####
 205   static char*  as_quoted_ascii(oop java_string);
 206 
 207   // Compute the hash value for a java.lang.String object which would
 208   // contain the characters passed in.
 209   //
 210   // As the hash value used by the String object itself, in
 211   // String.hashCode().  This value is normally calculated in Java code
 212   // in the String.hashCode method(), but is precomputed for String
 213   // objects in the shared archive file.
 214   // hash P(31) from Kernighan & Ritchie
 215   //
 216   // For this reason, THIS ALGORITHM MUST MATCH String.hashCode().
 217   static unsigned int hash_code(const jchar* s, int len) {
 218     unsigned int h = 0;
 219     while (len-- > 0) {
 220       h = 31*h + (unsigned int) *s;
 221       s++;
 222     }
 223     return h;
 224   }
 225 
 226   static unsigned int hash_code(const jbyte* s, int len) {
 227     unsigned int h = 0;
 228     while (len-- > 0) {
 229       h = 31*h + (((unsigned int) *s) & 0xFF);
 230       s++;
 231     }
 232     return h;
 233   }
 234 
 235   static unsigned int hash_code(oop java_string);
 236   static unsigned int hash_code_noupdate(oop java_string);
 237 
 238   static bool equals(oop java_string, const jchar* chars, int len);
 239   static bool equals(oop str1, oop str2);
 240   static inline bool value_equals(typeArrayOop str_value1, typeArrayOop str_value2);
 241 
 242   // Conversion between '.' and '/' formats, and allocate a String from the result.
 243   static Handle externalize_classname(Symbol* java_name, TRAPS);
 244 
 245   // Conversion
 246   static Symbol* as_symbol(oop java_string);
 247   static Symbol* as_symbol_or_null(oop java_string);
 248 
 249   // Tester
 250   static inline bool is_instance(oop obj);
 251 
 252   // Debugging
 253   static void print(oop java_string, outputStream* st);
 254   friend class JavaClasses;
 255   friend class StringTable;
 256 };
 257 
 258 
 259 // Interface to java.lang.Class objects
 260 
 261 #define CLASS_INJECTED_FIELDS(macro)                                       \
 262   macro(java_lang_Class, klass,                  intptr_signature,  false) \
 263   macro(java_lang_Class, array_klass,            intptr_signature,  false) \
 264   macro(java_lang_Class, oop_size,               int_signature,     false) \
 265   macro(java_lang_Class, static_oop_field_count, int_signature,     false) \
 266   macro(java_lang_Class, protection_domain,      object_signature,  false) \
 267   macro(java_lang_Class, signers,                object_signature,  false) \
 268   macro(java_lang_Class, source_file,            object_signature,  false) \
 269 
 270 class java_lang_Class : AllStatic {
 271   friend class VMStructs;
 272   friend class JVMCIVMStructs;
 273 
 274  private:
 275 
 276   // The fake offsets are added by the class loader when java.lang.Class is loaded
 277 
 278   static int _klass_offset;
 279   static int _array_klass_offset;
 280 
 281   static int _oop_size_offset;
 282   static int _static_oop_field_count_offset;
 283 
 284   static int _protection_domain_offset;
 285   static int _init_lock_offset;
 286   static int _signers_offset;
 287   static int _class_loader_offset;
 288   static int _module_offset;
 289   static int _component_mirror_offset;
 290   static int _name_offset;
 291   static int _source_file_offset;
 292   static int _classData_offset;
 293   static int _classRedefinedCount_offset;
 294 
 295   static bool _offsets_computed;
 296 
 297   static GrowableArray<Klass*>* _fixup_mirror_list;
 298   static GrowableArray<Klass*>* _fixup_module_field_list;
 299 
 300   static void set_init_lock(oop java_class, oop init_lock);
 301   static void set_protection_domain(oop java_class, oop protection_domain);
 302   static void set_class_loader(oop java_class, oop class_loader);
 303   static void set_component_mirror(oop java_class, oop comp_mirror);
 304   static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain,
 305                                        Handle classData, TRAPS);
 306   static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
 307  public:
 308   static void allocate_fixup_lists();
 309   static void compute_offsets();
 310 
 311   // Instance creation
 312   static void create_mirror(Klass* k, Handle class_loader, Handle module,
 313                             Handle protection_domain, Handle classData, TRAPS);
 314   static void fixup_mirror(Klass* k, TRAPS);
 315   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
 316   static void update_archived_primitive_mirror_native_pointers(oop archived_mirror) NOT_CDS_JAVA_HEAP_RETURN;
 317   static void update_archived_mirror_native_pointers(oop archived_mirror) NOT_CDS_JAVA_HEAP_RETURN;
 318 
 319   // Archiving
 320   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 321   static void archive_basic_type_mirrors() NOT_CDS_JAVA_HEAP_RETURN;
 322   static oop  archive_mirror(Klass* k) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
 323   static oop  process_archived_mirror(Klass* k, oop mirror, oop archived_mirror)
 324                                       NOT_CDS_JAVA_HEAP_RETURN_(NULL);
 325   static bool restore_archived_mirror(Klass *k, Handle class_loader, Handle module,
 326                                       Handle protection_domain,
 327                                       TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(false);
 328 
 329   static void fixup_module_field(Klass* k, Handle module);
 330 
 331   // Conversion
 332   static Klass* as_Klass(oop java_class);
 333   static void set_klass(oop java_class, Klass* klass);
 334   static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL);
 335   static Symbol* as_signature(oop java_class, bool intern_if_not_found);
 336   static void print_signature(oop java_class, outputStream *st);
 337   static const char* as_external_name(oop java_class);
 338   // Testing
 339   static bool is_instance(oop obj);
 340 
 341   static bool is_primitive(oop java_class);
 342   static BasicType primitive_type(oop java_class);
 343   static oop primitive_mirror(BasicType t);
 344   // JVM_NewArray support
 345   static Klass* array_klass_acquire(oop java_class);
 346   static void release_set_array_klass(oop java_class, Klass* klass);
 347   // compiler support for class operations
 348   static int klass_offset()                { CHECK_INIT(_klass_offset); }
 349   static int array_klass_offset()          { CHECK_INIT(_array_klass_offset); }
 350   // Support for classRedefinedCount field
 351   static int classRedefinedCount(oop the_class_mirror);
 352   static void set_classRedefinedCount(oop the_class_mirror, int value);
 353 
 354   // Support for embedded per-class oops
 355   static oop  protection_domain(oop java_class);
 356   static oop  init_lock(oop java_class);
 357   static void clear_init_lock(oop java_class) {
 358     set_init_lock(java_class, NULL);
 359   }
 360   static oop  component_mirror(oop java_class);
 361   static objArrayOop  signers(oop java_class);
 362   static void set_signers(oop java_class, objArrayOop signers);
 363   static oop  class_data(oop java_class);
 364   static void set_class_data(oop java_class, oop classData);
 365 
 366   static int component_mirror_offset() { return _component_mirror_offset; }
 367 
 368   static oop class_loader(oop java_class);
 369   static void set_module(oop java_class, oop module);
 370   static oop module(oop java_class);
 371 
 372   static oop name(Handle java_class, TRAPS);
 373 
 374   static oop source_file(oop java_class);
 375   static void set_source_file(oop java_class, oop source_file);
 376 
 377   static int oop_size(oop java_class);
 378   static void set_oop_size(HeapWord* java_class, int size);
 379   static int static_oop_field_count(oop java_class);
 380   static void set_static_oop_field_count(oop java_class, int size);
 381 
 382   static GrowableArray<Klass*>* fixup_mirror_list() {
 383     return _fixup_mirror_list;
 384   }
 385   static void set_fixup_mirror_list(GrowableArray<Klass*>* v) {
 386     _fixup_mirror_list = v;
 387   }
 388 
 389   static GrowableArray<Klass*>* fixup_module_field_list() {
 390     return _fixup_module_field_list;
 391   }
 392   static void set_fixup_module_field_list(GrowableArray<Klass*>* v) {
 393     _fixup_module_field_list = v;
 394   }
 395 
 396   // Debugging
 397   friend class JavaClasses;
 398 };
 399 
 400 // Interface to java.lang.Thread objects
 401 
 402 #define THREAD_INJECTED_FIELDS(macro)                            \
 403   macro(java_lang_Thread, jvmti_thread_state, intptr_signature, false)
 404 
 405 class java_lang_Thread : AllStatic {
 406   friend class java_lang_VirtualThread;
 407  private:
 408   // Note that for this class the layout changed between JDK1.2 and JDK1.3,
 409   // so we compute the offsets at startup rather than hard-wiring them.
 410   static int _holder_offset;
 411   static int _name_offset;
 412   static int _contextClassLoader_offset;
 413   static int _inheritedAccessControlContext_offset;
 414   static int _eetop_offset;
 415   static int _jvmti_thread_state_offset;
 416   static int _interrupted_offset;
 417   static int _tid_offset;
 418   static int _continuation_offset;
 419   static int _park_blocker_offset;
 420   static int _scopeLocalBindings_offset;
 421 
 422   static void compute_offsets();
 423 
 424  public:
 425   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 426 
 427   // Returns the JavaThread associated with the thread obj
 428   static JavaThread* thread(oop java_thread);
 429   // Set JavaThread for instance
 430   static void set_thread(oop java_thread, JavaThread* thread);
 431   // FieldHolder
 432   static oop holder(oop java_thread);
 433   // Interrupted status
 434   static bool interrupted(oop java_thread);
 435   static void set_interrupted(oop java_thread, bool val);
 436   // Name
 437   static oop name(oop java_thread);
 438   static void set_name(oop java_thread, oop name);
 439   // Priority
 440   static ThreadPriority priority(oop java_thread);
 441   static void set_priority(oop java_thread, ThreadPriority priority);
 442   // Thread group
 443   static oop  threadGroup(oop java_thread);
 444   // Stillborn
 445   static bool is_stillborn(oop java_thread);
 446   static void set_stillborn(oop java_thread);
 447   // Alive (NOTE: this is not really a field, but provides the correct
 448   // definition without doing a Java call)
 449   static bool is_alive(oop java_thread);
 450   // Daemon
 451   static bool is_daemon(oop java_thread);
 452   static void set_daemon(oop java_thread);
 453   // Context ClassLoader
 454   static oop context_class_loader(oop java_thread);
 455   // Control context
 456   static oop inherited_access_control_context(oop java_thread);
 457   // Stack size hint
 458   static jlong stackSize(oop java_thread);
 459   // Thread ID
 460   static jlong thread_id(oop java_thread);
 461   static ByteSize thread_id_offset();
 462   // Continuation
 463   static inline oop continuation(oop java_thread);
 464 
 465   static JvmtiThreadState* jvmti_thread_state(oop java_thread);
 466   static void set_jvmti_thread_state(oop java_thread, JvmtiThreadState* state);
 467 
 468   // Clear all scope local bindings on error
 469   static void clear_scopeLocalBindings(oop java_thread);
 470 
 471   // Blocker object responsible for thread parking
 472   static oop park_blocker(oop java_thread);
 473 
 474   // Write thread status info to threadStatus field of java.lang.Thread.
 475   static void set_thread_status(oop java_thread_oop, JavaThreadStatus status);
 476   // Read thread status info from threadStatus field of java.lang.Thread.
 477   static JavaThreadStatus get_thread_status(oop java_thread_oop);
 478 
 479   static const char*  thread_status_name(oop java_thread_oop);
 480 
 481   // Fill in current stack trace, can cause GC
 482   static oop async_get_stack_trace(oop java_thread, TRAPS);
 483 
 484   // Debugging
 485   friend class JavaClasses;
 486 };
 487 
 488 // Interface to java.lang.Thread$FieldHolder objects
 489 
 490 class java_lang_Thread_FieldHolder : AllStatic {
 491  private:
 492   static int _group_offset;
 493   static int _priority_offset;
 494   static int _stackSize_offset;
 495   static int _stillborn_offset;
 496   static int _daemon_offset;
 497   static int _thread_status_offset;
 498 
 499   static void compute_offsets();
 500  public:
 501   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 502 
 503   static oop threadGroup(oop holder);
 504 
 505   static ThreadPriority priority(oop holder);
 506   static void set_priority(oop holder, ThreadPriority priority);
 507 
 508   static jlong stackSize(oop holder);
 509 
 510   static bool is_stillborn(oop holder);
 511   static void set_stillborn(oop holder);
 512 
 513   static bool is_daemon(oop holder);
 514   static void set_daemon(oop holder);
 515 
 516   static void set_thread_status(oop holder, JavaThreadStatus);
 517   static JavaThreadStatus get_thread_status(oop holder);
 518 
 519   friend class JavaClasses;
 520 };
 521 
 522 // Interface to java.lang.Thread$VirtualThreads objects
 523 
 524 class java_lang_Thread_VirtualThreads : AllStatic {
 525  private:
 526   static int _static_THREAD_GROUP_offset;
 527 
 528   static void compute_offsets();
 529   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 530  public:
 531   static oop get_THREAD_GROUP();
 532 
 533   friend class JavaClasses;
 534 };
 535 
 536 
 537 // Interface to java.lang.Thread$ClassLoaders objects
 538 
 539 class java_lang_Thread_ClassLoaders : AllStatic {
 540  private:
 541   static int _static_NOT_SUPPORTED_offset;
 542 
 543   static void compute_offsets();
 544   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 545  public:
 546   static oop get_NOT_SUPPORTED();
 547 
 548   friend class JavaClasses;
 549 };
 550 
 551 
 552 // Interface to java.lang.ThreadGroup objects
 553 
 554 class java_lang_ThreadGroup : AllStatic {
 555  private:
 556   static int _parent_offset;
 557   static int _name_offset;
 558   static int _maxPriority_offset;
 559 
 560   static int _ngroups_offset;
 561   static int _groups_offset;
 562   static int _nweaks_offset;
 563   static int _weaks_offset;
 564 
 565   static void compute_offsets();
 566 
 567  public:
 568   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 569 
 570   // parent ThreadGroup
 571   static oop parent(oop java_thread_group);
 572   // name
 573   static const char* name(oop java_thread_group);
 574   // maxPriority in group
 575   static ThreadPriority maxPriority(oop java_thread_group);
 576 
 577   // Number of strongly reachable thread groups
 578   static int ngroups(oop java_thread_group);
 579   // Strongly reachable thread groups
 580   static objArrayOop groups(oop java_thread_group);
 581   // Number of weakly reachable thread groups
 582   static int nweaks(oop java_thread_group);
 583   // Weakly reachable thread groups
 584   static objArrayOop weaks(oop java_thread_group);
 585 
 586   // Debugging
 587   friend class JavaClasses;
 588 };
 589 
 590 
 591 // Interface to java.lang.VirtualThread objects
 592 
 593 class java_lang_VirtualThread : AllStatic {
 594  private:
 595   static int static_notify_jvmti_events_offset;
 596   static int static_vthread_scope_offset;
 597   static int _carrierThread_offset;
 598   static int _continuation_offset;
 599   static int _state_offset;
 600 
 601  public:
 602   enum {
 603     NEW          = 0,
 604     STARTED      = 1,
 605     RUNNABLE     = 2,
 606     RUNNING      = 3,
 607     PARKING      = 4,
 608     PARKED       = 5,
 609     PINNED       = 6,
 610     YIELDING     = 7,
 611     TERMINATED   = 99,
 612 
 613     // can be suspended from scheduling when parked
 614     SUSPENDED    = 1 << 8,
 615     PARKED_SUSPENDED = (PARKED | SUSPENDED)
 616   };
 617 
 618   static void compute_offsets();
 619   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 620 
 621   // Testers
 622   static bool is_subclass(Klass* klass) {
 623     return klass->is_subclass_of(vmClasses::VirtualThread_klass());
 624   }
 625   static bool is_instance(oop obj);
 626 
 627   static oop vthread_scope();
 628   static oop carrier_thread(oop vthread);
 629   static oop continuation(oop vthread);
 630   static jshort state(oop vthread);
 631   static JavaThreadStatus map_state_to_thread_status(jint state);
 632   static bool notify_jvmti_events();
 633   static void set_notify_jvmti_events(jboolean enable);
 634   static void init_static_notify_jvmti_events();
 635   static jlong set_jfrTraceId(oop vthread, jlong id);
 636 };
 637 
 638 
 639 // Interface to java.lang.Throwable objects
 640 
 641 class java_lang_Throwable: AllStatic {
 642   friend class BacktraceBuilder;
 643   friend class BacktraceIterator;
 644 
 645  private:
 646   // Trace constants
 647   enum {
 648     trace_methods_offset = 0,
 649     trace_bcis_offset    = 1,
 650     trace_mirrors_offset = 2,
 651     trace_names_offset   = 3,
 652     trace_conts_offset   = 4,
 653     trace_next_offset    = 5,
 654     trace_hidden_offset  = 6,
 655     trace_size           = 7,
 656     trace_chunk_size     = 32
 657   };
 658 
 659   static int _backtrace_offset;
 660   static int _detailMessage_offset;
 661   static int _stackTrace_offset;
 662   static int _depth_offset;
 663   static int _cause_offset;
 664   static int _static_unassigned_stacktrace_offset;
 665 
 666   // StackTrace (programmatic access, new since 1.4)
 667   static void clear_stacktrace(oop throwable);
 668   // Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed)
 669   static void set_stacktrace(oop throwable, oop st_element_array);
 670   static oop unassigned_stacktrace();
 671 
 672  public:
 673   // Backtrace
 674   static oop backtrace(oop throwable);
 675   static void set_backtrace(oop throwable, oop value);
 676   static int depth(oop throwable);
 677   static void set_depth(oop throwable, int value);
 678   static int get_detailMessage_offset() { CHECK_INIT(_detailMessage_offset); }
 679   // Message
 680   static oop message(oop throwable);
 681   static oop cause(oop throwable);
 682   static void set_message(oop throwable, oop value);
 683   static Symbol* detail_message(oop throwable);
 684   static void print_stack_element(outputStream *st, Method* method, int bci);
 685 
 686   static void compute_offsets();
 687   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 688 
 689   // Allocate space for backtrace (created but stack trace not filled in)
 690   static void allocate_backtrace(Handle throwable, TRAPS);
 691   // Fill in current stack trace for throwable with preallocated backtrace (no GC)
 692   static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
 693   // Fill in current stack trace, can cause GC
 694   static void fill_in_stack_trace(Handle throwable, const methodHandle& method, TRAPS);
 695   static void fill_in_stack_trace(Handle throwable, const methodHandle& method = methodHandle());
 696 
 697   // Programmatic access to stack trace
 698   static void get_stack_trace_elements(int depth, Handle backtrace, objArrayHandle stack_trace, TRAPS);
 699 
 700   // For recreating class initialization error exceptions.
 701   static Handle get_cause_with_stack_trace(Handle throwable, TRAPS);
 702 
 703   // Printing
 704   static void print(oop throwable, outputStream* st);
 705   static void print_stack_trace(Handle throwable, outputStream* st);
 706   static void java_printStackTrace(Handle throwable, TRAPS);
 707   // Debugging
 708   friend class JavaClasses;
 709   // Gets the method and bci of the top frame (TOS). Returns false if this failed.
 710   static bool get_top_method_and_bci(oop throwable, Method** method, int* bci);
 711 };
 712 
 713 
 714 // Interface to java.lang.reflect.AccessibleObject objects
 715 
 716 class java_lang_reflect_AccessibleObject: AllStatic {
 717  private:
 718   // Note that to reduce dependencies on the JDK we compute these
 719   // offsets at run-time.
 720   static int _override_offset;
 721 
 722   static void compute_offsets();
 723 
 724  public:
 725   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 726 
 727   // Accessors
 728   static jboolean override(oop reflect);
 729   static void set_override(oop reflect, jboolean value);
 730 
 731   // Debugging
 732   friend class JavaClasses;
 733 };
 734 
 735 
 736 // Interface to java.lang.reflect.Method objects
 737 
 738 class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject {
 739  private:
 740   // Note that to reduce dependencies on the JDK we compute these
 741   // offsets at run-time.
 742   static int _clazz_offset;
 743   static int _name_offset;
 744   static int _returnType_offset;
 745   static int _parameterTypes_offset;
 746   static int _exceptionTypes_offset;
 747   static int _slot_offset;
 748   static int _modifiers_offset;
 749   static int _signature_offset;
 750   static int _annotations_offset;
 751   static int _parameter_annotations_offset;
 752   static int _annotation_default_offset;
 753 
 754   static void compute_offsets();
 755  public:
 756   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 757 
 758   // Allocation
 759   static Handle create(TRAPS);
 760 
 761   // Accessors
 762   static oop clazz(oop reflect);
 763   static void set_clazz(oop reflect, oop value);
 764 
 765   static void set_name(oop method, oop value);
 766 
 767   static oop return_type(oop method);
 768   static void set_return_type(oop method, oop value);
 769 
 770   static oop parameter_types(oop method);
 771   static void set_parameter_types(oop method, oop value);
 772 
 773   static int slot(oop reflect);
 774   static void set_slot(oop reflect, int value);
 775 
 776   static void set_exception_types(oop method, oop value);
 777   static void set_modifiers(oop method, int value);
 778   static void set_signature(oop method, oop value);
 779   static void set_annotations(oop method, oop value);
 780   static void set_parameter_annotations(oop method, oop value);
 781   static void set_annotation_default(oop method, oop value);
 782 
 783   // Debugging
 784   friend class JavaClasses;
 785 };
 786 
 787 
 788 // Interface to java.lang.reflect.Constructor objects
 789 
 790 class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject {
 791  private:
 792   // Note that to reduce dependencies on the JDK we compute these
 793   // offsets at run-time.
 794   static int _clazz_offset;
 795   static int _parameterTypes_offset;
 796   static int _exceptionTypes_offset;
 797   static int _slot_offset;
 798   static int _modifiers_offset;
 799   static int _signature_offset;
 800   static int _annotations_offset;
 801   static int _parameter_annotations_offset;
 802 
 803   static void compute_offsets();
 804  public:
 805   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 806 
 807   // Allocation
 808   static Handle create(TRAPS);
 809 
 810   // Accessors
 811   static oop clazz(oop reflect);
 812   static void set_clazz(oop reflect, oop value);
 813 
 814   static oop parameter_types(oop constructor);
 815   static void set_parameter_types(oop constructor, oop value);
 816 
 817   static int slot(oop reflect);
 818   static void set_slot(oop reflect, int value);
 819 
 820   static void set_exception_types(oop constructor, oop value);
 821   static void set_modifiers(oop constructor, int value);
 822   static void set_signature(oop constructor, oop value);
 823   static void set_annotations(oop constructor, oop value);
 824   static void set_parameter_annotations(oop method, oop value);
 825 
 826   // Debugging
 827   friend class JavaClasses;
 828 };
 829 
 830 
 831 // Interface to java.lang.reflect.Field objects
 832 
 833 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
 834  private:
 835   // Note that to reduce dependencies on the JDK we compute these
 836   // offsets at run-time.
 837   static int _clazz_offset;
 838   static int _name_offset;
 839   static int _type_offset;
 840   static int _slot_offset;
 841   static int _modifiers_offset;
 842   static int _trusted_final_offset;
 843   static int _signature_offset;
 844   static int _annotations_offset;
 845 
 846   static void compute_offsets();
 847 
 848  public:
 849   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 850 
 851   // Allocation
 852   static Handle create(TRAPS);
 853 
 854   // Accessors
 855   static oop clazz(oop reflect);
 856   static void set_clazz(oop reflect, oop value);
 857 
 858   static oop name(oop field);
 859   static void set_name(oop field, oop value);
 860 
 861   static oop type(oop field);
 862   static void set_type(oop field, oop value);
 863 
 864   static int slot(oop reflect);
 865   static void set_slot(oop reflect, int value);
 866 
 867   static int modifiers(oop field);
 868   static void set_modifiers(oop field, int value);
 869 
 870   static void set_trusted_final(oop field);
 871 
 872   static void set_signature(oop constructor, oop value);
 873   static void set_annotations(oop constructor, oop value);
 874 
 875   // Debugging
 876   friend class JavaClasses;
 877 };
 878 
 879 class java_lang_reflect_Parameter {
 880  private:
 881   // Note that to reduce dependencies on the JDK we compute these
 882   // offsets at run-time.
 883   static int _name_offset;
 884   static int _modifiers_offset;
 885   static int _index_offset;
 886   static int _executable_offset;
 887 
 888   static void compute_offsets();
 889 
 890  public:
 891   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 892 
 893   // Allocation
 894   static Handle create(TRAPS);
 895 
 896   // Accessors
 897   static oop name(oop field);
 898   static void set_name(oop field, oop value);
 899 
 900   static int index(oop reflect);
 901   static void set_index(oop reflect, int value);
 902 
 903   static int modifiers(oop reflect);
 904   static void set_modifiers(oop reflect, int value);
 905 
 906   static oop executable(oop constructor);
 907   static void set_executable(oop constructor, oop value);
 908 
 909   friend class JavaClasses;
 910 };
 911 
 912 #define MODULE_INJECTED_FIELDS(macro)                            \
 913   macro(java_lang_Module, module_entry, intptr_signature, false)
 914 
 915 class java_lang_Module {
 916   private:
 917     static int _loader_offset;
 918     static int _name_offset;
 919     static int _module_entry_offset;
 920 
 921     static void compute_offsets();
 922 
 923   public:
 924     static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 925 
 926     // Allocation
 927     static Handle create(Handle loader, Handle module_name, TRAPS);
 928 
 929     // Testers
 930     static bool is_instance(oop obj);
 931 
 932     // Accessors
 933     static oop loader(oop module);
 934     static void set_loader(oop module, oop value);
 935 
 936     static oop name(oop module);
 937     static void set_name(oop module, oop value);
 938 
 939     static ModuleEntry* module_entry(oop module);
 940     static ModuleEntry* module_entry_raw(oop module);
 941     static void set_module_entry(oop module, ModuleEntry* module_entry);
 942 
 943   friend class JavaClasses;
 944 };
 945 
 946 // Interface to jdk.internal.reflect.ConstantPool objects
 947 class reflect_ConstantPool {
 948  private:
 949   // Note that to reduce dependencies on the JDK we compute these
 950   // offsets at run-time.
 951   static int _oop_offset;
 952 
 953   static void compute_offsets();
 954 
 955  public:
 956   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 957 
 958   // Allocation
 959   static Handle create(TRAPS);
 960 
 961   // Accessors
 962   static void set_cp(oop reflect, ConstantPool* value);
 963   static int oop_offset() { CHECK_INIT(_oop_offset); }
 964 
 965   static ConstantPool* get_cp(oop reflect);
 966 
 967   // Debugging
 968   friend class JavaClasses;
 969 };
 970 
 971 // Interface to jdk.internal.reflect.UnsafeStaticFieldAccessorImpl objects
 972 class reflect_UnsafeStaticFieldAccessorImpl {
 973  private:
 974   static int _base_offset;
 975   static void compute_offsets();
 976 
 977  public:
 978   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 979 
 980   static int base_offset() { CHECK_INIT(_base_offset); }
 981 
 982   // Debugging
 983   friend class JavaClasses;
 984 };
 985 
 986 // Interface to java.lang primitive type boxing objects:
 987 //  - java.lang.Boolean
 988 //  - java.lang.Character
 989 //  - java.lang.Float
 990 //  - java.lang.Double
 991 //  - java.lang.Byte
 992 //  - java.lang.Short
 993 //  - java.lang.Integer
 994 //  - java.lang.Long
 995 
 996 // This could be separated out into 8 individual classes.
 997 
 998 class java_lang_boxing_object: AllStatic {
 999  private:
1000   static int _value_offset;
1001   static int _long_value_offset;
1002 
1003   static void compute_offsets();
1004   static oop initialize_and_allocate(BasicType type, TRAPS);
1005  public:
1006   // Allocation. Returns a boxed value, or NULL for invalid type.
1007   static oop create(BasicType type, jvalue* value, TRAPS);
1008   // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
1009   static BasicType get_value(oop box, jvalue* value);
1010   static BasicType set_value(oop box, jvalue* value);
1011   static BasicType basic_type(oop box);
1012   static bool is_instance(oop box)                 { return basic_type(box) != T_ILLEGAL; }
1013   static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
1014   static void print(oop box, outputStream* st)     { jvalue value;  print(get_value(box, &value), &value, st); }
1015   static void print(BasicType type, jvalue* value, outputStream* st);
1016 
1017   static int value_offset(BasicType type) {
1018     return is_double_word_type(type) ? _long_value_offset : _value_offset;
1019   }
1020 
1021   static void serialize_offsets(SerializeClosure* f);
1022 
1023   // Debugging
1024   friend class JavaClasses;
1025 };
1026 
1027 
1028 
1029 // Interface to java.lang.ref.Reference objects
1030 
1031 class java_lang_ref_Reference: AllStatic {
1032   static int _referent_offset;
1033   static int _queue_offset;
1034   static int _next_offset;
1035   static int _discovered_offset;
1036 
1037   static bool _offsets_initialized;
1038 
1039  public:
1040   // Accessors
1041   static inline oop weak_referent_no_keepalive(oop ref);
1042   static inline oop phantom_referent_no_keepalive(oop ref);
1043   static inline oop unknown_referent_no_keepalive(oop ref);
1044   static inline oop unknown_referent(oop ref);
1045   static inline void clear_referent(oop ref);
1046   static inline HeapWord* referent_addr_raw(oop ref);
1047   static inline oop next(oop ref);
1048   static inline void set_next(oop ref, oop value);
1049   static inline void set_next_raw(oop ref, oop value);
1050   static inline HeapWord* next_addr_raw(oop ref);
1051   static inline oop discovered(oop ref);
1052   static inline void set_discovered(oop ref, oop value);
1053   static inline void set_discovered_raw(oop ref, oop value);
1054   static inline HeapWord* discovered_addr_raw(oop ref);
1055   static bool is_referent_field(oop obj, ptrdiff_t offset);
1056   static inline bool is_final(oop ref);
1057   static inline bool is_phantom(oop ref);
1058 
1059   static int referent_offset()    { CHECK_INIT(_referent_offset); }
1060   static int queue_offset()       { CHECK_INIT(_queue_offset); }
1061   static int next_offset()        { CHECK_INIT(_next_offset); }
1062   static int discovered_offset()  { CHECK_INIT(_discovered_offset); }
1063 
1064   static void compute_offsets();
1065   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1066 };
1067 
1068 
1069 // Interface to java.lang.ref.SoftReference objects
1070 
1071 class java_lang_ref_SoftReference: public java_lang_ref_Reference {
1072   static int _timestamp_offset;
1073   static int _static_clock_offset;
1074 
1075  public:
1076   // Accessors
1077   static jlong timestamp(oop ref);
1078 
1079   // Accessors for statics
1080   static jlong clock();
1081   static void set_clock(jlong value);
1082 
1083   static void compute_offsets();
1084   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1085 };
1086 
1087 // Interface to jdk.internal.vm.ContinuationScope objects
1088 class jdk_internal_vm_ContinuationScope: AllStatic {
1089   friend class JavaClasses;
1090  private:
1091   static int _name_offset;
1092 
1093   static void compute_offsets();
1094  public:
1095   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1096 
1097   static inline oop name(oop ref);
1098 };
1099 
1100 // Interface to jdk.internal.vm.Continuation objects
1101 class jdk_internal_vm_Continuation: AllStatic {
1102   friend class JavaClasses;
1103  private:
1104   static int _scope_offset;
1105   static int _target_offset;
1106   static int _parent_offset;
1107   static int _yieldInfo_offset;
1108   static int _tail_offset;
1109   static int _cs_offset;
1110   static int _reset_offset;
1111   static int _mounted_offset;
1112   static int _done_offset;
1113   static int _preempted_offset;
1114 
1115   static void compute_offsets();
1116  public:
1117   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1118   // Accessors
1119   static inline oop scope(oop ref);
1120   static inline oop target(oop ref);
1121   static inline oop parent(oop ref);
1122   static inline oop yieldInfo(oop ref);
1123   static inline void set_yieldInfo(oop ref, oop value);
1124   static inline stackChunkOop tail(oop ref);
1125   static inline void set_tail(oop ref, stackChunkOop value);
1126   static inline jshort critical_section(oop ref);
1127   static inline void set_critical_section(oop ref, jshort value);
1128   static inline bool on_local_stack(oop ref, address adr);
1129   static inline bool is_reset(oop ref);
1130   static inline bool is_mounted(oop ref);
1131   static inline bool done(oop ref);
1132   static inline bool is_preempted(oop ref);
1133   static inline void set_preempted(oop ref, bool value);
1134 };
1135 
1136 // Interface to jdk.internal.vm.StackChunk objects
1137 class jdk_internal_vm_StackChunk: AllStatic {
1138   friend class JavaClasses;
1139  private:
1140   static int _parent_offset;
1141   static int _size_offset;
1142   static int _sp_offset;
1143   static int _pc_offset;
1144   static int _argsize_offset;
1145   static int _flags_offset;
1146   static int _gcSP_offset;
1147   static int _markCycle_offset;
1148   static int _maxSize_offset;
1149   static int _numFrames_offset;
1150   static int _numOops_offset;
1151   static int _cont_offset;
1152 
1153   static void compute_offsets();
1154  public:
1155   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1156 
1157   static inline int parent_offset() { return _parent_offset; }
1158   static inline int cont_offset()   { return _cont_offset; }
1159 
1160   // Accessors
1161   static inline oop parent(oop ref);
1162   static inline void set_parent(oop ref, oop value);
1163   template<typename P>
1164   static inline bool is_parent_null(oop ref); // bypasses barriers for a faster test
1165   template<typename P>
1166   static inline void set_parent_raw(oop ref, oop value);
1167   static inline jint size(oop ref);
1168   static inline void set_size(HeapWord* ref, jint value);
1169   static inline jint sp(oop ref);
1170   static inline void set_sp(oop ref, jint value);
1171   static inline jlong pc(oop ref);
1172   static inline void set_pc(oop ref, jlong value);
1173   static inline jint argsize(oop ref);
1174   static inline void set_argsize(oop ref, jint value);
1175   static inline jbyte flags(oop ref);
1176   static inline void set_flags(oop ref, jbyte value);
1177   static inline jint gc_sp(oop ref);
1178   static inline void set_gc_sp(oop ref, jint value);
1179   static inline jlong mark_cycle(oop ref);
1180   static inline void set_mark_cycle(oop ref, jlong value);
1181   static inline jint maxSize(oop ref);
1182   static inline void set_maxSize(oop ref, jint value);
1183   static inline jint numFrames(oop ref);
1184   static inline void set_numFrames(oop ref, jint value);
1185   static inline jint numOops(oop ref);
1186   static inline void set_numOops(oop ref, jint value);
1187   static inline oop cont(oop ref);
1188   static inline void set_cont(oop ref, oop value);
1189   template<typename P>
1190   static inline oop cont_raw(oop ref);
1191   template<typename P>
1192   static inline void set_cont_raw(oop ref, oop value);
1193 };
1194 
1195 // Interface to java.lang.invoke.MethodHandle objects
1196 
1197 class java_lang_invoke_MethodHandle: AllStatic {
1198   friend class JavaClasses;
1199 
1200  private:
1201   static int _type_offset;               // the MethodType of this MH
1202   static int _form_offset;               // the LambdaForm of this MH
1203 
1204   static void compute_offsets();
1205 
1206  public:
1207   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1208 
1209   // Accessors
1210   static oop            type(oop mh);
1211   static void       set_type(oop mh, oop mtype);
1212 
1213   static oop            form(oop mh);
1214   static void       set_form(oop mh, oop lform);
1215 
1216   // Testers
1217   static bool is_subclass(Klass* klass) {
1218     return klass->is_subclass_of(vmClasses::MethodHandle_klass());
1219   }
1220   static bool is_instance(oop obj);
1221 
1222   // Accessors for code generation:
1223   static int type_offset()             { CHECK_INIT(_type_offset); }
1224   static int form_offset()             { CHECK_INIT(_form_offset); }
1225 };
1226 
1227 // Interface to java.lang.invoke.DirectMethodHandle objects
1228 
1229 class java_lang_invoke_DirectMethodHandle: AllStatic {
1230   friend class JavaClasses;
1231 
1232  private:
1233   static int _member_offset;               // the MemberName of this DMH
1234 
1235   static void compute_offsets();
1236 
1237  public:
1238   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1239 
1240   // Accessors
1241   static oop  member(oop mh);
1242 
1243   // Testers
1244   static bool is_subclass(Klass* klass) {
1245     return klass->is_subclass_of(vmClasses::DirectMethodHandle_klass());
1246   }
1247   static bool is_instance(oop obj);
1248 
1249   // Accessors for code generation:
1250   static int member_offset()           { CHECK_INIT(_member_offset); }
1251 };
1252 
1253 // Interface to java.lang.invoke.LambdaForm objects
1254 // (These are a private interface for managing adapter code generation.)
1255 
1256 class java_lang_invoke_LambdaForm: AllStatic {
1257   friend class JavaClasses;
1258 
1259  private:
1260   static int _vmentry_offset;  // type is MemberName
1261 
1262   static void compute_offsets();
1263 
1264  public:
1265   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1266 
1267   // Accessors
1268   static oop            vmentry(oop lform);
1269 
1270   // Testers
1271   static bool is_subclass(Klass* klass) {
1272     return vmClasses::LambdaForm_klass() != NULL &&
1273       klass->is_subclass_of(vmClasses::LambdaForm_klass());
1274   }
1275   static bool is_instance(oop obj);
1276 
1277   // Accessors for code generation:
1278   static int vmentry_offset()          { CHECK_INIT(_vmentry_offset); }
1279 };
1280 
1281 // Interface to java.lang.invoke.NativeEntryPoint objects
1282 // (These are a private interface for managing adapter code generation.)
1283 
1284 class jdk_internal_invoke_NativeEntryPoint: AllStatic {
1285   friend class JavaClasses;
1286 
1287  private:
1288   static int _shadow_space_offset;
1289   static int _argMoves_offset;
1290   static int _returnMoves_offset;
1291   static int _need_transition_offset;
1292   static int _method_type_offset;
1293   static int _name_offset;
1294 
1295   static void compute_offsets();
1296 
1297  public:
1298   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1299 
1300   // Accessors
1301   static jint       shadow_space(oop entry);
1302   static oop        argMoves(oop entry);
1303   static oop        returnMoves(oop entry);
1304   static jboolean   need_transition(oop entry);
1305   static oop        method_type(oop entry);
1306   static oop        name(oop entry);
1307 
1308   // Testers
1309   static bool is_subclass(Klass* klass) {
1310     return vmClasses::NativeEntryPoint_klass() != NULL &&
1311       klass->is_subclass_of(vmClasses::NativeEntryPoint_klass());
1312   }
1313   static bool is_instance(oop obj);
1314 
1315   // Accessors for code generation:
1316   static int shadow_space_offset_in_bytes()    { return _shadow_space_offset;    }
1317   static int argMoves_offset_in_bytes()        { return _argMoves_offset;        }
1318   static int returnMoves_offset_in_bytes()     { return _returnMoves_offset;     }
1319   static int need_transition_offset_in_bytes() { return _need_transition_offset; }
1320   static int method_type_offset_in_bytes()     { return _method_type_offset;     }
1321   static int name_offset_in_bytes()            { return _name_offset;            }
1322 };
1323 
1324 // Interface to java.lang.invoke.MemberName objects
1325 // (These are a private interface for Java code to query the class hierarchy.)
1326 
1327 #define RESOLVEDMETHOD_INJECTED_FIELDS(macro)                                   \
1328   macro(java_lang_invoke_ResolvedMethodName, vmholder, object_signature, false) \
1329   macro(java_lang_invoke_ResolvedMethodName, vmtarget, intptr_signature, false)
1330 
1331 class java_lang_invoke_ResolvedMethodName : AllStatic {
1332   friend class JavaClasses;
1333 
1334   static int _vmtarget_offset;
1335   static int _vmholder_offset;
1336 
1337   static void compute_offsets();
1338  public:
1339   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1340 
1341   static int vmtarget_offset() { CHECK_INIT(_vmtarget_offset); }
1342 
1343   static Method* vmtarget(oop resolved_method);
1344   static void set_vmtarget(oop resolved_method, Method* method);
1345 
1346   static void set_vmholder(oop resolved_method, oop holder);
1347 
1348   // find or create resolved member name
1349   static oop find_resolved_method(const methodHandle& m, TRAPS);
1350 
1351   static bool is_instance(oop resolved_method);
1352 };
1353 
1354 
1355 #define MEMBERNAME_INJECTED_FIELDS(macro)                               \
1356   macro(java_lang_invoke_MemberName, vmindex,  intptr_signature, false)
1357 
1358 
1359 class java_lang_invoke_MemberName: AllStatic {
1360   friend class JavaClasses;
1361 
1362  private:
1363   // From java.lang.invoke.MemberName:
1364   //    private Class<?>   clazz;       // class in which the method is defined
1365   //    private String     name;        // may be null if not yet materialized
1366   //    private Object     type;        // may be null if not yet materialized
1367   //    private int        flags;       // modifier bits; see reflect.Modifier
1368   //    private ResolvedMethodName method;    // holds VM-specific target value
1369   //    private intptr_t   vmindex;     // member index within class or interface
1370   static int _clazz_offset;
1371   static int _name_offset;
1372   static int _type_offset;
1373   static int _flags_offset;
1374   static int _method_offset;
1375   static int _vmindex_offset;
1376 
1377   static void compute_offsets();
1378 
1379  public:
1380   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1381   // Accessors
1382   static oop            clazz(oop mname);
1383   static void       set_clazz(oop mname, oop clazz);
1384 
1385   static oop            type(oop mname);
1386   static void       set_type(oop mname, oop type);
1387 
1388   static oop            name(oop mname);
1389   static void       set_name(oop mname, oop name);
1390 
1391   static int            flags(oop mname);
1392   static void       set_flags(oop mname, int flags);
1393 
1394   // Link through ResolvedMethodName field to get Method*
1395   static Method*        vmtarget(oop mname);
1396   static void       set_method(oop mname, oop method);
1397 
1398   static intptr_t       vmindex(oop mname);
1399   static void       set_vmindex(oop mname, intptr_t index);
1400 
1401   // Testers
1402   static bool is_subclass(Klass* klass) {
1403     return klass->is_subclass_of(vmClasses::MemberName_klass());
1404   }
1405   static bool is_instance(oop obj);
1406 
1407   static bool is_method(oop obj);
1408 
1409   // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
1410   enum {
1411     MN_IS_METHOD             = 0x00010000, // method (not constructor)
1412     MN_IS_CONSTRUCTOR        = 0x00020000, // constructor
1413     MN_IS_FIELD              = 0x00040000, // field
1414     MN_IS_TYPE               = 0x00080000, // nested type
1415     MN_CALLER_SENSITIVE      = 0x00100000, // @CallerSensitive annotation detected
1416     MN_TRUSTED_FINAL         = 0x00200000, // trusted final field
1417     MN_REFERENCE_KIND_SHIFT  = 24, // refKind
1418     MN_REFERENCE_KIND_MASK   = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT,
1419     // The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers:
1420     MN_SEARCH_SUPERCLASSES   = 0x00100000, // walk super classes
1421     MN_SEARCH_INTERFACES     = 0x00200000, // walk implemented interfaces
1422     MN_NESTMATE_CLASS        = 0x00000001,
1423     MN_HIDDEN_CLASS          = 0x00000002,
1424     MN_STRONG_LOADER_LINK    = 0x00000004,
1425     MN_ACCESS_VM_ANNOTATIONS = 0x00000008,
1426     // Lookup modes
1427     MN_MODULE_MODE           = 0x00000010,
1428     MN_UNCONDITIONAL_MODE    = 0x00000020,
1429     MN_TRUSTED_MODE          = -1
1430   };
1431 
1432   // Accessors for code generation:
1433   static int clazz_offset()   { CHECK_INIT(_clazz_offset); }
1434   static int type_offset()    { CHECK_INIT(_type_offset); }
1435   static int flags_offset()   { CHECK_INIT(_flags_offset); }
1436   static int method_offset()  { CHECK_INIT(_method_offset); }
1437   static int vmindex_offset() { CHECK_INIT(_vmindex_offset); }
1438 };
1439 
1440 
1441 // Interface to java.lang.invoke.MethodType objects
1442 
1443 class java_lang_invoke_MethodType: AllStatic {
1444   friend class JavaClasses;
1445 
1446  private:
1447   static int _rtype_offset;
1448   static int _ptypes_offset;
1449 
1450   static void compute_offsets();
1451 
1452  public:
1453   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1454   // Accessors
1455   static oop            rtype(oop mt);
1456   static objArrayOop    ptypes(oop mt);
1457 
1458   static oop            ptype(oop mt, int index);
1459   static int            ptype_count(oop mt);
1460 
1461   static int            ptype_slot_count(oop mt);  // extra counts for long/double
1462   static int            rtype_slot_count(oop mt);  // extra counts for long/double
1463 
1464   static Symbol*        as_signature(oop mt, bool intern_if_not_found);
1465   static void           print_signature(oop mt, outputStream* st);
1466 
1467   static bool is_instance(oop obj);
1468 
1469   static bool equals(oop mt1, oop mt2);
1470 
1471   // Accessors for code generation:
1472   static int rtype_offset()  { CHECK_INIT(_rtype_offset); }
1473   static int ptypes_offset() { CHECK_INIT(_ptypes_offset); }
1474 };
1475 
1476 
1477 // Interface to java.lang.invoke.CallSite objects
1478 
1479 class java_lang_invoke_CallSite: AllStatic {
1480   friend class JavaClasses;
1481 
1482 private:
1483   static int _target_offset;
1484   static int _context_offset;
1485 
1486   static void compute_offsets();
1487 
1488 public:
1489   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1490   // Accessors
1491   static oop              target(          oop site);
1492   static void         set_target(          oop site, oop target);
1493   static void         set_target_volatile( oop site, oop target);
1494 
1495   static oop context_no_keepalive(oop site);
1496 
1497   // Testers
1498   static bool is_subclass(Klass* klass) {
1499     return klass->is_subclass_of(vmClasses::CallSite_klass());
1500   }
1501   static bool is_instance(oop obj);
1502 
1503   // Accessors for code generation:
1504   static int target_offset()  { CHECK_INIT(_target_offset); }
1505   static int context_offset() { CHECK_INIT(_context_offset); }
1506 };
1507 
1508 // Interface to java.lang.invoke.ConstantCallSite objects
1509 
1510 class java_lang_invoke_ConstantCallSite: AllStatic {
1511   friend class JavaClasses;
1512 
1513 private:
1514   static int _is_frozen_offset;
1515 
1516   static void compute_offsets();
1517 
1518 public:
1519   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1520   // Accessors
1521   static jboolean is_frozen(oop site);
1522 
1523   // Testers
1524   static bool is_subclass(Klass* klass) {
1525     return klass->is_subclass_of(vmClasses::ConstantCallSite_klass());
1526   }
1527   static bool is_instance(oop obj);
1528 };
1529 
1530 // Interface to java.lang.invoke.MethodHandleNatives$CallSiteContext objects
1531 
1532 #define CALLSITECONTEXT_INJECTED_FIELDS(macro) \
1533   macro(java_lang_invoke_MethodHandleNatives_CallSiteContext, vmdependencies, intptr_signature, false) \
1534   macro(java_lang_invoke_MethodHandleNatives_CallSiteContext, last_cleanup, long_signature, false)
1535 
1536 class DependencyContext;
1537 
1538 class java_lang_invoke_MethodHandleNatives_CallSiteContext : AllStatic {
1539   friend class JavaClasses;
1540 
1541 private:
1542   static int _vmdependencies_offset;
1543   static int _last_cleanup_offset;
1544 
1545   static void compute_offsets();
1546 
1547 public:
1548   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1549   // Accessors
1550   static DependencyContext vmdependencies(oop context);
1551 
1552   // Testers
1553   static bool is_subclass(Klass* klass) {
1554     return klass->is_subclass_of(vmClasses::Context_klass());
1555   }
1556   static bool is_instance(oop obj);
1557 };
1558 
1559 // Interface to java.security.AccessControlContext objects
1560 
1561 class java_security_AccessControlContext: AllStatic {
1562  private:
1563   // Note that for this class the layout changed between JDK1.2 and JDK1.3,
1564   // so we compute the offsets at startup rather than hard-wiring them.
1565   static int _context_offset;
1566   static int _privilegedContext_offset;
1567   static int _isPrivileged_offset;
1568   static int _isAuthorized_offset;
1569 
1570   static void compute_offsets();
1571  public:
1572   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1573   static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS);
1574 
1575   // Debugging/initialization
1576   friend class JavaClasses;
1577 };
1578 
1579 
1580 // Interface to java.lang.ClassLoader objects
1581 
1582 #define CLASSLOADER_INJECTED_FIELDS(macro)                            \
1583   macro(java_lang_ClassLoader, loader_data,  intptr_signature, false)
1584 
1585 class java_lang_ClassLoader : AllStatic {
1586  private:
1587   static int _loader_data_offset;
1588   static int _parent_offset;
1589   static int _parallelCapable_offset;
1590   static int _name_offset;
1591   static int _nameAndId_offset;
1592   static int _unnamedModule_offset;
1593 
1594   static void compute_offsets();
1595 
1596  public:
1597   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1598 
1599   static ClassLoaderData* loader_data_acquire(oop loader);
1600   static ClassLoaderData* loader_data(oop loader);
1601   static void release_set_loader_data(oop loader, ClassLoaderData* new_data);
1602 
1603   static oop parent(oop loader);
1604   static oop name(oop loader);
1605   static oop nameAndId(oop loader);
1606   static bool isAncestor(oop loader, oop cl);
1607 
1608   // Support for parallelCapable field
1609   static bool parallelCapable(oop the_class_mirror);
1610 
1611   static bool is_trusted_loader(oop loader);
1612 
1613   // Return true if this is one of the class loaders associated with
1614   // the generated bytecodes for reflection.
1615   static bool is_reflection_class_loader(oop loader);
1616 
1617   // Fix for 4474172
1618   static oop  non_reflection_class_loader(oop loader);
1619 
1620   // Testers
1621   static bool is_subclass(Klass* klass) {
1622     return klass->is_subclass_of(vmClasses::ClassLoader_klass());
1623   }
1624   static bool is_instance(oop obj);
1625 
1626   static oop unnamedModule(oop loader);
1627 
1628   // Debugging
1629   friend class JavaClasses;
1630 };
1631 
1632 
1633 // Interface to java.lang.System objects
1634 
1635 class java_lang_System : AllStatic {
1636  private:
1637   static int _static_in_offset;
1638   static int _static_out_offset;
1639   static int _static_err_offset;
1640   static int _static_security_offset;
1641   static int _static_allow_security_offset;
1642   static int _static_never_offset;
1643 
1644  public:
1645   static int  in_offset() { CHECK_INIT(_static_in_offset); }
1646   static int out_offset() { CHECK_INIT(_static_out_offset); }
1647   static int err_offset() { CHECK_INIT(_static_err_offset); }
1648   static bool allow_security_manager();
1649   static bool has_security_manager();
1650 
1651   static void compute_offsets();
1652   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1653 
1654   // Debugging
1655   friend class JavaClasses;
1656 };
1657 
1658 
1659 // Interface to java.lang.StackTraceElement objects
1660 
1661 class java_lang_StackTraceElement: AllStatic {
1662  private:
1663   static int _declaringClassObject_offset;
1664   static int _classLoaderName_offset;
1665   static int _moduleName_offset;
1666   static int _moduleVersion_offset;
1667   static int _declaringClass_offset;
1668   static int _methodName_offset;
1669   static int _fileName_offset;
1670   static int _lineNumber_offset;
1671   static int _contScopeName_offset;
1672 
1673   // Setters
1674   static void set_classLoaderName(oop element, oop value);
1675   static void set_moduleName(oop element, oop value);
1676   static void set_moduleVersion(oop element, oop value);
1677   static void set_declaringClass(oop element, oop value);
1678   static void set_methodName(oop element, oop value);
1679   static void set_fileName(oop element, oop value);
1680   static void set_lineNumber(oop element, int value);
1681   static void set_declaringClassObject(oop element, oop value);
1682   static void set_contScopeName(oop element, oop value);
1683 
1684   static void decode_file_and_line(Handle java_mirror, InstanceKlass* holder, int version,
1685                                    const methodHandle& method, int bci,
1686                                    Symbol*& source, oop& source_file, int& line_number, TRAPS);
1687 
1688  public:
1689   // Create an instance of StackTraceElement
1690   static oop create(const methodHandle& method, int bci, Handle contScopeName, TRAPS);
1691 
1692   static void fill_in(Handle element, InstanceKlass* holder, const methodHandle& method,
1693                       int version, int bci, Symbol* name, Handle contScopeName, TRAPS);
1694 
1695   static void compute_offsets();
1696   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1697 
1698 #if INCLUDE_JVMCI
1699   static void decode(const methodHandle& method, int bci, Symbol*& fileName, int& lineNumber, TRAPS);
1700 #endif
1701 
1702   // Debugging
1703   friend class JavaClasses;
1704 };
1705 
1706 
1707 class Backtrace: AllStatic {
1708  public:
1709   // Helper backtrace functions to store bci|version together.
1710   static int merge_bci_and_version(int bci, int version);
1711   static int merge_mid_and_cpref(int mid, int cpref);
1712   static int bci_at(unsigned int merged);
1713   static int version_at(unsigned int merged);
1714   static int mid_at(unsigned int merged);
1715   static int cpref_at(unsigned int merged);
1716   static int get_line_number(Method* method, int bci);
1717   static Symbol* get_source_file_name(InstanceKlass* holder, int version);
1718 
1719   // Debugging
1720   friend class JavaClasses;
1721 };
1722 
1723 // Interface to java.lang.StackFrameInfo objects
1724 
1725 #define STACKFRAMEINFO_INJECTED_FIELDS(macro)                      \
1726   macro(java_lang_StackFrameInfo, version, short_signature, false)
1727 
1728 class java_lang_StackFrameInfo: AllStatic {
1729 private:
1730   static int _memberName_offset;
1731   static int _bci_offset;
1732   static int _version_offset;
1733   static int _contScope_offset;
1734 
1735   static Method* get_method(Handle stackFrame, InstanceKlass* holder, TRAPS);
1736 
1737 public:
1738   // Setters
1739   static void set_method_and_bci(Handle stackFrame, const methodHandle& method, int bci, oop cont, TRAPS);
1740   static void set_bci(oop info, int value);
1741 
1742   static void set_version(oop info, short value);
1743   static void set_contScope(oop info, oop value);
1744 
1745   static void compute_offsets();
1746   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1747 
1748   static void to_stack_trace_element(Handle stackFrame, Handle stack_trace_element, TRAPS);
1749 
1750   // Debugging
1751   friend class JavaClasses;
1752 };
1753 
1754 class java_lang_LiveStackFrameInfo: AllStatic {
1755  private:
1756   static int _monitors_offset;
1757   static int _locals_offset;
1758   static int _operands_offset;
1759   static int _mode_offset;
1760 
1761  public:
1762   static void set_monitors(oop info, oop value);
1763   static void set_locals(oop info, oop value);
1764   static void set_operands(oop info, oop value);
1765   static void set_mode(oop info, int value);
1766 
1767   static void compute_offsets();
1768   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1769 
1770   // Debugging
1771   friend class JavaClasses;
1772 };
1773 
1774 // Interface to java.lang.reflect.RecordComponent objects
1775 
1776 class java_lang_reflect_RecordComponent: AllStatic {
1777  private:
1778   static int _clazz_offset;
1779   static int _name_offset;
1780   static int _type_offset;
1781   static int _accessor_offset;
1782   static int _signature_offset;
1783   static int _annotations_offset;
1784   static int _typeAnnotations_offset;
1785 
1786   // Setters
1787   static void set_clazz(oop element, oop value);
1788   static void set_name(oop element, oop value);
1789   static void set_type(oop element, oop value);
1790   static void set_accessor(oop element, oop value);
1791   static void set_signature(oop element, oop value);
1792   static void set_annotations(oop element, oop value);
1793   static void set_typeAnnotations(oop element, oop value);
1794 
1795  public:
1796   // Create an instance of RecordComponent
1797   static oop create(InstanceKlass* holder, RecordComponent* component, TRAPS);
1798 
1799   static void compute_offsets();
1800   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1801 
1802   // Debugging
1803   friend class JavaClasses;
1804 };
1805 
1806 
1807 // Interface to java.lang.AssertionStatusDirectives objects
1808 
1809 class java_lang_AssertionStatusDirectives: AllStatic {
1810  private:
1811   static int _classes_offset;
1812   static int _classEnabled_offset;
1813   static int _packages_offset;
1814   static int _packageEnabled_offset;
1815   static int _deflt_offset;
1816 
1817  public:
1818   // Setters
1819   static void set_classes(oop obj, oop val);
1820   static void set_classEnabled(oop obj, oop val);
1821   static void set_packages(oop obj, oop val);
1822   static void set_packageEnabled(oop obj, oop val);
1823   static void set_deflt(oop obj, bool val);
1824 
1825   static void compute_offsets();
1826   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1827 
1828   // Debugging
1829   friend class JavaClasses;
1830 };
1831 
1832 
1833 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
1834  private:
1835   static int  _owner_offset;
1836  public:
1837   static void compute_offsets();
1838   static oop  get_owner_threadObj(oop obj);
1839   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1840 };
1841 
1842  // Interface to jdk.internal.misc.UnsafeConsants
1843 
1844 class jdk_internal_misc_UnsafeConstants : AllStatic {
1845  public:
1846   static void set_unsafe_constants();
1847   static void compute_offsets() { }
1848   static void serialize_offsets(SerializeClosure* f) { }
1849 };
1850 
1851 // Interface to jdk.internal.vm.vector.VectorSupport.VectorPayload objects
1852 
1853 class vector_VectorPayload : AllStatic {
1854  private:
1855   static int _payload_offset;
1856  public:
1857   static void set_payload(oop o, oop val);
1858 
1859   static void compute_offsets();
1860   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1861 
1862   // Testers
1863   static bool is_subclass(Klass* klass) {
1864     return klass->is_subclass_of(vmClasses::vector_VectorPayload_klass());
1865   }
1866   static bool is_instance(oop obj);
1867 };
1868 
1869 class java_lang_Integer : AllStatic {
1870 public:
1871   static jint value(oop obj);
1872 };
1873 
1874 class java_lang_Long : AllStatic {
1875 public:
1876   static jlong value(oop obj);
1877 };
1878 
1879 class java_lang_Character : AllStatic {
1880 public:
1881   static jchar value(oop obj);
1882 };
1883 
1884 class java_lang_Short : AllStatic {
1885 public:
1886   static jshort value(oop obj);
1887 };
1888 
1889 class java_lang_Byte : AllStatic {
1890 public:
1891   static jbyte value(oop obj);
1892 };
1893 
1894 class java_lang_Boolean : AllStatic {
1895  private:
1896   static int _static_TRUE_offset;
1897   static int _static_FALSE_offset;
1898  public:
1899   static Symbol* symbol();
1900   static void compute_offsets(InstanceKlass* k);
1901   static oop  get_TRUE(InstanceKlass *k);
1902   static oop  get_FALSE(InstanceKlass *k);
1903   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1904   static jboolean value(oop obj);
1905 };
1906 
1907 class java_lang_Integer_IntegerCache : AllStatic {
1908  private:
1909   static int _static_cache_offset;
1910  public:
1911   static Symbol* symbol();
1912   static void compute_offsets(InstanceKlass* k);
1913   static objArrayOop  cache(InstanceKlass *k);
1914   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1915 };
1916 
1917 class java_lang_Long_LongCache : AllStatic {
1918  private:
1919   static int _static_cache_offset;
1920  public:
1921   static Symbol* symbol();
1922   static void compute_offsets(InstanceKlass* k);
1923   static objArrayOop  cache(InstanceKlass *k);
1924   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1925 };
1926 
1927 class java_lang_Character_CharacterCache : AllStatic {
1928  private:
1929   static int _static_cache_offset;
1930  public:
1931   static Symbol* symbol();
1932   static void compute_offsets(InstanceKlass* k);
1933   static objArrayOop  cache(InstanceKlass *k);
1934   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1935 };
1936 
1937 class java_lang_Short_ShortCache : AllStatic {
1938  private:
1939   static int _static_cache_offset;
1940  public:
1941   static Symbol* symbol();
1942   static void compute_offsets(InstanceKlass* k);
1943   static objArrayOop  cache(InstanceKlass *k);
1944   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1945 };
1946 
1947 class java_lang_Byte_ByteCache : AllStatic {
1948  private:
1949   static int _static_cache_offset;
1950  public:
1951   static Symbol* symbol();
1952   static void compute_offsets(InstanceKlass* k);
1953   static objArrayOop  cache(InstanceKlass *k);
1954   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1955 };
1956 
1957 
1958 // Interface to java.lang.InternalError objects
1959 
1960 #define INTERNALERROR_INJECTED_FIELDS(macro)                      \
1961   macro(java_lang_InternalError, during_unsafe_access, bool_signature, false)
1962 
1963 class java_lang_InternalError : AllStatic {
1964  private:
1965   static int _during_unsafe_access_offset;
1966  public:
1967   static jboolean during_unsafe_access(oop internal_error);
1968   static void set_during_unsafe_access(oop internal_error);
1969   static void compute_offsets();
1970   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1971 };
1972 
1973 // Use to declare fields that need to be injected into Java classes
1974 // for the JVM to use.  The name_index and signature_index are
1975 // declared in vmSymbols.  The may_be_java flag is used to declare
1976 // fields that might already exist in Java but should be injected if
1977 // they don't.  Otherwise the field is unconditionally injected and
1978 // the JVM uses the injected one.  This is to ensure that name
1979 // collisions don't occur.  In general may_be_java should be false
1980 // unless there's a good reason.
1981 
1982 class InjectedField {
1983  public:
1984   const vmClassID klass_id;
1985   const vmSymbolID name_index;
1986   const vmSymbolID signature_index;
1987   const bool           may_be_java;
1988 
1989 
1990   Klass* klass() const      { return vmClasses::klass_at(klass_id); }
1991   Symbol* name() const      { return lookup_symbol(name_index); }
1992   Symbol* signature() const { return lookup_symbol(signature_index); }
1993 
1994   int compute_offset();
1995 
1996   // Find the Symbol for this index
1997   static Symbol* lookup_symbol(vmSymbolID symbol_index) {
1998     return Symbol::vm_symbol_at(symbol_index);
1999   }
2000 };
2001 
2002 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \
2003   klass##_##name##_enum,
2004 
2005 #define ALL_INJECTED_FIELDS(macro)          \
2006   STRING_INJECTED_FIELDS(macro)             \
2007   CLASS_INJECTED_FIELDS(macro)              \
2008   CLASSLOADER_INJECTED_FIELDS(macro)        \
2009   RESOLVEDMETHOD_INJECTED_FIELDS(macro)     \
2010   MEMBERNAME_INJECTED_FIELDS(macro)         \
2011   CALLSITECONTEXT_INJECTED_FIELDS(macro)    \
2012   STACKFRAMEINFO_INJECTED_FIELDS(macro)     \
2013   MODULE_INJECTED_FIELDS(macro)             \
2014   THREAD_INJECTED_FIELDS(macro)             \
2015   INTERNALERROR_INJECTED_FIELDS(macro)
2016 
2017 
2018 // Interface to hard-coded offset checking
2019 
2020 class JavaClasses : AllStatic {
2021  private:
2022 
2023   static InjectedField _injected_fields[];
2024 
2025   static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
2026  public:
2027   enum InjectedFieldID {
2028     ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM)
2029     MAX_enum
2030   };
2031 
2032   static int compute_injected_offset(InjectedFieldID id);
2033 
2034   static void compute_offsets();
2035   static void check_offsets() PRODUCT_RETURN;
2036   static void serialize_offsets(SerializeClosure* soc) NOT_CDS_RETURN;
2037   static InjectedField* get_injected(Symbol* class_name, int* field_count);
2038   static bool is_supported_for_archiving(oop obj) NOT_CDS_JAVA_HEAP_RETURN_(false);
2039 };
2040 
2041 #undef DECLARE_INJECTED_FIELD_ENUM
2042 
2043 #undef CHECK_INIT
2044 #endif // SHARE_CLASSFILE_JAVACLASSES_HPP