On 27/11/2023 17:18, Alex Orlov wrote:
Hello all,

I have a JPMS application with layer tree. In Module X on|Layer C|I need to create Spring context while Spring framework is located on|Layer B|:

|boot layer |- Layer B with Spring framework. |- Layer C with Module X and Module Y|
All child created this way:
          parentClassLoader = ClassLoader.getSystemClassLoader();
          ModuleLayer.Controller controller =
ModuleLayer.defineModulesWithOneLoader(cf, parentLayers, parentClassLoader);

Here's what we have in the ModuleLayer.defineModulesWithOnLoader method description:

"The class loader created by this method locates resources (getResource, getResources, and other resource methods) in all modules in the layer before searching the parent class loader."

When creating layer C, can you specify the parentLoader to be the loader for any module in layer B? I think that should work for this setup.

-Alan

Reply via email to