Dynamic compilation of multiple Scala classes at runtime
问题 I know I can compile individual "snippets" in Scala using the Toolbox like this: import scala.reflect.runtime.universe import scala.tools.reflect.ToolBox object Compiler { val tb = universe.runtimeMirror(getClass.getClassLoader).mkToolBox() def main(args: Array[String]): Unit = { tb.eval(tb.parse("""println("hello!")""")) } } Is there any way I can compile more than just "snippets", i.e., classes that refer to each other? Like this: import scala.reflect.runtime.universe import scala.tools