In SystemDictionary::resolve_super_or_fail()
http://hg.openjdk.java.net/jdk/jdk/file/5ac19bd3a1e2/src/hotspot/share/classfile/systemDictionary.cpp#l338
It seems that we should first check if the super class has already been loaded. That way, we don't need the expensive operation of updating the placeholder for the child class, etc:
E.g.,
ClassLoaderData* loader_data = class_loader_data(class_loader);
Dictionary* dictionary = loader_data->dictionary();
+ {
+ unsigned int sd_hash = dictionary->compute_hash(super_name);
+ InstanceKlass* squick = dictionary->find(sd_hash, super_name, protection_domain);
+ if (squick != NULL) {
+ return squick;
+ }
+ }
unsigned int d_hash = dictionary->compute_hash(child_name);
unsigned int p_hash = placeholders()->compute_hash(child_name);
The placeholder code in this function is for checking ClassCircularityError. However, if the super has already been loaded (i.e., super doesn't have ClassCircularityError), we cannot cause ClassCircularityError by simply adding a sub class the to super.
http://hg.openjdk.java.net/jdk/jdk/file/5ac19bd3a1e2/src/hotspot/share/classfile/systemDictionary.cpp#l338
It seems that we should first check if the super class has already been loaded. That way, we don't need the expensive operation of updating the placeholder for the child class, etc:
E.g.,
ClassLoaderData* loader_data = class_loader_data(class_loader);
Dictionary* dictionary = loader_data->dictionary();
+ {
+ unsigned int sd_hash = dictionary->compute_hash(super_name);
+ InstanceKlass* squick = dictionary->find(sd_hash, super_name, protection_domain);
+ if (squick != NULL) {
+ return squick;
+ }
+ }
unsigned int d_hash = dictionary->compute_hash(child_name);
unsigned int p_hash = placeholders()->compute_hash(child_name);
The placeholder code in this function is for checking ClassCircularityError. However, if the super has already been loaded (i.e., super doesn't have ClassCircularityError), we cannot cause ClassCircularityError by simply adding a sub class the to super.