FangYongs commented on PR #22718:
URL: https://github.com/apache/flink/pull/22718#issuecomment-1578869662

   @zentol I got some help from our JVM team and the detailed structure is in 
JVM native codes. For Java 10 and later, each classloader has a 
`ClassLoaderData` and there is a `Dictionary` in `ClassLoaderData` to cache the 
loaded class:
   class ClassLoaderData : public CHeapObj<mtClass> {
     ...
     **Dictionary*  _dictionary;              // The loaded InstanceKlasses, 
including initiated by this class loader**
   
     // Loaded class dictionary
     Dictionary* dictionary() const { return _dictionary; }
   
     Dictionary* ClassLoaderData::create_dictionary() {
       ...
       // const int _boot_loader_dictionary_size    = 1009;
       // const int _default_loader_dictionary_size = 107;
       return new Dictionary(this, size, resizable);
     }
   }
   
   Each classloader tries to find class from dictionary in its 
`ClassLoaderData` first.
   Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
                                                           Handle class_loader,
                                                           Handle 
protection_domain,
                                                           TRAPS) {
     class_loader = Handle(THREAD, 
java_lang_ClassLoader::non_reflection_class_loader(class_loader()));
     ClassLoaderData* loader_data = register_loader(class_loader);
     **Dictionary* dictionary = loader_data->dictionary();**
     unsigned int d_hash = dictionary->compute_hash(name); 
     ...
     {
       **Klass* probe = dictionary->find(d_hash, name, protection_domain);**
       if (probe != NULL) return probe;
     }
     ...
   }
   
   After a classloader load class from its parent classloader, it will put the 
class to the dictionary as a local cache
   void SystemDictionary::update_dictionary(unsigned int d_hash,
                                            int p_index, unsigned int p_hash,
                                            InstanceKlass* k,
                                            Handle class_loader,
                                            TRAPS) {
   ...
     ClassLoaderData *loader_data = class_loader_data(class_loader);
   ...
       **// Make a new dictionary entry.**
       Dictionary* dictionary = loader_data->dictionary();
       InstanceKlass* sd_check = find_class(d_hash, name, dictionary);
       if (sd_check == NULL) {
         dictionary->add_klass(d_hash, name, k);
       }
    ... 
   
   
   The issue of JDK is https://bugs.openjdk.org/browse/JDK-7133093
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to