From 32657f9ef4e781254fb918adef8802d9998ef083 Mon Sep 17 00:00:00 2001
Date: Fri, 22 Sep 2023 14:44:01 +0800
Subject: add Do-not-collect_class-when-DynamicCDS-dump

---
 hotspot/src/share/vm/classfile/dictionary.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hotspot/src/share/vm/classfile/dictionary.cpp b/hotspot/src/share/vm/classfile/dictionary.cpp
index 530c3fdfb..79aaa99e5 100644
--- a/hotspot/src/share/vm/classfile/dictionary.cpp
+++ b/hotspot/src/share/vm/classfile/dictionary.cpp
@@ -209,7 +209,9 @@ void Dictionary::remove_classes_in_error_state(void f(Klass*)) {
           _current_class_entry = NULL;
         }
         free_entry(probe);
-        f(ik);
+        if (DumpSharedSpaces) {
+          f(ik);
+        }
         ResourceMark rm;
         tty->print_cr("Preload Warning: Removed error class: %s", ik->external_name());
         continue;
-- 
2.22.0

