Output java files in UTF-8 and force compiler to use UTF-8

This commit is contained in:
Jakub Valtar
2018-03-13 15:35:26 +01:00
parent 104b59e3a8
commit 728cb75494
2 changed files with 7 additions and 3 deletions

View File

@@ -68,6 +68,7 @@ public class Compiler {
//"-noExit", // not necessary for ecj
"-source", "1.7",
"-target", "1.7",
"-encoding", "utf8",
"-classpath", build.getClassPath(),
"-nowarn", // we're not currently interested in warnings (works in ecj)
"-d", build.getBinFolder().getAbsolutePath() // output the classes in the buildPath

View File

@@ -24,6 +24,8 @@ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package processing.mode.java;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
@@ -249,14 +251,15 @@ public class JavaBuild {
outputFolder.mkdirs();
// Base.openFolder(outputFolder);
final File java = new File(outputFolder, sketch.getName() + ".java");
final PrintWriter stream = new PrintWriter(new FileWriter(java));
BufferedWriter bw = Files.newBufferedWriter(java.toPath(), StandardCharsets.UTF_8);
final PrintWriter stream = new PrintWriter(bw);
try {
result = preprocessor.write(stream, bigCode.toString(), codeFolderPackages);
} finally {
stream.close();
}
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
String msg = "Build folder disappeared or could not be written";
throw new SketchException(msg);