From e59e2e2591a9e7517dc52e56abc2a5072e039732 Mon Sep 17 00:00:00 2001
From: Alexei Voitylov <avoitylov@openjdk.org>
Date: Fri, 16 Aug 2024 10:50:34 +0200
Subject: [PATCH] 8311208: Improve CDS Support

Reviewed-by: mbalao
Backport-of: 2c60805bc380945a8266112c7b5aee0498cb7d5b
---
 src/hotspot/share/classfile/verifier.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/hotspot/share/classfile/verifier.cpp b/src/hotspot/share/classfile/verifier.cpp
index 590cce18ba2..5ad53e9eca1 100644
--- a/src/hotspot/share/classfile/verifier.cpp
+++ b/src/hotspot/share/classfile/verifier.cpp
@@ -32,6 +32,7 @@
 #include "classfile/stackMapTableFormat.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
+#include "classfile/systemDictionaryShared.hpp"
 #include "classfile/verifier.hpp"
 #include "classfile/vmClasses.hpp"
 #include "classfile/vmSymbols.hpp"
@@ -211,6 +212,12 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) {
          exception_name == vmSymbols::java_lang_ClassFormatError())) {
       log_info(verification)("Fail over class verification to old verifier for: %s", klass->external_name());
       log_info(class, init)("Fail over class verification to old verifier for: %s", klass->external_name());
+      // Exclude any classes that fail over during dynamic dumping
+      if (CDS_ONLY(DynamicDumpSharedSpaces) NOT_CDS(false)) {
+        ResourceMark rm;
+        log_warning(cds)("Skipping %s: Failed over class verification while dynamic dumping", klass->name()->as_C_string());
+        SystemDictionaryShared::set_excluded(klass);
+      }
       message_buffer = NEW_RESOURCE_ARRAY(char, message_buffer_len);
       exception_message = message_buffer;
       exception_name = inference_verify(
-- 
GitLab