8235876: Misleading warning message in java source-file mode

Reviewed-by: vromero
This commit is contained in:
Adam Sotona 2021-11-24 17:03:53 +00:00
parent 663e33de13
commit 951247c8cb
2 changed files with 16 additions and 1 deletions
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher
test/langtools/tools/javac/launcher

@ -354,6 +354,7 @@ public class Main {
javacOpts.add("-Xdiags:verbose");
javacOpts.add("-Xlint:deprecation");
javacOpts.add("-Xlint:unchecked");
javacOpts.add("-Xlint:-options");
return javacOpts;
}

@ -23,7 +23,7 @@
/*
* @test
* @bug 8192920 8204588 8246774 8248843 8268869
* @bug 8192920 8204588 8246774 8248843 8268869 8235876
* @summary Test source launcher
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
@ -630,6 +630,20 @@ public class SourceLauncherTest extends TestRunner {
}
}
@Test
public void testNoOptionsWarnings(Path base) throws IOException {
tb.writeJavaFiles(base, "public class Main { public static void main(String... args) {}}");
String log = new JavaTask(tb)
.vmOptions("--source", "7")
.className(base.resolve("Main.java").toString())
.run(Task.Expect.SUCCESS)
.getOutput(Task.OutputKind.STDERR);
if (log.contains("warning: [options]")) {
error("Unexpected options warning in error output: " + log);
}
}
void testError(Path file, String expectStdErr, String expectFault) throws IOException {
Result r = run(file, Collections.emptyList(), List.of("1", "2", "3"));
checkEmpty("stdout", r.stdOut);