mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8335989: Implement JEP 494: Module Import Declarations (Second Preview)
Reviewed-by: vromero, abimpoudis, mcimadamore, alanb
This commit is contained in:
parent
e7d90b941f
commit
1e97c1c913
28 changed files with 716 additions and 182 deletions
|
@ -432,6 +432,40 @@ public class ConvenientAccessErrorsTest extends ModuleTestBase {
|
|||
throw new Exception("expected output not found; actual: " + log);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInModuleImport(Path base) throws Exception {
|
||||
Path src = base.resolve("src");
|
||||
Path src_m1 = src.resolve("m1x");
|
||||
tb.writeJavaFiles(src_m1,
|
||||
"module m1x { }",
|
||||
"package api; public class Api { public String test() { return null; } }");
|
||||
Path src_m2 = src.resolve("m2x");
|
||||
tb.writeJavaFiles(src_m2,
|
||||
"module m2x { requires m1x; }",
|
||||
"package test; import module m1x; public class Test { Api api; { api.test().length(); } }");
|
||||
Path classes = base.resolve("classes");
|
||||
tb.createDirectories(classes);
|
||||
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"--enable-preview", "--source", System.getProperty("java.specification.version"),
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutputLines(Task.OutputKind.DIRECT);
|
||||
|
||||
List<String> expected = Arrays.asList(
|
||||
"Test.java:1:54: compiler.err.cant.resolve.location: kindname.class, Api, , , (compiler.misc.location: kindname.class, test.Test, null)",
|
||||
"- compiler.note.preview.filename: Test.java, DEFAULT",
|
||||
"- compiler.note.preview.recompile",
|
||||
"1 error");
|
||||
|
||||
if (!expected.equals(log))
|
||||
throw new Exception("expected output not found; actual: " + log);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnusedImportOnDemand2(Path base) throws Exception {
|
||||
Path src = base.resolve("src");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue