diff a/src/hotspot/share/classfile/systemDictionaryShared.hpp b/src/hotspot/share/classfile/systemDictionaryShared.hpp
--- a/src/hotspot/share/classfile/systemDictionaryShared.hpp
+++ b/src/hotspot/share/classfile/systemDictionaryShared.hpp
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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.
@@ -27,16 +27,18 @@
 
 #include "cds/cds_globals.hpp"
 #include "cds/filemap.hpp"
 #include "cds/dumpTimeClassInfo.hpp"
 #include "cds/lambdaProxyClassDictionary.hpp"
+#include "cds/methodDataDictionary.hpp"
 #include "cds/runTimeClassInfo.hpp"
 #include "classfile/classLoaderData.hpp"
 #include "classfile/packageEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "oops/klass.hpp"
 #include "oops/oopHandle.hpp"
+#include "oops/trainingData.hpp"
 
 
 /*===============================================================================
 
     Handling of the classes in the AppCDS archive
@@ -142,15 +144,21 @@
 
   struct ArchiveInfo {
     RunTimeSharedDictionary _builtin_dictionary;
     RunTimeSharedDictionary _unregistered_dictionary;
     LambdaProxyClassDictionary _lambda_proxy_class_dictionary;
+    MethodDataInfoDictionary _method_info_dictionary;
 
     const RunTimeLambdaProxyClassInfo* lookup_lambda_proxy_class(LambdaProxyClassKey* key) {
       return _lambda_proxy_class_dictionary.lookup(key, key->hash(), 0);
     }
 
+    const RunTimeMethodDataInfo* lookup_method_info(Method* m) {
+      MethodDataKey key(m);
+      return _method_info_dictionary.lookup(&key, key.hash(), 0);
+    }
+
     void print_on(const char* prefix, outputStream* st);
     void print_table_statistics(const char* prefix, outputStream* st);
   };
 
 public:
@@ -163,10 +171,13 @@
 private:
 
   static DumpTimeSharedClassTable* _dumptime_table;
   static DumpTimeLambdaProxyClassDictionary* _dumptime_lambda_proxy_class_dictionary;
 
+  static DumpTimeMethodInfoDictionary* _dumptime_method_info_dictionary;
+  static DumpTimeMethodInfoDictionary* _cloned_dumptime_method_info_dictionary;
+
   static ArchiveInfo _static_archive;
   static ArchiveInfo _dynamic_archive;
 
   static ArchiveInfo* get_archive(bool is_static_archive) {
     return is_static_archive ? &_static_archive : &_dynamic_archive;
@@ -181,30 +192,35 @@
                                  Handle class_loader,
                                  Handle protection_domain,
                                  const ClassFileStream* cfs,
                                  TRAPS);
 
-  // Guaranteed to return non-null value for non-shared classes.
-  // k must not be a shared class.
-  static DumpTimeClassInfo* get_info(InstanceKlass* k);
-  static DumpTimeClassInfo* get_info_locked(InstanceKlass* k);
-
   static void write_dictionary(RunTimeSharedDictionary* dictionary,
                                bool is_builtin);
   static void write_lambda_proxy_class_dictionary(LambdaProxyClassDictionary* dictionary);
+  static void write_method_info_dictionary(MethodDataInfoDictionary* dictionary);
   static void cleanup_lambda_proxy_class_dictionary();
+  static void cleanup_method_info_dictionary();
   static void reset_registered_lambda_proxy_class(InstanceKlass* ik);
-  static bool is_jfr_event_class(InstanceKlass *k);
   static bool is_registered_lambda_proxy_class(InstanceKlass* ik);
   static bool check_for_exclusion_impl(InstanceKlass* k);
   static void remove_dumptime_info(InstanceKlass* k) NOT_CDS_RETURN;
-  static bool has_been_redefined(InstanceKlass* k);
   static InstanceKlass* retrieve_lambda_proxy_class(const RunTimeLambdaProxyClassInfo* info) NOT_CDS_RETURN_(nullptr);
-
+  static void scan_constant_pool(InstanceKlass* k);
   DEBUG_ONLY(static bool _class_loading_may_happen;)
 
 public:
+  // Guaranteed to return non-null value for non-shared classes.
+  // k must not be a shared class.
+  static DumpTimeClassInfo* get_info(InstanceKlass* k);
+  static DumpTimeClassInfo* get_info_locked(InstanceKlass* k);
+  static DumpTimeSharedClassTable* dumptime_table() { return _dumptime_table; }
+
+  static bool should_hidden_class_be_archived(InstanceKlass* k);
+  static void mark_required_class(InstanceKlass* k);
+  static bool has_been_redefined(InstanceKlass* k);
+  static bool is_jfr_event_class(InstanceKlass *k);
   static bool is_hidden_lambda_proxy(InstanceKlass* ik);
   static bool is_early_klass(InstanceKlass* k);   // Was k loaded while JvmtiExport::is_early_phase()==true
   static bool has_archived_enum_objs(InstanceKlass* ik);
   static void set_has_archived_enum_objs(InstanceKlass* ik);
 
@@ -219,10 +235,11 @@
   // Called by PLATFORM/APP loader only
   static InstanceKlass* find_or_load_shared_class(Symbol* class_name,
                                                Handle class_loader,
                                                TRAPS);
 
+  static void preload_archived_classes(TRAPS);
 
   static void allocate_shared_data_arrays(int size, TRAPS);
 
   static bool is_builtin_loader(ClassLoaderData* loader_data);
 
@@ -231,10 +248,14 @@
 
   static void initialize() NOT_CDS_RETURN;
   static void init_dumptime_info(InstanceKlass* k) NOT_CDS_RETURN;
   static void handle_class_unloading(InstanceKlass* k) NOT_CDS_RETURN;
 
+  static bool can_be_preinited(InstanceKlass* ik);
+  static bool can_be_preinited_locked(InstanceKlass* ik);
+  static void reset_preinit_check();
+
   static Dictionary* boot_loader_dictionary() {
     return ClassLoaderData::the_null_class_loader_data()->dictionary();
   }
 
   static void update_shared_entry(InstanceKlass* klass, int id);
@@ -281,11 +302,11 @@
   static InstanceKlass* prepare_shared_lambda_proxy_class(InstanceKlass* lambda_ik,
                                                           InstanceKlass* caller_ik, TRAPS) NOT_CDS_RETURN_(nullptr);
   static bool check_linking_constraints(Thread* current, InstanceKlass* klass) NOT_CDS_RETURN_(false);
   static void record_linking_constraint(Symbol* name, InstanceKlass* klass,
                                      Handle loader1, Handle loader2) NOT_CDS_RETURN;
-  static bool is_builtin(InstanceKlass* k) {
+  static bool is_builtin(const InstanceKlass* k) {
     return (k->shared_classpath_index() != UNREGISTERED_INDEX);
   }
   static bool add_unregistered_class(Thread* current, InstanceKlass* k);
 
   static void check_excluded_classes();
@@ -297,10 +318,13 @@
   static bool warn_excluded(InstanceKlass* k, const char* reason);
   static void dumptime_classes_do(class MetaspaceClosure* it);
   static size_t estimate_size_for_archive();
   static void write_to_archive(bool is_static_archive = true);
   static void adjust_lambda_proxy_class_dictionary();
+
+  static void adjust_method_info_dictionary();
+
   static void serialize_dictionary_headers(class SerializeClosure* soc,
                                            bool is_static_archive = true);
   static void serialize_vm_classes(class SerializeClosure* soc);
   static void print() { return print_on(tty); }
   static void print_on(outputStream* st) NOT_CDS_RETURN;
@@ -308,10 +332,30 @@
   static void print_table_statistics(outputStream* st) NOT_CDS_RETURN;
   static bool is_dumptime_table_empty() NOT_CDS_RETURN_(true);
   static bool is_supported_invokedynamic(BootstrapInfo* bsi) NOT_CDS_RETURN_(false);
   DEBUG_ONLY(static bool class_loading_may_happen() {return _class_loading_may_happen;})
 
+  static MethodData* lookup_method_data(Method* m) {
+    const RunTimeMethodDataInfo* info = _dynamic_archive.lookup_method_info(m);
+    if (info != nullptr) {
+      return info->method_data();
+    }
+    return nullptr;
+  }
+
+  static MethodCounters* lookup_method_counters(Method* m) {
+    const RunTimeMethodDataInfo* info = _dynamic_archive.lookup_method_info(m);
+    if (info != nullptr) {
+      return info->method_counters();
+    }
+    return nullptr;
+  }
+
+  // Do not archive any new InstanceKlasses that are loaded after this method is called.
+  // This avoids polluting the archive with classes that are only used by GenerateJLIClassesHelper.
+  static void ignore_new_classes();
+
 #ifdef ASSERT
   // This object marks a critical period when writing the CDS archive. During this
   // period, the JVM must not load any new classes, so as to avoid adding new
   // items in the SystemDictionaryShared::_dumptime_table.
   class NoClassLoadingMark: public StackObj {
@@ -333,8 +377,10 @@
     uintx offset = uintx(ptr) - uintx(SharedBaseAddress);
     return primitive_hash<uintx>(offset);
   }
 
   static unsigned int hash_for_shared_dictionary(address ptr);
+  static const char* class_loader_name_for_shared(Klass* k);
+  static void create_loader_positive_lookup_cache(TRAPS);
 };
 
 #endif // SHARE_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
