diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp
index c66398cefac..b6f5d2be50f 100644
--- a/src/hotspot/share/cds/metaspaceShared.cpp
+++ b/src/hotspot/share/cds/metaspaceShared.cpp
@@ -77,6 +77,7 @@
 #include "runtime/globals.hpp"
 #include "runtime/globals_extension.hpp"
 #include "runtime/handles.inline.hpp"
+#include "runtime/javaCalls.hpp"
 #include "runtime/os.inline.hpp"
 #include "runtime/safepointVerifiers.hpp"
 #include "runtime/sharedRuntime.hpp"
@@ -794,6 +795,16 @@ void MetaspaceShared::preload_and_dump_impl(StaticArchiveBuilder& builder, TRAPS
   }
 #endif
 
+  // Dummy call to load classes used at CDS runtime
+  JavaValue result(T_OBJECT);
+  Handle path_string = java_lang_String::create_from_str("dummy.jar", CHECK);
+  JavaCalls::call_static(&result,
+                         vmClasses::jdk_internal_loader_ClassLoaders_klass(),
+                         vmSymbols::toFileURL_name(),
+                         vmSymbols::toFileURL_signature(),
+                         path_string,
+                         CHECK);
+
   VM_PopulateDumpSharedSpace op(builder);
   VMThread::execute(&op);
 
diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups
index 4ab4ba68692..37bcb6883a4 100644
--- a/test/hotspot/jtreg/TEST.groups
+++ b/test/hotspot/jtreg/TEST.groups
@@ -454,6 +454,7 @@ hotspot_appcds_dynamic = \
  -runtime/cds/appcds/BadBSM.java \
  -runtime/cds/appcds/DumpClassList.java \
  -runtime/cds/appcds/DumpClassListWithLF.java \
+ -runtime/cds/appcds/DumpRuntimeClassesTest.java \
  -runtime/cds/appcds/DumpingWithNoCoops.java \
  -runtime/cds/appcds/ExtraSymbols.java \
  -runtime/cds/appcds/LambdaContainsOldInf.java \
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/DumpRuntimeClassesTest.java b/test/hotspot/jtreg/runtime/cds/appcds/DumpRuntimeClassesTest.java
new file mode 100644
index 00000000000..2e530a8d6dd
--- /dev/null
+++ b/test/hotspot/jtreg/runtime/cds/appcds/DumpRuntimeClassesTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/*
+ * @test
+ * @summary Classes used by CDS at runtime should be in the archived
+ * @bug 8324259
+ * @requires vm.cds
+ * @library /test/lib
+ * @compile test-classes/Hello.java
+ * @run driver DumpRuntimeClassesTest
+ */
+
+import jdk.test.lib.cds.CDSOptions;
+import jdk.test.lib.cds.CDSTestUtils;
+
+public class DumpRuntimeClassesTest {
+    public static void main(String[] args) throws Exception {
+        // build The app
+        String appClass = "Hello";
+        String classList = "hello.classlist";
+        String archiveName = "hello.jsa";
+        JarBuilder.build("hello", appClass);
+        String appJar = TestCommon.getTestJar("hello.jar");
+
+        // Dump class list
+        CDSTestUtils.dumpClassList(classList, "-cp", appJar, appClass);
+
+        // Dump archive
+        CDSOptions opts = (new CDSOptions())
+            .addPrefix("-cp", appJar, "-XX:SharedClassListFile=" + classList)
+            .setArchiveName(archiveName);
+        CDSTestUtils.createArchive(opts);
+
+        // Run with archive and ensure all the classes used were in the archive
+        CDSOptions runOpts = (new CDSOptions())
+            .addPrefix("-cp", appJar, "-Xlog:class+load,cds=debug")
+            .setArchiveName(archiveName)
+            .setUseVersion(false)
+            .addSuffix(appClass);
+        CDSTestUtils.runWithArchive(runOpts)
+            .shouldNotContain("source: jrt:/java.base");
+    }
+}