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