use of com.alibaba.otter.shared.common.utils.compile.model.JdkCompilerClassLoader in project otter by alibaba.
the class JdkCompiler method compile.
public Class compile(JavaSource javaSource) {
try {
final DiagnosticCollector<JavaFileObject> errs = new DiagnosticCollector<JavaFileObject>();
JdkCompileTask compileTask = new JdkCompileTask(new JdkCompilerClassLoader(this.getClass().getClassLoader()), options);
String fullName = javaSource.getPackageName() + "." + javaSource.getClassName();
Class newClass = compileTask.compile(fullName, javaSource.getSource(), errs);
return newClass;
} catch (JdkCompileException ex) {
DiagnosticCollector<JavaFileObject> diagnostics = ex.getDiagnostics();
throw new CompileExprException("compile error, source : \n" + javaSource + ", " + diagnostics.getDiagnostics(), ex);
} catch (Exception ex) {
throw new CompileExprException("compile error, source : \n" + javaSource, ex);
}
}
Aggregations