218 class java_lang_Class : AllStatic {
219 friend class VMStructs;
220 friend class JVMCIVMStructs;
221
222 private:
223
224 // The fake offsets are added by the class loader when java.lang.Class is loaded
225
226 static int _klass_offset;
227 static int _array_klass_offset;
228
229 static int _oop_size_offset;
230 static int _static_oop_field_count_offset;
231
232 static int _protection_domain_offset;
233 static int _init_lock_offset;
234 static int _signers_offset;
235 static int _class_loader_offset;
236 static int _module_offset;
237 static int _component_mirror_offset;
238 static int _name_offset;
239 static int _source_file_offset;
240 static int _classData_offset;
241 static int _classRedefinedCount_offset;
242
243 static bool _offsets_computed;
244
245 static GrowableArray<Klass*>* _fixup_mirror_list;
246 static GrowableArray<Klass*>* _fixup_module_field_list;
247
248 static void set_init_lock(oop java_class, oop init_lock);
249 static void set_protection_domain(oop java_class, oop protection_domain);
250 static void set_class_loader(oop java_class, oop class_loader);
251 static void set_component_mirror(oop java_class, oop comp_mirror);
252 static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain,
253 Handle classData, TRAPS);
254 static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
255 public:
256 static void allocate_fixup_lists();
257 static void compute_offsets();
258
259 // Instance creation
260 static void allocate_mirror(Klass* k, bool is_scratch, Handle protection_domain, Handle classData,
261 Handle& mirror, Handle& comp_mirror, TRAPS); // returns mirror and comp_mirror
262 static void create_mirror(Klass* k, Handle class_loader, Handle module,
263 Handle protection_domain, Handle classData, TRAPS);
264 static void fixup_mirror(Klass* k, TRAPS);
265 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
266
267 // Archiving
268 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
269 static void create_scratch_mirror(Klass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
270 static bool restore_archived_mirror(Klass *k, Handle class_loader, Handle module,
271 Handle protection_domain,
275
276 // Conversion
277 static Klass* as_Klass(oop java_class);
278 static void set_klass(oop java_class, Klass* klass);
279 static BasicType as_BasicType(oop java_class, Klass** reference_klass = nullptr);
280 static Symbol* as_signature(oop java_class, bool intern_if_not_found);
281 static void print_signature(oop java_class, outputStream *st);
282 static const char* as_external_name(oop java_class);
283 // Testing
284 static bool is_instance(oop obj);
285
286 static bool is_primitive(oop java_class);
287 static BasicType primitive_type(oop java_class);
288 static oop primitive_mirror(BasicType t);
289 // JVM_NewArray support
290 static Klass* array_klass_acquire(oop java_class);
291 static void release_set_array_klass(oop java_class, Klass* klass);
292 // compiler support for class operations
293 static int klass_offset() { CHECK_INIT(_klass_offset); }
294 static int array_klass_offset() { CHECK_INIT(_array_klass_offset); }
295 // Support for classRedefinedCount field
296 static int classRedefinedCount(oop the_class_mirror);
297 static void set_classRedefinedCount(oop the_class_mirror, int value);
298
299 // Support for embedded per-class oops
300 static oop protection_domain(oop java_class);
301 static oop init_lock(oop java_class);
302 static void clear_init_lock(oop java_class) {
303 set_init_lock(java_class, nullptr);
304 }
305 static oop component_mirror(oop java_class);
306 static objArrayOop signers(oop java_class);
307 static oop class_data(oop java_class);
308 static void set_class_data(oop java_class, oop classData);
309
310 static int component_mirror_offset() { return _component_mirror_offset; }
311
312 static oop class_loader(oop java_class);
313 static void set_module(oop java_class, oop module);
314 static oop module(oop java_class);
315
316 static oop name(Handle java_class, TRAPS);
317
318 static oop source_file(oop java_class);
319 static void set_source_file(oop java_class, oop source_file);
320
321 static size_t oop_size(oop java_class);
322 static void set_oop_size(HeapWord* java_class, size_t size);
323 static int static_oop_field_count(oop java_class);
324 static void set_static_oop_field_count(oop java_class, int size);
325
326 static GrowableArray<Klass*>* fixup_mirror_list() {
327 return _fixup_mirror_list;
328 }
329 static void set_fixup_mirror_list(GrowableArray<Klass*>* v) {
330 _fixup_mirror_list = v;
331 }
756 static void set_signature(oop constructor, oop value);
757 static void set_annotations(oop constructor, oop value);
758 static void set_parameter_annotations(oop method, oop value);
759
760 // Debugging
761 friend class JavaClasses;
762 };
763
764
765 // Interface to java.lang.reflect.Field objects
766
767 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
768 private:
769 // Note that to reduce dependencies on the JDK we compute these
770 // offsets at run-time.
771 static int _clazz_offset;
772 static int _name_offset;
773 static int _type_offset;
774 static int _slot_offset;
775 static int _modifiers_offset;
776 static int _trusted_final_offset;
777 static int _signature_offset;
778 static int _annotations_offset;
779
780 static void compute_offsets();
781
782 public:
783 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
784
785 // Allocation
786 static Handle create(TRAPS);
787
788 // Accessors
789 static oop clazz(oop reflect);
790 static void set_clazz(oop reflect, oop value);
791
792 static oop name(oop field);
793 static void set_name(oop field, oop value);
794
795 static oop type(oop field);
796 static void set_type(oop field, oop value);
797
798 static int slot(oop reflect);
799 static void set_slot(oop reflect, int value);
800
801 static int modifiers(oop field);
802 static void set_modifiers(oop field, int value);
803
804 static void set_trusted_final(oop field);
805
806 static void set_signature(oop constructor, oop value);
807 static void set_annotations(oop constructor, oop value);
808
809 // Debugging
810 friend class JavaClasses;
811 };
812
813 class java_lang_reflect_Parameter {
814 private:
815 // Note that to reduce dependencies on the JDK we compute these
816 // offsets at run-time.
817 static int _name_offset;
818 static int _modifiers_offset;
819 static int _index_offset;
820 static int _executable_offset;
821
822 static void compute_offsets();
823
824 public:
1283 static void set_flags(oop mname, int flags);
1284
1285 // Link through ResolvedMethodName field to get Method*
1286 static Method* vmtarget(oop mname);
1287 static void set_method(oop mname, oop method);
1288
1289 static intptr_t vmindex(oop mname);
1290 static void set_vmindex(oop mname, intptr_t index);
1291
1292 // Testers
1293 static bool is_subclass(Klass* klass) {
1294 return klass->is_subclass_of(vmClasses::MemberName_klass());
1295 }
1296 static bool is_instance(oop obj);
1297
1298 static bool is_method(oop obj);
1299
1300 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
1301 enum {
1302 MN_IS_METHOD = 0x00010000, // method (not constructor)
1303 MN_IS_CONSTRUCTOR = 0x00020000, // constructor
1304 MN_IS_FIELD = 0x00040000, // field
1305 MN_IS_TYPE = 0x00080000, // nested type
1306 MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected
1307 MN_TRUSTED_FINAL = 0x00200000, // trusted final field
1308 MN_HIDDEN_MEMBER = 0x00400000, // @Hidden annotation detected
1309 MN_REFERENCE_KIND_SHIFT = 24, // refKind
1310 MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT,
1311 MN_NESTMATE_CLASS = 0x00000001,
1312 MN_HIDDEN_CLASS = 0x00000002,
1313 MN_STRONG_LOADER_LINK = 0x00000004,
1314 MN_ACCESS_VM_ANNOTATIONS = 0x00000008,
1315 // Lookup modes
1316 MN_MODULE_MODE = 0x00000010,
1317 MN_UNCONDITIONAL_MODE = 0x00000020,
1318 MN_TRUSTED_MODE = -1
1319 };
1320
1321 // Accessors for code generation:
1322 static int clazz_offset() { CHECK_INIT(_clazz_offset); }
1323 static int type_offset() { CHECK_INIT(_type_offset); }
1324 static int flags_offset() { CHECK_INIT(_flags_offset); }
1325 static int method_offset() { CHECK_INIT(_method_offset); }
1326 static int vmindex_offset() { CHECK_INIT(_vmindex_offset); }
1327 };
1328
1329
1330 // Interface to java.lang.invoke.MethodType objects
1854 class java_lang_Short_ShortCache : AllStatic {
1855 private:
1856 static int _static_cache_offset;
1857 public:
1858 static Symbol* symbol();
1859 static void compute_offsets(InstanceKlass* k);
1860 static objArrayOop cache(InstanceKlass *k);
1861 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1862 };
1863
1864 class java_lang_Byte_ByteCache : AllStatic {
1865 private:
1866 static int _static_cache_offset;
1867 public:
1868 static Symbol* symbol();
1869 static void compute_offsets(InstanceKlass* k);
1870 static objArrayOop cache(InstanceKlass *k);
1871 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1872 };
1873
1874
1875 // Interface to java.lang.InternalError objects
1876
1877 #define INTERNALERROR_INJECTED_FIELDS(macro) \
1878 macro(java_lang_InternalError, during_unsafe_access, bool_signature, false)
1879
1880 class java_lang_InternalError : AllStatic {
1881 private:
1882 static int _during_unsafe_access_offset;
1883 public:
1884 static jboolean during_unsafe_access(oop internal_error);
1885 static void set_during_unsafe_access(oop internal_error);
1886 static void compute_offsets();
1887 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1888 };
1889
1890 // Use to declare fields that need to be injected into Java classes
1891 // for the JVM to use. The name_index and signature_index are
1892 // declared in vmSymbols. The may_be_java flag is used to declare
1893 // fields that might already exist in Java but should be injected if
1894 // they don't. Otherwise the field is unconditionally injected and
|
218 class java_lang_Class : AllStatic {
219 friend class VMStructs;
220 friend class JVMCIVMStructs;
221
222 private:
223
224 // The fake offsets are added by the class loader when java.lang.Class is loaded
225
226 static int _klass_offset;
227 static int _array_klass_offset;
228
229 static int _oop_size_offset;
230 static int _static_oop_field_count_offset;
231
232 static int _protection_domain_offset;
233 static int _init_lock_offset;
234 static int _signers_offset;
235 static int _class_loader_offset;
236 static int _module_offset;
237 static int _component_mirror_offset;
238
239 static int _name_offset;
240 static int _source_file_offset;
241 static int _classData_offset;
242 static int _classRedefinedCount_offset;
243
244 static bool _offsets_computed;
245
246 static GrowableArray<Klass*>* _fixup_mirror_list;
247 static GrowableArray<Klass*>* _fixup_module_field_list;
248
249 static void set_init_lock(oop java_class, oop init_lock);
250 static void set_protection_domain(oop java_class, oop protection_domain);
251 static void set_class_loader(oop java_class, oop class_loader);
252 static void set_component_mirror(oop java_class, oop comp_mirror);
253
254 static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain,
255 Handle classData, TRAPS);
256 static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
257 public:
258 static void allocate_fixup_lists();
259 static void compute_offsets();
260
261 // Instance creation
262 static void allocate_mirror(Klass* k, bool is_scratch, Handle protection_domain, Handle classData,
263 Handle& mirror, Handle& comp_mirror, TRAPS); // returns mirror and comp_mirror
264 static void create_mirror(Klass* k, Handle class_loader, Handle module,
265 Handle protection_domain, Handle classData, TRAPS);
266 static void fixup_mirror(Klass* k, TRAPS);
267 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
268
269 // Archiving
270 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
271 static void create_scratch_mirror(Klass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
272 static bool restore_archived_mirror(Klass *k, Handle class_loader, Handle module,
273 Handle protection_domain,
277
278 // Conversion
279 static Klass* as_Klass(oop java_class);
280 static void set_klass(oop java_class, Klass* klass);
281 static BasicType as_BasicType(oop java_class, Klass** reference_klass = nullptr);
282 static Symbol* as_signature(oop java_class, bool intern_if_not_found);
283 static void print_signature(oop java_class, outputStream *st);
284 static const char* as_external_name(oop java_class);
285 // Testing
286 static bool is_instance(oop obj);
287
288 static bool is_primitive(oop java_class);
289 static BasicType primitive_type(oop java_class);
290 static oop primitive_mirror(BasicType t);
291 // JVM_NewArray support
292 static Klass* array_klass_acquire(oop java_class);
293 static void release_set_array_klass(oop java_class, Klass* klass);
294 // compiler support for class operations
295 static int klass_offset() { CHECK_INIT(_klass_offset); }
296 static int array_klass_offset() { CHECK_INIT(_array_klass_offset); }
297 static int component_mirror_offset() { CHECK_INIT(_component_mirror_offset); }
298
299 // Support for classRedefinedCount field
300 static int classRedefinedCount(oop the_class_mirror);
301 static void set_classRedefinedCount(oop the_class_mirror, int value);
302
303 // Support for embedded per-class oops
304 static oop protection_domain(oop java_class);
305 static oop init_lock(oop java_class);
306 static void clear_init_lock(oop java_class) {
307 set_init_lock(java_class, nullptr);
308 }
309 static oop component_mirror(oop java_class);
310 static objArrayOop signers(oop java_class);
311 static oop class_data(oop java_class);
312 static void set_class_data(oop java_class, oop classData);
313
314 static oop class_loader(oop java_class);
315 static void set_module(oop java_class, oop module);
316 static oop module(oop java_class);
317
318 static oop name(Handle java_class, TRAPS);
319
320 static oop source_file(oop java_class);
321 static void set_source_file(oop java_class, oop source_file);
322
323 static size_t oop_size(oop java_class);
324 static void set_oop_size(HeapWord* java_class, size_t size);
325 static int static_oop_field_count(oop java_class);
326 static void set_static_oop_field_count(oop java_class, int size);
327
328 static GrowableArray<Klass*>* fixup_mirror_list() {
329 return _fixup_mirror_list;
330 }
331 static void set_fixup_mirror_list(GrowableArray<Klass*>* v) {
332 _fixup_mirror_list = v;
333 }
758 static void set_signature(oop constructor, oop value);
759 static void set_annotations(oop constructor, oop value);
760 static void set_parameter_annotations(oop method, oop value);
761
762 // Debugging
763 friend class JavaClasses;
764 };
765
766
767 // Interface to java.lang.reflect.Field objects
768
769 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
770 private:
771 // Note that to reduce dependencies on the JDK we compute these
772 // offsets at run-time.
773 static int _clazz_offset;
774 static int _name_offset;
775 static int _type_offset;
776 static int _slot_offset;
777 static int _modifiers_offset;
778 static int _flags_offset;
779 static int _signature_offset;
780 static int _annotations_offset;
781
782 static void compute_offsets();
783
784 public:
785 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
786
787 // Allocation
788 static Handle create(TRAPS);
789
790 // Accessors
791 static oop clazz(oop reflect);
792 static void set_clazz(oop reflect, oop value);
793
794 static oop name(oop field);
795 static void set_name(oop field, oop value);
796
797 static oop type(oop field);
798 static void set_type(oop field, oop value);
799
800 static int slot(oop reflect);
801 static void set_slot(oop reflect, int value);
802
803 static int modifiers(oop field);
804 static void set_modifiers(oop field, int value);
805
806 static void set_flags(oop field, int value);
807
808 static void set_signature(oop constructor, oop value);
809 static void set_annotations(oop constructor, oop value);
810
811 // Debugging
812 friend class JavaClasses;
813 };
814
815 class java_lang_reflect_Parameter {
816 private:
817 // Note that to reduce dependencies on the JDK we compute these
818 // offsets at run-time.
819 static int _name_offset;
820 static int _modifiers_offset;
821 static int _index_offset;
822 static int _executable_offset;
823
824 static void compute_offsets();
825
826 public:
1285 static void set_flags(oop mname, int flags);
1286
1287 // Link through ResolvedMethodName field to get Method*
1288 static Method* vmtarget(oop mname);
1289 static void set_method(oop mname, oop method);
1290
1291 static intptr_t vmindex(oop mname);
1292 static void set_vmindex(oop mname, intptr_t index);
1293
1294 // Testers
1295 static bool is_subclass(Klass* klass) {
1296 return klass->is_subclass_of(vmClasses::MemberName_klass());
1297 }
1298 static bool is_instance(oop obj);
1299
1300 static bool is_method(oop obj);
1301
1302 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
1303 enum {
1304 MN_IS_METHOD = 0x00010000, // method (not constructor)
1305 MN_IS_OBJECT_CONSTRUCTOR = 0x00020000, // constructor
1306 MN_IS_FIELD = 0x00040000, // field
1307 MN_IS_TYPE = 0x00080000, // nested type
1308 MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected
1309 MN_TRUSTED_FINAL = 0x00200000, // trusted final field
1310 MN_HIDDEN_MEMBER = 0x00400000, // @Hidden annotation detected
1311 MN_FLAT_FIELD = 0x00800000, // flat field
1312 MN_NULL_RESTRICTED_FIELD = 0x01000000, // null-restricted field
1313 MN_REFERENCE_KIND_SHIFT = 26, // refKind
1314 MN_REFERENCE_KIND_MASK = 0x3C000000 >> MN_REFERENCE_KIND_SHIFT,
1315 MN_NESTMATE_CLASS = 0x00000001,
1316 MN_HIDDEN_CLASS = 0x00000002,
1317 MN_STRONG_LOADER_LINK = 0x00000004,
1318 MN_ACCESS_VM_ANNOTATIONS = 0x00000008,
1319 // Lookup modes
1320 MN_MODULE_MODE = 0x00000010,
1321 MN_UNCONDITIONAL_MODE = 0x00000020,
1322 MN_TRUSTED_MODE = -1
1323 };
1324
1325 // Accessors for code generation:
1326 static int clazz_offset() { CHECK_INIT(_clazz_offset); }
1327 static int type_offset() { CHECK_INIT(_type_offset); }
1328 static int flags_offset() { CHECK_INIT(_flags_offset); }
1329 static int method_offset() { CHECK_INIT(_method_offset); }
1330 static int vmindex_offset() { CHECK_INIT(_vmindex_offset); }
1331 };
1332
1333
1334 // Interface to java.lang.invoke.MethodType objects
1858 class java_lang_Short_ShortCache : AllStatic {
1859 private:
1860 static int _static_cache_offset;
1861 public:
1862 static Symbol* symbol();
1863 static void compute_offsets(InstanceKlass* k);
1864 static objArrayOop cache(InstanceKlass *k);
1865 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1866 };
1867
1868 class java_lang_Byte_ByteCache : AllStatic {
1869 private:
1870 static int _static_cache_offset;
1871 public:
1872 static Symbol* symbol();
1873 static void compute_offsets(InstanceKlass* k);
1874 static objArrayOop cache(InstanceKlass *k);
1875 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1876 };
1877
1878 // Interface to java.lang.InternalError objects
1879
1880 #define INTERNALERROR_INJECTED_FIELDS(macro) \
1881 macro(java_lang_InternalError, during_unsafe_access, bool_signature, false)
1882
1883 class java_lang_InternalError : AllStatic {
1884 private:
1885 static int _during_unsafe_access_offset;
1886 public:
1887 static jboolean during_unsafe_access(oop internal_error);
1888 static void set_during_unsafe_access(oop internal_error);
1889 static void compute_offsets();
1890 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1891 };
1892
1893 // Use to declare fields that need to be injected into Java classes
1894 // for the JVM to use. The name_index and signature_index are
1895 // declared in vmSymbols. The may_be_java flag is used to declare
1896 // fields that might already exist in Java but should be injected if
1897 // they don't. Otherwise the field is unconditionally injected and
|