From JEP 371:
Despite the fact that a hidden class has a corresponding Class object, and the fact that a hidden class's supertypes are created by class loaders, no class loader is involved in the creation of the hidden class itself. Notice that this JEP never says that a hidden class is "loaded". No class loaders are recorded as initiating loaders of a hidden class, and no loading constraints are generated that involve hidden classes. Consequently, hidden classes are not known to any class loader:
https://openjdk.org/jeps/371
---
Lookup.defineHiddenClass similarly states:
C is derived with name CN, class loader L, and purported representation newBytes as if by the rules of JVMS 5.3.5, with the following adjustments:
...
The Java Virtual Machine marks L as the defining class loader of C, but no class loader is recorded as an initiating class loader of C.
---
However in SystemDictionary we have:
void SystemDictionary::post_class_load_event(EventClassLoad* event, const InstanceKlass* k, const ClassLoaderData* init_cld) {
assert(event != nullptr, "invariant");
assert(k != nullptr, "invariant");
event->set_loadedClass(k);
event->set_definingClassLoader(k->class_loader_data());
event->set_initiatingClassLoader(init_cld);
event->commit();
}
which sets the initiating loader unconditionally.
Despite the fact that a hidden class has a corresponding Class object, and the fact that a hidden class's supertypes are created by class loaders, no class loader is involved in the creation of the hidden class itself. Notice that this JEP never says that a hidden class is "loaded". No class loaders are recorded as initiating loaders of a hidden class, and no loading constraints are generated that involve hidden classes. Consequently, hidden classes are not known to any class loader:
https://openjdk.org/jeps/371
---
Lookup.defineHiddenClass similarly states:
C is derived with name CN, class loader L, and purported representation newBytes as if by the rules of JVMS 5.3.5, with the following adjustments:
...
The Java Virtual Machine marks L as the defining class loader of C, but no class loader is recorded as an initiating class loader of C.
---
However in SystemDictionary we have:
void SystemDictionary::post_class_load_event(EventClassLoad* event, const InstanceKlass* k, const ClassLoaderData* init_cld) {
assert(event != nullptr, "invariant");
assert(k != nullptr, "invariant");
event->set_loadedClass(k);
event->set_definingClassLoader(k->class_loader_data());
event->set_initiatingClassLoader(init_cld);
event->commit();
}
which sets the initiating loader unconditionally.