提交 5d096b58 authored 作者: Thomas Mueller's avatar Thomas Mueller

Synchronize compilation, to avoid bugs in the compiler

上级 5aeca7eb
......@@ -282,8 +282,11 @@ public class SourceCompiler {
.getStandardFileManager(null, null, null));
ArrayList<JavaFileObject> compilationUnits = new ArrayList<JavaFileObject>();
compilationUnits.add(new StringJavaFileObject(fullClassName, source));
// can not concurrently compile
synchronized (JAVA_COMPILER) {
JAVA_COMPILER.getTask(writer, fileManager, null, null,
null, compilationUnits).call();
}
String err = writer.toString();
throwSyntaxError(err);
try {
......@@ -333,7 +336,7 @@ public class SourceCompiler {
}.execute();
}
private static void javacSun(File javaFile) {
private synchronized static void javacSun(File javaFile) {
PrintStream old = System.err;
ByteArrayOutputStream buff = new ByteArrayOutputStream();
PrintStream temp = new PrintStream(buff);
......@@ -344,6 +347,7 @@ public class SourceCompiler {
Object javac = JAVAC_SUN.newInstance();
compile.invoke(javac, (Object) new String[] {
"-sourcepath", COMPILE_DIR,
// "-Xlint:unchecked",
"-d", COMPILE_DIR,
"-encoding", "UTF-8",
javaFile.getAbsolutePath() });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论