It seems that there is no simple way to have the JavaCompiler
load dependencies of compiled code from a ClassLoader
. However, one could implement JavaFileManager
directly and redirect the operations for the StandardLocation.CLASS_PATH
using resource lookups on the context ClassLoader
(getResource(<class/resource name>)
). This would withdraw the limitation of StandardJavaFileManager
directly operating on File
s.
Someone already seems to have prototypically implemented that approach: http://atamur.blogspot.de/2009/10/using-built-in-javacompiler-with-custom.html