 <p>You maybe intrested in <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javap.html" rel="nofollow">javap</a></p> <p>I have created A.java, B.java, C.java, D.java fiels:</p> <pre><code> public class A { public static void main(String[] args) { B b = new B(); b.getC().getD(); } } </code></pre> <p>and compile these classes.</p> <p>Now we can use javap to dissemble A.class:</p> <pre><code>javap -c A </code></pre> <p>and get bytecodes:</p> <p>public class A { public A(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."":() 4: return</p> <pre><code> public static void main(java.lang.String[]); Code: 0: new #2 // class B 3: dup 4: invokespecial #3 // Method B."&lt;init&gt;":()V 7: astore_1 8: aload_1 9: invokevirtual #4 // Method B.getC:()LC; 12: invokevirtual #5 // Method C.getD:()LD; 15: pop 16: return } </code></pre> <p>Now you can get A.class have used imported class, like:</p> <ul> <li>// Method B.getC:()LC; --> used class B </li> <li>// Method C.getD:()LD; --> used class C</li> </ul> <p>but I think the best way is use <a href="https://en.wikipedia.org/wiki/Abstract_syntax_tree" rel="nofollow">Abstract Syntax Tree</a> as @Kong, </p>