title: JavaCompiler with custom ClassLoader and FileManager
body: <p>I wish to compile source without having the dependencies present on the machine.<br/>
  Example: File A.java: <br/></p>
  
  <pre><code>import some.pkg.B; 
  public class A extends B {...}
  </code></pre>
  
  <p>I don't have B source present,  I wish to hook either JavaFileManager or a custom ClassLoader in order to get the symbols in question (the package 'some.package' and class B) and then use a service I have that retrieves the source string.<br/></p>
  
  <p>The compiling code: (inputFiles has A.java)</p>
  
  <pre><code>JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
  CustomClassLoader classLoader = new CustomClassLoader();
  StandardJavaFileManager standardfileManager = compiler.getStandardFileManager(this, null, null);
  JavaFileManager fileManager = new CustomFileManager(standardfileManager, output, classLoader);
  CompilationTask task = compiler.getTask(null, fileManager, this, null, null, inputFiles);
  boolean result = task.call();
  </code></pre>
  
  <p>Hooks on JavaFileManager (getFileForInput..) and on my classloader (findClass, loadClass ..) didn't triggered when compiling and I got error messages:</p>
  
  <pre><code>A.java:#: package some.pkg does not exist
  A.java:#: cannot find symbol
  symbol: class B
  </code></pre>
  
  <p>EDIT<br/></p>
  
  <p>After playing around with the API, going over JavaCompiler (older version) source and reading <a href="http://openjdk.java.net/groups/compiler/doc/compilation-overview/index.html" rel="nofollow">Compilation Overview</a> I still can't find an API hook I can use to provide me Symbols from the syntax trees. It seems that the API needs to get all resources based on package names as suggested by kschneid. <br/>
  One workaround I thought about is running the JavaCompiler and analyze the error messages for missing symbols. That way I will know which symbols are needed, get them and recompile.<br/>
  Any other workarounds / solutions?</p>