22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classFileStream.hpp"
27 #include "classfile/classListParser.hpp"
28 #include "classfile/classLoader.hpp"
29 #include "classfile/classLoaderData.inline.hpp"
30 #include "classfile/classLoaderDataGraph.hpp"
31 #include "classfile/classLoaderExt.hpp"
32 #include "classfile/dictionary.hpp"
33 #include "classfile/javaClasses.hpp"
34 #include "classfile/symbolTable.hpp"
35 #include "classfile/systemDictionary.hpp"
36 #include "classfile/systemDictionaryShared.hpp"
37 #include "classfile/verificationType.hpp"
38 #include "classfile/vmSymbols.hpp"
39 #include "logging/log.hpp"
40 #include "memory/allocation.hpp"
41 #include "memory/archiveUtils.hpp"
42 #include "memory/filemap.hpp"
43 #include "memory/heapShared.hpp"
44 #include "memory/metadataFactory.hpp"
45 #include "memory/metaspaceClosure.hpp"
46 #include "memory/oopFactory.hpp"
47 #include "memory/resourceArea.hpp"
48 #include "memory/universe.hpp"
49 #include "memory/dynamicArchive.hpp"
50 #include "oops/instanceKlass.hpp"
51 #include "oops/klass.inline.hpp"
52 #include "oops/objArrayOop.inline.hpp"
53 #include "oops/oop.inline.hpp"
54 #include "oops/typeArrayOop.inline.hpp"
55 #include "runtime/handles.inline.hpp"
56 #include "runtime/java.hpp"
57 #include "runtime/javaCalls.hpp"
58 #include "runtime/mutexLocker.hpp"
59 #include "utilities/hashtable.inline.hpp"
60 #include "utilities/resourceHash.hpp"
61 #include "utilities/stringUtils.hpp"
62
63
64 objArrayOop SystemDictionaryShared::_shared_protection_domains = NULL;
65 objArrayOop SystemDictionaryShared::_shared_jar_urls = NULL;
66 objArrayOop SystemDictionaryShared::_shared_jar_manifests = NULL;
67 DEBUG_ONLY(bool SystemDictionaryShared::_no_class_loading_should_happen = false;)
68
69 class DumpTimeSharedClassInfo: public CHeapObj<mtClass> {
84 }
85 };
86
87 struct DTVerifierConstraint {
88 Symbol* _name;
89 Symbol* _from_name;
90 DTVerifierConstraint() : _name(NULL), _from_name(NULL) {}
91 DTVerifierConstraint(Symbol* n, Symbol* fn) : _name(n), _from_name(fn) {
92 _name->increment_refcount();
93 _from_name->increment_refcount();
94 }
95 };
96
97 InstanceKlass* _klass;
98 bool _failed_verification;
99 int _id;
100 int _clsfile_size;
101 int _clsfile_crc32;
102 GrowableArray<DTVerifierConstraint>* _verifier_constraints;
103 GrowableArray<char>* _verifier_constraint_flags;
104 GrowableArray<DTLoaderConstraint>* _loader_constraints;
105
106 DumpTimeSharedClassInfo() {
107 _klass = NULL;
108 _failed_verification = false;
109 _id = -1;
110 _clsfile_size = -1;
111 _clsfile_crc32 = -1;
112 _excluded = false;
113 _verifier_constraints = NULL;
114 _verifier_constraint_flags = NULL;
115 _loader_constraints = NULL;
116 }
117
118 void add_verification_constraint(InstanceKlass* k, Symbol* name,
119 Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object);
120 void record_linking_constraint(Symbol* name, Handle loader1, Handle loader2);
121
122 bool is_builtin() {
123 return SystemDictionaryShared::is_builtin(_klass);
124 }
125
126 int num_verifier_constraints() {
127 if (_verifier_constraint_flags != NULL) {
128 return _verifier_constraint_flags->length();
129 } else {
130 return 0;
131 }
132 }
133
134 int num_loader_constraints() {
225 return true; // keep on iterating
226 }
227 };
228
229 void update_counts() {
230 _builtin_count = 0;
231 _unregistered_count = 0;
232 CountClassByCategory counter(this);
233 iterate(&counter);
234 }
235
236 int count_of(bool is_builtin) const {
237 if (is_builtin) {
238 return _builtin_count;
239 } else {
240 return _unregistered_count;
241 }
242 }
243 };
244
245 class RunTimeSharedClassInfo {
246 public:
247 struct CrcInfo {
248 int _clsfile_size;
249 int _clsfile_crc32;
250 };
251
252 // This is different than DumpTimeSharedClassInfo::DTVerifierConstraint. We use
253 // u4 instead of Symbol* to save space on 64-bit CPU.
254 struct RTVerifierConstraint {
255 u4 _name;
256 u4 _from_name;
257 Symbol* name() { return (Symbol*)(SharedBaseAddress + _name);}
258 Symbol* from_name() { return (Symbol*)(SharedBaseAddress + _from_name); }
259 };
260
261 struct RTLoaderConstraint {
262 u4 _name;
263 char _loader_type1;
264 char _loader_type2;
265 Symbol* constraint_name() {
266 return (Symbol*)(SharedBaseAddress + _name);
267 }
268 };
269
270 InstanceKlass* _klass;
271 int _num_verifier_constraints;
272 int _num_loader_constraints;
273
274 // optional CrcInfo _crc; (only for UNREGISTERED classes)
275 // optional RTLoaderConstraint _loader_constraint_types[_num_loader_constraints]
276 // optional RTVerifierConstraint _verifier_constraints[_num_verifier_constraints]
277 // optional char _verifier_constraint_flags[_num_verifier_constraints]
278
279 private:
280 static size_t header_size_size() {
281 return sizeof(RunTimeSharedClassInfo);
282 }
283 static size_t crc_size(InstanceKlass* klass) {
284 if (!SystemDictionaryShared::is_builtin(klass)) {
285 return sizeof(CrcInfo);
286 } else {
287 return 0;
288 }
289 }
290 static size_t verifier_constraints_size(int num_verifier_constraints) {
291 return sizeof(RTVerifierConstraint) * num_verifier_constraints;
292 }
293 static size_t verifier_constraint_flags_size(int num_verifier_constraints) {
294 return sizeof(char) * num_verifier_constraints;
295 }
296 static size_t loader_constraints_size(int num_loader_constraints) {
297 return sizeof(RTLoaderConstraint) * num_loader_constraints;
298 }
299
300 public:
301 static size_t byte_size(InstanceKlass* klass, int num_verifier_constraints, int num_loader_constraints) {
302 return header_size_size() +
303 crc_size(klass) +
304 loader_constraints_size(num_loader_constraints) +
305 verifier_constraints_size(num_verifier_constraints) +
306 verifier_constraint_flags_size(num_verifier_constraints);
307 }
308
309 private:
310 size_t crc_offset() const {
311 return header_size_size();
312 }
313
314 size_t loader_constraints_offset() const {
315 return crc_offset() + crc_size(_klass);
316 }
317 size_t verifier_constraints_offset() const {
318 return loader_constraints_offset() + loader_constraints_size(_num_loader_constraints);
319 }
320 size_t verifier_constraint_flags_offset() const {
321 return verifier_constraints_offset() + verifier_constraints_size(_num_verifier_constraints);
322 }
323
324 void check_verifier_constraint_offset(int i) const {
325 assert(0 <= i && i < _num_verifier_constraints, "sanity");
326 }
327
328 void check_loader_constraint_offset(int i) const {
329 assert(0 <= i && i < _num_loader_constraints, "sanity");
330 }
331
332 public:
333 CrcInfo* crc() const {
334 assert(crc_size(_klass) > 0, "must be");
335 return (CrcInfo*)(address(this) + crc_offset());
336 }
337 RTVerifierConstraint* verifier_constraints() {
338 assert(_num_verifier_constraints > 0, "sanity");
339 return (RTVerifierConstraint*)(address(this) + verifier_constraints_offset());
340 }
341 RTVerifierConstraint* verifier_constraint_at(int i) {
342 check_verifier_constraint_offset(i);
343 return verifier_constraints() + i;
344 }
345
346 char* verifier_constraint_flags() {
347 assert(_num_verifier_constraints > 0, "sanity");
348 return (char*)(address(this) + verifier_constraint_flags_offset());
349 }
350
351 RTLoaderConstraint* loader_constraints() {
352 assert(_num_loader_constraints > 0, "sanity");
353 return (RTLoaderConstraint*)(address(this) + loader_constraints_offset());
354 }
355
356 RTLoaderConstraint* loader_constraint_at(int i) {
357 check_loader_constraint_offset(i);
358 return loader_constraints() + i;
359 }
360
361 static u4 object_delta_u4(Symbol* sym) {
362 if (DynamicDumpSharedSpaces) {
363 sym = DynamicArchive::original_to_target(sym);
364 }
365 return MetaspaceShared::object_delta_u4(sym);
366 }
367
368 void init(DumpTimeSharedClassInfo& info) {
369 _klass = info._klass;
370 if (!SystemDictionaryShared::is_builtin(_klass)) {
379 RTVerifierConstraint* vf_constraints = verifier_constraints();
380 char* flags = verifier_constraint_flags();
381 for (i = 0; i < _num_verifier_constraints; i++) {
382 vf_constraints[i]._name = object_delta_u4(info._verifier_constraints->at(i)._name);
383 vf_constraints[i]._from_name = object_delta_u4(info._verifier_constraints->at(i)._from_name);
384 }
385 for (i = 0; i < _num_verifier_constraints; i++) {
386 flags[i] = info._verifier_constraint_flags->at(i);
387 }
388 }
389
390 if (_num_loader_constraints > 0) {
391 RTLoaderConstraint* ld_constraints = loader_constraints();
392 for (i = 0; i < _num_loader_constraints; i++) {
393 ld_constraints[i]._name = object_delta_u4(info._loader_constraints->at(i)._name);
394 ld_constraints[i]._loader_type1 = info._loader_constraints->at(i)._loader_type1;
395 ld_constraints[i]._loader_type2 = info._loader_constraints->at(i)._loader_type2;
396 }
397 }
398 if (DynamicDumpSharedSpaces) {
399 _klass = DynamicArchive::original_to_target(info._klass);
400 }
401 ArchivePtrMarker::mark_pointer(&_klass);
402 }
403
404 bool matches(int clsfile_size, int clsfile_crc32) const {
405 return crc()->_clsfile_size == clsfile_size &&
406 crc()->_clsfile_crc32 == clsfile_crc32;
407 }
408
409 char verifier_constraint_flag(int i) {
410 check_verifier_constraint_offset(i);
411 return verifier_constraint_flags()[i];
412 }
413
414 private:
415 // ArchiveCompactor::allocate() has reserved a pointer immediately before
416 // archived InstanceKlasses. We can use this slot to do a quick
417 // lookup of InstanceKlass* -> RunTimeSharedClassInfo* without
418 // building a new hashtable.
419 //
420 // info_pointer_addr(klass) --> 0x0100 RunTimeSharedClassInfo*
421 // InstanceKlass* klass --> 0x0108 <C++ vtbl>
422 // 0x0110 fields from Klass ...
423 static RunTimeSharedClassInfo** info_pointer_addr(InstanceKlass* klass) {
424 return &((RunTimeSharedClassInfo**)klass)[-1];
425 }
426
427 public:
428 static RunTimeSharedClassInfo* get_for(InstanceKlass* klass) {
429 return *info_pointer_addr(klass);
430 }
431 static void set_for(InstanceKlass* klass, RunTimeSharedClassInfo* record) {
432 if (DynamicDumpSharedSpaces) {
433 klass = DynamicArchive::original_to_buffer(klass);
434 *info_pointer_addr(klass) = DynamicArchive::buffer_to_target(record);
435 } else {
436 *info_pointer_addr(klass) = record;
437 }
438
439 ArchivePtrMarker::mark_pointer(info_pointer_addr(klass));
440 }
441
442 // Used by RunTimeSharedDictionary to implement OffsetCompactHashtable::EQUALS
443 static inline bool EQUALS(
444 const RunTimeSharedClassInfo* value, Symbol* key, int len_unused) {
445 return (value->_klass->name() == key);
446 }
447 };
448
1134 if (ld._name != NULL) {
1135 ld._name->decrement_refcount();
1136 }
1137 }
1138 FREE_C_HEAP_ARRAY(DumpTimeSharedClassInfo::DTLoaderConstraint, p->_loader_constraints);
1139 p->_loader_constraints = NULL;
1140 }
1141 _dumptime_table->remove(k);
1142 }
1143
1144 bool SystemDictionaryShared::is_jfr_event_class(InstanceKlass *k) {
1145 while (k) {
1146 if (k->name()->equals("jdk/internal/event/Event")) {
1147 return true;
1148 }
1149 k = k->java_super();
1150 }
1151 return false;
1152 }
1153
1154 void SystemDictionaryShared::warn_excluded(InstanceKlass* k, const char* reason) {
1155 ResourceMark rm;
1156 log_warning(cds)("Skipping %s: %s", k->name()->as_C_string(), reason);
1157 }
1158
1159 bool SystemDictionaryShared::should_be_excluded(InstanceKlass* k) {
1160 if (k->is_hidden() || k->is_unsafe_anonymous()) {
1161 warn_excluded(k, "Hidden or Unsafe anonymous class");
1162 return true; // hidden and unsafe anonymous classes are not archived, skip
1163 }
1164 if (k->is_in_error_state()) {
1165 warn_excluded(k, "In error state");
1166 return true;
1167 }
1168 if (k->has_been_redefined()) {
1169 warn_excluded(k, "Has been redefined");
1170 return true;
1171 }
1172 if (k->shared_classpath_index() < 0 && is_builtin(k)) {
1173 // These are classes loaded from unsupported locations (such as those loaded by JVMTI native
1174 // agent during dump time).
1175 warn_excluded(k, "Unsupported location");
1176 return true;
1177 }
1178 if (k->signers() != NULL) {
1179 // We cannot include signed classes in the archive because the certificates
1180 // used during dump time may be different than those used during
1181 // runtime (due to expiration, etc).
1182 warn_excluded(k, "Signed JAR");
1183 return true;
1184 }
1185 if (is_jfr_event_class(k)) {
1186 // We cannot include JFR event classes because they need runtime-specific
1187 // instrumentation in order to work with -XX:FlightRecorderOptions=retransform=false.
1188 // There are only a small number of these classes, so it's not worthwhile to
1189 // support them and make CDS more complicated.
1190 warn_excluded(k, "JFR event class");
1191 return true;
1192 }
1205 warn_excluded(k, "Failed verification");
1206 } else {
1207 warn_excluded(k, "Not linked");
1208 }
1209 return true;
1210 }
1211 if (k->major_version() < 50 /*JAVA_6_VERSION*/) {
1212 ResourceMark rm;
1213 log_warning(cds)("Pre JDK 6 class not supported by CDS: %u.%u %s",
1214 k->major_version(), k->minor_version(), k->name()->as_C_string());
1215 return true;
1216 }
1217
1218 InstanceKlass* super = k->java_super();
1219 if (super != NULL && should_be_excluded(super)) {
1220 ResourceMark rm;
1221 log_warning(cds)("Skipping %s: super class %s is excluded", k->name()->as_C_string(), super->name()->as_C_string());
1222 return true;
1223 }
1224
1225 Array<InstanceKlass*>* interfaces = k->local_interfaces();
1226 int len = interfaces->length();
1227 for (int i = 0; i < len; i++) {
1228 InstanceKlass* intf = interfaces->at(i);
1229 if (should_be_excluded(intf)) {
1230 log_warning(cds)("Skipping %s: interface %s is excluded", k->name()->as_C_string(), intf->name()->as_C_string());
1231 return true;
1232 }
1233 }
1234
1235 return false;
1236 }
1237
1238 // k is a class before relocating by ArchiveCompactor
1239 void SystemDictionaryShared::validate_before_archiving(InstanceKlass* k) {
1240 ResourceMark rm;
1241 const char* name = k->name()->as_C_string();
1242 DumpTimeSharedClassInfo* info = _dumptime_table->get(k);
1243 assert(_no_class_loading_should_happen, "class loading must be disabled");
1244 guarantee(info != NULL, "Class %s must be entered into _dumptime_table", name);
1245 guarantee(!info->is_excluded(), "Should not attempt to archive excluded class %s", name);
1246 if (is_builtin(k)) {
1247 guarantee(!k->is_shared_unregistered_class(),
1248 "Class loader type must be set for BUILTIN class %s", name);
1249 } else {
1250 guarantee(k->is_shared_unregistered_class(),
1251 "Class loader type must not be set for UNREGISTERED class %s", name);
1252 }
1253 }
1254
1255 class ExcludeDumpTimeSharedClasses : StackObj {
1256 public:
1257 bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1258 if (SystemDictionaryShared::should_be_excluded(k)) {
1259 info.set_excluded();
1260 }
1261 return true; // keep on iterating
1262 }
1263 };
1264
1265 void SystemDictionaryShared::check_excluded_classes() {
1266 ExcludeDumpTimeSharedClasses excl;
1267 _dumptime_table->iterate(&excl);
1268 _dumptime_table->update_counts();
1344 }
1345 GrowableArray<DTVerifierConstraint>* vc_array = _verifier_constraints;
1346 for (int i = 0; i < vc_array->length(); i++) {
1347 DTVerifierConstraint* p = vc_array->adr_at(i);
1348 if (name == p->_name && from_name == p->_from_name) {
1349 return;
1350 }
1351 }
1352 DTVerifierConstraint cons(name, from_name);
1353 vc_array->append(cons);
1354
1355 GrowableArray<char>* vcflags_array = _verifier_constraint_flags;
1356 char c = 0;
1357 c |= from_field_is_protected ? SystemDictionaryShared::FROM_FIELD_IS_PROTECTED : 0;
1358 c |= from_is_array ? SystemDictionaryShared::FROM_IS_ARRAY : 0;
1359 c |= from_is_object ? SystemDictionaryShared::FROM_IS_OBJECT : 0;
1360 vcflags_array->append(c);
1361
1362 if (log_is_enabled(Trace, cds, verification)) {
1363 ResourceMark rm;
1364 log_trace(cds, verification)("add_verification_constraint: %s: %s must be subclass of %s [0x%x]",
1365 k->external_name(), from_name->as_klass_external_name(),
1366 name->as_klass_external_name(), c);
1367 }
1368 }
1369
1370 static char get_loader_type_by(oop loader) {
1371 assert(SystemDictionary::is_builtin_class_loader(loader), "Must be built-in loader");
1372 if (SystemDictionary::is_boot_class_loader(loader)) {
1373 return (char)ClassLoader::BOOT_LOADER;
1374 } else if (SystemDictionary::is_platform_class_loader(loader)) {
1375 return (char)ClassLoader::PLATFORM_LOADER;
1376 } else {
1377 assert(SystemDictionary::is_system_class_loader(loader), "Class loader mismatch");
1378 return (char)ClassLoader::APP_LOADER;
1379 }
1380 }
1381
1382 static oop get_class_loader_by(char type) {
1383 if (type == (char)ClassLoader::BOOT_LOADER) {
1384 return (oop)NULL;
1385 } else if (type == (char)ClassLoader::PLATFORM_LOADER) {
1386 return SystemDictionary::java_platform_loader();
1387 } else {
1580 _num_builtin_klasses = 0;
1581 _num_unregistered_klasses = 0;
1582 }
1583
1584 bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1585 if (!info.is_excluded()) {
1586 size_t byte_size = RunTimeSharedClassInfo::byte_size(info._klass, info.num_verifier_constraints(), info.num_loader_constraints());
1587 _shared_class_info_size += align_up(byte_size, BytesPerWord);
1588 }
1589 return true; // keep on iterating
1590 }
1591
1592 size_t total() {
1593 return _shared_class_info_size;
1594 }
1595 };
1596
1597 size_t SystemDictionaryShared::estimate_size_for_archive() {
1598 EstimateSizeForArchive est;
1599 _dumptime_table->iterate(&est);
1600 return est.total() +
1601 CompactHashtableWriter::estimate_size(_dumptime_table->count_of(true)) +
1602 CompactHashtableWriter::estimate_size(_dumptime_table->count_of(false));
1603 }
1604
1605 class CopySharedClassInfoToArchive : StackObj {
1606 CompactHashtableWriter* _writer;
1607 bool _is_builtin;
1608 public:
1609 CopySharedClassInfoToArchive(CompactHashtableWriter* writer,
1610 bool is_builtin,
1611 bool is_static_archive)
1612 : _writer(writer), _is_builtin(is_builtin) {}
1613
1614 bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1615 if (!info.is_excluded() && info.is_builtin() == _is_builtin) {
1616 size_t byte_size = RunTimeSharedClassInfo::byte_size(info._klass, info.num_verifier_constraints(), info.num_loader_constraints());
1617 RunTimeSharedClassInfo* record;
1618 record = (RunTimeSharedClassInfo*)MetaspaceShared::read_only_space_alloc(byte_size);
1619 record->init(info);
1620
1621 unsigned int hash;
1622 Symbol* name = info._klass->name();
1623 if (DynamicDumpSharedSpaces) {
1624 name = DynamicArchive::original_to_target(name);
1625 }
1626 hash = SystemDictionaryShared::hash_for_shared_dictionary(name);
1627 u4 delta;
1628 if (DynamicDumpSharedSpaces) {
1629 delta = MetaspaceShared::object_delta_u4(DynamicArchive::buffer_to_target(record));
1630 } else {
1631 delta = MetaspaceShared::object_delta_u4(record);
1632 }
1633 _writer->add(hash, delta);
1634 if (log_is_enabled(Trace, cds, hashtables)) {
1635 ResourceMark rm;
1636 log_trace(cds,hashtables)("%s dictionary: %s", (_is_builtin ? "builtin" : "unregistered"), info._klass->external_name());
1637 }
1638
1639 // Save this for quick runtime lookup of InstanceKlass* -> RunTimeSharedClassInfo*
1640 RunTimeSharedClassInfo::set_for(info._klass, record);
1641 }
1642 return true; // keep on iterating
1643 }
1644 };
1645
1646 void SystemDictionaryShared::write_dictionary(RunTimeSharedDictionary* dictionary,
1647 bool is_builtin,
1648 bool is_static_archive) {
1649 CompactHashtableStats stats;
1650 dictionary->reset();
1651 CompactHashtableWriter writer(_dumptime_table->count_of(is_builtin), &stats);
1652 CopySharedClassInfoToArchive copy(&writer, is_builtin, is_static_archive);
1653 _dumptime_table->iterate(©);
1654 writer.dump(dictionary, is_builtin ? "builtin dictionary" : "unregistered dictionary");
1655 }
1656
1657 void SystemDictionaryShared::write_to_archive(bool is_static_archive) {
1658 if (is_static_archive) {
1659 write_dictionary(&_builtin_dictionary, true);
1660 write_dictionary(&_unregistered_dictionary, false);
1661 } else {
1662 write_dictionary(&_dynamic_builtin_dictionary, true);
1663 write_dictionary(&_dynamic_unregistered_dictionary, false);
1664 }
1665 }
1666
1667 void SystemDictionaryShared::serialize_dictionary_headers(SerializeClosure* soc,
1668 bool is_static_archive) {
1669 if (is_static_archive) {
1670 _builtin_dictionary.serialize_header(soc);
1671 _unregistered_dictionary.serialize_header(soc);
1672 } else {
1673 _dynamic_builtin_dictionary.serialize_header(soc);
1674 _dynamic_unregistered_dictionary.serialize_header(soc);
1675 }
1676 }
1677
1678 void SystemDictionaryShared::serialize_well_known_klasses(SerializeClosure* soc) {
1679 for (int i = FIRST_WKID; i < WKID_LIMIT; i++) {
1680 soc->do_ptr((void**)&_well_known_klasses[i]);
1681 }
1682 }
1683
1684 const RunTimeSharedClassInfo*
1685 SystemDictionaryShared::find_record(RunTimeSharedDictionary* static_dict, RunTimeSharedDictionary* dynamic_dict, Symbol* name) {
1686 if (!UseSharedSpaces || !name->is_shared()) {
1687 // The names of all shared classes must also be a shared Symbol.
1688 return NULL;
1689 }
1690
1691 unsigned int hash = SystemDictionaryShared::hash_for_shared_dictionary(name);
1692 const RunTimeSharedClassInfo* record = NULL;
1693 if (!MetaspaceShared::is_shared_dynamic(name)) {
1694 // The names of all shared classes in the static dict must also be in the
1695 // static archive
1696 record = static_dict->lookup(name, hash, 0);
1697 }
1698
1699 if (record == NULL && DynamicArchive::is_mapped()) {
1700 record = dynamic_dict->lookup(name, hash, 0);
1701 }
1702
1703 return record;
1704 }
1705
1706 InstanceKlass* SystemDictionaryShared::find_builtin_class(Symbol* name) {
1707 const RunTimeSharedClassInfo* record = find_record(&_builtin_dictionary, &_dynamic_builtin_dictionary, name);
1708 if (record != NULL) {
1709 return record->_klass;
1710 } else {
1711 return NULL;
1712 }
1713 }
1714
1715 void SystemDictionaryShared::update_shared_entry(InstanceKlass* k, int id) {
1716 assert(DumpSharedSpaces, "supported only when dumping");
1717 DumpTimeSharedClassInfo* info = find_or_allocate_info_for(k);
1718 info->_id = id;
1719 }
1720
1721 class SharedDictionaryPrinter : StackObj {
1722 outputStream* _st;
1723 int _index;
1724 public:
1725 SharedDictionaryPrinter(outputStream* st) : _st(st), _index(0) {}
1726
1727 void do_value(const RunTimeSharedClassInfo* record) {
1728 ResourceMark rm;
1729 _st->print_cr("%4d: %s", (_index++), record->_klass->external_name());
1730 }
1731 };
1732
1733 void SystemDictionaryShared::print_on(outputStream* st) {
1734 if (UseSharedSpaces) {
1735 st->print_cr("Shared Dictionary");
1736 SharedDictionaryPrinter p(st);
1737 _builtin_dictionary.iterate(&p);
1738 _unregistered_dictionary.iterate(&p);
1739 if (DynamicArchive::is_mapped()) {
1740 _dynamic_builtin_dictionary.iterate(&p);
1741 _unregistered_dictionary.iterate(&p);
1742 }
1743 }
1744 }
1745
1746 void SystemDictionaryShared::print_table_statistics(outputStream* st) {
1747 if (UseSharedSpaces) {
1748 _builtin_dictionary.print_table_statistics(st, "Builtin Shared Dictionary");
1749 _unregistered_dictionary.print_table_statistics(st, "Unregistered Shared Dictionary");
1750 if (DynamicArchive::is_mapped()) {
1751 _dynamic_builtin_dictionary.print_table_statistics(st, "Dynamic Builtin Shared Dictionary");
1752 _dynamic_unregistered_dictionary.print_table_statistics(st, "Unregistered Shared Dictionary");
1753 }
1754 }
1755 }
1756
1757 bool SystemDictionaryShared::empty_dumptime_table() {
1758 if (_dumptime_table == NULL) {
1759 return true;
1760 }
1761 _dumptime_table->update_counts();
1762 if (_dumptime_table->count_of(true) == 0 && _dumptime_table->count_of(false) == 0){
1763 return true;
1764 }
1765 return false;
1766 }
1767
1768 #if INCLUDE_CDS_JAVA_HEAP
1769
1770 class ArchivedMirrorPatcher {
1771 static void update(Klass* k) {
1772 if (k->has_raw_archived_mirror()) {
|
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classFileStream.hpp"
27 #include "classfile/classListParser.hpp"
28 #include "classfile/classLoader.hpp"
29 #include "classfile/classLoaderData.inline.hpp"
30 #include "classfile/classLoaderDataGraph.hpp"
31 #include "classfile/classLoaderExt.hpp"
32 #include "classfile/dictionary.hpp"
33 #include "classfile/javaClasses.hpp"
34 #include "classfile/symbolTable.hpp"
35 #include "classfile/systemDictionary.hpp"
36 #include "classfile/systemDictionaryShared.hpp"
37 #include "classfile/verificationType.hpp"
38 #include "classfile/vmSymbols.hpp"
39 #include "logging/log.hpp"
40 #include "memory/allocation.hpp"
41 #include "memory/archiveUtils.hpp"
42 #include "memory/dynamicArchive.hpp"
43 #include "memory/filemap.hpp"
44 #include "memory/heapShared.hpp"
45 #include "memory/metadataFactory.hpp"
46 #include "memory/metaspaceClosure.hpp"
47 #include "memory/oopFactory.hpp"
48 #include "memory/resourceArea.hpp"
49 #include "memory/universe.hpp"
50 #include "oops/instanceKlass.hpp"
51 #include "oops/klass.inline.hpp"
52 #include "oops/objArrayOop.inline.hpp"
53 #include "oops/oop.inline.hpp"
54 #include "oops/typeArrayOop.inline.hpp"
55 #include "runtime/handles.inline.hpp"
56 #include "runtime/java.hpp"
57 #include "runtime/javaCalls.hpp"
58 #include "runtime/mutexLocker.hpp"
59 #include "utilities/hashtable.inline.hpp"
60 #include "utilities/resourceHash.hpp"
61 #include "utilities/stringUtils.hpp"
62
63
64 objArrayOop SystemDictionaryShared::_shared_protection_domains = NULL;
65 objArrayOop SystemDictionaryShared::_shared_jar_urls = NULL;
66 objArrayOop SystemDictionaryShared::_shared_jar_manifests = NULL;
67 DEBUG_ONLY(bool SystemDictionaryShared::_no_class_loading_should_happen = false;)
68
69 class DumpTimeSharedClassInfo: public CHeapObj<mtClass> {
84 }
85 };
86
87 struct DTVerifierConstraint {
88 Symbol* _name;
89 Symbol* _from_name;
90 DTVerifierConstraint() : _name(NULL), _from_name(NULL) {}
91 DTVerifierConstraint(Symbol* n, Symbol* fn) : _name(n), _from_name(fn) {
92 _name->increment_refcount();
93 _from_name->increment_refcount();
94 }
95 };
96
97 InstanceKlass* _klass;
98 bool _failed_verification;
99 int _id;
100 int _clsfile_size;
101 int _clsfile_crc32;
102 GrowableArray<DTVerifierConstraint>* _verifier_constraints;
103 GrowableArray<char>* _verifier_constraint_flags;
104 bool _is_archived_lambda_proxy;
105 GrowableArray<DTLoaderConstraint>* _loader_constraints;
106
107 DumpTimeSharedClassInfo() {
108 _klass = NULL;
109 _failed_verification = false;
110 _id = -1;
111 _clsfile_size = -1;
112 _clsfile_crc32 = -1;
113 _excluded = false;
114 _verifier_constraints = NULL;
115 _verifier_constraint_flags = NULL;
116 _is_archived_lambda_proxy = false;
117 _loader_constraints = NULL;
118 }
119
120 void add_verification_constraint(InstanceKlass* k, Symbol* name,
121 Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object);
122 void record_linking_constraint(Symbol* name, Handle loader1, Handle loader2);
123
124 bool is_builtin() {
125 return SystemDictionaryShared::is_builtin(_klass);
126 }
127
128 int num_verifier_constraints() {
129 if (_verifier_constraint_flags != NULL) {
130 return _verifier_constraint_flags->length();
131 } else {
132 return 0;
133 }
134 }
135
136 int num_loader_constraints() {
227 return true; // keep on iterating
228 }
229 };
230
231 void update_counts() {
232 _builtin_count = 0;
233 _unregistered_count = 0;
234 CountClassByCategory counter(this);
235 iterate(&counter);
236 }
237
238 int count_of(bool is_builtin) const {
239 if (is_builtin) {
240 return _builtin_count;
241 } else {
242 return _unregistered_count;
243 }
244 }
245 };
246
247 class LambdaProxyClassKey {
248 template <typename T> static void original_to_target(T& field) {
249 if (field != NULL) {
250 field = DynamicArchive::original_to_target(field);
251 ArchivePtrMarker::mark_pointer(&field);
252 }
253 }
254
255 InstanceKlass* _caller_ik;
256 Symbol* _invoked_name;
257 Symbol* _invoked_type;
258 Symbol* _method_type;
259 Method* _member_method;
260 Symbol* _instantiated_method_type;
261
262 public:
263 LambdaProxyClassKey(InstanceKlass* caller_ik,
264 Symbol* invoked_name,
265 Symbol* invoked_type,
266 Symbol* method_type,
267 Method* member_method,
268 Symbol* instantiated_method_type) :
269 _caller_ik(caller_ik),
270 _invoked_name(invoked_name),
271 _invoked_type(invoked_type),
272 _method_type(method_type),
273 _member_method(member_method),
274 _instantiated_method_type(instantiated_method_type) {}
275
276 void original_to_target() {
277 original_to_target(_caller_ik);
278 original_to_target(_instantiated_method_type);
279 original_to_target(_invoked_name);
280 original_to_target(_invoked_type);
281 original_to_target(_member_method);
282 original_to_target(_method_type);
283 }
284
285 bool equals(LambdaProxyClassKey const& other) const {
286 return _caller_ik == other._caller_ik &&
287 _invoked_name == other._invoked_name &&
288 _invoked_type == other._invoked_type &&
289 _method_type == other._method_type &&
290 _member_method == other._member_method &&
291 _instantiated_method_type == other._instantiated_method_type;
292 }
293
294 unsigned int hash() const {
295 return SystemDictionaryShared::hash_for_shared_dictionary(_caller_ik) +
296 SystemDictionaryShared::hash_for_shared_dictionary(_invoked_name) +
297 SystemDictionaryShared::hash_for_shared_dictionary(_invoked_type) +
298 SystemDictionaryShared::hash_for_shared_dictionary(_method_type) +
299 SystemDictionaryShared::hash_for_shared_dictionary(_instantiated_method_type);
300 }
301
302 unsigned int dumptime_hash() const {
303 return primitive_hash<InstanceKlass*>(_caller_ik) +
304 primitive_hash<Symbol*>(_invoked_name) +
305 primitive_hash<Symbol*>(_invoked_type) +
306 primitive_hash<Symbol*>(_method_type) +
307 primitive_hash<Symbol*>(_instantiated_method_type);
308 }
309
310 static inline unsigned int DUMPTIME_HASH(LambdaProxyClassKey const& key) {
311 return (key.dumptime_hash());
312 }
313
314 static inline bool DUMPTIME_EQUALS(
315 LambdaProxyClassKey const& k1, LambdaProxyClassKey const& k2) {
316 return (k1.equals(k2));
317 }
318 };
319
320
321 class DumpTimeLambdaProxyClassInfo {
322 public:
323 GrowableArray<InstanceKlass*>* _proxy_klass;
324 DumpTimeLambdaProxyClassInfo() : _proxy_klass(NULL) {}
325 void add_proxy_klass(InstanceKlass* proxy_klass) {
326 if (_proxy_klass == NULL) {
327 _proxy_klass = new (ResourceObj::C_HEAP, mtInternal)GrowableArray<InstanceKlass*>(5, true);
328 }
329 assert(_proxy_klass != NULL, "sanity");
330 _proxy_klass->append(proxy_klass);
331 }
332 };
333
334 class RunTimeLambdaProxyClassInfo {
335 LambdaProxyClassKey _key;
336 InstanceKlass* _proxy_klass;
337 public:
338 RunTimeLambdaProxyClassInfo(LambdaProxyClassKey key, InstanceKlass* proxy_klass) :
339 _key(key), _proxy_klass(proxy_klass) {}
340
341 InstanceKlass* proxy_klass() const { return _proxy_klass; }
342
343 // Used by LambdaProxyClassDictionary to implement OffsetCompactHashtable::EQUALS
344 static inline bool EQUALS(
345 const RunTimeLambdaProxyClassInfo* value, LambdaProxyClassKey* key, int len_unused) {
346 return (value->_key.equals(*key));
347 }
348 void init(LambdaProxyClassKey& key, DumpTimeLambdaProxyClassInfo& info) {
349 _key = key;
350 _key.original_to_target();
351 _proxy_klass = DynamicArchive::original_to_target(info._proxy_klass->at(0));
352 ArchivePtrMarker::mark_pointer(&_proxy_klass);
353 }
354
355 unsigned int hash() const {
356 return _key.hash();
357 }
358 };
359
360 class LambdaProxyClassDictionary : public OffsetCompactHashtable<
361 LambdaProxyClassKey*,
362 const RunTimeLambdaProxyClassInfo*,
363 RunTimeLambdaProxyClassInfo::EQUALS> {};
364
365 LambdaProxyClassDictionary _lambda_proxy_class_dictionary;
366
367 class DumpTimeLambdaProxyClassDictionary
368 : public ResourceHashtable<LambdaProxyClassKey,
369 DumpTimeLambdaProxyClassInfo,
370 LambdaProxyClassKey::DUMPTIME_HASH,
371 LambdaProxyClassKey::DUMPTIME_EQUALS,
372 137, // prime number
373 ResourceObj::C_HEAP> {
374 public:
375 int _count;
376 };
377
378 DumpTimeLambdaProxyClassDictionary* _dumptime_lambda_proxy_class_dictionary = NULL;
379
380 static void add_to_dump_time_lambda_proxy_class_dictionary(LambdaProxyClassKey key,
381 InstanceKlass* proxy_klass) {
382 if (_dumptime_lambda_proxy_class_dictionary == NULL) {
383 _dumptime_lambda_proxy_class_dictionary =
384 new (ResourceObj::C_HEAP, mtClass)DumpTimeLambdaProxyClassDictionary();
385 }
386 DumpTimeLambdaProxyClassInfo* lambda_info = _dumptime_lambda_proxy_class_dictionary->get(key);
387 if (lambda_info == NULL) {
388 DumpTimeLambdaProxyClassInfo info;
389 info.add_proxy_klass(proxy_klass);
390 _dumptime_lambda_proxy_class_dictionary->put(key, info);
391 //lambda_info = _dumptime_lambda_proxy_class_dictionary->get(key);
392 //assert(lambda_info->_proxy_klass == proxy_klass, "must be"); // debug only -- remove
393 ++_dumptime_lambda_proxy_class_dictionary->_count;
394 } else {
395 lambda_info->add_proxy_klass(proxy_klass);
396 }
397 }
398
399 class RunTimeSharedClassInfo {
400 public:
401 struct CrcInfo {
402 int _clsfile_size;
403 int _clsfile_crc32;
404 };
405
406 // This is different than DumpTimeSharedClassInfo::DTVerifierConstraint. We use
407 // u4 instead of Symbol* to save space on 64-bit CPU.
408 struct RTVerifierConstraint {
409 u4 _name;
410 u4 _from_name;
411 Symbol* name() { return (Symbol*)(SharedBaseAddress + _name);}
412 Symbol* from_name() { return (Symbol*)(SharedBaseAddress + _from_name); }
413 };
414
415 struct RTLoaderConstraint {
416 u4 _name;
417 char _loader_type1;
418 char _loader_type2;
419 Symbol* constraint_name() {
420 return (Symbol*)(SharedBaseAddress + _name);
421 }
422 };
423
424 InstanceKlass* _klass;
425 int _num_verifier_constraints;
426 int _num_loader_constraints;
427
428 // optional CrcInfo _crc; (only for UNREGISTERED classes)
429 // optional InstanceKlass* _nest_host
430 // optional RTLoaderConstraint _loader_constraint_types[_num_loader_constraints]
431 // optional RTVerifierConstraint _verifier_constraints[_num_verifier_constraints]
432 // optional char _verifier_constraint_flags[_num_verifier_constraints]
433
434 private:
435 static size_t header_size_size() {
436 return sizeof(RunTimeSharedClassInfo);
437 }
438 static size_t crc_size(InstanceKlass* klass) {
439 if (!SystemDictionaryShared::is_builtin(klass)) {
440 return sizeof(CrcInfo);
441 } else {
442 return 0;
443 }
444 }
445 static size_t verifier_constraints_size(int num_verifier_constraints) {
446 return sizeof(RTVerifierConstraint) * num_verifier_constraints;
447 }
448 static size_t verifier_constraint_flags_size(int num_verifier_constraints) {
449 return sizeof(char) * num_verifier_constraints;
450 }
451 static size_t loader_constraints_size(int num_loader_constraints) {
452 return sizeof(RTLoaderConstraint) * num_loader_constraints;
453 }
454 static size_t nest_host_size(InstanceKlass* klass) {
455 if (klass->is_hidden()) {
456 return sizeof(InstanceKlass*);
457 } else {
458 return 0;
459 }
460 }
461
462 public:
463 static size_t byte_size(InstanceKlass* klass, int num_verifier_constraints, int num_loader_constraints) {
464 return header_size_size() +
465 crc_size(klass) +
466 nest_host_size(klass) +
467 loader_constraints_size(num_loader_constraints) +
468 verifier_constraints_size(num_verifier_constraints) +
469 verifier_constraint_flags_size(num_verifier_constraints);
470 }
471
472 private:
473 size_t crc_offset() const {
474 return header_size_size();
475 }
476
477 size_t nest_host_offset() const {
478 return crc_offset() + crc_size(_klass);
479 }
480
481 size_t loader_constraints_offset() const {
482 return nest_host_offset() + nest_host_size(_klass);
483 }
484 size_t verifier_constraints_offset() const {
485 return loader_constraints_offset() + loader_constraints_size(_num_loader_constraints);
486 }
487 size_t verifier_constraint_flags_offset() const {
488 return verifier_constraints_offset() + verifier_constraints_size(_num_verifier_constraints);
489 }
490
491 void check_verifier_constraint_offset(int i) const {
492 assert(0 <= i && i < _num_verifier_constraints, "sanity");
493 }
494
495 void check_loader_constraint_offset(int i) const {
496 assert(0 <= i && i < _num_loader_constraints, "sanity");
497 }
498
499 public:
500 CrcInfo* crc() const {
501 assert(crc_size(_klass) > 0, "must be");
502 return (CrcInfo*)(address(this) + crc_offset());
503 }
504 RTVerifierConstraint* verifier_constraints() {
505 assert(_num_verifier_constraints > 0, "sanity");
506 return (RTVerifierConstraint*)(address(this) + verifier_constraints_offset());
507 }
508 RTVerifierConstraint* verifier_constraint_at(int i) {
509 check_verifier_constraint_offset(i);
510 return verifier_constraints() + i;
511 }
512
513 char* verifier_constraint_flags() {
514 assert(_num_verifier_constraints > 0, "sanity");
515 return (char*)(address(this) + verifier_constraint_flags_offset());
516 }
517
518 InstanceKlass** nest_host_addr() {
519 assert(_klass->is_hidden(), "sanity");
520 return (InstanceKlass**)(address(this) + nest_host_offset());
521 }
522 InstanceKlass* nest_host() {
523 return *nest_host_addr();
524 }
525 void set_nest_host(InstanceKlass* k) {
526 *nest_host_addr() = k;
527 ArchivePtrMarker::mark_pointer((address*)nest_host_addr());
528 }
529
530 RTLoaderConstraint* loader_constraints() {
531 assert(_num_loader_constraints > 0, "sanity");
532 return (RTLoaderConstraint*)(address(this) + loader_constraints_offset());
533 }
534
535 RTLoaderConstraint* loader_constraint_at(int i) {
536 check_loader_constraint_offset(i);
537 return loader_constraints() + i;
538 }
539
540 static u4 object_delta_u4(Symbol* sym) {
541 if (DynamicDumpSharedSpaces) {
542 sym = DynamicArchive::original_to_target(sym);
543 }
544 return MetaspaceShared::object_delta_u4(sym);
545 }
546
547 void init(DumpTimeSharedClassInfo& info) {
548 _klass = info._klass;
549 if (!SystemDictionaryShared::is_builtin(_klass)) {
558 RTVerifierConstraint* vf_constraints = verifier_constraints();
559 char* flags = verifier_constraint_flags();
560 for (i = 0; i < _num_verifier_constraints; i++) {
561 vf_constraints[i]._name = object_delta_u4(info._verifier_constraints->at(i)._name);
562 vf_constraints[i]._from_name = object_delta_u4(info._verifier_constraints->at(i)._from_name);
563 }
564 for (i = 0; i < _num_verifier_constraints; i++) {
565 flags[i] = info._verifier_constraint_flags->at(i);
566 }
567 }
568
569 if (_num_loader_constraints > 0) {
570 RTLoaderConstraint* ld_constraints = loader_constraints();
571 for (i = 0; i < _num_loader_constraints; i++) {
572 ld_constraints[i]._name = object_delta_u4(info._loader_constraints->at(i)._name);
573 ld_constraints[i]._loader_type1 = info._loader_constraints->at(i)._loader_type1;
574 ld_constraints[i]._loader_type2 = info._loader_constraints->at(i)._loader_type2;
575 }
576 }
577 if (DynamicDumpSharedSpaces) {
578 if (_klass->is_hidden()) {
579 Thread* THREAD = Thread::current();
580 InstanceKlass* n_h = _klass->nest_host(THREAD);
581 n_h = DynamicArchive::original_to_target(n_h);
582 set_nest_host(n_h);
583 ArchivePtrMarker::mark_pointer(&n_h);
584 }
585 _klass = DynamicArchive::original_to_target(info._klass);
586 }
587 ArchivePtrMarker::mark_pointer(&_klass);
588 }
589
590 bool matches(int clsfile_size, int clsfile_crc32) const {
591 return crc()->_clsfile_size == clsfile_size &&
592 crc()->_clsfile_crc32 == clsfile_crc32;
593 }
594
595 char verifier_constraint_flag(int i) {
596 check_verifier_constraint_offset(i);
597 return verifier_constraint_flags()[i];
598 }
599
600 private:
601 // ArchiveCompactor::allocate() has reserved a pointer immediately before
602 // archived InstanceKlasses. We can use this slot to do a quick
603 // lookup of InstanceKlass* -> RunTimeSharedClassInfo* without
604 // building a new hashtable.
605 //
606 // info_pointer_addr(klass) --> 0x0100 RunTimeSharedClassInfo*
607 // InstanceKlass* klass --> 0x0108 <C++ vtbl>
608 // 0x0110 fields from Klass ...
609 static RunTimeSharedClassInfo** info_pointer_addr(InstanceKlass* klass) {
610 return &((RunTimeSharedClassInfo**)klass)[-1];
611 }
612
613 public:
614 static RunTimeSharedClassInfo* get_for(InstanceKlass* klass) {
615 assert(klass->is_shared(), "don't call for non-shared class");
616 return *info_pointer_addr(klass);
617 }
618 static void set_for(InstanceKlass* klass, RunTimeSharedClassInfo* record) {
619 if (DynamicDumpSharedSpaces) {
620 klass = DynamicArchive::original_to_buffer(klass);
621 *info_pointer_addr(klass) = DynamicArchive::buffer_to_target(record);
622 } else {
623 *info_pointer_addr(klass) = record;
624 }
625
626 ArchivePtrMarker::mark_pointer(info_pointer_addr(klass));
627 }
628
629 // Used by RunTimeSharedDictionary to implement OffsetCompactHashtable::EQUALS
630 static inline bool EQUALS(
631 const RunTimeSharedClassInfo* value, Symbol* key, int len_unused) {
632 return (value->_klass->name() == key);
633 }
634 };
635
1321 if (ld._name != NULL) {
1322 ld._name->decrement_refcount();
1323 }
1324 }
1325 FREE_C_HEAP_ARRAY(DumpTimeSharedClassInfo::DTLoaderConstraint, p->_loader_constraints);
1326 p->_loader_constraints = NULL;
1327 }
1328 _dumptime_table->remove(k);
1329 }
1330
1331 bool SystemDictionaryShared::is_jfr_event_class(InstanceKlass *k) {
1332 while (k) {
1333 if (k->name()->equals("jdk/internal/event/Event")) {
1334 return true;
1335 }
1336 k = k->java_super();
1337 }
1338 return false;
1339 }
1340
1341 bool SystemDictionaryShared::is_registered_lambda_proxy_class(InstanceKlass* ik) {
1342 DumpTimeSharedClassInfo* info = _dumptime_table->get(ik);
1343 return (info != NULL) ? info->_is_archived_lambda_proxy : false;
1344 }
1345
1346 bool SystemDictionaryShared::is_in_shared_lambda_proxy_table(InstanceKlass* ik) {
1347 assert(!DumpSharedSpaces && UseSharedSpaces, "called at run time with CDS enabled only");
1348 RunTimeSharedClassInfo* record = RunTimeSharedClassInfo::get_for(ik);
1349 if (record != NULL && record->nest_host() != NULL) {
1350 return true;
1351 } else {
1352 return false;
1353 }
1354 }
1355
1356 bool SystemDictionaryShared::is_hidden_lambda_proxy(InstanceKlass* ik) {
1357 assert(ik->is_shared(), "applicable to only a shared class");
1358 if (ik->is_hidden()) {
1359 assert(is_in_shared_lambda_proxy_table(ik), "we don't archive other hidden classes");
1360 return true;
1361 } else {
1362 return false;
1363 }
1364 }
1365
1366 void SystemDictionaryShared::warn_excluded(InstanceKlass* k, const char* reason) {
1367 ResourceMark rm;
1368 log_warning(cds)("Skipping %s: %s", k->name()->as_C_string(), reason);
1369 }
1370
1371 bool SystemDictionaryShared::should_be_excluded(InstanceKlass* k) {
1372
1373 if (k->is_unsafe_anonymous()) {
1374 warn_excluded(k, "Unsafe anonymous class");
1375 return true; // unsafe anonymous classes are not archived, skip
1376 }
1377
1378 if (k->is_in_error_state()) {
1379 warn_excluded(k, "In error state");
1380 return true;
1381 }
1382 if (k->has_been_redefined()) {
1383 warn_excluded(k, "Has been redefined");
1384 return true;
1385 }
1386 if (!k->is_hidden() && k->shared_classpath_index() < 0 && is_builtin(k)) {
1387 // These are classes loaded from unsupported locations (such as those loaded by JVMTI native
1388 // agent during dump time).
1389 warn_excluded(k, "Unsupported location");
1390 return true;
1391 }
1392 if (k->signers() != NULL) {
1393 // We cannot include signed classes in the archive because the certificates
1394 // used during dump time may be different than those used during
1395 // runtime (due to expiration, etc).
1396 warn_excluded(k, "Signed JAR");
1397 return true;
1398 }
1399 if (is_jfr_event_class(k)) {
1400 // We cannot include JFR event classes because they need runtime-specific
1401 // instrumentation in order to work with -XX:FlightRecorderOptions=retransform=false.
1402 // There are only a small number of these classes, so it's not worthwhile to
1403 // support them and make CDS more complicated.
1404 warn_excluded(k, "JFR event class");
1405 return true;
1406 }
1419 warn_excluded(k, "Failed verification");
1420 } else {
1421 warn_excluded(k, "Not linked");
1422 }
1423 return true;
1424 }
1425 if (k->major_version() < 50 /*JAVA_6_VERSION*/) {
1426 ResourceMark rm;
1427 log_warning(cds)("Pre JDK 6 class not supported by CDS: %u.%u %s",
1428 k->major_version(), k->minor_version(), k->name()->as_C_string());
1429 return true;
1430 }
1431
1432 InstanceKlass* super = k->java_super();
1433 if (super != NULL && should_be_excluded(super)) {
1434 ResourceMark rm;
1435 log_warning(cds)("Skipping %s: super class %s is excluded", k->name()->as_C_string(), super->name()->as_C_string());
1436 return true;
1437 }
1438
1439 if (k->is_hidden() && !is_registered_lambda_proxy_class(k)) {
1440 warn_excluded(k, "Hidden class");
1441 return true;
1442 }
1443
1444 Array<InstanceKlass*>* interfaces = k->local_interfaces();
1445 int len = interfaces->length();
1446 for (int i = 0; i < len; i++) {
1447 InstanceKlass* intf = interfaces->at(i);
1448 if (should_be_excluded(intf)) {
1449 log_warning(cds)("Skipping %s: interface %s is excluded", k->name()->as_C_string(), intf->name()->as_C_string());
1450 return true;
1451 }
1452 }
1453
1454 return false;
1455 }
1456
1457 // k is a class before relocating by ArchiveCompactor
1458 void SystemDictionaryShared::validate_before_archiving(InstanceKlass* k) {
1459 ResourceMark rm;
1460 const char* name = k->name()->as_C_string();
1461 DumpTimeSharedClassInfo* info = _dumptime_table->get(k);
1462 assert(_no_class_loading_should_happen, "class loading must be disabled");
1463 guarantee(info != NULL, "Class %s must be entered into _dumptime_table", name);
1464 guarantee(!info->is_excluded(), "Should not attempt to archive excluded class %s", name);
1465 if (is_builtin(k)) {
1466 if (k->is_hidden()) {
1467 assert(is_registered_lambda_proxy_class(k), "unexpected hidden class %s", name);
1468 }
1469 guarantee(!k->is_shared_unregistered_class(),
1470 "Class loader type must be set for BUILTIN class %s", name);
1471
1472 } else {
1473 guarantee(k->is_shared_unregistered_class(),
1474 "Class loader type must not be set for UNREGISTERED class %s", name);
1475 }
1476 }
1477
1478 class ExcludeDumpTimeSharedClasses : StackObj {
1479 public:
1480 bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1481 if (SystemDictionaryShared::should_be_excluded(k)) {
1482 info.set_excluded();
1483 }
1484 return true; // keep on iterating
1485 }
1486 };
1487
1488 void SystemDictionaryShared::check_excluded_classes() {
1489 ExcludeDumpTimeSharedClasses excl;
1490 _dumptime_table->iterate(&excl);
1491 _dumptime_table->update_counts();
1567 }
1568 GrowableArray<DTVerifierConstraint>* vc_array = _verifier_constraints;
1569 for (int i = 0; i < vc_array->length(); i++) {
1570 DTVerifierConstraint* p = vc_array->adr_at(i);
1571 if (name == p->_name && from_name == p->_from_name) {
1572 return;
1573 }
1574 }
1575 DTVerifierConstraint cons(name, from_name);
1576 vc_array->append(cons);
1577
1578 GrowableArray<char>* vcflags_array = _verifier_constraint_flags;
1579 char c = 0;
1580 c |= from_field_is_protected ? SystemDictionaryShared::FROM_FIELD_IS_PROTECTED : 0;
1581 c |= from_is_array ? SystemDictionaryShared::FROM_IS_ARRAY : 0;
1582 c |= from_is_object ? SystemDictionaryShared::FROM_IS_OBJECT : 0;
1583 vcflags_array->append(c);
1584
1585 if (log_is_enabled(Trace, cds, verification)) {
1586 ResourceMark rm;
1587 log_trace(cds, verification)("add_verification_constraint: %s: %s must be subclass of %s [0x%x] array len %d flags len %d",
1588 k->external_name(), from_name->as_klass_external_name(),
1589 name->as_klass_external_name(), c, vc_array->length(), vcflags_array->length());
1590 }
1591 }
1592
1593 void SystemDictionaryShared::add_lambda_proxy_class(InstanceKlass* caller_ik,
1594 InstanceKlass* lambda_ik,
1595 Symbol* invoked_name,
1596 Symbol* invoked_type,
1597 Symbol* method_type,
1598 Method* member_method,
1599 Symbol* instantiated_method_type) {
1600
1601 assert(caller_ik->class_loader() == lambda_ik->class_loader(), "mismatched class loader");
1602 assert(caller_ik->class_loader_data() == lambda_ik->class_loader_data(), "mismatched class loader data");
1603
1604 MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
1605
1606 lambda_ik->assign_class_loader_type();
1607
1608 DumpTimeSharedClassInfo* info = _dumptime_table->get(lambda_ik);
1609 if (info != NULL) {
1610 // Set _is_archived_lambda_proxy in DumpTimeSharedClassInfo so that the lambda_ik
1611 // won't be excluded during dumping of shared archive. See ExcludeDumpTimeSharedClasses.
1612 info->_is_archived_lambda_proxy = true;
1613 }
1614
1615 LambdaProxyClassKey key(caller_ik,
1616 invoked_name,
1617 invoked_type,
1618 method_type,
1619 member_method,
1620 instantiated_method_type);
1621 add_to_dump_time_lambda_proxy_class_dictionary(key, lambda_ik);
1622 }
1623
1624 InstanceKlass* SystemDictionaryShared::get_shared_lambda_proxy_class(InstanceKlass* caller_ik,
1625 Symbol* invoked_name,
1626 Symbol* invoked_type,
1627 Symbol* method_type,
1628 Method* member_method,
1629 Symbol* instantiated_method_type) {
1630 MutexLocker ml(CDSLambda_lock, Mutex::_no_safepoint_check_flag);
1631 LambdaProxyClassKey key(caller_ik, invoked_name, invoked_type,
1632 method_type, member_method, instantiated_method_type);
1633 const RunTimeLambdaProxyClassInfo* info = _lambda_proxy_class_dictionary.lookup(&key, key.hash(), 0);
1634 InstanceKlass* proxy_klass = NULL;
1635 if (info != NULL) {
1636 InstanceKlass* curr_klass = info->proxy_klass();
1637 InstanceKlass* prev_klass = curr_klass;
1638 if (curr_klass->lambda_proxy_is_available()) {
1639 while (curr_klass->next_link() != NULL) {
1640 prev_klass = curr_klass;
1641 curr_klass = InstanceKlass::cast(curr_klass->next_link());
1642 }
1643 assert(curr_klass->is_hidden(), "must be");
1644 assert(curr_klass->lambda_proxy_is_available(), "must be");
1645
1646 prev_klass->set_next_link(NULL);
1647 proxy_klass = curr_klass;
1648 proxy_klass->clear_lambda_proxy_is_available();
1649 if (log_is_enabled(Debug, cds)) {
1650 ResourceMark rm;
1651 log_debug(cds)("Loaded lambda proxy: %s", proxy_klass->external_name());
1652 }
1653 } else {
1654 if (log_is_enabled(Debug, cds)) {
1655 ResourceMark rm;
1656 log_debug(cds)("Used all archived lambda proxy classes for: %s %s%s",
1657 caller_ik->external_name(), invoked_name->as_C_string(), invoked_type->as_C_string());
1658 }
1659 }
1660 }
1661 return proxy_klass;
1662 }
1663
1664 InstanceKlass* SystemDictionaryShared::get_shared_nest_host(InstanceKlass* lambda_ik) {
1665 assert(!DumpSharedSpaces && UseSharedSpaces, "called at run time with CDS enabled only");
1666 RunTimeSharedClassInfo* record = RunTimeSharedClassInfo::get_for(lambda_ik);
1667 return record->nest_host();
1668 }
1669
1670 InstanceKlass* SystemDictionaryShared::load_shared_lambda_proxy_class(InstanceKlass* lambda_ik,
1671 InstanceKlass* caller_ik, TRAPS) {
1672 Handle class_loader(THREAD, caller_ik->class_loader());
1673 Handle protection_domain;
1674 PackageEntry* pkg_entry = get_package_entry_from_class_name(class_loader, caller_ik->name());
1675 if (caller_ik->class_loader() != NULL) {
1676 protection_domain = SystemDictionaryShared::init_security_info(class_loader, caller_ik, pkg_entry, CHECK_NULL);
1677 }
1678
1679 InstanceKlass* shared_n_h = get_shared_nest_host(lambda_ik);
1680 assert(shared_n_h != NULL, "unexpected NULL _nest_host");
1681
1682 InstanceKlass* loaded_lambda =
1683 SystemDictionary::load_shared_lambda_proxy_class(lambda_ik, class_loader, protection_domain, pkg_entry, CHECK_NULL);
1684
1685 InstanceKlass* n_h = caller_ik->nest_host(THREAD);
1686 assert(n_h->has_nest_member(caller_ik, THREAD) ||
1687 n_h == caller_ik, "mismatched nest host");
1688
1689 SystemDictionary::set_shared_class_init_state(lambda_ik, InstanceKlass::loaded);
1690 return loaded_lambda;
1691 }
1692
1693 static char get_loader_type_by(oop loader) {
1694 assert(SystemDictionary::is_builtin_class_loader(loader), "Must be built-in loader");
1695 if (SystemDictionary::is_boot_class_loader(loader)) {
1696 return (char)ClassLoader::BOOT_LOADER;
1697 } else if (SystemDictionary::is_platform_class_loader(loader)) {
1698 return (char)ClassLoader::PLATFORM_LOADER;
1699 } else {
1700 assert(SystemDictionary::is_system_class_loader(loader), "Class loader mismatch");
1701 return (char)ClassLoader::APP_LOADER;
1702 }
1703 }
1704
1705 static oop get_class_loader_by(char type) {
1706 if (type == (char)ClassLoader::BOOT_LOADER) {
1707 return (oop)NULL;
1708 } else if (type == (char)ClassLoader::PLATFORM_LOADER) {
1709 return SystemDictionary::java_platform_loader();
1710 } else {
1903 _num_builtin_klasses = 0;
1904 _num_unregistered_klasses = 0;
1905 }
1906
1907 bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1908 if (!info.is_excluded()) {
1909 size_t byte_size = RunTimeSharedClassInfo::byte_size(info._klass, info.num_verifier_constraints(), info.num_loader_constraints());
1910 _shared_class_info_size += align_up(byte_size, BytesPerWord);
1911 }
1912 return true; // keep on iterating
1913 }
1914
1915 size_t total() {
1916 return _shared_class_info_size;
1917 }
1918 };
1919
1920 size_t SystemDictionaryShared::estimate_size_for_archive() {
1921 EstimateSizeForArchive est;
1922 _dumptime_table->iterate(&est);
1923 size_t total_size = est.total() +
1924 CompactHashtableWriter::estimate_size(_dumptime_table->count_of(true)) +
1925 CompactHashtableWriter::estimate_size(_dumptime_table->count_of(false));
1926 if (_dumptime_lambda_proxy_class_dictionary != NULL) {
1927 total_size +=
1928 (sizeof(RunTimeLambdaProxyClassInfo) * _dumptime_lambda_proxy_class_dictionary->_count) +
1929 CompactHashtableWriter::estimate_size(_dumptime_lambda_proxy_class_dictionary->_count);
1930 } else {
1931 total_size += CompactHashtableWriter::estimate_size(0);
1932 }
1933 return total_size;
1934 }
1935
1936 class CopyLambdaProxyClassInfoToArchive : StackObj {
1937 CompactHashtableWriter* _writer;
1938 public:
1939 CopyLambdaProxyClassInfoToArchive(CompactHashtableWriter* writer)
1940 : _writer(writer) {}
1941 bool do_entry(LambdaProxyClassKey& key, DumpTimeLambdaProxyClassInfo& info) {
1942 if (SystemDictionaryShared::is_excluded_class(info._proxy_klass->at(0))) {
1943 return true;
1944 }
1945 ResourceMark rm;
1946 log_info(cds,dynamic)("Archiving hidden %s", info._proxy_klass->at(0)->external_name());
1947 size_t byte_size = sizeof(RunTimeLambdaProxyClassInfo);
1948 RunTimeLambdaProxyClassInfo* runtime_info =
1949 (RunTimeLambdaProxyClassInfo*)MetaspaceShared::read_only_space_alloc(byte_size);
1950 runtime_info->init(key, info);
1951 unsigned int hash = runtime_info->hash(); // Fields in runtime_info->_key already point to target space.
1952 u4 delta = MetaspaceShared::object_delta_u4(DynamicArchive::buffer_to_target(runtime_info));
1953 _writer->add(hash, delta);
1954 return true;
1955 }
1956 };
1957
1958 class AdjustLambdaProxyClassInfo : StackObj {
1959 public:
1960 AdjustLambdaProxyClassInfo() {}
1961 bool do_entry(LambdaProxyClassKey& key, DumpTimeLambdaProxyClassInfo& info) {
1962 if (SystemDictionaryShared::is_excluded_class(info._proxy_klass->at(0))) {
1963 return true;
1964 }
1965 int len = info._proxy_klass->length();
1966 if (len > 1) {
1967 for (int i = 0; i < len-1; i++) {
1968 InstanceKlass* ok0 = info._proxy_klass->at(i+0); // this is original klass
1969 InstanceKlass* ok1 = info._proxy_klass->at(i+1); // this is original klass
1970 InstanceKlass* bk0 = DynamicArchive::original_to_buffer(ok0);
1971 InstanceKlass* bk1 = DynamicArchive::original_to_buffer(ok1);
1972 assert(bk0->next_link() == 0, "must be called after Klass::remove_unshareable_info()");
1973 assert(bk1->next_link() == 0, "must be called after Klass::remove_unshareable_info()");
1974 bk0->set_next_link(bk1);
1975 bk1->set_lambda_proxy_is_available();
1976 ArchivePtrMarker::mark_pointer(bk0->next_link_addr());
1977 }
1978 }
1979 DynamicArchive::original_to_buffer(info._proxy_klass->at(0))->set_lambda_proxy_is_available();
1980 return true;
1981 }
1982 };
1983
1984 class CopySharedClassInfoToArchive : StackObj {
1985 CompactHashtableWriter* _writer;
1986 bool _is_builtin;
1987 public:
1988 CopySharedClassInfoToArchive(CompactHashtableWriter* writer,
1989 bool is_builtin,
1990 bool is_static_archive)
1991 : _writer(writer), _is_builtin(is_builtin) {}
1992
1993 bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1994 if (!info.is_excluded() && info.is_builtin() == _is_builtin) {
1995 size_t byte_size = RunTimeSharedClassInfo::byte_size(info._klass, info.num_verifier_constraints(), info.num_loader_constraints());
1996 RunTimeSharedClassInfo* record;
1997 record = (RunTimeSharedClassInfo*)MetaspaceShared::read_only_space_alloc(byte_size);
1998 record->init(info);
1999
2000 unsigned int hash;
2001 Symbol* name = info._klass->name();
2002 if (DynamicDumpSharedSpaces) {
2003 name = DynamicArchive::original_to_target(name);
2004 }
2005 hash = SystemDictionaryShared::hash_for_shared_dictionary(name);
2006 u4 delta;
2007 if (DynamicDumpSharedSpaces) {
2008 delta = MetaspaceShared::object_delta_u4(DynamicArchive::buffer_to_target(record));
2009 } else {
2010 delta = MetaspaceShared::object_delta_u4(record);
2011 }
2012 if (_is_builtin && info._klass->is_hidden()) {
2013 // skip
2014 } else {
2015 _writer->add(hash, delta);
2016 }
2017 if (log_is_enabled(Trace, cds, hashtables)) {
2018 ResourceMark rm;
2019 log_trace(cds,hashtables)("%s dictionary: %s", (_is_builtin ? "builtin" : "unregistered"), info._klass->external_name());
2020 }
2021
2022 // Save this for quick runtime lookup of InstanceKlass* -> RunTimeSharedClassInfo*
2023 RunTimeSharedClassInfo::set_for(info._klass, record);
2024 }
2025 return true; // keep on iterating
2026 }
2027 };
2028
2029 void SystemDictionaryShared::write_lambda_proxy_class_dictionary(LambdaProxyClassDictionary *dictionary) {
2030 CompactHashtableStats stats;
2031 dictionary->reset();
2032 CompactHashtableWriter writer(_dumptime_lambda_proxy_class_dictionary->_count, &stats);
2033 CopyLambdaProxyClassInfoToArchive copy(&writer);
2034 _dumptime_lambda_proxy_class_dictionary->iterate(©);
2035 writer.dump(dictionary, "lambda proxy class dictionary");
2036 }
2037
2038 void SystemDictionaryShared::write_dictionary(RunTimeSharedDictionary* dictionary,
2039 bool is_builtin,
2040 bool is_static_archive) {
2041 CompactHashtableStats stats;
2042 dictionary->reset();
2043 CompactHashtableWriter writer(_dumptime_table->count_of(is_builtin), &stats);
2044 CopySharedClassInfoToArchive copy(&writer, is_builtin, is_static_archive);
2045 _dumptime_table->iterate(©);
2046 writer.dump(dictionary, is_builtin ? "builtin dictionary" : "unregistered dictionary");
2047 }
2048
2049 void SystemDictionaryShared::write_to_archive(bool is_static_archive) {
2050 if (is_static_archive) {
2051 write_dictionary(&_builtin_dictionary, true);
2052 write_dictionary(&_unregistered_dictionary, false);
2053 } else {
2054 write_dictionary(&_dynamic_builtin_dictionary, true);
2055 write_dictionary(&_dynamic_unregistered_dictionary, false);
2056 }
2057 if (_dumptime_lambda_proxy_class_dictionary != NULL) {
2058 write_lambda_proxy_class_dictionary(&_lambda_proxy_class_dictionary);
2059 }
2060 }
2061
2062 void SystemDictionaryShared::adjust_lambda_proxy_class_dictionary() {
2063 if (_dumptime_lambda_proxy_class_dictionary != NULL) {
2064 AdjustLambdaProxyClassInfo adjuster;
2065 _dumptime_lambda_proxy_class_dictionary->iterate(&adjuster);
2066 }
2067 }
2068
2069 void SystemDictionaryShared::serialize_dictionary_headers(SerializeClosure* soc,
2070 bool is_static_archive) {
2071 if (is_static_archive) {
2072 _builtin_dictionary.serialize_header(soc);
2073 _unregistered_dictionary.serialize_header(soc);
2074 } else {
2075 _dynamic_builtin_dictionary.serialize_header(soc);
2076 _dynamic_unregistered_dictionary.serialize_header(soc);
2077 _lambda_proxy_class_dictionary.serialize_header(soc);
2078 }
2079 }
2080
2081 void SystemDictionaryShared::serialize_well_known_klasses(SerializeClosure* soc) {
2082 for (int i = FIRST_WKID; i < WKID_LIMIT; i++) {
2083 soc->do_ptr((void**)&_well_known_klasses[i]);
2084 }
2085 }
2086
2087 const RunTimeSharedClassInfo*
2088 SystemDictionaryShared::find_record(RunTimeSharedDictionary* static_dict, RunTimeSharedDictionary* dynamic_dict, Symbol* name) {
2089 if (!UseSharedSpaces || !name->is_shared()) {
2090 // The names of all shared classes must also be a shared Symbol.
2091 return NULL;
2092 }
2093
2094 unsigned int hash = SystemDictionaryShared::hash_for_shared_dictionary(name);
2095 const RunTimeSharedClassInfo* record = NULL;
2096 if (!MetaspaceShared::is_shared_dynamic(name)) {
2097 // The names of all shared classes in the static dict must also be in the
2098 // static archive
2099 record = static_dict->lookup(name, hash, 0);
2100 }
2101
2102 if (record == NULL && DynamicArchive::is_mapped()) {
2103 record = dynamic_dict->lookup(name, hash, 0);
2104 }
2105
2106 return record;
2107 }
2108
2109 InstanceKlass* SystemDictionaryShared::find_builtin_class(Symbol* name) {
2110 const RunTimeSharedClassInfo* record = find_record(&_builtin_dictionary, &_dynamic_builtin_dictionary, name);
2111 if (record != NULL) {
2112 assert(!record->_klass->is_hidden(), "hidden class cannot be looked up by name");
2113 return record->_klass;
2114 } else {
2115 return NULL;
2116 }
2117 }
2118
2119 void SystemDictionaryShared::update_shared_entry(InstanceKlass* k, int id) {
2120 assert(DumpSharedSpaces, "supported only when dumping");
2121 DumpTimeSharedClassInfo* info = find_or_allocate_info_for(k);
2122 info->_id = id;
2123 }
2124
2125 class SharedDictionaryPrinter : StackObj {
2126 outputStream* _st;
2127 int _index;
2128 public:
2129 SharedDictionaryPrinter(outputStream* st) : _st(st), _index(0) {}
2130
2131 void do_value(const RunTimeSharedClassInfo* record) {
2132 ResourceMark rm;
2133 _st->print_cr("%4d: %s", (_index++), record->_klass->external_name());
2134 }
2135 };
2136
2137 class SharedLambdaDictionaryPrinter : StackObj {
2138 outputStream* _st;
2139 int _index;
2140 public:
2141 SharedLambdaDictionaryPrinter(outputStream* st) : _st(st), _index(0) {}
2142
2143 void do_value(const RunTimeLambdaProxyClassInfo* record) {
2144 ResourceMark rm;
2145 _st->print_cr("%4d: %s", (_index++), record->proxy_klass()->external_name());
2146 Klass* k = record->proxy_klass()->next_link();
2147 while (k != NULL) {
2148 _st->print_cr("%4d: %s", (_index++), k->external_name());
2149 k = k->next_link();
2150 }
2151 }
2152 };
2153
2154 void SystemDictionaryShared::print_on(outputStream* st) {
2155 if (UseSharedSpaces) {
2156 st->print_cr("Shared Dictionary");
2157 SharedDictionaryPrinter p(st);
2158 _builtin_dictionary.iterate(&p);
2159 _unregistered_dictionary.iterate(&p);
2160 if (DynamicArchive::is_mapped()) {
2161 _dynamic_builtin_dictionary.iterate(&p);
2162 _unregistered_dictionary.iterate(&p);
2163 if (!_lambda_proxy_class_dictionary.empty()) {
2164 st->print_cr("Shared Lambda Dictionary");
2165 SharedLambdaDictionaryPrinter ldp(st);
2166 _lambda_proxy_class_dictionary.iterate(&ldp);
2167 }
2168 }
2169 }
2170 }
2171
2172 void SystemDictionaryShared::print_table_statistics(outputStream* st) {
2173 if (UseSharedSpaces) {
2174 _builtin_dictionary.print_table_statistics(st, "Builtin Shared Dictionary");
2175 _unregistered_dictionary.print_table_statistics(st, "Unregistered Shared Dictionary");
2176 if (DynamicArchive::is_mapped()) {
2177 _dynamic_builtin_dictionary.print_table_statistics(st, "Dynamic Builtin Shared Dictionary");
2178 _dynamic_unregistered_dictionary.print_table_statistics(st, "Unregistered Shared Dictionary");
2179 _lambda_proxy_class_dictionary.print_table_statistics(st, "Lambda Shared Dictionary");
2180 }
2181 }
2182 }
2183
2184 bool SystemDictionaryShared::empty_dumptime_table() {
2185 if (_dumptime_table == NULL) {
2186 return true;
2187 }
2188 _dumptime_table->update_counts();
2189 if (_dumptime_table->count_of(true) == 0 && _dumptime_table->count_of(false) == 0){
2190 return true;
2191 }
2192 return false;
2193 }
2194
2195 #if INCLUDE_CDS_JAVA_HEAP
2196
2197 class ArchivedMirrorPatcher {
2198 static void update(Klass* k) {
2199 if (k->has_raw_archived_mirror()) {
|