title: Find java class dependencies at runtime
body: <p>What's the most effective way to get a list of dependencies for a Java class at runtime?</p>
  
  <p>Using <a href="https://stackoverflow.com/a/3735007/791406">this</a> (based on ASM ByteCode Manipulator 3.3.1), I can do the following: </p>
  
  <pre><code>final Collection&lt;Class&lt;?&gt;&gt; classes = 
    getClassesUsedBy(MyService.class.getName(), "com");
  </code></pre>
  
  <p>This returns references to <code>BasicService</code> and <code>IService</code>, but misses <code>ContainerValue</code>, and that's the issue. I played around with the ASM code but could not figure out how to pick up ContainerValue. </p>
  
  <pre><code>package com.foo.bar;
  
      public class MyService extends BasicService implements IService {
           public String invoke(){
              return new ContainerValue("bar").toString();
      }
  </code></pre>
  
  <p>As a side note, if I make <code>ContainerValue</code> the return type on <code>invoke</code>, it works. </p>
  
  <p>Is there any alternative to using ASM to get a list of dependencies for a class? Why the heck is that so difficult?</p>