提交 1d018117 authored 作者: Thomas Mueller's avatar Thomas Mueller

CREATE ALIAS ... AS: Compilation was incorrect if the source code contained…

CREATE ALIAS ... AS: Compilation was incorrect if the source code contained characters that are not supported by the default file encoding.
上级 ae805215
...@@ -111,6 +111,7 @@ public class FunctionAlias extends DbObjectBase { ...@@ -111,6 +111,7 @@ public class FunctionAlias extends DbObjectBase {
private void loadFromSource() { private void loadFromSource() {
SourceCompiler compiler = database.getCompiler(); SourceCompiler compiler = database.getCompiler();
synchronized (compiler) {
String fullClassName = Constants.USER_PACKAGE + "." + getName(); String fullClassName = Constants.USER_PACKAGE + "." + getName();
compiler.setSource(fullClassName, source); compiler.setSource(fullClassName, source);
try { try {
...@@ -125,6 +126,7 @@ public class FunctionAlias extends DbObjectBase { ...@@ -125,6 +126,7 @@ public class FunctionAlias extends DbObjectBase {
throw DbException.get(ErrorCode.SYNTAX_ERROR_1, e, source); throw DbException.get(ErrorCode.SYNTAX_ERROR_1, e, source);
} }
} }
}
private void loadClass() { private void loadClass() {
Class< ? > javaClass = Utils.loadUserClass(className); Class< ? > javaClass = Utils.loadUserClass(className);
......
...@@ -10,7 +10,6 @@ import java.io.ByteArrayOutputStream; ...@@ -10,7 +10,6 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
...@@ -148,7 +147,8 @@ public class SourceCompiler { ...@@ -148,7 +147,8 @@ public class SourceCompiler {
File javaFile = new File(dir, className + ".java"); File javaFile = new File(dir, className + ".java");
File classFile = new File(dir, className + ".class"); File classFile = new File(dir, className + ".class");
try { try {
PrintWriter out = new PrintWriter(new FileWriter(javaFile)); OutputStream f = IOUtils.openFileOutputStream(javaFile.getAbsolutePath(), false);
PrintWriter out = new PrintWriter(IOUtils.getWriter(f));
classFile.delete(); classFile.delete();
int endImport = source.indexOf("@CODE"); int endImport = source.indexOf("@CODE");
String importCode = "import java.util.*;\n" + String importCode = "import java.util.*;\n" +
...@@ -189,6 +189,7 @@ public class SourceCompiler { ...@@ -189,6 +189,7 @@ public class SourceCompiler {
exec("javac", exec("javac",
"-sourcepath", compileDir, "-sourcepath", compileDir,
"-d", compileDir, "-d", compileDir,
"-encoding", "UTF-8",
javaFile.getAbsolutePath()); javaFile.getAbsolutePath());
} }
...@@ -245,6 +246,7 @@ public class SourceCompiler { ...@@ -245,6 +246,7 @@ public class SourceCompiler {
compile.invoke(javac, (Object) new String[] { compile.invoke(javac, (Object) new String[] {
"-sourcepath", compileDir, "-sourcepath", compileDir,
"-d", compileDir, "-d", compileDir,
"-encoding", "UTF-8",
javaFile.getAbsolutePath() }); javaFile.getAbsolutePath() });
throwSyntaxError(buff); throwSyntaxError(buff);
} catch (Exception e) { } catch (Exception e) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论