3376 MODULE_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
3377 }
3378 #endif
3379
3380 oop java_lang_Module::loader(oop module) {
3381 return module->obj_field(_loader_offset);
3382 }
3383
3384 void java_lang_Module::set_loader(oop module, oop value) {
3385 module->obj_field_put(_loader_offset, value);
3386 }
3387
3388 oop java_lang_Module::name(oop module) {
3389 return module->obj_field(_name_offset);
3390 }
3391
3392 void java_lang_Module::set_name(oop module, oop value) {
3393 module->obj_field_put(_name_offset, value);
3394 }
3395
3396 ModuleEntry* java_lang_Module::module_entry(oop module) {
3397 assert(_module_entry_offset != 0, "Uninitialized module_entry_offset");
3398 assert(module != NULL, "module can't be null");
3399 assert(oopDesc::is_oop(module), "module must be oop");
3400
3401 ModuleEntry* module_entry = (ModuleEntry*)module->address_field(_module_entry_offset);
3402 if (module_entry == NULL) {
3403 // If the inject field containing the ModuleEntry* is null then return the
3404 // class loader's unnamed module.
3405 oop loader = java_lang_Module::loader(module);
3406 Handle h_loader = Handle(Thread::current(), loader);
3407 ClassLoaderData* loader_cld = SystemDictionary::register_loader(h_loader);
3408 return loader_cld->unnamed_module();
3409 }
3410 return module_entry;
3411 }
3412
3413 void java_lang_Module::set_module_entry(oop module, ModuleEntry* module_entry) {
3414 assert(_module_entry_offset != 0, "Uninitialized module_entry_offset");
3415 assert(module != NULL, "module can't be null");
3416 assert(oopDesc::is_oop(module), "module must be oop");
3417 module->address_field_put(_module_entry_offset, (address)module_entry);
3418 }
3419
3420 Handle reflect_ConstantPool::create(TRAPS) {
3421 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
4805
4806 // We have already called the compute_offsets() of the
4807 // BASIC_JAVA_CLASSES_DO_PART1 classes (java_lang_String, java_lang_Class and
4808 // java_lang_ref_Reference) earlier inside SystemDictionary::resolve_well_known_classes()
4809 BASIC_JAVA_CLASSES_DO_PART2(DO_COMPUTE_OFFSETS);
4810 }
4811
4812 #if INCLUDE_CDS
4813 #define DO_SERIALIZE_OFFSETS(k) k::serialize_offsets(soc);
4814
4815 void JavaClasses::serialize_offsets(SerializeClosure* soc) {
4816 BASIC_JAVA_CLASSES_DO(DO_SERIALIZE_OFFSETS);
4817 }
4818 #endif
4819
4820 #if INCLUDE_CDS_JAVA_HEAP
4821 bool JavaClasses::is_supported_for_archiving(oop obj) {
4822 Klass* klass = obj->klass();
4823
4824 if (klass == SystemDictionary::ClassLoader_klass() || // ClassLoader::loader_data is malloc'ed.
4825 klass == SystemDictionary::Module_klass() || // Module::module_entry is malloc'ed
4826 // The next 3 classes are used to implement java.lang.invoke, and are not used directly in
4827 // regular Java code. The implementation of java.lang.invoke uses generated anonymoys classes
4828 // (e.g., as referenced by ResolvedMethodName::vmholder) that are not yet supported by CDS.
4829 // So for now we cannot not support these classes for archiving.
4830 //
4831 // These objects typically are not referenced by static fields, but rather by resolved
4832 // constant pool entries, so excluding them shouldn't affect the archiving of static fields.
4833 klass == SystemDictionary::ResolvedMethodName_klass() ||
4834 klass == SystemDictionary::MemberName_klass() ||
4835 klass == SystemDictionary::Context_klass()) {
4836 return false;
4837 }
4838
4839 return true;
4840 }
4841 #endif
4842
4843 #ifndef PRODUCT
4844
4845 // These functions exist to assert the validity of de-serialized offsets in boxing object as a sanity check.
|
3376 MODULE_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
3377 }
3378 #endif
3379
3380 oop java_lang_Module::loader(oop module) {
3381 return module->obj_field(_loader_offset);
3382 }
3383
3384 void java_lang_Module::set_loader(oop module, oop value) {
3385 module->obj_field_put(_loader_offset, value);
3386 }
3387
3388 oop java_lang_Module::name(oop module) {
3389 return module->obj_field(_name_offset);
3390 }
3391
3392 void java_lang_Module::set_name(oop module, oop value) {
3393 module->obj_field_put(_name_offset, value);
3394 }
3395
3396 ModuleEntry* java_lang_Module::module_entry_raw(oop module) {
3397 assert(_module_entry_offset != 0, "Uninitialized module_entry_offset");
3398 assert(module != NULL, "module can't be null");
3399 assert(oopDesc::is_oop(module), "module must be oop");
3400
3401 ModuleEntry* module_entry = (ModuleEntry*)module->address_field(_module_entry_offset);
3402 return module_entry;
3403 }
3404
3405 ModuleEntry* java_lang_Module::module_entry(oop module) {
3406 ModuleEntry* module_entry = module_entry_raw(module);
3407 if (module_entry == NULL) {
3408 // If the inject field containing the ModuleEntry* is null then return the
3409 // class loader's unnamed module.
3410 oop loader = java_lang_Module::loader(module);
3411 Handle h_loader = Handle(Thread::current(), loader);
3412 ClassLoaderData* loader_cld = SystemDictionary::register_loader(h_loader);
3413 return loader_cld->unnamed_module();
3414 }
3415 return module_entry;
3416 }
3417
3418 void java_lang_Module::set_module_entry(oop module, ModuleEntry* module_entry) {
3419 assert(_module_entry_offset != 0, "Uninitialized module_entry_offset");
3420 assert(module != NULL, "module can't be null");
3421 assert(oopDesc::is_oop(module), "module must be oop");
3422 module->address_field_put(_module_entry_offset, (address)module_entry);
3423 }
3424
3425 Handle reflect_ConstantPool::create(TRAPS) {
3426 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
4810
4811 // We have already called the compute_offsets() of the
4812 // BASIC_JAVA_CLASSES_DO_PART1 classes (java_lang_String, java_lang_Class and
4813 // java_lang_ref_Reference) earlier inside SystemDictionary::resolve_well_known_classes()
4814 BASIC_JAVA_CLASSES_DO_PART2(DO_COMPUTE_OFFSETS);
4815 }
4816
4817 #if INCLUDE_CDS
4818 #define DO_SERIALIZE_OFFSETS(k) k::serialize_offsets(soc);
4819
4820 void JavaClasses::serialize_offsets(SerializeClosure* soc) {
4821 BASIC_JAVA_CLASSES_DO(DO_SERIALIZE_OFFSETS);
4822 }
4823 #endif
4824
4825 #if INCLUDE_CDS_JAVA_HEAP
4826 bool JavaClasses::is_supported_for_archiving(oop obj) {
4827 Klass* klass = obj->klass();
4828
4829 if (klass == SystemDictionary::ClassLoader_klass() || // ClassLoader::loader_data is malloc'ed.
4830 // The next 3 classes are used to implement java.lang.invoke, and are not used directly in
4831 // regular Java code. The implementation of java.lang.invoke uses generated anonymoys classes
4832 // (e.g., as referenced by ResolvedMethodName::vmholder) that are not yet supported by CDS.
4833 // So for now we cannot not support these classes for archiving.
4834 //
4835 // These objects typically are not referenced by static fields, but rather by resolved
4836 // constant pool entries, so excluding them shouldn't affect the archiving of static fields.
4837 klass == SystemDictionary::ResolvedMethodName_klass() ||
4838 klass == SystemDictionary::MemberName_klass() ||
4839 klass == SystemDictionary::Context_klass()) {
4840 return false;
4841 }
4842
4843 return true;
4844 }
4845 #endif
4846
4847 #ifndef PRODUCT
4848
4849 // These functions exist to assert the validity of de-serialized offsets in boxing object as a sanity check.
|