test/tools/javac/T6900149.java

changeset 1669
d3648557391b
parent 678
014cf6234586
child 2525
2eb010b6cb22
equal deleted inserted replaced
1668:991f11e13598 1669:d3648557391b
1 /* 1 /*
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
37 DiagnosticCollector<JavaFileObject> diag = 37 DiagnosticCollector<JavaFileObject> diag =
38 new DiagnosticCollector<JavaFileObject>(); 38 new DiagnosticCollector<JavaFileObject>();
39 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 39 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
40 StandardJavaFileManager fm = 40 StandardJavaFileManager fm =
41 compiler.getStandardFileManager(null, null, null); 41 compiler.getStandardFileManager(null, null, null);
42 File emptyFile = File.createTempFile("Empty", ".java"); 42 File emptyFile = createTempFile("Empty.java");
43 File[] files = new File[] { emptyFile, emptyFile }; 43 File[] files = new File[] { emptyFile, emptyFile };
44 CompilationTask task = compiler.getTask(null, fm, diag, 44 CompilationTask task = compiler.getTask(null, fm, diag,
45 null, null, fm.getJavaFileObjects(files)); 45 null, null, fm.getJavaFileObjects(files));
46 if (! task.call()) { 46 if (! task.call()) {
47 throw new AssertionError("compilation failed"); 47 throw new AssertionError("compilation failed");
48 } 48 }
49 } 49 }
50
51 private static File createTempFile(String path) throws IOException {
52 File f = new File(path);
53 try (FileWriter out = new FileWriter(f)) { }
54 return f;
55 }
50 } 56 }

mercurial