Monday 15 June 2015

java - How do I get a list of all sources a compiler needs to compile one class -


To create and load a class on runtime, I read my content from the database for the first time, to create the new SimpleJavaFileObject <

Compile it at the runtime by sending it to an compilation ticket and finally it is that this new file is copied to other files (directly imported or" indirectly "by DPK. *) ), Which are also stored in DB and sections or source code-files Are not available. Testing of Public Sector 1 {Public Deopor Package. Test 2 answers () {return tap; }}

Like Test 1, I have to move one step ahead and have to compile the test 2, because there is no JavaFileObjects or feed to the compiler Classes for

Then: How do I get a list of all the sources, which a compiler needs to compile a class?

It would be enough to know that Test 1 is required Test 2 I tried to do this for the first time compilation for processor passed it Examined all the features in the trees, but did not find anything useful or complete. If a package is imported using the * on the package then there is no way to get the full qualification name ... at least not for me: - /

Any ideas? Perhaps there are better ways to parse javaswans?

Thank you for helping: -)

If you are asking There is no way to do this before you compile the class, then the answer is "is not it". Source code, and source code alone determine direct dependency. And you need to compile the source code to remove.

If you are asking if there is any way to remove reliance during compilation or later, then there are some options:

  • The javac command has a - verbose option, due to which it causes the reason for loading each class, and each file is compiled.

  • If you use the standard compiler API, then it provides hooks to load dependent sections and search for source files. You can use it to track them.

  • You can get more information about this by yourself from the bytecode files though some alerts are:

    • If the code is < If the code is compiled with "-g: none , then the" source file names in the .class will not be named "files.

    • You can define dependencies, are not recorded at the time of compilation ... unless you can not guess them from file timestamps.

    • The reliance on compile-time stability declared in another category is completely solved (and inline) on time compilation ... and any of the generated ".class" files The mark will not be there.

      > If the compiler feels that he needs to load or compiling a dependent class , then it automatically does at least, how does javac behaves as default.

No comments:

Post a Comment