A couple of questions
Alan Bateman
Alan.Bateman at oracle.com
Tue Jan 2 08:03:19 UTC 2024
On 29/12/2023 11:47, PavelTurk wrote:
> Hello all. Could anyone help me with the following questions:
>
> 1. Let's suppose I have a reference to an unnamed module:
> module.getName() == null . But I need at least some information about it.
> How can I get file name of this module - jar/war etc?
If you have a reference to an unnamed module then you can get its class
loader with Module::getClassLoader. There's unnamed module for each
class loader, 1:1 relationship. You can get the set of packages for the
classes defined in the unnamed module with Module::getPackages which may
help get closer to what you are looking for. That said, there is no API
to expose the class path or the locations where the class loader has
loaded classes. The class bytes can come from anywhere.
What is the context for this question? Agents/tooling can use APIs to
enumerate all classes loaded in the VM and most of these classes will
have a URL code source. I think that is the closest to what you are
looking for (if I understand your question correctly).
>
> 2. Let's suppose I have the following layer graph:
>
> 1) boot
> 2) layerA (parent - boot) has moduleX
> 3) layerB (parent - boot) has moduleX
> 4) layerC (parents - layerA, layerB) has moduleY
>
> As I understand it is a possible situation. ModuleY requires moduleX
> that is present in two parent layers.
> The question - how can I find out from which layer moduleX will be
> used for moduleY?
The Configuration objects for layerA, layerB and layerC encapsulate the
readability graphs used to the these module layers. Use
Configuration::modules to get the set the resolved modules in the
configuration, and ResovledRead::read to get the set of modules that are
read. This will allow you to see which modules in C read "moduleX" in A
and which modules in C read "moduleX" in B.
-Alan.
More information about the jigsaw-dev
mailing list