For a given Java source code file I want to list all the (fully qualified names of) classes that are (directly) required for compilation. In other words: All classes that are directly used by the code in the source code file, coming from imports, fully qualified names in the source code and other compile time means, but not by reflection or other runtime means.
Is there a way to "ask" the java compiler for this list? Are there other ways to get it?
PS: By "directly" I mean the following: If my source code file requires class A for compilation which uses class B, then class B has to be present to compile the code, but it is not a direct use.