< prev index next >

src/hotspot/share/classfile/javaClasses.hpp

Print this page




  64   f(java_lang_invoke_MemberName) \
  65   f(java_lang_invoke_ResolvedMethodName) \
  66   f(java_lang_invoke_LambdaForm) \
  67   f(java_lang_invoke_MethodType) \
  68   f(java_lang_invoke_CallSite) \
  69   f(java_lang_invoke_MethodHandleNatives_CallSiteContext) \
  70   f(java_security_AccessControlContext) \
  71   f(java_lang_reflect_AccessibleObject) \
  72   f(java_lang_reflect_Method) \
  73   f(java_lang_reflect_Constructor) \
  74   f(java_lang_reflect_Field) \
  75   f(java_nio_Buffer) \
  76   f(reflect_ConstantPool) \
  77   f(reflect_UnsafeStaticFieldAccessorImpl) \
  78   f(java_lang_reflect_Parameter) \
  79   f(java_lang_Module) \
  80   f(java_lang_StackTraceElement) \
  81   f(java_lang_StackFrameInfo) \
  82   f(java_lang_LiveStackFrameInfo) \
  83   f(java_util_concurrent_locks_AbstractOwnableSynchronizer) \
  84   f(jdk_internal_misc_UnsafeConstants) \
  85   //end
  86 
  87 #define BASIC_JAVA_CLASSES_DO(f) \
  88         BASIC_JAVA_CLASSES_DO_PART1(f) \
  89         BASIC_JAVA_CLASSES_DO_PART2(f)
  90 
  91 // Interface to java.lang.String objects
  92 
  93 class java_lang_String : AllStatic {
  94  private:
  95   static int value_offset;
  96   static int hash_offset;
  97   static int hashIsZero_offset;
  98   static int coder_offset;
  99 
 100   static bool initialized;
 101 
 102   static Handle basic_create(int length, bool byte_arr, TRAPS);
 103 
 104   static inline void set_coder(oop string, jbyte coder);
 105 
 106  public:
 107 
 108   // Coders
 109   enum Coder {
 110     CODER_LATIN1 =  0,
 111     CODER_UTF16  =  1
 112   };
 113 
 114   static void compute_offsets();
 115   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 116 
 117   // Instance creation
 118   static Handle create_from_unicode(const jchar* unicode, int len, TRAPS);
 119   static oop    create_oop_from_unicode(const jchar* unicode, int len, TRAPS);
 120   static Handle create_from_str(const char* utf8_str, TRAPS);
 121   static oop    create_oop_from_str(const char* utf8_str, TRAPS);
 122   static Handle create_from_symbol(Symbol* symbol, TRAPS);
 123   static Handle create_from_platform_dependent_str(const char* str, TRAPS);
 124   static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS);
 125 
 126   static void set_compact_strings(bool value);
 127 
 128   static int value_offset_in_bytes()  {
 129     assert(initialized && (value_offset > 0), "Must be initialized");
 130     return value_offset;
 131   }
 132   static int hash_offset_in_bytes()   {
 133     assert(initialized && (hash_offset > 0), "Must be initialized");
 134     return hash_offset;
 135   }
 136   static int hashIsZero_offset_in_bytes()   {
 137     assert(initialized && (hashIsZero_offset > 0), "Must be initialized");
 138     return hashIsZero_offset;
 139   }
 140   static int coder_offset_in_bytes()   {
 141     assert(initialized && (coder_offset > 0), "Must be initialized");
 142     return coder_offset;
 143   }
 144 
 145   static inline void set_value_raw(oop string, typeArrayOop buffer);
 146   static inline void set_value(oop string, typeArrayOop buffer);

 147 
 148   // Accessors
 149   static inline typeArrayOop value(oop java_string);
 150   static inline typeArrayOop value_no_keepalive(oop java_string);
 151   static inline bool hash_is_set(oop string);
 152   static inline bool is_latin1(oop java_string);
 153   static inline int length(oop java_string);
 154   static inline int length(oop java_string, typeArrayOop string_value);
 155   static int utf8_length(oop java_string);
 156   static int utf8_length(oop java_string, typeArrayOop string_value);
 157 
 158   // String converters
 159   static char*  as_utf8_string(oop java_string);
 160   static char*  as_utf8_string(oop java_string, char* buf, int buflen);
 161   static char*  as_utf8_string(oop java_string, int start, int len);
 162   static char*  as_utf8_string(oop java_string, typeArrayOop value, char* buf, int buflen);
 163   static char*  as_utf8_string(oop java_string, typeArrayOop value, int start, int len, char* buf, int buflen);
 164   static char*  as_platform_dependent_str(Handle java_string, TRAPS);
 165   static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
 166   // produce an ascii string with all other values quoted using \u####
 167   static char*  as_quoted_ascii(oop java_string);
 168 
 169   // Compute the hash value for a java.lang.String object which would
 170   // contain the characters passed in.
 171   //


 188   static unsigned int hash_code(const jbyte* s, int len) {
 189     unsigned int h = 0;
 190     while (len-- > 0) {
 191       h = 31*h + (((unsigned int) *s) & 0xFF);
 192       s++;
 193     }
 194     return h;
 195   }
 196 
 197   static unsigned int hash_code(oop java_string);
 198 
 199   static bool equals(oop java_string, const jchar* chars, int len);
 200   static bool equals(oop str1, oop str2);
 201   static inline bool value_equals(typeArrayOop str_value1, typeArrayOop str_value2);
 202 
 203   // Conversion between '.' and '/' formats
 204   static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); }
 205   static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); }
 206 
 207   // Conversion
 208   static Symbol* as_symbol(oop java_string);
 209   static Symbol* as_symbol_or_null(oop java_string);
 210 
 211   // Testers
 212   static bool is_instance(oop obj);
 213   static inline bool is_instance_inlined(oop obj);
 214 
 215   // Debugging
 216   static void print(oop java_string, outputStream* st);
 217   friend class JavaClasses;
 218   friend class StringTable;
 219 };
 220 
 221 
 222 // Interface to java.lang.Class objects
 223 
 224 #define CLASS_INJECTED_FIELDS(macro)                                       \
 225   macro(java_lang_Class, klass,                  intptr_signature,  false) \
 226   macro(java_lang_Class, array_klass,            intptr_signature,  false) \
 227   macro(java_lang_Class, oop_size,               int_signature,     false) \
 228   macro(java_lang_Class, static_oop_field_count, int_signature,     false) \


 274   static void fixup_mirror(Klass* k, TRAPS);
 275   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
 276 
 277   // Archiving
 278   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 279   static void archive_basic_type_mirrors(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
 280   static oop  archive_mirror(Klass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
 281   static oop  process_archived_mirror(Klass* k, oop mirror, oop archived_mirror, Thread *THREAD)
 282                                       NOT_CDS_JAVA_HEAP_RETURN_(NULL);
 283   static bool restore_archived_mirror(Klass *k, Handle class_loader, Handle module,
 284                                       Handle protection_domain,
 285                                       TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(false);
 286 
 287   static void fixup_module_field(Klass* k, Handle module);
 288 
 289   // Conversion
 290   static Klass* as_Klass(oop java_class);
 291   static Klass* as_Klass_raw(oop java_class);
 292   static void set_klass(oop java_class, Klass* klass);
 293   static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL);
 294   static Symbol* as_signature(oop java_class, bool intern_if_not_found);
 295   static void print_signature(oop java_class, outputStream *st);
 296   static const char* as_external_name(oop java_class);
 297   // Testing
 298   static bool is_instance(oop obj);
 299 
 300   static bool is_primitive(oop java_class);
 301   static BasicType primitive_type(oop java_class);
 302   static oop primitive_mirror(BasicType t);
 303   // JVM_NewArray support
 304   static Klass* array_klass_acquire(oop java_class);
 305   static void release_set_array_klass(oop java_class, Klass* klass);
 306   // compiler support for class operations
 307   static int klass_offset_in_bytes()                { return _klass_offset; }
 308   static int array_klass_offset_in_bytes()          { return _array_klass_offset; }
 309   // Support for classRedefinedCount field
 310   static int classRedefinedCount(oop the_class_mirror);
 311   static void set_classRedefinedCount(oop the_class_mirror, int value);
 312 
 313   // Support for embedded per-class oops
 314   static oop  protection_domain(oop java_class);


 354 };
 355 
 356 // Interface to java.lang.Thread objects
 357 
 358 class java_lang_Thread : AllStatic {
 359  private:
 360   // Note that for this class the layout changed between JDK1.2 and JDK1.3,
 361   // so we compute the offsets at startup rather than hard-wiring them.
 362   static int _name_offset;
 363   static int _group_offset;
 364   static int _contextClassLoader_offset;
 365   static int _inheritedAccessControlContext_offset;
 366   static int _priority_offset;
 367   static int _eetop_offset;
 368   static int _daemon_offset;
 369   static int _stillborn_offset;
 370   static int _stackSize_offset;
 371   static int _tid_offset;
 372   static int _thread_status_offset;
 373   static int _park_blocker_offset;

 374 
 375   static void compute_offsets();
 376 
 377  public:
 378   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 379 
 380   // Instance creation
 381   static oop create();
 382   // Returns the JavaThread associated with the thread obj
 383   static JavaThread* thread(oop java_thread);
 384   // Set JavaThread for instance
 385   static void set_thread(oop java_thread, JavaThread* thread);
 386   // Name
 387   static oop name(oop java_thread);
 388   static void set_name(oop java_thread, oop name);
 389   // Priority
 390   static ThreadPriority priority(oop java_thread);
 391   static void set_priority(oop java_thread, ThreadPriority priority);
 392   // Thread group
 393   static oop  threadGroup(oop java_thread);


 395   static bool is_stillborn(oop java_thread);
 396   static void set_stillborn(oop java_thread);
 397   // Alive (NOTE: this is not really a field, but provides the correct
 398   // definition without doing a Java call)
 399   static bool is_alive(oop java_thread);
 400   // Daemon
 401   static bool is_daemon(oop java_thread);
 402   static void set_daemon(oop java_thread);
 403   // Context ClassLoader
 404   static oop context_class_loader(oop java_thread);
 405   // Control context
 406   static oop inherited_access_control_context(oop java_thread);
 407   // Stack size hint
 408   static jlong stackSize(oop java_thread);
 409   // Thread ID
 410   static jlong thread_id(oop java_thread);
 411 
 412   // Blocker object responsible for thread parking
 413   static oop park_blocker(oop java_thread);
 414 






 415   // Java Thread Status for JVMTI and M&M use.
 416   // This thread status info is saved in threadStatus field of
 417   // java.lang.Thread java class.
 418   enum ThreadStatus {
 419     NEW                      = 0,
 420     RUNNABLE                 = JVMTI_THREAD_STATE_ALIVE +          // runnable / running
 421                                JVMTI_THREAD_STATE_RUNNABLE,
 422     SLEEPING                 = JVMTI_THREAD_STATE_ALIVE +          // Thread.sleep()
 423                                JVMTI_THREAD_STATE_WAITING +
 424                                JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
 425                                JVMTI_THREAD_STATE_SLEEPING,
 426     IN_OBJECT_WAIT           = JVMTI_THREAD_STATE_ALIVE +          // Object.wait()
 427                                JVMTI_THREAD_STATE_WAITING +
 428                                JVMTI_THREAD_STATE_WAITING_INDEFINITELY +
 429                                JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
 430     IN_OBJECT_WAIT_TIMED     = JVMTI_THREAD_STATE_ALIVE +          // Object.wait(long)
 431                                JVMTI_THREAD_STATE_WAITING +
 432                                JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
 433                                JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
 434     PARKED                   = JVMTI_THREAD_STATE_ALIVE +          // LockSupport.park()


1039 
1040 #define RESOLVEDMETHOD_INJECTED_FIELDS(macro)                                   \
1041   macro(java_lang_invoke_ResolvedMethodName, vmholder, object_signature, false) \
1042   macro(java_lang_invoke_ResolvedMethodName, vmtarget, intptr_signature, false)
1043 
1044 class java_lang_invoke_ResolvedMethodName : AllStatic {
1045   friend class JavaClasses;
1046 
1047   static int _vmtarget_offset;
1048   static int _vmholder_offset;
1049 
1050   static void compute_offsets();
1051  public:
1052   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1053 
1054   static int vmtarget_offset_in_bytes() { return _vmtarget_offset; }
1055 
1056   static Method* vmtarget(oop resolved_method);
1057   static void set_vmtarget(oop resolved_method, Method* method);
1058 
1059   static void set_vmholder(oop resolved_method, oop holder);
1060 
1061   // find or create resolved member name
1062   static oop find_resolved_method(const methodHandle& m, TRAPS);
1063 
1064   static bool is_instance(oop resolved_method);
1065 };
1066 
1067 
1068 #define MEMBERNAME_INJECTED_FIELDS(macro)                               \
1069   macro(java_lang_invoke_MemberName, vmindex,  intptr_signature, false)
1070 
1071 
1072 class java_lang_invoke_MemberName: AllStatic {
1073   friend class JavaClasses;
1074 
1075  private:
1076   // From java.lang.invoke.MemberName:
1077   //    private Class<?>   clazz;       // class in which the method is defined
1078   //    private String     name;        // may be null if not yet materialized
1079   //    private Object     type;        // may be null if not yet materialized
1080   //    private int        flags;       // modifier bits; see reflect.Modifier


1149   friend class JavaClasses;
1150 
1151  private:
1152   static int _rtype_offset;
1153   static int _ptypes_offset;
1154 
1155   static void compute_offsets();
1156 
1157  public:
1158   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1159   // Accessors
1160   static oop            rtype(oop mt);
1161   static objArrayOop    ptypes(oop mt);
1162 
1163   static oop            ptype(oop mt, int index);
1164   static int            ptype_count(oop mt);
1165 
1166   static int            ptype_slot_count(oop mt);  // extra counts for long/double
1167   static int            rtype_slot_count(oop mt);  // extra counts for long/double
1168 
1169   static Symbol*        as_signature(oop mt, bool intern_if_not_found);
1170   static void           print_signature(oop mt, outputStream* st);
1171 
1172   static bool is_instance(oop obj);
1173 
1174   static bool equals(oop mt1, oop mt2);
1175 
1176   // Accessors for code generation:
1177   static int rtype_offset_in_bytes()            { return _rtype_offset; }
1178   static int ptypes_offset_in_bytes()           { return _ptypes_offset; }
1179 };
1180 
1181 
1182 // Interface to java.lang.invoke.CallSite objects
1183 
1184 class java_lang_invoke_CallSite: AllStatic {
1185   friend class JavaClasses;
1186 
1187 private:
1188   static int _target_offset;
1189   static int _context_offset;


1351   // Setters
1352   static void set_classLoaderName(oop element, oop value);
1353   static void set_moduleName(oop element, oop value);
1354   static void set_moduleVersion(oop element, oop value);
1355   static void set_declaringClass(oop element, oop value);
1356   static void set_methodName(oop element, oop value);
1357   static void set_fileName(oop element, oop value);
1358   static void set_lineNumber(oop element, int value);
1359   static void set_declaringClassObject(oop element, oop value);
1360 
1361  public:
1362   // Create an instance of StackTraceElement
1363   static oop create(const methodHandle& method, int bci, TRAPS);
1364 
1365   static void fill_in(Handle element, InstanceKlass* holder, const methodHandle& method,
1366                       int version, int bci, Symbol* name, TRAPS);
1367 
1368   static void compute_offsets();
1369   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1370 
1371 #if INCLUDE_JVMCI
1372   static void decode(Handle mirror, int method, int version, int bci, int cpref, Symbol*& methodName, Symbol*& fileName, int& lineNumber);
1373   static void decode(Handle mirror, methodHandle method, int bci, Symbol*& methodName, Symbol*& fileName, int& lineNumber);
1374 #endif
1375 
1376   // Debugging
1377   friend class JavaClasses;
1378 };
1379 
1380 
1381 class Backtrace: AllStatic {
1382  public:
1383   // Helper backtrace functions to store bci|version together.
1384   static int merge_bci_and_version(int bci, int version);
1385   static int merge_mid_and_cpref(int mid, int cpref);
1386   static int bci_at(unsigned int merged);
1387   static int version_at(unsigned int merged);
1388   static int mid_at(unsigned int merged);
1389   static int cpref_at(unsigned int merged);
1390   static int get_line_number(const methodHandle& method, int bci);
1391   static Symbol* get_source_file_name(InstanceKlass* holder, int version);
1392 
1393   // Debugging
1394   friend class JavaClasses;
1395 };


1469 };
1470 
1471 
1472 class java_nio_Buffer: AllStatic {
1473  private:
1474   static int _limit_offset;
1475 
1476  public:
1477   static int  limit_offset();
1478   static void compute_offsets();
1479   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1480 };
1481 
1482 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
1483  private:
1484   static int  _owner_offset;
1485  public:
1486   static void compute_offsets();
1487   static oop  get_owner_threadObj(oop obj);
1488   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1489 };
1490 
1491  // Interface to jdk.internal.misc.UnsafeConsants
1492 
1493 class jdk_internal_misc_UnsafeConstants : AllStatic {
1494  public:
1495   static void set_unsafe_constants();
1496   static void compute_offsets() { }
1497   static void serialize_offsets(SerializeClosure* f) { }
1498 };
1499 
1500 // Use to declare fields that need to be injected into Java classes
1501 // for the JVM to use.  The name_index and signature_index are
1502 // declared in vmSymbols.  The may_be_java flag is used to declare
1503 // fields that might already exist in Java but should be injected if
1504 // they don't.  Otherwise the field is unconditionally injected and
1505 // the JVM uses the injected one.  This is to ensure that name
1506 // collisions don't occur.  In general may_be_java should be false
1507 // unless there's a good reason.
1508 
1509 class InjectedField {
1510  public:
1511   const SystemDictionary::WKID klass_id;
1512   const vmSymbols::SID name_index;
1513   const vmSymbols::SID signature_index;
1514   const bool           may_be_java;
1515 
1516 
1517   Klass* klass() const    { return SystemDictionary::well_known_klass(klass_id); }




  64   f(java_lang_invoke_MemberName) \
  65   f(java_lang_invoke_ResolvedMethodName) \
  66   f(java_lang_invoke_LambdaForm) \
  67   f(java_lang_invoke_MethodType) \
  68   f(java_lang_invoke_CallSite) \
  69   f(java_lang_invoke_MethodHandleNatives_CallSiteContext) \
  70   f(java_security_AccessControlContext) \
  71   f(java_lang_reflect_AccessibleObject) \
  72   f(java_lang_reflect_Method) \
  73   f(java_lang_reflect_Constructor) \
  74   f(java_lang_reflect_Field) \
  75   f(java_nio_Buffer) \
  76   f(reflect_ConstantPool) \
  77   f(reflect_UnsafeStaticFieldAccessorImpl) \
  78   f(java_lang_reflect_Parameter) \
  79   f(java_lang_Module) \
  80   f(java_lang_StackTraceElement) \
  81   f(java_lang_StackFrameInfo) \
  82   f(java_lang_LiveStackFrameInfo) \
  83   f(java_util_concurrent_locks_AbstractOwnableSynchronizer) \

  84   //end
  85 
  86 #define BASIC_JAVA_CLASSES_DO(f) \
  87         BASIC_JAVA_CLASSES_DO_PART1(f) \
  88         BASIC_JAVA_CLASSES_DO_PART2(f)
  89 
  90 // Interface to java.lang.String objects
  91 
  92 class java_lang_String : AllStatic {
  93  private:
  94   static int value_offset;
  95   static int hash_offset;

  96   static int coder_offset;
  97 
  98   static bool initialized;
  99 
 100   static Handle basic_create(int length, bool byte_arr, TRAPS);
 101 
 102   static inline void set_coder(oop string, jbyte coder);
 103 
 104  public:
 105 
 106   // Coders
 107   enum Coder {
 108     CODER_LATIN1 =  0,
 109     CODER_UTF16  =  1
 110   };
 111 
 112   static void compute_offsets();
 113   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 114 
 115   // Instance creation
 116   static Handle create_from_unicode(const jchar* unicode, int len, TRAPS);
 117   static oop    create_oop_from_unicode(const jchar* unicode, int len, TRAPS);
 118   static Handle create_from_str(const char* utf8_str, TRAPS);
 119   static oop    create_oop_from_str(const char* utf8_str, TRAPS);
 120   static Handle create_from_symbol(Symbol* symbol, TRAPS);
 121   static Handle create_from_platform_dependent_str(const char* str, TRAPS);
 122   static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS);
 123 
 124   static void set_compact_strings(bool value);
 125 
 126   static int value_offset_in_bytes()  {
 127     assert(initialized && (value_offset > 0), "Must be initialized");
 128     return value_offset;
 129   }
 130   static int hash_offset_in_bytes()   {
 131     assert(initialized && (hash_offset > 0), "Must be initialized");
 132     return hash_offset;
 133   }




 134   static int coder_offset_in_bytes()   {
 135     assert(initialized && (coder_offset > 0), "Must be initialized");
 136     return coder_offset;
 137   }
 138 
 139   static inline void set_value_raw(oop string, typeArrayOop buffer);
 140   static inline void set_value(oop string, typeArrayOop buffer);
 141   static inline void set_hash(oop string, unsigned int hash);
 142 
 143   // Accessors
 144   static inline typeArrayOop value(oop java_string);
 145   static inline typeArrayOop value_no_keepalive(oop java_string);
 146   static inline unsigned int hash(oop java_string);
 147   static inline bool is_latin1(oop java_string);
 148   static inline int length(oop java_string);
 149   static inline int length(oop java_string, typeArrayOop string_value);
 150   static int utf8_length(oop java_string);
 151   static int utf8_length(oop java_string, typeArrayOop string_value);
 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_utf8_string(oop java_string, typeArrayOop value, char* buf, int buflen);
 158   static char*  as_utf8_string(oop java_string, typeArrayOop value, int start, int len, char* buf, int buflen);
 159   static char*  as_platform_dependent_str(Handle java_string, TRAPS);
 160   static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
 161   // produce an ascii string with all other values quoted using \u####
 162   static char*  as_quoted_ascii(oop java_string);
 163 
 164   // Compute the hash value for a java.lang.String object which would
 165   // contain the characters passed in.
 166   //


 183   static unsigned int hash_code(const jbyte* s, int len) {
 184     unsigned int h = 0;
 185     while (len-- > 0) {
 186       h = 31*h + (((unsigned int) *s) & 0xFF);
 187       s++;
 188     }
 189     return h;
 190   }
 191 
 192   static unsigned int hash_code(oop java_string);
 193 
 194   static bool equals(oop java_string, const jchar* chars, int len);
 195   static bool equals(oop str1, oop str2);
 196   static inline bool value_equals(typeArrayOop str_value1, typeArrayOop str_value2);
 197 
 198   // Conversion between '.' and '/' formats
 199   static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); }
 200   static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); }
 201 
 202   // Conversion
 203   static Symbol* as_symbol(oop java_string, TRAPS);
 204   static Symbol* as_symbol_or_null(oop java_string);
 205 
 206   // Testers
 207   static bool is_instance(oop obj);
 208   static inline bool is_instance_inlined(oop obj);
 209 
 210   // Debugging
 211   static void print(oop java_string, outputStream* st);
 212   friend class JavaClasses;
 213   friend class StringTable;
 214 };
 215 
 216 
 217 // Interface to java.lang.Class objects
 218 
 219 #define CLASS_INJECTED_FIELDS(macro)                                       \
 220   macro(java_lang_Class, klass,                  intptr_signature,  false) \
 221   macro(java_lang_Class, array_klass,            intptr_signature,  false) \
 222   macro(java_lang_Class, oop_size,               int_signature,     false) \
 223   macro(java_lang_Class, static_oop_field_count, int_signature,     false) \


 269   static void fixup_mirror(Klass* k, TRAPS);
 270   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
 271 
 272   // Archiving
 273   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 274   static void archive_basic_type_mirrors(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
 275   static oop  archive_mirror(Klass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
 276   static oop  process_archived_mirror(Klass* k, oop mirror, oop archived_mirror, Thread *THREAD)
 277                                       NOT_CDS_JAVA_HEAP_RETURN_(NULL);
 278   static bool restore_archived_mirror(Klass *k, Handle class_loader, Handle module,
 279                                       Handle protection_domain,
 280                                       TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(false);
 281 
 282   static void fixup_module_field(Klass* k, Handle module);
 283 
 284   // Conversion
 285   static Klass* as_Klass(oop java_class);
 286   static Klass* as_Klass_raw(oop java_class);
 287   static void set_klass(oop java_class, Klass* klass);
 288   static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL);
 289   static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS);
 290   static void print_signature(oop java_class, outputStream *st);
 291   static const char* as_external_name(oop java_class);
 292   // Testing
 293   static bool is_instance(oop obj);
 294 
 295   static bool is_primitive(oop java_class);
 296   static BasicType primitive_type(oop java_class);
 297   static oop primitive_mirror(BasicType t);
 298   // JVM_NewArray support
 299   static Klass* array_klass_acquire(oop java_class);
 300   static void release_set_array_klass(oop java_class, Klass* klass);
 301   // compiler support for class operations
 302   static int klass_offset_in_bytes()                { return _klass_offset; }
 303   static int array_klass_offset_in_bytes()          { return _array_klass_offset; }
 304   // Support for classRedefinedCount field
 305   static int classRedefinedCount(oop the_class_mirror);
 306   static void set_classRedefinedCount(oop the_class_mirror, int value);
 307 
 308   // Support for embedded per-class oops
 309   static oop  protection_domain(oop java_class);


 349 };
 350 
 351 // Interface to java.lang.Thread objects
 352 
 353 class java_lang_Thread : AllStatic {
 354  private:
 355   // Note that for this class the layout changed between JDK1.2 and JDK1.3,
 356   // so we compute the offsets at startup rather than hard-wiring them.
 357   static int _name_offset;
 358   static int _group_offset;
 359   static int _contextClassLoader_offset;
 360   static int _inheritedAccessControlContext_offset;
 361   static int _priority_offset;
 362   static int _eetop_offset;
 363   static int _daemon_offset;
 364   static int _stillborn_offset;
 365   static int _stackSize_offset;
 366   static int _tid_offset;
 367   static int _thread_status_offset;
 368   static int _park_blocker_offset;
 369   static int _park_event_offset ;
 370 
 371   static void compute_offsets();
 372 
 373  public:
 374   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 375 
 376   // Instance creation
 377   static oop create();
 378   // Returns the JavaThread associated with the thread obj
 379   static JavaThread* thread(oop java_thread);
 380   // Set JavaThread for instance
 381   static void set_thread(oop java_thread, JavaThread* thread);
 382   // Name
 383   static oop name(oop java_thread);
 384   static void set_name(oop java_thread, oop name);
 385   // Priority
 386   static ThreadPriority priority(oop java_thread);
 387   static void set_priority(oop java_thread, ThreadPriority priority);
 388   // Thread group
 389   static oop  threadGroup(oop java_thread);


 391   static bool is_stillborn(oop java_thread);
 392   static void set_stillborn(oop java_thread);
 393   // Alive (NOTE: this is not really a field, but provides the correct
 394   // definition without doing a Java call)
 395   static bool is_alive(oop java_thread);
 396   // Daemon
 397   static bool is_daemon(oop java_thread);
 398   static void set_daemon(oop java_thread);
 399   // Context ClassLoader
 400   static oop context_class_loader(oop java_thread);
 401   // Control context
 402   static oop inherited_access_control_context(oop java_thread);
 403   // Stack size hint
 404   static jlong stackSize(oop java_thread);
 405   // Thread ID
 406   static jlong thread_id(oop java_thread);
 407 
 408   // Blocker object responsible for thread parking
 409   static oop park_blocker(oop java_thread);
 410 
 411   // Pointer to type-stable park handler, encoded as jlong.
 412   // Should be set when apparently null
 413   // For details, see unsafe.cpp Unsafe_Unpark
 414   static jlong park_event(oop java_thread);
 415   static bool set_park_event(oop java_thread, jlong ptr);
 416 
 417   // Java Thread Status for JVMTI and M&M use.
 418   // This thread status info is saved in threadStatus field of
 419   // java.lang.Thread java class.
 420   enum ThreadStatus {
 421     NEW                      = 0,
 422     RUNNABLE                 = JVMTI_THREAD_STATE_ALIVE +          // runnable / running
 423                                JVMTI_THREAD_STATE_RUNNABLE,
 424     SLEEPING                 = JVMTI_THREAD_STATE_ALIVE +          // Thread.sleep()
 425                                JVMTI_THREAD_STATE_WAITING +
 426                                JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
 427                                JVMTI_THREAD_STATE_SLEEPING,
 428     IN_OBJECT_WAIT           = JVMTI_THREAD_STATE_ALIVE +          // Object.wait()
 429                                JVMTI_THREAD_STATE_WAITING +
 430                                JVMTI_THREAD_STATE_WAITING_INDEFINITELY +
 431                                JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
 432     IN_OBJECT_WAIT_TIMED     = JVMTI_THREAD_STATE_ALIVE +          // Object.wait(long)
 433                                JVMTI_THREAD_STATE_WAITING +
 434                                JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
 435                                JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
 436     PARKED                   = JVMTI_THREAD_STATE_ALIVE +          // LockSupport.park()


1041 
1042 #define RESOLVEDMETHOD_INJECTED_FIELDS(macro)                                   \
1043   macro(java_lang_invoke_ResolvedMethodName, vmholder, object_signature, false) \
1044   macro(java_lang_invoke_ResolvedMethodName, vmtarget, intptr_signature, false)
1045 
1046 class java_lang_invoke_ResolvedMethodName : AllStatic {
1047   friend class JavaClasses;
1048 
1049   static int _vmtarget_offset;
1050   static int _vmholder_offset;
1051 
1052   static void compute_offsets();
1053  public:
1054   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1055 
1056   static int vmtarget_offset_in_bytes() { return _vmtarget_offset; }
1057 
1058   static Method* vmtarget(oop resolved_method);
1059   static void set_vmtarget(oop resolved_method, Method* method);
1060 


1061   // find or create resolved member name
1062   static oop find_resolved_method(const methodHandle& m, TRAPS);
1063 
1064   static bool is_instance(oop resolved_method);
1065 };
1066 
1067 
1068 #define MEMBERNAME_INJECTED_FIELDS(macro)                               \
1069   macro(java_lang_invoke_MemberName, vmindex,  intptr_signature, false)
1070 
1071 
1072 class java_lang_invoke_MemberName: AllStatic {
1073   friend class JavaClasses;
1074 
1075  private:
1076   // From java.lang.invoke.MemberName:
1077   //    private Class<?>   clazz;       // class in which the method is defined
1078   //    private String     name;        // may be null if not yet materialized
1079   //    private Object     type;        // may be null if not yet materialized
1080   //    private int        flags;       // modifier bits; see reflect.Modifier


1149   friend class JavaClasses;
1150 
1151  private:
1152   static int _rtype_offset;
1153   static int _ptypes_offset;
1154 
1155   static void compute_offsets();
1156 
1157  public:
1158   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1159   // Accessors
1160   static oop            rtype(oop mt);
1161   static objArrayOop    ptypes(oop mt);
1162 
1163   static oop            ptype(oop mt, int index);
1164   static int            ptype_count(oop mt);
1165 
1166   static int            ptype_slot_count(oop mt);  // extra counts for long/double
1167   static int            rtype_slot_count(oop mt);  // extra counts for long/double
1168 
1169   static Symbol*        as_signature(oop mt, bool intern_if_not_found, TRAPS);
1170   static void           print_signature(oop mt, outputStream* st);
1171 
1172   static bool is_instance(oop obj);
1173 
1174   static bool equals(oop mt1, oop mt2);
1175 
1176   // Accessors for code generation:
1177   static int rtype_offset_in_bytes()            { return _rtype_offset; }
1178   static int ptypes_offset_in_bytes()           { return _ptypes_offset; }
1179 };
1180 
1181 
1182 // Interface to java.lang.invoke.CallSite objects
1183 
1184 class java_lang_invoke_CallSite: AllStatic {
1185   friend class JavaClasses;
1186 
1187 private:
1188   static int _target_offset;
1189   static int _context_offset;


1351   // Setters
1352   static void set_classLoaderName(oop element, oop value);
1353   static void set_moduleName(oop element, oop value);
1354   static void set_moduleVersion(oop element, oop value);
1355   static void set_declaringClass(oop element, oop value);
1356   static void set_methodName(oop element, oop value);
1357   static void set_fileName(oop element, oop value);
1358   static void set_lineNumber(oop element, int value);
1359   static void set_declaringClassObject(oop element, oop value);
1360 
1361  public:
1362   // Create an instance of StackTraceElement
1363   static oop create(const methodHandle& method, int bci, TRAPS);
1364 
1365   static void fill_in(Handle element, InstanceKlass* holder, const methodHandle& method,
1366                       int version, int bci, Symbol* name, TRAPS);
1367 
1368   static void compute_offsets();
1369   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1370 





1371   // Debugging
1372   friend class JavaClasses;
1373 };
1374 
1375 
1376 class Backtrace: AllStatic {
1377  public:
1378   // Helper backtrace functions to store bci|version together.
1379   static int merge_bci_and_version(int bci, int version);
1380   static int merge_mid_and_cpref(int mid, int cpref);
1381   static int bci_at(unsigned int merged);
1382   static int version_at(unsigned int merged);
1383   static int mid_at(unsigned int merged);
1384   static int cpref_at(unsigned int merged);
1385   static int get_line_number(const methodHandle& method, int bci);
1386   static Symbol* get_source_file_name(InstanceKlass* holder, int version);
1387 
1388   // Debugging
1389   friend class JavaClasses;
1390 };


1464 };
1465 
1466 
1467 class java_nio_Buffer: AllStatic {
1468  private:
1469   static int _limit_offset;
1470 
1471  public:
1472   static int  limit_offset();
1473   static void compute_offsets();
1474   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1475 };
1476 
1477 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
1478  private:
1479   static int  _owner_offset;
1480  public:
1481   static void compute_offsets();
1482   static oop  get_owner_threadObj(oop obj);
1483   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;









1484 };
1485 
1486 // Use to declare fields that need to be injected into Java classes
1487 // for the JVM to use.  The name_index and signature_index are
1488 // declared in vmSymbols.  The may_be_java flag is used to declare
1489 // fields that might already exist in Java but should be injected if
1490 // they don't.  Otherwise the field is unconditionally injected and
1491 // the JVM uses the injected one.  This is to ensure that name
1492 // collisions don't occur.  In general may_be_java should be false
1493 // unless there's a good reason.
1494 
1495 class InjectedField {
1496  public:
1497   const SystemDictionary::WKID klass_id;
1498   const vmSymbols::SID name_index;
1499   const vmSymbols::SID signature_index;
1500   const bool           may_be_java;
1501 
1502 
1503   Klass* klass() const    { return SystemDictionary::well_known_klass(klass_id); }


< prev index next >