< prev index next >

src/hotspot/share/cds/dumpTimeClassInfo.inline.hpp

Print this page
@@ -26,10 +26,11 @@
  #ifndef SHARE_CDS_DUMPTIMECLASSINFO_INLINE_HPP
  #define SHARE_CDS_DUMPTIMECLASSINFO_INLINE_HPP
  
  #include "cds/dumpTimeClassInfo.hpp"
  
+ #include "cds/cdsConfig.hpp"
  #include "classfile/systemDictionaryShared.hpp"
  #include "classfile/classLoaderData.inline.hpp"
  #include "oops/instanceKlass.hpp"
  #include "oops/klass.inline.hpp"
  #include "runtime/safepoint.hpp"

@@ -40,13 +41,21 @@
  // This function must be called only inside a safepoint, where the value of
  // k->is_loader_alive() will not change.
  template<typename Function>
  void DumpTimeSharedClassTable::iterate_all_live_classes(Function function) const {
    auto wrapper = [&] (InstanceKlass* k, DumpTimeClassInfo& info) {
-     assert(SafepointSynchronize::is_at_safepoint(), "invariant");
+     // Iterating the classes for creating loader cache in SystemDictionaryShared::create_loader_positive_lookup_cache
+     // is done outside the safepoint, and hence the need to comment the following assert.
+     // Also, it is safe to iterate the classes in SystemDictionaryShared::create_loader_positive_lookup_cache
+     // because it is only interested in classes loaded by built-in loaders which should never become unreachable.
+ 
+     // assert(SafepointSynchronize::is_at_safepoint(), "invariant");
      assert_lock_strong(DumpTimeTable_lock);
-     if (k->is_loader_alive()) {
+     if (CDSConfig::is_dumping_final_static_archive() && !k->is_loaded()) {
+       assert(k->is_shared_unregistered_class(), "must be");
+       function(k, info);
+     } else if (k->is_loader_alive()) {
        function(k, info);
        assert(k->is_loader_alive(), "must not change");
      } else {
        if (!SystemDictionaryShared::is_excluded_class(k)) {
          SystemDictionaryShared::warn_excluded(k, "Class loader not alive");
< prev index next >