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

Synchronize compilation, to avoid bugs in the compiler

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