A couple of questions
PavelTurk
pavelturk2000 at gmail.com
Thu Jan 11 21:57:05 UTC 2024
> Starting in model world (Configuration/ResolvedModule) is right and you first need to find the Configuration containing the moduleX that moduleY reads, this should do it:
>
Yes, I understand it, I sent a piece of real application code, so it was a little different.
> Once you have the Configuration then you need to find the ModuleLayer that was reifed from that Configuration, this should do it:
>
> ModuleLayer layer = layerC.parents().stream()
> .filter(l -> l.configuration() == cf)
> .findAny()
> .orElseThrow();
>
> Can you try it?
>
Yes, it worked. Thank you very much for your help. I didn't understand that we could map layer and modules of this layer by configuration.
So I just created Map where as a key I used the configuration of all layers and after that
for (var readModule : m.reads()) {
var layer = moduleLayersByConfiguration.get(readModule.configuration());
}
Several notes:
1. Your code `ModuleLayer layer = layerC.parents().stream()...` didn't find layer if moduleX was in boot layer, but not in direct parents of layerC. In our example 4
layers:
1) boot
2) layerA (parent - boot) has moduleX
3) layerB (parent - boot) has moduleX
4) layerC (parents - layerA, layerB) has moduleY
2. Please see this diagram https://i.stack.imgur.com/ss2os.png that was generated for real application using reads and ResolvedModules (the topic of this thread).
Here we have two layers - the right is a boot layer and the left is a webserver layer. The program must show reads of com.google.gson. Reads are shown using dashed arrows.
a) we see that gson reads 5 modules. At the same time gson requires only 1 module:
module com.google.gson {
exports com.google.gson;
exports com.google.gson.annotations;
exports com.google.gson.reflect;
exports com.google.gson.stream;
requires transitive java.sql;
}
Do I understand it correctly that extra 4 modules are read via java.sql?
3. Do I understand it correctly if some explicit module (with module-info) from webserver layer will require any automatic module from webserver layer then this explicit
module will read ALL automatic modules from both layers?
Best regards, Pavel
More information about the jigsaw-dev
mailing list