提交 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,18 +111,20 @@ public class FunctionAlias extends DbObjectBase {
private void loadFromSource() {
SourceCompiler compiler = database.getCompiler();
String fullClassName = Constants.USER_PACKAGE + "." + getName();
compiler.setSource(fullClassName, source);
try {
Method m = compiler.getMethod(fullClassName);
JavaMethod method = new JavaMethod(m, 0);
javaMethods = new JavaMethod[] {
method
};
} catch (DbException e) {
throw e;
} catch (Exception e) {
throw DbException.get(ErrorCode.SYNTAX_ERROR_1, e, source);
synchronized (compiler) {
String fullClassName = Constants.USER_PACKAGE + "." + getName();
compiler.setSource(fullClassName, source);
try {
Method m = compiler.getMethod(fullClassName);
JavaMethod method = new JavaMethod(m, 0);
javaMethods = new JavaMethod[] {
method
};
} catch (DbException e) {
throw e;
} catch (Exception e) {
throw DbException.get(ErrorCode.SYNTAX_ERROR_1, e, source);
}
}
}
......
......@@ -10,7 +10,6 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
......@@ -148,7 +147,8 @@ public class SourceCompiler {
File javaFile = new File(dir, className + ".java");
File classFile = new File(dir, className + ".class");
try {
PrintWriter out = new PrintWriter(new FileWriter(javaFile));
OutputStream f = IOUtils.openFileOutputStream(javaFile.getAbsolutePath(), false);
PrintWriter out = new PrintWriter(IOUtils.getWriter(f));
classFile.delete();
int endImport = source.indexOf("@CODE");
String importCode = "import java.util.*;\n" +
......@@ -189,6 +189,7 @@ public class SourceCompiler {
exec("javac",
"-sourcepath", compileDir,
"-d", compileDir,
"-encoding", "UTF-8",
javaFile.getAbsolutePath());
}
......@@ -245,6 +246,7 @@ public class SourceCompiler {
compile.invoke(javac, (Object) new String[] {
"-sourcepath", compileDir,
"-d", compileDir,
"-encoding", "UTF-8",
javaFile.getAbsolutePath() });
throwSyntaxError(buff);
} catch (Exception e) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论