How to find out what module provides concrete class?
Glavo
zjx001202 at gmail.com
Sat Dec 16 06:53:33 UTC 2023
I guess you could get the package name from the class name and then iterate
through the modules in the ModuleLayer to find which module the package is
in.
Glavo
On Sat, Dec 16, 2023 at 5:47 AM PavelTurk <pavelturk2000 at gmail.com> wrote:
> Hello all.
>
> Please, consider the following code:
>
> ClassLoader cl = ....
> String className = "com.foo.Bar";
> Module module = ???
>
> So, we have class name in a String and it is necessary to get reference to
> module
> that has this class. The question - is it possible to find out:
> 1) without loading the class -
> Module module = cl.loadClass(className).getModule();
> 2) without reading content of every module
> ModuleReference reference = ...
> reference.open().list()....
>
> I mean, is there any ready solution that I can use to find module by class
> name and without loading class?
>
> Best regards, Pavel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20231216/c9bfcbe5/attachment-0001.htm>
More information about the jigsaw-dev
mailing list