<div dir="ltr">Hi Pavel,<div><br></div><div>It seems to be the issue that you're loading the Gson jar twice -- once in layer A and once in layer B. The problem is analogous to loading the same jar file in different ClassLoaders (in fact, that's what is happening behind the scenes). You'll get different Class instances, which quickly turns into a debugging nightmare, a hellish classloading situation which was one of the original motivations for JPMS.</div><div><br></div><div>If, by saying "moduleY can only be located in ONE layer," you mean that moduleY must only be <i>loaded</i> by one layer, then yes, I would say that you are correct. However, in terms of usability, and this is what Alan seems to be getting at, you can indeed have Gson be visible to multiple layers at the same time.</div><div><br></div><div>Hope this helps.</div><div><br></div><div>Anand</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 14, 2023 at 11:55 AM PavelTurk <<a href="mailto:pavelturk2000@gmail.com">pavelturk2000@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello, Alan<br>
<br>
Thank you very much for your answer. I could reproduce this problem.<br>
Please, see <a href="https://github.com/PavelTurk/jpms-test1" rel="noreferrer" target="_blank">https://github.com/PavelTurk/jpms-test1</a><br>
There is a detailed readme and only one class that throws ResolutionException.<br>
<br>
Best regards, Pavel<br>
<br>
On 12/14/23 3:07 PM, Alan Bateman wrote:<br>
> On 14/12/2023 10:56, PavelTurk wrote:<br>
>> Hello all.<br>
>><br>
>> Let's suppose that we have 4 layers:<br>
>> 1) boot<br>
>> 2) layerA (parent - boot)<br>
>> 3) layerB (parent-boot)<br>
>> 4) layerC (parents - layerA, layerB)<br>
>><br>
>> Layers A,B,C were created using defineModulesWithOneLoader(...).<br>
>><br>
>> And we have two modules - moduleX and moduleY. ModuleX uses moduleY.<br>
>> ModuleX is located in layerC.<br>
>><br>
>> Do I understand correctly that moduleY can be located in any layer, but only<br>
>> in ONE layer? I mean, that it is impossible to place moduleY in any TWO layers<br>
>> at the same time - for example in boot layer and layerB.<br>
>><br>
>> I am asking this because I read that it was possible but I tried all variants and<br>
>> always got ResolutionException: Module ModuleX reads more than one module named<br>
>> ModuleY.<br>
><br>
> It's possible to have a module "X" n several module layers at the same time.<br>
><br>
> It's hard to diagnose things from the info in your mail. Can you print the Configuration object for layer A, B and C and paste it into a reply? There may be implied readability in the picture, or it may be related to using a multi-parent Configuration, I can't tell. Also when you say X uses Y then I assume you don't mean services, instead you mean X requires Y, is that right?<br>
><br>
> -Alan<br>
<br>
</blockquote></div>