< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page

 825     st->print(" (abridged) ");
 826   }
 827 }
 828 
 829 // java_lang_Class
 830 
 831 int java_lang_Class::_klass_offset;
 832 int java_lang_Class::_array_klass_offset;
 833 int java_lang_Class::_oop_size_offset;
 834 int java_lang_Class::_static_oop_field_count_offset;
 835 int java_lang_Class::_class_loader_offset;
 836 int java_lang_Class::_module_offset;
 837 int java_lang_Class::_protection_domain_offset;
 838 int java_lang_Class::_component_mirror_offset;
 839 int java_lang_Class::_init_lock_offset;
 840 int java_lang_Class::_signers_offset;
 841 int java_lang_Class::_name_offset;
 842 int java_lang_Class::_source_file_offset;
 843 int java_lang_Class::_classData_offset;
 844 int java_lang_Class::_classRedefinedCount_offset;

 845 
 846 bool java_lang_Class::_offsets_computed = false;
 847 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = nullptr;
 848 GrowableArray<Klass*>* java_lang_Class::_fixup_module_field_list = nullptr;
 849 
 850 #ifdef ASSERT
 851 inline static void assert_valid_static_string_field(fieldDescriptor* fd) {
 852   assert(fd->has_initial_value(), "caller should have checked this");
 853   assert(fd->field_type() == T_OBJECT, "caller should have checked this");
 854   assert(fd->signature() == vmSymbols::string_signature(), "just checking");
 855 }
 856 #endif
 857 
 858 static void initialize_static_string_field(fieldDescriptor* fd, Handle mirror, TRAPS) {
 859   DEBUG_ONLY(assert_valid_static_string_field(fd);)
 860   oop string = fd->string_initial_value(CHECK);
 861   mirror()->obj_field_put(fd->offset(), string);
 862 }
 863 
 864 static void initialize_static_primitive_field(fieldDescriptor* fd, Handle mirror) {

1102     allocate_mirror(k, /*is_scratch=*/false, protection_domain, classData, mirror, comp_mirror, CHECK);
1103 
1104     // set the classLoader field in the java_lang_Class instance
1105     assert(class_loader() == k->class_loader(), "should be same");
1106     set_class_loader(mirror(), class_loader());
1107 
1108     // Setup indirection from klass->mirror
1109     // after any exceptions can happen during allocations.
1110     k->set_java_mirror(mirror);
1111 
1112     // Set the module field in the java_lang_Class instance.  This must be done
1113     // after the mirror is set.
1114     set_mirror_module_field(THREAD, k, mirror, module);
1115 
1116     if (comp_mirror() != nullptr) {
1117       // Set after k->java_mirror() is published, because compiled code running
1118       // concurrently doesn't expect a k to have a null java_mirror.
1119       release_set_array_klass(comp_mirror(), k);
1120     }
1121     if (CDSConfig::is_dumping_heap()) {
1122       create_scratch_mirror(k, CHECK);




1123     }
1124   } else {
1125     assert(fixup_mirror_list() != nullptr, "fixup_mirror_list not initialized");
1126     fixup_mirror_list()->push(k);
1127   }
1128 }
1129 
1130 #if INCLUDE_CDS_JAVA_HEAP
1131 // The "scratch mirror" stores the states of the mirror object that can be
1132 // decided at dump time (such as the initial values of the static fields, the
1133 // component mirror, etc). At runtime, more information is added to it by
1134 // java_lang_Class::restore_archived_mirror().
1135 //
1136 // Essentially, /*dumptime*/create_scratch_mirror() + /*runtime*/restore_archived_mirror()
1137 // produces the same result as /*runtime*/create_mirror().
1138 //
1139 // Note: we archive the "scratch mirror" instead of k->java_mirror(), because the
1140 // latter may contain dumptime-specific information that cannot be archived
1141 // (e.g., ClassLoaderData*, or static fields that are modified by Java code execution).
1142 void java_lang_Class::create_scratch_mirror(Klass* k, TRAPS) {
1143   if (k->class_loader() != nullptr &&
1144       k->class_loader() != SystemDictionary::java_platform_loader() &&
1145       k->class_loader() != SystemDictionary::java_system_loader()) {
1146     // We only archive the mirrors of classes loaded by the built-in loaders
1147     return;
1148   }
1149 
1150   Handle protection_domain, classData; // set to null. Will be reinitialized at runtime
1151   Handle mirror;
1152   Handle comp_mirror;
1153   allocate_mirror(k, /*is_scratch=*/true, protection_domain, classData, mirror, comp_mirror, CHECK);
1154 
1155   if (comp_mirror() != nullptr) {
1156     release_set_array_klass(comp_mirror(), k);
1157   }
1158 
1159   HeapShared::set_scratch_java_mirror(k, mirror());
1160 }
1161 
1162 // Returns true if the mirror is updated, false if no archived mirror
1163 // data is present. After the archived mirror object is restored, the
1164 // shared klass' _has_raw_archived_mirror flag is cleared.
1165 bool java_lang_Class::restore_archived_mirror(Klass *k,
1166                                               Handle class_loader, Handle module,
1167                                               Handle protection_domain, TRAPS) {
1168   // Postpone restoring archived mirror until java.lang.Class is loaded. Please
1169   // see more details in vmClasses::resolve_all().
1170   if (!vmClasses::Class_klass_loaded()) {

1261 }
1262 void java_lang_Class::set_init_lock(oop java_class, oop init_lock) {
1263   assert(_init_lock_offset != 0, "must be set");
1264   java_class->obj_field_put(_init_lock_offset, init_lock);
1265 }
1266 
1267 objArrayOop java_lang_Class::signers(oop java_class) {
1268   assert(_signers_offset != 0, "must be set");
1269   return (objArrayOop)java_class->obj_field(_signers_offset);
1270 }
1271 
1272 oop java_lang_Class::class_data(oop java_class) {
1273   assert(_classData_offset != 0, "must be set");
1274   return java_class->obj_field(_classData_offset);
1275 }
1276 void java_lang_Class::set_class_data(oop java_class, oop class_data) {
1277   assert(_classData_offset != 0, "must be set");
1278   java_class->obj_field_put(_classData_offset, class_data);
1279 }
1280 














1281 void java_lang_Class::set_class_loader(oop java_class, oop loader) {
1282   assert(_class_loader_offset != 0, "offsets should have been initialized");
1283   java_class->obj_field_put(_class_loader_offset, loader);
1284 }
1285 
1286 oop java_lang_Class::class_loader(oop java_class) {
1287   assert(_class_loader_offset != 0, "must be set");
1288   return java_class->obj_field(_class_loader_offset);
1289 }
1290 
1291 oop java_lang_Class::module(oop java_class) {
1292   assert(_module_offset != 0, "must be set");
1293   return java_class->obj_field(_module_offset);
1294 }
1295 
1296 void java_lang_Class::set_module(oop java_class, oop module) {
1297   assert(_module_offset != 0, "must be set");
1298   java_class->obj_field_put(_module_offset, module);
1299 }
1300 

1451       (*reference_klass) = as_Klass(java_class);
1452     return T_OBJECT;
1453   }
1454 }
1455 
1456 
1457 oop java_lang_Class::primitive_mirror(BasicType t) {
1458   oop mirror = Universe::java_mirror(t);
1459   assert(mirror != nullptr && mirror->is_a(vmClasses::Class_klass()), "must be a Class");
1460   assert(is_primitive(mirror), "must be primitive");
1461   return mirror;
1462 }
1463 
1464 #define CLASS_FIELDS_DO(macro) \
1465   macro(_classRedefinedCount_offset, k, "classRedefinedCount", int_signature,          false); \
1466   macro(_class_loader_offset,        k, "classLoader",         classloader_signature,  false); \
1467   macro(_component_mirror_offset,    k, "componentType",       class_signature,        false); \
1468   macro(_module_offset,              k, "module",              module_signature,       false); \
1469   macro(_name_offset,                k, "name",                string_signature,       false); \
1470   macro(_classData_offset,           k, "classData",           object_signature,       false); \

1471   macro(_signers_offset,             k, "signers",             object_array_signature, false);
1472 
1473 void java_lang_Class::compute_offsets() {
1474   if (_offsets_computed) {
1475     return;
1476   }
1477 
1478   _offsets_computed = true;
1479 
1480   InstanceKlass* k = vmClasses::Class_klass();
1481   CLASS_FIELDS_DO(FIELD_COMPUTE_OFFSET);
1482   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
1483 }
1484 
1485 #if INCLUDE_CDS
1486 void java_lang_Class::serialize_offsets(SerializeClosure* f) {
1487   f->do_bool(&_offsets_computed);
1488 
1489   CLASS_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
1490 

2154   return msg_utf8;
2155 }
2156 
2157 oop java_lang_Throwable::cause(oop throwable) {
2158   return throwable->obj_field(_cause_offset);
2159 }
2160 
2161 void java_lang_Throwable::set_message(oop throwable, oop value) {
2162   throwable->obj_field_put(_detailMessage_offset, value);
2163 }
2164 
2165 
2166 void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) {
2167   throwable->obj_field_put(_stackTrace_offset, st_element_array);
2168 }
2169 
2170 void java_lang_Throwable::clear_stacktrace(oop throwable) {
2171   set_stacktrace(throwable, nullptr);
2172 }
2173 




2174 
2175 void java_lang_Throwable::print(oop throwable, outputStream* st) {
2176   ResourceMark rm;
2177   Klass* k = throwable->klass();
2178   assert(k != nullptr, "just checking");
2179   st->print("%s", k->external_name());
2180   oop msg = message(throwable);
2181   if (msg != nullptr) {
2182     st->print(": %s", java_lang_String::as_utf8_string(msg));
2183   }
2184 }
2185 
2186 // After this many redefines, the stack trace is unreliable.
2187 const int MAX_VERSION = USHRT_MAX;
2188 
2189 static inline bool version_matches(Method* method, int version) {
2190   assert(version < MAX_VERSION, "version is too big");
2191   return method != nullptr && (method->constants()->version() == version);
2192 }
2193 

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

 825     st->print(" (abridged) ");
 826   }
 827 }
 828 
 829 // java_lang_Class
 830 
 831 int java_lang_Class::_klass_offset;
 832 int java_lang_Class::_array_klass_offset;
 833 int java_lang_Class::_oop_size_offset;
 834 int java_lang_Class::_static_oop_field_count_offset;
 835 int java_lang_Class::_class_loader_offset;
 836 int java_lang_Class::_module_offset;
 837 int java_lang_Class::_protection_domain_offset;
 838 int java_lang_Class::_component_mirror_offset;
 839 int java_lang_Class::_init_lock_offset;
 840 int java_lang_Class::_signers_offset;
 841 int java_lang_Class::_name_offset;
 842 int java_lang_Class::_source_file_offset;
 843 int java_lang_Class::_classData_offset;
 844 int java_lang_Class::_classRedefinedCount_offset;
 845 int java_lang_Class::_reflectionData_offset;
 846 
 847 bool java_lang_Class::_offsets_computed = false;
 848 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = nullptr;
 849 GrowableArray<Klass*>* java_lang_Class::_fixup_module_field_list = nullptr;
 850 
 851 #ifdef ASSERT
 852 inline static void assert_valid_static_string_field(fieldDescriptor* fd) {
 853   assert(fd->has_initial_value(), "caller should have checked this");
 854   assert(fd->field_type() == T_OBJECT, "caller should have checked this");
 855   assert(fd->signature() == vmSymbols::string_signature(), "just checking");
 856 }
 857 #endif
 858 
 859 static void initialize_static_string_field(fieldDescriptor* fd, Handle mirror, TRAPS) {
 860   DEBUG_ONLY(assert_valid_static_string_field(fd);)
 861   oop string = fd->string_initial_value(CHECK);
 862   mirror()->obj_field_put(fd->offset(), string);
 863 }
 864 
 865 static void initialize_static_primitive_field(fieldDescriptor* fd, Handle mirror) {

1103     allocate_mirror(k, /*is_scratch=*/false, protection_domain, classData, mirror, comp_mirror, CHECK);
1104 
1105     // set the classLoader field in the java_lang_Class instance
1106     assert(class_loader() == k->class_loader(), "should be same");
1107     set_class_loader(mirror(), class_loader());
1108 
1109     // Setup indirection from klass->mirror
1110     // after any exceptions can happen during allocations.
1111     k->set_java_mirror(mirror);
1112 
1113     // Set the module field in the java_lang_Class instance.  This must be done
1114     // after the mirror is set.
1115     set_mirror_module_field(THREAD, k, mirror, module);
1116 
1117     if (comp_mirror() != nullptr) {
1118       // Set after k->java_mirror() is published, because compiled code running
1119       // concurrently doesn't expect a k to have a null java_mirror.
1120       release_set_array_klass(comp_mirror(), k);
1121     }
1122     if (CDSConfig::is_dumping_heap()) {
1123       if (CDSConfig::is_dumping_protection_domains()) {
1124         create_scratch_mirror(k, protection_domain, CHECK);
1125       } else {
1126         create_scratch_mirror(k, Handle() /* null protection_domain*/, CHECK);
1127       }
1128     }
1129   } else {
1130     assert(fixup_mirror_list() != nullptr, "fixup_mirror_list not initialized");
1131     fixup_mirror_list()->push(k);
1132   }
1133 }
1134 
1135 #if INCLUDE_CDS_JAVA_HEAP
1136 // The "scratch mirror" stores the states of the mirror object that can be
1137 // decided at dump time (such as the initial values of the static fields, the
1138 // component mirror, etc). At runtime, more information is added to it by
1139 // java_lang_Class::restore_archived_mirror().
1140 //
1141 // Essentially, /*dumptime*/create_scratch_mirror() + /*runtime*/restore_archived_mirror()
1142 // produces the same result as /*runtime*/create_mirror().
1143 //
1144 // Note: we archive the "scratch mirror" instead of k->java_mirror(), because the
1145 // latter may contain dumptime-specific information that cannot be archived
1146 // (e.g., ClassLoaderData*, or static fields that are modified by Java code execution).
1147 void java_lang_Class::create_scratch_mirror(Klass* k, Handle protection_domain, TRAPS) {
1148   if (k->class_loader() != nullptr &&
1149       k->class_loader() != SystemDictionary::java_platform_loader() &&
1150       k->class_loader() != SystemDictionary::java_system_loader()) {
1151     // We only archive the mirrors of classes loaded by the built-in loaders
1152     return;
1153   }
1154 
1155   Handle classData; // set to null. Will be reinitialized at runtime
1156   Handle mirror;
1157   Handle comp_mirror;
1158   allocate_mirror(k, /*is_scratch=*/true, protection_domain, classData, mirror, comp_mirror, CHECK);
1159 
1160   if (comp_mirror() != nullptr) {
1161     release_set_array_klass(comp_mirror(), k);
1162   }
1163 
1164   HeapShared::set_scratch_java_mirror(k, mirror());
1165 }
1166 
1167 // Returns true if the mirror is updated, false if no archived mirror
1168 // data is present. After the archived mirror object is restored, the
1169 // shared klass' _has_raw_archived_mirror flag is cleared.
1170 bool java_lang_Class::restore_archived_mirror(Klass *k,
1171                                               Handle class_loader, Handle module,
1172                                               Handle protection_domain, TRAPS) {
1173   // Postpone restoring archived mirror until java.lang.Class is loaded. Please
1174   // see more details in vmClasses::resolve_all().
1175   if (!vmClasses::Class_klass_loaded()) {

1266 }
1267 void java_lang_Class::set_init_lock(oop java_class, oop init_lock) {
1268   assert(_init_lock_offset != 0, "must be set");
1269   java_class->obj_field_put(_init_lock_offset, init_lock);
1270 }
1271 
1272 objArrayOop java_lang_Class::signers(oop java_class) {
1273   assert(_signers_offset != 0, "must be set");
1274   return (objArrayOop)java_class->obj_field(_signers_offset);
1275 }
1276 
1277 oop java_lang_Class::class_data(oop java_class) {
1278   assert(_classData_offset != 0, "must be set");
1279   return java_class->obj_field(_classData_offset);
1280 }
1281 void java_lang_Class::set_class_data(oop java_class, oop class_data) {
1282   assert(_classData_offset != 0, "must be set");
1283   java_class->obj_field_put(_classData_offset, class_data);
1284 }
1285 
1286 oop java_lang_Class::reflection_data(oop java_class) {
1287   assert(_reflectionData_offset != 0, "must be set");
1288   return java_class->obj_field(_reflectionData_offset);
1289 }
1290 
1291 bool java_lang_Class::has_reflection_data(oop java_class) {
1292   return (java_lang_Class::reflection_data(java_class) != nullptr);
1293 }
1294 
1295 void java_lang_Class::set_reflection_data(oop java_class, oop reflection_data) {
1296   assert(_reflectionData_offset != 0, "must be set");
1297   java_class->obj_field_put(_reflectionData_offset, reflection_data);
1298 }
1299 
1300 void java_lang_Class::set_class_loader(oop java_class, oop loader) {
1301   assert(_class_loader_offset != 0, "offsets should have been initialized");
1302   java_class->obj_field_put(_class_loader_offset, loader);
1303 }
1304 
1305 oop java_lang_Class::class_loader(oop java_class) {
1306   assert(_class_loader_offset != 0, "must be set");
1307   return java_class->obj_field(_class_loader_offset);
1308 }
1309 
1310 oop java_lang_Class::module(oop java_class) {
1311   assert(_module_offset != 0, "must be set");
1312   return java_class->obj_field(_module_offset);
1313 }
1314 
1315 void java_lang_Class::set_module(oop java_class, oop module) {
1316   assert(_module_offset != 0, "must be set");
1317   java_class->obj_field_put(_module_offset, module);
1318 }
1319 

1470       (*reference_klass) = as_Klass(java_class);
1471     return T_OBJECT;
1472   }
1473 }
1474 
1475 
1476 oop java_lang_Class::primitive_mirror(BasicType t) {
1477   oop mirror = Universe::java_mirror(t);
1478   assert(mirror != nullptr && mirror->is_a(vmClasses::Class_klass()), "must be a Class");
1479   assert(is_primitive(mirror), "must be primitive");
1480   return mirror;
1481 }
1482 
1483 #define CLASS_FIELDS_DO(macro) \
1484   macro(_classRedefinedCount_offset, k, "classRedefinedCount", int_signature,          false); \
1485   macro(_class_loader_offset,        k, "classLoader",         classloader_signature,  false); \
1486   macro(_component_mirror_offset,    k, "componentType",       class_signature,        false); \
1487   macro(_module_offset,              k, "module",              module_signature,       false); \
1488   macro(_name_offset,                k, "name",                string_signature,       false); \
1489   macro(_classData_offset,           k, "classData",           object_signature,       false); \
1490   macro(_reflectionData_offset,      k, "reflectionData",      class_ReflectionData_signature, false); \
1491   macro(_signers_offset,             k, "signers",             object_array_signature, false);
1492 
1493 void java_lang_Class::compute_offsets() {
1494   if (_offsets_computed) {
1495     return;
1496   }
1497 
1498   _offsets_computed = true;
1499 
1500   InstanceKlass* k = vmClasses::Class_klass();
1501   CLASS_FIELDS_DO(FIELD_COMPUTE_OFFSET);
1502   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
1503 }
1504 
1505 #if INCLUDE_CDS
1506 void java_lang_Class::serialize_offsets(SerializeClosure* f) {
1507   f->do_bool(&_offsets_computed);
1508 
1509   CLASS_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
1510 

2174   return msg_utf8;
2175 }
2176 
2177 oop java_lang_Throwable::cause(oop throwable) {
2178   return throwable->obj_field(_cause_offset);
2179 }
2180 
2181 void java_lang_Throwable::set_message(oop throwable, oop value) {
2182   throwable->obj_field_put(_detailMessage_offset, value);
2183 }
2184 
2185 
2186 void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) {
2187   throwable->obj_field_put(_stackTrace_offset, st_element_array);
2188 }
2189 
2190 void java_lang_Throwable::clear_stacktrace(oop throwable) {
2191   set_stacktrace(throwable, nullptr);
2192 }
2193 
2194 oop java_lang_Throwable::create_exception_instance(Symbol* class_name, TRAPS) {
2195   Klass* k = SystemDictionary::resolve_or_fail(class_name, true, CHECK_NULL);
2196   return InstanceKlass::cast(k)->allocate_instance(CHECK_NULL);
2197 }
2198 
2199 void java_lang_Throwable::print(oop throwable, outputStream* st) {
2200   ResourceMark rm;
2201   Klass* k = throwable->klass();
2202   assert(k != nullptr, "just checking");
2203   st->print("%s", k->external_name());
2204   oop msg = message(throwable);
2205   if (msg != nullptr) {
2206     st->print(": %s", java_lang_String::as_utf8_string(msg));
2207   }
2208 }
2209 
2210 // After this many redefines, the stack trace is unreliable.
2211 const int MAX_VERSION = USHRT_MAX;
2212 
2213 static inline bool version_matches(Method* method, int version) {
2214   assert(version < MAX_VERSION, "version is too big");
2215   return method != nullptr && (method->constants()->version() == version);
2216 }
2217 

5429   }
5430 
5431   // We have already called the compute_offsets() of the
5432   // BASIC_JAVA_CLASSES_DO_PART1 classes (java_lang_String, java_lang_Class and
5433   // java_lang_ref_Reference) earlier inside vmClasses::resolve_all()
5434   BASIC_JAVA_CLASSES_DO_PART2(DO_COMPUTE_OFFSETS);
5435 }
5436 
5437 #if INCLUDE_CDS
5438 #define DO_SERIALIZE_OFFSETS(k) k::serialize_offsets(soc);
5439 
5440 void JavaClasses::serialize_offsets(SerializeClosure* soc) {
5441   BASIC_JAVA_CLASSES_DO(DO_SERIALIZE_OFFSETS);
5442 }
5443 #endif
5444 
5445 #if INCLUDE_CDS_JAVA_HEAP
5446 bool JavaClasses::is_supported_for_archiving(oop obj) {
5447   Klass* klass = obj->klass();
5448 
5449   if (!CDSConfig::is_dumping_invokedynamic()) {
5450     // These are supported by CDS only when CDSConfig::is_dumping_invokedynamic() is enabled.
5451     if (klass == vmClasses::ResolvedMethodName_klass() ||
5452         klass == vmClasses::MemberName_klass() ||
5453         klass == vmClasses::Context_klass()) {
5454       return false;
5455     }
5456   }
5457 
5458   if (klass->is_subclass_of(vmClasses::Reference_klass())) {
5459     // It's problematic to archive Reference objects. One of the reasons is that
5460     // Reference::discovered may pull in unwanted objects (see JDK-8284336)


5461     return false;
5462   }
5463 
5464   return true;
5465 }
5466 #endif
5467 
5468 #ifndef PRODUCT
5469 
5470 // These functions exist to assert the validity of de-serialized offsets in boxing object as a sanity check.
5471 
5472 bool JavaClasses::check_offset(const char *klass_name, int deserialized_offset, const char *field_name,
5473                                const char* field_sig) {
5474   EXCEPTION_MARK;
5475   fieldDescriptor fd;
5476   TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name);
5477   Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH);
5478   InstanceKlass* ik = InstanceKlass::cast(k);
5479   TempNewSymbol f_name = SymbolTable::new_symbol(field_name);
5480   TempNewSymbol f_sig  = SymbolTable::new_symbol(field_sig);
< prev index next >