3

I have a running JVM instance with a known PID.

Given that there are some UNNAMED modules in play, is there any sane way to find out which named JPMS modules are currently loaded by this JVM instance, from outside?

I think it can be achieved by processing the output of jcmd <pid> VM.class_hierarchy, but it sure is too much work for a simple and logical question in Java9+ era.

Naman
  • 27,789
  • 26
  • 218
  • 353
Hamid Nazari
  • 506
  • 1
  • 6
  • 18
  • Possible to start the application again? [List the modules resolved during the application startup](https://stackoverflow.com/questions/48339598/list-the-modules-resolved-during-the-application-startup) – Naman Oct 19 '19 at 03:00
  • On the other hand, *there are some UNNAMED modules*, would **mostly** be one for all the jars resolved on your classpath [unless you have multiple ClassLoaders resolving one for them](https://stackoverflow.com/questions/46263256/how-many-unnamed-modules-are-created-in-java-9). Did you possible meant *automatic modules*? – Naman Oct 19 '19 at 03:10
  • I believe he is looking for `observable modules` that are loaded into jvm @Naman correct me if i'm wrong – Ryuzaki L Oct 19 '19 at 03:11
  • @Naman My application is OSGi based, therefore yes, there are multiple ClassLoaders in play, hence multiple JPMS UNNAMED modules. – Hamid Nazari Oct 20 '19 at 00:31
  • @Naman Since JPMS resolves UNNAMED modules's references (required modules) at run-time, restarting the application won't help me in this scenario. I need to get the list of all resolved modules when application is at a known internal state. – Hamid Nazari Oct 20 '19 at 00:33
  • @Deadpool Obseravle modules are not of my interest; the set of referenced (resolved) NAMED modules by the single UNNAMED OSGi framework (Equinox in my case) is what I'm looking for. Note that OSGi framework is on ClassPath, not on ModulePath which would have made it an AUTOMATIC module. – Hamid Nazari Oct 20 '19 at 00:42
  • 1
    I went through the APIs and it seems, even from within the JVM getting all modules is not as easy as one might expect. Then, there’s no builtin feature to export that list either. You’d have to implement it yourself. But it’s not clear whether you’re looking for a way to implement such a feature (i.e. in Java code) or a command line tool giving you the information. – Holger Nov 05 '19 at 11:30
  • @Holger Your are correct, I've finally came to the same conclusion. Right now, I'm not willing to write code for that and I managed to work it around by remote debugging, but what I was looking for was a simple command in `jcmd`. – Hamid Nazari Nov 05 '19 at 12:59

0 Answers0