2
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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
7
* published by the Free Software Foundation.
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
28
* @summary compiler gives misleading message for no input files
29
* @modules jdk.compiler
35
public class T6986895 {
36
public static void main(String... args) throws Exception {
40
String noSourceFiles = "no source files";
41
String noSourceFilesOrClasses = "no source files or class names";
42
String invalidFileName = "Invalid filename";
43
boolean isWindows = System.getProperty("os.name").startsWith("Windows");
45
void run() throws Exception {
46
Locale prev = Locale.getDefault();
48
Locale.setDefault(Locale.ENGLISH);
49
test(noSourceFiles, "-Werror");
50
test(noSourceFilesOrClasses, "-Werror", "-Xprint");
52
test(invalidFileName, "-Werror", "someNonExistingFile*.java");
54
Locale.setDefault(prev);
58
void test(String expect, String... args) throws Exception {
59
System.err.println("Test " + expect + ": " + Arrays.asList(args));
60
StringWriter sw = new StringWriter();
61
PrintWriter pw = new PrintWriter(sw);
62
int rc = com.sun.tools.javac.Main.compile(args, pw);
64
System.err.println("compilation failed; rc=" + rc);
65
String out = sw.toString();
67
System.err.println(out);
68
if (!out.contains(expect))
69
throw new Exception("expected text not found: " + expect);