How to find out what module provides concrete class?

PavelTurk pavelturk2000 at gmail.com
Fri Dec 15 21:47:06 UTC 2023


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



More information about the jigsaw-dev mailing list