mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8341070
: javac fails with an exception when compiling import module under source level 8
Reviewed-by: asotona
This commit is contained in:
parent
519544c1d7
commit
6133866150
2 changed files with 63 additions and 19 deletions
|
@ -797,4 +797,50 @@ public class ImportModule extends TestRunner {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportModuleNoModules(Path base) throws Exception {
|
||||
Path current = base.resolve(".");
|
||||
Path src = current.resolve("src");
|
||||
Path classes = current.resolve("classes");
|
||||
tb.writeJavaFiles(src,
|
||||
"""
|
||||
package test;
|
||||
import module java.base;
|
||||
public class Test {
|
||||
List<String> l;
|
||||
}
|
||||
""");
|
||||
|
||||
Files.createDirectories(classes);
|
||||
|
||||
List<String> actualErrors = new JavacTask(tb)
|
||||
.options("--release", "8",
|
||||
"-XDshould-stop.at=FLOW",
|
||||
"-XDdev",
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(tb.findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutputLines(Task.OutputKind.DIRECT);
|
||||
|
||||
List<String> expectedErrors = List.of(
|
||||
"- compiler.warn.option.obsolete.source: 8",
|
||||
"- compiler.warn.option.obsolete.target: 8",
|
||||
"- compiler.warn.option.obsolete.suppression",
|
||||
"Test.java:2:8: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.module.imports)",
|
||||
"Test.java:2:1: compiler.err.import.module.not.found: java.base",
|
||||
"Test.java:4:5: compiler.err.cant.resolve.location: kindname.class, List, , , (compiler.misc.location: kindname.class, test.Test, null)",
|
||||
"3 errors",
|
||||
"3 warnings"
|
||||
);
|
||||
|
||||
if (!Objects.equals(expectedErrors, actualErrors)) {
|
||||
throw new AssertionError("Incorrect Output, expected: " + expectedErrors +
|
||||
", actual: " + out);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue