196 }
197
198 static unsigned int hash_code(oop java_string);
199 static unsigned int hash_code_noupdate(oop java_string);
200
201 // Compare strings (of different types/encodings), length is the string (array) length
202 static bool equals(oop java_string, const jchar* chars, int len);
203 static bool equals(oop java_string, const char* utf8_str, size_t utf8_len);
204 static bool equals(oop str1, oop str2);
205 static inline bool value_equals(typeArrayOop str_value1, typeArrayOop str_value2);
206
207 // Conversion between '.' and '/' formats, and allocate a String from the result.
208 static Handle externalize_classname(Symbol* java_name, TRAPS);
209
210 // Conversion
211 static Symbol* as_symbol(oop java_string);
212 static Symbol* as_symbol_or_null(oop java_string);
213
214 // Tester
215 static inline bool is_instance(oop obj);
216
217 // Debugging
218 static void print(oop java_string, outputStream* st, int max_length = MaxStringPrintSize);
219 friend class JavaClasses;
220 friend class StringTable;
221 };
222
223
224 // Interface to java.lang.Class objects
225
226 #define CLASS_INJECTED_FIELDS(macro) \
227 macro(java_lang_Class, klass, intptr_signature, false) \
228 macro(java_lang_Class, array_klass, intptr_signature, false) \
229 macro(java_lang_Class, oop_size, int_signature, false) \
230 macro(java_lang_Class, static_oop_field_count, int_signature, false) \
231 macro(java_lang_Class, source_file, object_signature, false) \
232 macro(java_lang_Class, init_lock, object_signature, false)
233
234 class java_lang_Class : AllStatic {
235 friend class VMStructs;
236 friend class JVMCIVMStructs;
237 friend class HeapShared;
238
239 private:
240
241 // The fake offsets are added by the class loader when java.lang.Class is loaded
242
243 static int _klass_offset;
244 static int _array_klass_offset;
245
246 static int _oop_size_offset;
247 static int _static_oop_field_count_offset;
248
249 static int _protection_domain_offset;
250 static int _init_lock_offset;
251 static int _signers_offset;
252 static int _class_loader_offset;
253 static int _module_offset;
254 static int _component_mirror_offset;
255 static int _name_offset;
256 static int _source_file_offset;
257 static int _classData_offset;
258 static int _classRedefinedCount_offset;
259 static int _reflectionData_offset;
260 static int _modifiers_offset;
261 static int _is_primitive_offset;
262 static int _raw_access_flags_offset;
263
264 static bool _offsets_computed;
265
266 static GrowableArray<Klass*>* _fixup_mirror_list;
267 static GrowableArray<Klass*>* _fixup_module_field_list;
268
269 static void set_init_lock(oop java_class, oop init_lock);
270 static void set_protection_domain(oop java_class, oop protection_domain);
271 static void set_class_loader(oop java_class, oop class_loader);
272 static void set_component_mirror(oop java_class, oop comp_mirror);
273 static void initialize_mirror_fields(InstanceKlass* ik, Handle mirror, Handle protection_domain,
274 Handle classData, TRAPS);
275 static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
276
277 static void set_modifiers(oop java_class, u2 value);
278 static void set_raw_access_flags(oop java_class, u2 value);
279 static void set_is_primitive(oop java_class);
280 static void release_set_array_klass(oop java_class, Klass* klass);
281
282 public:
283 static void allocate_fixup_lists();
284 static void compute_offsets();
285
286 // Instance creation
287 static void allocate_mirror(Klass* k, bool is_scratch, Handle protection_domain, Handle classData,
288 Handle& mirror, Handle& comp_mirror, TRAPS); // returns mirror and comp_mirror
289 static void create_mirror(Klass* k, Handle class_loader, Handle module,
290 Handle protection_domain, Handle classData, TRAPS);
291 static void fixup_mirror(Klass* k, TRAPS);
292 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
293
294 // Archiving
295 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
303 // Conversion -- java_class must not be null. The return value is null only if java_class is a primitive type.
304 static Klass* as_Klass(oop java_class);
305 static InstanceKlass* as_InstanceKlass(oop java_class);
306
307 static void set_klass(oop java_class, Klass* klass);
308 static BasicType as_BasicType(oop java_class, Klass** reference_klass = nullptr);
309 static Symbol* as_signature(oop java_class, bool intern_if_not_found);
310 static void print_signature(oop java_class, outputStream *st);
311 static const char* as_external_name(oop java_class);
312 // Testing
313 static bool is_instance(oop obj);
314
315 static bool is_primitive(oop java_class);
316 static BasicType primitive_type(oop java_class);
317 static oop primitive_mirror(BasicType t);
318 static Klass* array_klass_acquire(oop java_class);
319
320 // compiler support for class operations
321 static int klass_offset() { CHECK_INIT(_klass_offset); }
322 static int array_klass_offset() { CHECK_INIT(_array_klass_offset); }
323 // Support for classRedefinedCount field
324 static int classRedefinedCount(oop the_class_mirror);
325 static void set_classRedefinedCount(oop the_class_mirror, int value);
326
327 // Support for embedded per-class oops
328 static oop protection_domain(oop java_class);
329 static oop init_lock(oop java_class);
330 static void clear_init_lock(oop java_class) {
331 set_init_lock(java_class, nullptr);
332 }
333 static oop component_mirror(oop java_class);
334 static int component_mirror_offset() { return _component_mirror_offset; }
335 static objArrayOop signers(oop java_class);
336 static oop class_data(oop java_class);
337 static void set_class_data(oop java_class, oop classData);
338 static int reflection_data_offset() { return _reflectionData_offset; }
339
340 static oop class_loader(oop java_class);
341 static void set_module(oop java_class, oop module);
342 static oop module(oop java_class);
814 static void set_signature(oop constructor, oop value);
815 static void set_annotations(oop constructor, oop value);
816 static void set_parameter_annotations(oop method, oop value);
817
818 // Debugging
819 friend class JavaClasses;
820 };
821
822
823 // Interface to java.lang.reflect.Field objects
824
825 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
826 private:
827 // Note that to reduce dependencies on the JDK we compute these
828 // offsets at run-time.
829 static int _clazz_offset;
830 static int _name_offset;
831 static int _type_offset;
832 static int _slot_offset;
833 static int _modifiers_offset;
834 static int _trusted_final_offset;
835 static int _signature_offset;
836 static int _annotations_offset;
837
838 static void compute_offsets();
839
840 public:
841 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
842
843 // Allocation
844 static Handle create(TRAPS);
845
846 // Accessors
847 static oop clazz(oop reflect);
848 static void set_clazz(oop reflect, oop value);
849
850 static oop name(oop field);
851 static void set_name(oop field, oop value);
852
853 static oop type(oop field);
854 static void set_type(oop field, oop value);
855
856 static int slot(oop reflect);
857 static void set_slot(oop reflect, int value);
858
859 static int modifiers(oop field);
860 static void set_modifiers(oop field, int value);
861
862 static void set_trusted_final(oop field);
863
864 static void set_signature(oop constructor, oop value);
865 static void set_annotations(oop constructor, oop value);
866
867 // Debugging
868 friend class JavaClasses;
869 };
870
871 class java_lang_reflect_Parameter {
872 private:
873 // Note that to reduce dependencies on the JDK we compute these
874 // offsets at run-time.
875 static int _name_offset;
876 static int _modifiers_offset;
877 static int _index_offset;
878 static int _executable_offset;
879
880 static void compute_offsets();
881
882 public:
964
965 // Debugging
966 friend class JavaClasses;
967 };
968
969
970 // Interface to java.lang primitive type boxing objects:
971 // - java.lang.Boolean
972 // - java.lang.Character
973 // - java.lang.Float
974 // - java.lang.Double
975 // - java.lang.Byte
976 // - java.lang.Short
977 // - java.lang.Integer
978 // - java.lang.Long
979
980 // This could be separated out into 8 individual classes.
981
982 class java_lang_boxing_object: AllStatic {
983 private:
984 static int _value_offset;
985 static int _long_value_offset;
986
987 static void compute_offsets();
988 static oop initialize_and_allocate(BasicType type, TRAPS);
989 public:
990 // Allocation. Returns a boxed value, or null for invalid type.
991 static oop create(BasicType type, jvalue* value, TRAPS);
992 // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
993 static BasicType get_value(oop box, jvalue* value);
994 static BasicType set_value(oop box, jvalue* value);
995 static BasicType basic_type(oop box);
996 static bool is_instance(oop box) { return basic_type(box) != T_ILLEGAL; }
997 static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
998 static void print(oop box, outputStream* st) { jvalue value; print(get_value(box, &value), &value, st); }
999 static void print(BasicType type, jvalue* value, outputStream* st);
1000
1001 static int value_offset(BasicType type) {
1002 return is_double_word_type(type) ? _long_value_offset : _value_offset;
1003 }
1004
1005 static void serialize_offsets(SerializeClosure* f);
1006
1007 // Debugging
1008 friend class JavaClasses;
1009 };
1010
1011
1012
1013 // Interface to java.lang.ref.Reference objects
1014
1015 class java_lang_ref_Reference: AllStatic {
1016 static int _referent_offset;
1017 static int _queue_offset;
1018 static int _next_offset;
1019 static int _discovered_offset;
1020
1021 static bool _offsets_initialized;
1022
1232 static bool is_subclass(Klass* klass) {
1233 return vmClasses::VMStorage_klass() != nullptr &&
1234 klass->is_subclass_of(vmClasses::VMStorage_klass());
1235 }
1236 static bool is_instance(oop obj);
1237 };
1238
1239 class jdk_internal_foreign_abi_CallConv: AllStatic {
1240 friend class JavaClasses;
1241
1242 private:
1243 static int _argRegs_offset;
1244 static int _retRegs_offset;
1245
1246 static void compute_offsets();
1247
1248 public:
1249 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1250
1251 // Accessors
1252 static objArrayOop argRegs(oop entry);
1253 static objArrayOop retRegs(oop entry);
1254
1255 // Testers
1256 static bool is_subclass(Klass* klass) {
1257 return vmClasses::CallConv_klass() != nullptr &&
1258 klass->is_subclass_of(vmClasses::CallConv_klass());
1259 }
1260 static bool is_instance(oop obj);
1261 };
1262
1263 // Interface to java.lang.invoke.MemberName objects
1264 // (These are a private interface for Java code to query the class hierarchy.)
1265
1266 #define RESOLVEDMETHOD_INJECTED_FIELDS(macro) \
1267 macro(java_lang_invoke_ResolvedMethodName, vmtarget, intptr_signature, false)
1268
1269 class java_lang_invoke_ResolvedMethodName : AllStatic {
1270 friend class JavaClasses;
1271
1272 static int _vmtarget_offset;
1273 static int _vmholder_offset;
1330 static void set_flags(oop mname, int flags);
1331
1332 // Link through ResolvedMethodName field to get Method*
1333 static Method* vmtarget(oop mname);
1334 static void set_method(oop mname, oop method);
1335
1336 static intptr_t vmindex(oop mname);
1337 static void set_vmindex(oop mname, intptr_t index);
1338
1339 // Testers
1340 static bool is_subclass(Klass* klass) {
1341 return klass->is_subclass_of(vmClasses::MemberName_klass());
1342 }
1343 static bool is_instance(oop obj);
1344
1345 static bool is_method(oop obj);
1346
1347 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
1348 enum {
1349 MN_IS_METHOD = 0x00010000, // method (not constructor)
1350 MN_IS_CONSTRUCTOR = 0x00020000, // constructor
1351 MN_IS_FIELD = 0x00040000, // field
1352 MN_IS_TYPE = 0x00080000, // nested type
1353 MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected
1354 MN_TRUSTED_FINAL = 0x00200000, // trusted final field
1355 MN_HIDDEN_MEMBER = 0x00400000, // @Hidden annotation detected
1356 MN_REFERENCE_KIND_SHIFT = 24, // refKind
1357 MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT,
1358 MN_NESTMATE_CLASS = 0x00000001,
1359 MN_HIDDEN_CLASS = 0x00000002,
1360 MN_STRONG_LOADER_LINK = 0x00000004,
1361 MN_ACCESS_VM_ANNOTATIONS = 0x00000008,
1362 // Lookup modes
1363 MN_MODULE_MODE = 0x00000010,
1364 MN_UNCONDITIONAL_MODE = 0x00000020,
1365 MN_TRUSTED_MODE = -1
1366 };
1367
1368 // Accessors for code generation:
1369 static int clazz_offset() { CHECK_INIT(_clazz_offset); }
1370 static int type_offset() { CHECK_INIT(_type_offset); }
1371 static int flags_offset() { CHECK_INIT(_flags_offset); }
1372 static int method_offset() { CHECK_INIT(_method_offset); }
1373 static int vmindex_offset() { CHECK_INIT(_vmindex_offset); }
1374 };
1375
1376
1377 // Interface to java.lang.invoke.MethodType objects
1841 class java_lang_Short_ShortCache : AllStatic {
1842 private:
1843 static int _static_cache_offset;
1844 public:
1845 static Symbol* symbol();
1846 static void compute_offsets(InstanceKlass* k);
1847 static objArrayOop cache(InstanceKlass *k);
1848 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1849 };
1850
1851 class java_lang_Byte_ByteCache : AllStatic {
1852 private:
1853 static int _static_cache_offset;
1854 public:
1855 static Symbol* symbol();
1856 static void compute_offsets(InstanceKlass* k);
1857 static objArrayOop cache(InstanceKlass *k);
1858 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1859 };
1860
1861
1862 // Interface to java.lang.InternalError objects
1863
1864 #define INTERNALERROR_INJECTED_FIELDS(macro) \
1865 macro(java_lang_InternalError, during_unsafe_access, bool_signature, false)
1866
1867 class java_lang_InternalError : AllStatic {
1868 private:
1869 static int _during_unsafe_access_offset;
1870 public:
1871 static jboolean during_unsafe_access(oop internal_error);
1872 static void set_during_unsafe_access(oop internal_error);
1873 static void compute_offsets();
1874 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1875 };
1876
1877 // Use to declare fields that need to be injected into Java classes
1878 // for the JVM to use. The name_index and signature_index are
1879 // declared in vmSymbols. The may_be_java flag is used to declare
1880 // fields that might already exist in Java but should be injected if
1881 // they don't. Otherwise the field is unconditionally injected and
|
196 }
197
198 static unsigned int hash_code(oop java_string);
199 static unsigned int hash_code_noupdate(oop java_string);
200
201 // Compare strings (of different types/encodings), length is the string (array) length
202 static bool equals(oop java_string, const jchar* chars, int len);
203 static bool equals(oop java_string, const char* utf8_str, size_t utf8_len);
204 static bool equals(oop str1, oop str2);
205 static inline bool value_equals(typeArrayOop str_value1, typeArrayOop str_value2);
206
207 // Conversion between '.' and '/' formats, and allocate a String from the result.
208 static Handle externalize_classname(Symbol* java_name, TRAPS);
209
210 // Conversion
211 static Symbol* as_symbol(oop java_string);
212 static Symbol* as_symbol_or_null(oop java_string);
213
214 // Tester
215 static inline bool is_instance(oop obj);
216 static inline bool is_instance_without_asserts(oop obj);
217
218 // Debugging
219 static void print(oop java_string, outputStream* st, int max_length = MaxStringPrintSize);
220 friend class JavaClasses;
221 friend class StringTable;
222 };
223
224
225 // Interface to java.lang.Class objects
226
227 #define CLASS_INJECTED_FIELDS(macro) \
228 macro(java_lang_Class, klass, intptr_signature, false) \
229 macro(java_lang_Class, array_klass, intptr_signature, false) \
230 macro(java_lang_Class, oop_size, int_signature, false) \
231 macro(java_lang_Class, static_oop_field_count, int_signature, false) \
232 macro(java_lang_Class, source_file, object_signature, false) \
233 macro(java_lang_Class, init_lock, object_signature, false)
234
235 class java_lang_Class : AllStatic {
236 friend class VMStructs;
237 friend class JVMCIVMStructs;
238 friend class HeapShared;
239
240 private:
241
242 // The fake offsets are added by the class loader when java.lang.Class is loaded
243
244 static int _klass_offset;
245 static int _array_klass_offset;
246
247 static int _oop_size_offset;
248 static int _static_oop_field_count_offset;
249
250 static int _protection_domain_offset;
251 static int _init_lock_offset;
252 static int _signers_offset;
253 static int _class_loader_offset;
254 static int _module_offset;
255 static int _component_mirror_offset;
256
257 static int _name_offset;
258 static int _source_file_offset;
259 static int _classData_offset;
260 static int _classRedefinedCount_offset;
261 static int _reflectionData_offset;
262 static int _modifiers_offset;
263 static int _is_primitive_offset;
264 static int _is_identity_offset;
265 static int _raw_access_flags_offset;
266
267 static bool _offsets_computed;
268
269 static GrowableArray<Klass*>* _fixup_mirror_list;
270 static GrowableArray<Klass*>* _fixup_module_field_list;
271
272 static void set_init_lock(oop java_class, oop init_lock);
273 static void set_protection_domain(oop java_class, oop protection_domain);
274 static void set_class_loader(oop java_class, oop class_loader);
275 static void set_component_mirror(oop java_class, oop comp_mirror);
276 static void initialize_mirror_fields(InstanceKlass* ik, Handle mirror, Handle protection_domain,
277 Handle classData, TRAPS);
278 static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
279 static void set_is_identity(oop java_class, bool value);
280
281 static void set_modifiers(oop java_class, u2 value);
282 static void set_raw_access_flags(oop java_class, u2 value);
283 static void set_is_primitive(oop java_class);
284 static void release_set_array_klass(oop java_class, Klass* klass);
285
286 public:
287 static void allocate_fixup_lists();
288 static void compute_offsets();
289
290 // Instance creation
291 static void allocate_mirror(Klass* k, bool is_scratch, Handle protection_domain, Handle classData,
292 Handle& mirror, Handle& comp_mirror, TRAPS); // returns mirror and comp_mirror
293 static void create_mirror(Klass* k, Handle class_loader, Handle module,
294 Handle protection_domain, Handle classData, TRAPS);
295 static void fixup_mirror(Klass* k, TRAPS);
296 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
297
298 // Archiving
299 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
307 // Conversion -- java_class must not be null. The return value is null only if java_class is a primitive type.
308 static Klass* as_Klass(oop java_class);
309 static InstanceKlass* as_InstanceKlass(oop java_class);
310
311 static void set_klass(oop java_class, Klass* klass);
312 static BasicType as_BasicType(oop java_class, Klass** reference_klass = nullptr);
313 static Symbol* as_signature(oop java_class, bool intern_if_not_found);
314 static void print_signature(oop java_class, outputStream *st);
315 static const char* as_external_name(oop java_class);
316 // Testing
317 static bool is_instance(oop obj);
318
319 static bool is_primitive(oop java_class);
320 static BasicType primitive_type(oop java_class);
321 static oop primitive_mirror(BasicType t);
322 static Klass* array_klass_acquire(oop java_class);
323
324 // compiler support for class operations
325 static int klass_offset() { CHECK_INIT(_klass_offset); }
326 static int array_klass_offset() { CHECK_INIT(_array_klass_offset); }
327
328 // Support for classRedefinedCount field
329 static int classRedefinedCount(oop the_class_mirror);
330 static void set_classRedefinedCount(oop the_class_mirror, int value);
331
332 // Support for embedded per-class oops
333 static oop protection_domain(oop java_class);
334 static oop init_lock(oop java_class);
335 static void clear_init_lock(oop java_class) {
336 set_init_lock(java_class, nullptr);
337 }
338 static oop component_mirror(oop java_class);
339 static int component_mirror_offset() { return _component_mirror_offset; }
340 static objArrayOop signers(oop java_class);
341 static oop class_data(oop java_class);
342 static void set_class_data(oop java_class, oop classData);
343 static int reflection_data_offset() { return _reflectionData_offset; }
344
345 static oop class_loader(oop java_class);
346 static void set_module(oop java_class, oop module);
347 static oop module(oop java_class);
819 static void set_signature(oop constructor, oop value);
820 static void set_annotations(oop constructor, oop value);
821 static void set_parameter_annotations(oop method, oop value);
822
823 // Debugging
824 friend class JavaClasses;
825 };
826
827
828 // Interface to java.lang.reflect.Field objects
829
830 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
831 private:
832 // Note that to reduce dependencies on the JDK we compute these
833 // offsets at run-time.
834 static int _clazz_offset;
835 static int _name_offset;
836 static int _type_offset;
837 static int _slot_offset;
838 static int _modifiers_offset;
839 static int _flags_offset;
840 static int _signature_offset;
841 static int _annotations_offset;
842
843 static void compute_offsets();
844
845 public:
846 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
847
848 // Allocation
849 static Handle create(TRAPS);
850
851 // Accessors
852 static oop clazz(oop reflect);
853 static void set_clazz(oop reflect, oop value);
854
855 static oop name(oop field);
856 static void set_name(oop field, oop value);
857
858 static oop type(oop field);
859 static void set_type(oop field, oop value);
860
861 static int slot(oop reflect);
862 static void set_slot(oop reflect, int value);
863
864 static int modifiers(oop field);
865 static void set_modifiers(oop field, int value);
866
867 static void set_flags(oop field, int value);
868
869 static void set_signature(oop constructor, oop value);
870 static void set_annotations(oop constructor, oop value);
871
872 // Debugging
873 friend class JavaClasses;
874 };
875
876 class java_lang_reflect_Parameter {
877 private:
878 // Note that to reduce dependencies on the JDK we compute these
879 // offsets at run-time.
880 static int _name_offset;
881 static int _modifiers_offset;
882 static int _index_offset;
883 static int _executable_offset;
884
885 static void compute_offsets();
886
887 public:
969
970 // Debugging
971 friend class JavaClasses;
972 };
973
974
975 // Interface to java.lang primitive type boxing objects:
976 // - java.lang.Boolean
977 // - java.lang.Character
978 // - java.lang.Float
979 // - java.lang.Double
980 // - java.lang.Byte
981 // - java.lang.Short
982 // - java.lang.Integer
983 // - java.lang.Long
984
985 // This could be separated out into 8 individual classes.
986
987 class java_lang_boxing_object: AllStatic {
988 private:
989 static int* _offsets;
990
991 static void compute_offsets();
992 static oop initialize_and_allocate(BasicType type, TRAPS);
993 public:
994 // Allocation. Returns a boxed value, or null for invalid type.
995 static oop create(BasicType type, jvalue* value, TRAPS);
996 // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
997 static BasicType get_value(oop box, jvalue* value);
998 static BasicType set_value(oop box, jvalue* value);
999 static BasicType basic_type(oop box);
1000 static bool is_instance(oop box) { return basic_type(box) != T_ILLEGAL; }
1001 static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
1002 static void print(oop box, outputStream* st) { jvalue value; print(get_value(box, &value), &value, st); }
1003 static void print(BasicType type, jvalue* value, outputStream* st);
1004
1005 static int value_offset(BasicType type) {
1006 assert(type >= T_BOOLEAN && type <= T_LONG, "BasicType out of range");
1007 assert(_offsets != nullptr, "Uninitialized offsets");
1008 return _offsets[type - T_BOOLEAN];
1009 }
1010
1011 static void serialize_offsets(SerializeClosure* f);
1012
1013 // Debugging
1014 friend class JavaClasses;
1015 };
1016
1017
1018
1019 // Interface to java.lang.ref.Reference objects
1020
1021 class java_lang_ref_Reference: AllStatic {
1022 static int _referent_offset;
1023 static int _queue_offset;
1024 static int _next_offset;
1025 static int _discovered_offset;
1026
1027 static bool _offsets_initialized;
1028
1238 static bool is_subclass(Klass* klass) {
1239 return vmClasses::VMStorage_klass() != nullptr &&
1240 klass->is_subclass_of(vmClasses::VMStorage_klass());
1241 }
1242 static bool is_instance(oop obj);
1243 };
1244
1245 class jdk_internal_foreign_abi_CallConv: AllStatic {
1246 friend class JavaClasses;
1247
1248 private:
1249 static int _argRegs_offset;
1250 static int _retRegs_offset;
1251
1252 static void compute_offsets();
1253
1254 public:
1255 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1256
1257 // Accessors
1258 static refArrayOop argRegs(oop entry);
1259 static refArrayOop retRegs(oop entry);
1260
1261 // Testers
1262 static bool is_subclass(Klass* klass) {
1263 return vmClasses::CallConv_klass() != nullptr &&
1264 klass->is_subclass_of(vmClasses::CallConv_klass());
1265 }
1266 static bool is_instance(oop obj);
1267 };
1268
1269 // Interface to java.lang.invoke.MemberName objects
1270 // (These are a private interface for Java code to query the class hierarchy.)
1271
1272 #define RESOLVEDMETHOD_INJECTED_FIELDS(macro) \
1273 macro(java_lang_invoke_ResolvedMethodName, vmtarget, intptr_signature, false)
1274
1275 class java_lang_invoke_ResolvedMethodName : AllStatic {
1276 friend class JavaClasses;
1277
1278 static int _vmtarget_offset;
1279 static int _vmholder_offset;
1336 static void set_flags(oop mname, int flags);
1337
1338 // Link through ResolvedMethodName field to get Method*
1339 static Method* vmtarget(oop mname);
1340 static void set_method(oop mname, oop method);
1341
1342 static intptr_t vmindex(oop mname);
1343 static void set_vmindex(oop mname, intptr_t index);
1344
1345 // Testers
1346 static bool is_subclass(Klass* klass) {
1347 return klass->is_subclass_of(vmClasses::MemberName_klass());
1348 }
1349 static bool is_instance(oop obj);
1350
1351 static bool is_method(oop obj);
1352
1353 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
1354 enum {
1355 MN_IS_METHOD = 0x00010000, // method (not constructor)
1356 MN_IS_OBJECT_CONSTRUCTOR = 0x00020000, // constructor
1357 MN_IS_FIELD = 0x00040000, // field
1358 MN_IS_TYPE = 0x00080000, // nested type
1359 MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected
1360 MN_TRUSTED_FINAL = 0x00200000, // trusted final field
1361 MN_HIDDEN_MEMBER = 0x00400000, // @Hidden annotation detected
1362 MN_NULL_RESTRICTED_FIELD = 0x00800000, // null-restricted field
1363 MN_REFERENCE_KIND_SHIFT = 24, // refKind
1364 MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT, // 4 bits
1365 MN_LAYOUT_SHIFT = 28, // field layout
1366 MN_LAYOUT_MASK = 0x70000000 >> MN_LAYOUT_SHIFT, // 3 bits
1367 MN_NESTMATE_CLASS = 0x00000001,
1368 MN_HIDDEN_CLASS = 0x00000002,
1369 MN_STRONG_LOADER_LINK = 0x00000004,
1370 MN_ACCESS_VM_ANNOTATIONS = 0x00000008,
1371 // Lookup modes
1372 MN_MODULE_MODE = 0x00000010,
1373 MN_UNCONDITIONAL_MODE = 0x00000020,
1374 MN_TRUSTED_MODE = -1
1375 };
1376
1377 // Accessors for code generation:
1378 static int clazz_offset() { CHECK_INIT(_clazz_offset); }
1379 static int type_offset() { CHECK_INIT(_type_offset); }
1380 static int flags_offset() { CHECK_INIT(_flags_offset); }
1381 static int method_offset() { CHECK_INIT(_method_offset); }
1382 static int vmindex_offset() { CHECK_INIT(_vmindex_offset); }
1383 };
1384
1385
1386 // Interface to java.lang.invoke.MethodType objects
1850 class java_lang_Short_ShortCache : AllStatic {
1851 private:
1852 static int _static_cache_offset;
1853 public:
1854 static Symbol* symbol();
1855 static void compute_offsets(InstanceKlass* k);
1856 static objArrayOop cache(InstanceKlass *k);
1857 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1858 };
1859
1860 class java_lang_Byte_ByteCache : AllStatic {
1861 private:
1862 static int _static_cache_offset;
1863 public:
1864 static Symbol* symbol();
1865 static void compute_offsets(InstanceKlass* k);
1866 static objArrayOop cache(InstanceKlass *k);
1867 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1868 };
1869
1870 // Interface to java.lang.InternalError objects
1871
1872 #define INTERNALERROR_INJECTED_FIELDS(macro) \
1873 macro(java_lang_InternalError, during_unsafe_access, bool_signature, false)
1874
1875 class java_lang_InternalError : AllStatic {
1876 private:
1877 static int _during_unsafe_access_offset;
1878 public:
1879 static jboolean during_unsafe_access(oop internal_error);
1880 static void set_during_unsafe_access(oop internal_error);
1881 static void compute_offsets();
1882 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1883 };
1884
1885 // Use to declare fields that need to be injected into Java classes
1886 // for the JVM to use. The name_index and signature_index are
1887 // declared in vmSymbols. The may_be_java flag is used to declare
1888 // fields that might already exist in Java but should be injected if
1889 // they don't. Otherwise the field is unconditionally injected and
|