Essentially I'm asking something similar to this: How do I get a list of Java class dependencies for a main class? but I'd like to do it using a Java API. I'd prefer not to exec jdeps
and scrape the output.
Extra points if it uses https://github.com/classgraph/classgraph since our project already uses that library and it is awesome for scanning classes without actually instantiating everything it processes.
Oh, and this would be restricted to working on JDK 8.
[Update]
Here is a bit more background. Let's say I have a bundled application. Perhaps a Spring Boot app or something that can be deployed to a cloud platform like Cloud Foundry or Heroku. The app probably contains framework jars (like Spring), utility jars (logging, templating, json/xml processing, etc.), application domain classes and then all necessary transitive dependencies. Assume this is all either bundled into an uber-jar or referenced via a classpath.
My use case would be: Given a class, and the uber-jar/classpath, what is the subset of jars (out of that uber-jar) that my given class requires as dependencies to instantiate it?