How does classloading work with multiple child layers?
Alex Sviridov
ooo_saturn7 at mail.ru
Tue Apr 14 19:48:00 UTC 2020
Hello everybody,
I try to understand how classloading works when there are multiple child layers
and have a problem.
Let's consider the following situation. There are three layers.
BootLayer (moduleA)
|
|_______Child1(moduleB)
|
|__________ Child2(moduleC)
Child1 is the child of the BootLayer, Child2 is the child of the Child1.
Child1 and Child2 were created with the same code:
ClassLoader parentClassLoader = ClassLoader.getSystemClassLoader();
ModuleLayer layer = parentLayer.defineModulesWithOneLoader(cf, parentClassLoader);
As you see the parent class loader of both child layers is SystemClassLoader.
I am a beginner at classloading, but I've read about parent-first delegation model. However, if for both child layers SystemClassLoader is used, then why they see classes from other layers? I mean, why does moduleC
see classes from moduleB if the parentClass is SystemClassLoader (SystemClassLoader as I understand
delegates to BootLayer, but not to Child1 layer). Could anyone explain?
--
Best regards, Alex Sviridov
More information about the jigsaw-dev
mailing list