How many times one module can exist in layer graph
Anand Beh
anandebeh at gmail.com
Thu Dec 14 23:58:18 UTC 2023
Hi Pavel,
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.
If, by saying "moduleY can only be located in ONE layer," you mean that
moduleY must only be *loaded* 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.
Hope this helps.
Anand
On Thu, Dec 14, 2023 at 11:55 AM PavelTurk <pavelturk2000 at gmail.com> wrote:
> Hello, Alan
>
> Thank you very much for your answer. I could reproduce this problem.
> Please, see https://github.com/PavelTurk/jpms-test1
> There is a detailed readme and only one class that throws
> ResolutionException.
>
> Best regards, Pavel
>
> On 12/14/23 3:07 PM, Alan Bateman wrote:
> > On 14/12/2023 10:56, PavelTurk wrote:
> >> Hello all.
> >>
> >> Let's suppose that we have 4 layers:
> >> 1) boot
> >> 2) layerA (parent - boot)
> >> 3) layerB (parent-boot)
> >> 4) layerC (parents - layerA, layerB)
> >>
> >> Layers A,B,C were created using defineModulesWithOneLoader(...).
> >>
> >> And we have two modules - moduleX and moduleY. ModuleX uses moduleY.
> >> ModuleX is located in layerC.
> >>
> >>
> Do I understand correctly that moduleY can be located in any layer, but only
> >>
> in ONE layer? I mean, that it is impossible to place moduleY in any TWO layers
> >> at the same time - for example in boot layer and layerB.
> >>
> >> I am asking this because I read that it was possible but I tried all
> variants and
> >> always got ResolutionException: Module ModuleX reads more than one
> module named
> >> ModuleY.
> >
> > It's possible to have a module "X" n several module layers at the same
> time.
> >
> > 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?
> >
> > -Alan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20231214/80ae98b0/attachment-0001.htm>
More information about the jigsaw-dev
mailing list