diff -r aceae9ceebbe -r c2d9303c3477 test/tools/javac/api/T6306137.java --- a/test/tools/javac/api/T6306137.java Tue Jun 25 20:08:52 2013 +0400 +++ b/test/tools/javac/api/T6306137.java Wed Jun 26 09:54:46 2013 -0700 @@ -31,8 +31,14 @@ */ import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import javax.tools.*; +import static java.nio.file.StandardOpenOption.*; public class T6306137 { boolean error; @@ -40,8 +46,9 @@ final JavaCompiler compiler; Iterable files; DiagnosticListener dl; + final File testFile = new File("Utf8.java"); - T6306137() { + T6306137() throws IOException { dl = new DiagnosticListener() { public void report(Diagnostic message) { if (message.getKind() == Diagnostic.Kind.ERROR) @@ -56,11 +63,17 @@ }; compiler = ToolProvider.getSystemJavaCompiler(); fm = compiler.getStandardFileManager(dl, null, null); - String srcdir = System.getProperty("test.src"); files = - fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6306137.java"))); + fm.getJavaFileObjectsFromFiles(Arrays.asList(testFile)); + createTestFile(); } - + final void createTestFile() throws IOException { + List scratch = new ArrayList<>(); + scratch.add("// @author Peter von der Ah" + (char)0xe9); + scratch.add("class Utf8{}"); + Files.write(testFile.toPath(), scratch, Charset.forName("UTF-8"), + CREATE, TRUNCATE_EXISTING); + } void test(String encoding, boolean good) { error = false; Iterable args = Arrays.asList("-source", "6", "-encoding", encoding, "-d", "."); @@ -74,7 +87,7 @@ } } - public static void main(String[] args) { + public static void main(String[] args) throws IOException { T6306137 self = new T6306137(); self.test("utf-8", true); self.test("ascii", false);