use of org.codehaus.groovy.tools.javac.MemJavaFileObject in project groovy by apache.
the class JavaShell method doCompile.
private void doCompile(String className, String src, Iterable<String> options) throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
try (BytesJavaFileManager bjfm = new BytesJavaFileManager(compiler.getStandardFileManager(null, locale, charset))) {
StringBuilderWriter out = new StringBuilderWriter();
JavaCompiler.CompilationTask task = compiler.getTask(out, bjfm, null, options, Collections.emptyList(), Collections.singletonList(new MemJavaFileObject(className, src)));
task.call();
if (bjfm.isEmpty()) {
throw new JavaShellCompilationException(out.toString());
}
final Map<String, byte[]> classMap = bjfm.getClassMap();
jscl.setClassMap(classMap);
}
}
Aggregations