Is it possible to get javac, on OpenJDK7 or 8, to print out a list of what all the fully qualified referenced classes are used for a given class without having to write some parsing Java code?
-
Any solution must be 100% invisible to the source code
-
Answer:
You're questions a bit wrong. You don't need javac. 1 2 3 4 5 6 7 8 9101112131415161718192021class QualifiedNameFinder { public String getQualifiedName(Object o) { return this.getQualifiedName(o.getClass()); } public String getQualifiedName(Class<?> c) { return c.getName(); } } Excuse the bad indentation. You can get the qualified name in three ways: 1) using an object- o.getClass().getName(); 2) using a class object-c.getName(); 3) if you only know the class name, you can get the name like this YourClass.class.getName() Here I wrote a class with two overloaded methods that do the qualified name finding.
Rishav Kundu at Quora Visit the source
Related Q & A:
- Is it correct to extend a bean class and write a class which holds logic to populate the bean we extend?Best solution by stackoverflow.com
- What type of jobs can I get with a MBA but without any experience?Best solution by Yahoo! Answers
- What is the best camcorder to get for a college class?Best solution by Yahoo! Answers
- How do I print out a list of my contacts email addresses?Best solution by Yahoo! Answers
- Can I see a list of what "I Like" on Facebook?
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.