< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page

 777   }
 778   st->print("\"");
 779 }
 780 
 781 // java_lang_Class
 782 
 783 int java_lang_Class::_klass_offset;
 784 int java_lang_Class::_array_klass_offset;
 785 int java_lang_Class::_oop_size_offset;
 786 int java_lang_Class::_static_oop_field_count_offset;
 787 int java_lang_Class::_class_loader_offset;
 788 int java_lang_Class::_module_offset;
 789 int java_lang_Class::_protection_domain_offset;
 790 int java_lang_Class::_component_mirror_offset;
 791 int java_lang_Class::_init_lock_offset;
 792 int java_lang_Class::_signers_offset;
 793 int java_lang_Class::_name_offset;
 794 int java_lang_Class::_source_file_offset;
 795 int java_lang_Class::_classData_offset;
 796 int java_lang_Class::_classRedefinedCount_offset;

 797 
 798 bool java_lang_Class::_offsets_computed = false;
 799 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = nullptr;
 800 GrowableArray<Klass*>* java_lang_Class::_fixup_module_field_list = nullptr;
 801 
 802 #ifdef ASSERT
 803 inline static void assert_valid_static_string_field(fieldDescriptor* fd) {
 804   assert(fd->has_initial_value(), "caller should have checked this");
 805   assert(fd->field_type() == T_OBJECT, "caller should have checked this");
 806   assert(fd->signature() == vmSymbols::string_signature(), "just checking");
 807 }
 808 #endif
 809 
 810 static void initialize_static_string_field(fieldDescriptor* fd, Handle mirror, TRAPS) {
 811   DEBUG_ONLY(assert_valid_static_string_field(fd);)
 812   oop string = fd->string_initial_value(CHECK);
 813   mirror()->obj_field_put(fd->offset(), string);
 814 }
 815 
 816 static void initialize_static_primitive_field(fieldDescriptor* fd, Handle mirror) {

1054     allocate_mirror(k, /*is_scratch=*/false, protection_domain, classData, mirror, comp_mirror, CHECK);
1055 
1056     // set the classLoader field in the java_lang_Class instance
1057     assert(class_loader() == k->class_loader(), "should be same");
1058     set_class_loader(mirror(), class_loader());
1059 
1060     // Setup indirection from klass->mirror
1061     // after any exceptions can happen during allocations.
1062     k->set_java_mirror(mirror);
1063 
1064     // Set the module field in the java_lang_Class instance.  This must be done
1065     // after the mirror is set.
1066     set_mirror_module_field(THREAD, k, mirror, module);
1067 
1068     if (comp_mirror() != nullptr) {
1069       // Set after k->java_mirror() is published, because compiled code running
1070       // concurrently doesn't expect a k to have a null java_mirror.
1071       release_set_array_klass(comp_mirror(), k);
1072     }
1073     if (CDSConfig::is_dumping_heap()) {
1074       create_scratch_mirror(k, CHECK);




1075     }
1076   } else {
1077     assert(fixup_mirror_list() != nullptr, "fixup_mirror_list not initialized");
1078     fixup_mirror_list()->push(k);
1079   }
1080 }
1081 
1082 #if INCLUDE_CDS_JAVA_HEAP
1083 // The "scratch mirror" stores the states of the mirror object that can be
1084 // decided at dump time (such as the initial values of the static fields, the
1085 // component mirror, etc). At runtime, more information is added to it by
1086 // java_lang_Class::restore_archived_mirror().
1087 //
1088 // Essentially, /*dumptime*/create_scratch_mirror() + /*runtime*/restore_archived_mirror()
1089 // produces the same result as /*runtime*/create_mirror().
1090 //
1091 // Note: we archive the "scratch mirror" instead of k->java_mirror(), because the
1092 // latter may contain dumptime-specific information that cannot be archived
1093 // (e.g., ClassLoaderData*, or static fields that are modified by Java code execution).
1094 void java_lang_Class::create_scratch_mirror(Klass* k, TRAPS) {
1095   if (k->class_loader() != nullptr &&
1096       k->class_loader() != SystemDictionary::java_platform_loader() &&
1097       k->class_loader() != SystemDictionary::java_system_loader()) {
1098     // We only archive the mirrors of classes loaded by the built-in loaders
1099     return;
1100   }
1101 
1102   Handle protection_domain, classData; // set to null. Will be reinitialized at runtime
1103   Handle mirror;
1104   Handle comp_mirror;
1105   allocate_mirror(k, /*is_scratch=*/true, protection_domain, classData, mirror, comp_mirror, CHECK);
1106 
1107   if (comp_mirror() != nullptr) {
1108     release_set_array_klass(comp_mirror(), k);
1109   }
1110 
1111   HeapShared::set_scratch_java_mirror(k, mirror());
1112 }
1113 
1114 // Returns true if the mirror is updated, false if no archived mirror
1115 // data is present. After the archived mirror object is restored, the
1116 // shared klass' _has_raw_archived_mirror flag is cleared.
1117 bool java_lang_Class::restore_archived_mirror(Klass *k,
1118                                               Handle class_loader, Handle module,
1119                                               Handle protection_domain, TRAPS) {
1120   // Postpone restoring archived mirror until java.lang.Class is loaded. Please
1121   // see more details in vmClasses::resolve_all().
1122   if (!vmClasses::Class_klass_loaded()) {

1217 }
1218 
1219 objArrayOop java_lang_Class::signers(oop java_class) {
1220   assert(_signers_offset != 0, "must be set");
1221   return (objArrayOop)java_class->obj_field(_signers_offset);
1222 }
1223 void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
1224   assert(_signers_offset != 0, "must be set");
1225   java_class->obj_field_put(_signers_offset, signers);
1226 }
1227 
1228 oop java_lang_Class::class_data(oop java_class) {
1229   assert(_classData_offset != 0, "must be set");
1230   return java_class->obj_field(_classData_offset);
1231 }
1232 void java_lang_Class::set_class_data(oop java_class, oop class_data) {
1233   assert(_classData_offset != 0, "must be set");
1234   java_class->obj_field_put(_classData_offset, class_data);
1235 }
1236 














1237 void java_lang_Class::set_class_loader(oop java_class, oop loader) {
1238   assert(_class_loader_offset != 0, "offsets should have been initialized");
1239   java_class->obj_field_put(_class_loader_offset, loader);
1240 }
1241 
1242 oop java_lang_Class::class_loader(oop java_class) {
1243   assert(_class_loader_offset != 0, "must be set");
1244   return java_class->obj_field(_class_loader_offset);
1245 }
1246 
1247 oop java_lang_Class::module(oop java_class) {
1248   assert(_module_offset != 0, "must be set");
1249   return java_class->obj_field(_module_offset);
1250 }
1251 
1252 void java_lang_Class::set_module(oop java_class, oop module) {
1253   assert(_module_offset != 0, "must be set");
1254   java_class->obj_field_put(_module_offset, module);
1255 }
1256 

1406     if (reference_klass != nullptr)
1407       (*reference_klass) = as_Klass(java_class);
1408     return T_OBJECT;
1409   }
1410 }
1411 
1412 
1413 oop java_lang_Class::primitive_mirror(BasicType t) {
1414   oop mirror = Universe::java_mirror(t);
1415   assert(mirror != nullptr && mirror->is_a(vmClasses::Class_klass()), "must be a Class");
1416   assert(is_primitive(mirror), "must be primitive");
1417   return mirror;
1418 }
1419 
1420 #define CLASS_FIELDS_DO(macro) \
1421   macro(_classRedefinedCount_offset, k, "classRedefinedCount", int_signature,         false); \
1422   macro(_class_loader_offset,        k, "classLoader",         classloader_signature, false); \
1423   macro(_component_mirror_offset,    k, "componentType",       class_signature,       false); \
1424   macro(_module_offset,              k, "module",              module_signature,      false); \
1425   macro(_name_offset,                k, "name",                string_signature,      false); \
1426   macro(_classData_offset,           k, "classData",           object_signature,      false);

1427 
1428 void java_lang_Class::compute_offsets() {
1429   if (_offsets_computed) {
1430     return;
1431   }
1432 
1433   _offsets_computed = true;
1434 
1435   InstanceKlass* k = vmClasses::Class_klass();
1436   CLASS_FIELDS_DO(FIELD_COMPUTE_OFFSET);
1437 
1438   // Init lock is a C union with component_mirror.  Only instanceKlass mirrors have
1439   // init_lock and only ArrayKlass mirrors have component_mirror.  Since both are oops
1440   // GC treats them the same.
1441   _init_lock_offset = _component_mirror_offset;
1442 
1443   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
1444 }
1445 
1446 #if INCLUDE_CDS

2116   return msg_utf8;
2117 }
2118 
2119 oop java_lang_Throwable::cause(oop throwable) {
2120   return throwable->obj_field(_cause_offset);
2121 }
2122 
2123 void java_lang_Throwable::set_message(oop throwable, oop value) {
2124   throwable->obj_field_put(_detailMessage_offset, value);
2125 }
2126 
2127 
2128 void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) {
2129   throwable->obj_field_put(_stackTrace_offset, st_element_array);
2130 }
2131 
2132 void java_lang_Throwable::clear_stacktrace(oop throwable) {
2133   set_stacktrace(throwable, nullptr);
2134 }
2135 




2136 
2137 void java_lang_Throwable::print(oop throwable, outputStream* st) {
2138   ResourceMark rm;
2139   Klass* k = throwable->klass();
2140   assert(k != nullptr, "just checking");
2141   st->print("%s", k->external_name());
2142   oop msg = message(throwable);
2143   if (msg != nullptr) {
2144     st->print(": %s", java_lang_String::as_utf8_string(msg));
2145   }
2146 }
2147 
2148 // After this many redefines, the stack trace is unreliable.
2149 const int MAX_VERSION = USHRT_MAX;
2150 
2151 static inline bool version_matches(Method* method, int version) {
2152   assert(version < MAX_VERSION, "version is too big");
2153   return method != nullptr && (method->constants()->version() == version);
2154 }
2155 

5367 
5368   // We have already called the compute_offsets() of the
5369   // BASIC_JAVA_CLASSES_DO_PART1 classes (java_lang_String, java_lang_Class and
5370   // java_lang_ref_Reference) earlier inside vmClasses::resolve_all()
5371   BASIC_JAVA_CLASSES_DO_PART2(DO_COMPUTE_OFFSETS);
5372 }
5373 
5374 #if INCLUDE_CDS
5375 #define DO_SERIALIZE_OFFSETS(k) k::serialize_offsets(soc);
5376 
5377 void JavaClasses::serialize_offsets(SerializeClosure* soc) {
5378   BASIC_JAVA_CLASSES_DO(DO_SERIALIZE_OFFSETS);
5379 }
5380 #endif
5381 
5382 #if INCLUDE_CDS_JAVA_HEAP
5383 bool JavaClasses::is_supported_for_archiving(oop obj) {
5384   Klass* klass = obj->klass();
5385 
5386   if (klass == vmClasses::ClassLoader_klass() ||  // ClassLoader::loader_data is malloc'ed.

5387       // The next 3 classes are used to implement java.lang.invoke, and are not used directly in
5388       // regular Java code. The implementation of java.lang.invoke uses generated hidden classes
5389       // (e.g., as referenced by ResolvedMethodName::vmholder) that are not yet supported by CDS.
5390       // So for now we cannot not support these classes for archiving.
5391       //
5392       // These objects typically are not referenced by static fields, but rather by resolved
5393       // constant pool entries, so excluding them shouldn't affect the archiving of static fields.
5394       klass == vmClasses::ResolvedMethodName_klass() ||
5395       klass == vmClasses::MemberName_klass() ||
5396       klass == vmClasses::Context_klass() ||

5397       // It's problematic to archive Reference objects. One of the reasons is that
5398       // Reference::discovered may pull in unwanted objects (see JDK-8284336)
5399       klass->is_subclass_of(vmClasses::Reference_klass())) {
5400     return false;
5401   }
5402 
5403   return true;
5404 }
5405 #endif
5406 
5407 #ifndef PRODUCT
5408 
5409 // These functions exist to assert the validity of de-serialized offsets in boxing object as a sanity check.
5410 
5411 bool JavaClasses::check_offset(const char *klass_name, int deserialized_offset, const char *field_name,
5412                                const char* field_sig) {
5413   EXCEPTION_MARK;
5414   fieldDescriptor fd;
5415   TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name);
5416   Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH);

 777   }
 778   st->print("\"");
 779 }
 780 
 781 // java_lang_Class
 782 
 783 int java_lang_Class::_klass_offset;
 784 int java_lang_Class::_array_klass_offset;
 785 int java_lang_Class::_oop_size_offset;
 786 int java_lang_Class::_static_oop_field_count_offset;
 787 int java_lang_Class::_class_loader_offset;
 788 int java_lang_Class::_module_offset;
 789 int java_lang_Class::_protection_domain_offset;
 790 int java_lang_Class::_component_mirror_offset;
 791 int java_lang_Class::_init_lock_offset;
 792 int java_lang_Class::_signers_offset;
 793 int java_lang_Class::_name_offset;
 794 int java_lang_Class::_source_file_offset;
 795 int java_lang_Class::_classData_offset;
 796 int java_lang_Class::_classRedefinedCount_offset;
 797 int java_lang_Class::_reflectionData_offset;
 798 
 799 bool java_lang_Class::_offsets_computed = false;
 800 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = nullptr;
 801 GrowableArray<Klass*>* java_lang_Class::_fixup_module_field_list = nullptr;
 802 
 803 #ifdef ASSERT
 804 inline static void assert_valid_static_string_field(fieldDescriptor* fd) {
 805   assert(fd->has_initial_value(), "caller should have checked this");
 806   assert(fd->field_type() == T_OBJECT, "caller should have checked this");
 807   assert(fd->signature() == vmSymbols::string_signature(), "just checking");
 808 }
 809 #endif
 810 
 811 static void initialize_static_string_field(fieldDescriptor* fd, Handle mirror, TRAPS) {
 812   DEBUG_ONLY(assert_valid_static_string_field(fd);)
 813   oop string = fd->string_initial_value(CHECK);
 814   mirror()->obj_field_put(fd->offset(), string);
 815 }
 816 
 817 static void initialize_static_primitive_field(fieldDescriptor* fd, Handle mirror) {

1055     allocate_mirror(k, /*is_scratch=*/false, protection_domain, classData, mirror, comp_mirror, CHECK);
1056 
1057     // set the classLoader field in the java_lang_Class instance
1058     assert(class_loader() == k->class_loader(), "should be same");
1059     set_class_loader(mirror(), class_loader());
1060 
1061     // Setup indirection from klass->mirror
1062     // after any exceptions can happen during allocations.
1063     k->set_java_mirror(mirror);
1064 
1065     // Set the module field in the java_lang_Class instance.  This must be done
1066     // after the mirror is set.
1067     set_mirror_module_field(THREAD, k, mirror, module);
1068 
1069     if (comp_mirror() != nullptr) {
1070       // Set after k->java_mirror() is published, because compiled code running
1071       // concurrently doesn't expect a k to have a null java_mirror.
1072       release_set_array_klass(comp_mirror(), k);
1073     }
1074     if (CDSConfig::is_dumping_heap()) {
1075       if (CDSConfig::is_dumping_protection_domains()) {
1076         create_scratch_mirror(k, protection_domain, CHECK);
1077       } else {
1078         create_scratch_mirror(k, Handle() /* null protection_domain*/, CHECK);
1079       }
1080     }
1081   } else {
1082     assert(fixup_mirror_list() != nullptr, "fixup_mirror_list not initialized");
1083     fixup_mirror_list()->push(k);
1084   }
1085 }
1086 
1087 #if INCLUDE_CDS_JAVA_HEAP
1088 // The "scratch mirror" stores the states of the mirror object that can be
1089 // decided at dump time (such as the initial values of the static fields, the
1090 // component mirror, etc). At runtime, more information is added to it by
1091 // java_lang_Class::restore_archived_mirror().
1092 //
1093 // Essentially, /*dumptime*/create_scratch_mirror() + /*runtime*/restore_archived_mirror()
1094 // produces the same result as /*runtime*/create_mirror().
1095 //
1096 // Note: we archive the "scratch mirror" instead of k->java_mirror(), because the
1097 // latter may contain dumptime-specific information that cannot be archived
1098 // (e.g., ClassLoaderData*, or static fields that are modified by Java code execution).
1099 void java_lang_Class::create_scratch_mirror(Klass* k, Handle protection_domain, TRAPS) {
1100   if (k->class_loader() != nullptr &&
1101       k->class_loader() != SystemDictionary::java_platform_loader() &&
1102       k->class_loader() != SystemDictionary::java_system_loader()) {
1103     // We only archive the mirrors of classes loaded by the built-in loaders
1104     return;
1105   }
1106 
1107   Handle classData; // set to null. Will be reinitialized at runtime
1108   Handle mirror;
1109   Handle comp_mirror;
1110   allocate_mirror(k, /*is_scratch=*/true, protection_domain, classData, mirror, comp_mirror, CHECK);
1111 
1112   if (comp_mirror() != nullptr) {
1113     release_set_array_klass(comp_mirror(), k);
1114   }
1115 
1116   HeapShared::set_scratch_java_mirror(k, mirror());
1117 }
1118 
1119 // Returns true if the mirror is updated, false if no archived mirror
1120 // data is present. After the archived mirror object is restored, the
1121 // shared klass' _has_raw_archived_mirror flag is cleared.
1122 bool java_lang_Class::restore_archived_mirror(Klass *k,
1123                                               Handle class_loader, Handle module,
1124                                               Handle protection_domain, TRAPS) {
1125   // Postpone restoring archived mirror until java.lang.Class is loaded. Please
1126   // see more details in vmClasses::resolve_all().
1127   if (!vmClasses::Class_klass_loaded()) {

1222 }
1223 
1224 objArrayOop java_lang_Class::signers(oop java_class) {
1225   assert(_signers_offset != 0, "must be set");
1226   return (objArrayOop)java_class->obj_field(_signers_offset);
1227 }
1228 void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
1229   assert(_signers_offset != 0, "must be set");
1230   java_class->obj_field_put(_signers_offset, signers);
1231 }
1232 
1233 oop java_lang_Class::class_data(oop java_class) {
1234   assert(_classData_offset != 0, "must be set");
1235   return java_class->obj_field(_classData_offset);
1236 }
1237 void java_lang_Class::set_class_data(oop java_class, oop class_data) {
1238   assert(_classData_offset != 0, "must be set");
1239   java_class->obj_field_put(_classData_offset, class_data);
1240 }
1241 
1242 oop java_lang_Class::reflection_data(oop java_class) {
1243   assert(_reflectionData_offset != 0, "must be set");
1244   return java_class->obj_field(_reflectionData_offset);
1245 }
1246 
1247 bool java_lang_Class::has_reflection_data(oop java_class) {
1248   return (java_lang_Class::reflection_data(java_class) != nullptr);
1249 }
1250 
1251 void java_lang_Class::set_reflection_data(oop java_class, oop reflection_data) {
1252   assert(_reflectionData_offset != 0, "must be set");
1253   java_class->obj_field_put(_reflectionData_offset, reflection_data);
1254 }
1255 
1256 void java_lang_Class::set_class_loader(oop java_class, oop loader) {
1257   assert(_class_loader_offset != 0, "offsets should have been initialized");
1258   java_class->obj_field_put(_class_loader_offset, loader);
1259 }
1260 
1261 oop java_lang_Class::class_loader(oop java_class) {
1262   assert(_class_loader_offset != 0, "must be set");
1263   return java_class->obj_field(_class_loader_offset);
1264 }
1265 
1266 oop java_lang_Class::module(oop java_class) {
1267   assert(_module_offset != 0, "must be set");
1268   return java_class->obj_field(_module_offset);
1269 }
1270 
1271 void java_lang_Class::set_module(oop java_class, oop module) {
1272   assert(_module_offset != 0, "must be set");
1273   java_class->obj_field_put(_module_offset, module);
1274 }
1275 

1425     if (reference_klass != nullptr)
1426       (*reference_klass) = as_Klass(java_class);
1427     return T_OBJECT;
1428   }
1429 }
1430 
1431 
1432 oop java_lang_Class::primitive_mirror(BasicType t) {
1433   oop mirror = Universe::java_mirror(t);
1434   assert(mirror != nullptr && mirror->is_a(vmClasses::Class_klass()), "must be a Class");
1435   assert(is_primitive(mirror), "must be primitive");
1436   return mirror;
1437 }
1438 
1439 #define CLASS_FIELDS_DO(macro) \
1440   macro(_classRedefinedCount_offset, k, "classRedefinedCount", int_signature,         false); \
1441   macro(_class_loader_offset,        k, "classLoader",         classloader_signature, false); \
1442   macro(_component_mirror_offset,    k, "componentType",       class_signature,       false); \
1443   macro(_module_offset,              k, "module",              module_signature,      false); \
1444   macro(_name_offset,                k, "name",                string_signature,      false); \
1445   macro(_classData_offset,           k, "classData",           object_signature,      false); \
1446   macro(_reflectionData_offset,      k, "reflectionData",      class_ReflectionData_signature, false); \
1447 
1448 void java_lang_Class::compute_offsets() {
1449   if (_offsets_computed) {
1450     return;
1451   }
1452 
1453   _offsets_computed = true;
1454 
1455   InstanceKlass* k = vmClasses::Class_klass();
1456   CLASS_FIELDS_DO(FIELD_COMPUTE_OFFSET);
1457 
1458   // Init lock is a C union with component_mirror.  Only instanceKlass mirrors have
1459   // init_lock and only ArrayKlass mirrors have component_mirror.  Since both are oops
1460   // GC treats them the same.
1461   _init_lock_offset = _component_mirror_offset;
1462 
1463   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
1464 }
1465 
1466 #if INCLUDE_CDS

2136   return msg_utf8;
2137 }
2138 
2139 oop java_lang_Throwable::cause(oop throwable) {
2140   return throwable->obj_field(_cause_offset);
2141 }
2142 
2143 void java_lang_Throwable::set_message(oop throwable, oop value) {
2144   throwable->obj_field_put(_detailMessage_offset, value);
2145 }
2146 
2147 
2148 void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) {
2149   throwable->obj_field_put(_stackTrace_offset, st_element_array);
2150 }
2151 
2152 void java_lang_Throwable::clear_stacktrace(oop throwable) {
2153   set_stacktrace(throwable, nullptr);
2154 }
2155 
2156 oop java_lang_Throwable::create_exception_instance(Symbol* class_name, TRAPS) {
2157   Klass* k = SystemDictionary::resolve_or_fail(class_name, true, CHECK_NULL);
2158   return InstanceKlass::cast(k)->allocate_instance(CHECK_NULL);
2159 }
2160 
2161 void java_lang_Throwable::print(oop throwable, outputStream* st) {
2162   ResourceMark rm;
2163   Klass* k = throwable->klass();
2164   assert(k != nullptr, "just checking");
2165   st->print("%s", k->external_name());
2166   oop msg = message(throwable);
2167   if (msg != nullptr) {
2168     st->print(": %s", java_lang_String::as_utf8_string(msg));
2169   }
2170 }
2171 
2172 // After this many redefines, the stack trace is unreliable.
2173 const int MAX_VERSION = USHRT_MAX;
2174 
2175 static inline bool version_matches(Method* method, int version) {
2176   assert(version < MAX_VERSION, "version is too big");
2177   return method != nullptr && (method->constants()->version() == version);
2178 }
2179 

5391 
5392   // We have already called the compute_offsets() of the
5393   // BASIC_JAVA_CLASSES_DO_PART1 classes (java_lang_String, java_lang_Class and
5394   // java_lang_ref_Reference) earlier inside vmClasses::resolve_all()
5395   BASIC_JAVA_CLASSES_DO_PART2(DO_COMPUTE_OFFSETS);
5396 }
5397 
5398 #if INCLUDE_CDS
5399 #define DO_SERIALIZE_OFFSETS(k) k::serialize_offsets(soc);
5400 
5401 void JavaClasses::serialize_offsets(SerializeClosure* soc) {
5402   BASIC_JAVA_CLASSES_DO(DO_SERIALIZE_OFFSETS);
5403 }
5404 #endif
5405 
5406 #if INCLUDE_CDS_JAVA_HEAP
5407 bool JavaClasses::is_supported_for_archiving(oop obj) {
5408   Klass* klass = obj->klass();
5409 
5410   if (klass == vmClasses::ClassLoader_klass() ||  // ClassLoader::loader_data is malloc'ed.
5411 #if 0
5412       // The next 3 classes are used to implement java.lang.invoke, and are not used directly in
5413       // regular Java code. The implementation of java.lang.invoke uses generated hidden classes
5414       // (e.g., as referenced by ResolvedMethodName::vmholder) that are not yet supported by CDS.
5415       // So for now we cannot not support these classes for archiving.
5416       //
5417       // These objects typically are not referenced by static fields, but rather by resolved
5418       // constant pool entries, so excluding them shouldn't affect the archiving of static fields.
5419       klass == vmClasses::ResolvedMethodName_klass() ||
5420       klass == vmClasses::MemberName_klass() ||
5421       klass == vmClasses::Context_klass() ||
5422 #endif
5423       // It's problematic to archive Reference objects. One of the reasons is that
5424       // Reference::discovered may pull in unwanted objects (see JDK-8284336)
5425       klass->is_subclass_of(vmClasses::Reference_klass())) {
5426     return false;
5427   }
5428 
5429   return true;
5430 }
5431 #endif
5432 
5433 #ifndef PRODUCT
5434 
5435 // These functions exist to assert the validity of de-serialized offsets in boxing object as a sanity check.
5436 
5437 bool JavaClasses::check_offset(const char *klass_name, int deserialized_offset, const char *field_name,
5438                                const char* field_sig) {
5439   EXCEPTION_MARK;
5440   fieldDescriptor fd;
5441   TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name);
5442   Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH);
< prev index next >