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

Reply via email to