2

I am developing a static code dependency analysis tool where I plan to read .java files into a Class/interface/etc objects and then build logic around its properties using public methods such as:

Class.getImports();

etc. Are there any existing libraries such as Java Reflection that can parse java files that belong to external projects into a Class/Enum/etc object?

1 Answer 1

4

The Class/Interface/etc. objects represent instances of the corresponding objects loaded into an actual Java virtual machine. They cannot be used to represent code in .java files, because the Java reflection APIs are final classes, not interfaces, and therefore cannot have alternative implementations.

To analyze .java files, you can use other APIs such as the Java compiler tree API.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.