|
23 | 23 |
|
24 | 24 | /**
|
25 | 25 | * @test
|
26 |
| - * @bug 8328481 8332236 8332890 |
| 26 | + * @bug 8328481 8332236 8332890 8344647 |
27 | 27 | * @summary Check behavior of module imports.
|
28 | 28 | * @library /tools/lib
|
29 | 29 | * @modules java.logging
|
|
33 | 33 | * jdk.compiler/com.sun.tools.javac.util
|
34 | 34 | * @build toolbox.ToolBox toolbox.JavacTask
|
35 | 35 | * @run main ImportModule
|
36 |
| -*/ |
| 36 | + */ |
37 | 37 |
|
38 | 38 | import com.sun.source.tree.Tree;
|
39 | 39 | import com.sun.source.util.TaskEvent;
|
@@ -829,6 +829,7 @@ public class Test {
|
829 | 829 | }
|
830 | 830 | }
|
831 | 831 |
|
| 832 | + @Test |
832 | 833 | public void testPackageImportDisambiguates(Path base) throws Exception {
|
833 | 834 | Path current = base.resolve(".");
|
834 | 835 | Path src = current.resolve("src");
|
@@ -919,4 +920,50 @@ public class Test {
|
919 | 920 | .run(Task.Expect.SUCCESS)
|
920 | 921 | .writeAll();
|
921 | 922 | }
|
| 923 | + |
| 924 | + @Test //JDK-8344647 |
| 925 | + public void testJavaBaseOverride(Path base) throws Exception { |
| 926 | + Path current = base.resolve("."); |
| 927 | + Path src = current.resolve("src"); |
| 928 | + Path javaBaseClasses = current.resolve("javaBaseClasses"); |
| 929 | + Path javaBase = src.resolve("java.base"); |
| 930 | + tb.writeJavaFiles(javaBase, |
| 931 | + """ |
| 932 | + module java.base { |
| 933 | + exports java.lang; |
| 934 | + } |
| 935 | + """, |
| 936 | + """ |
| 937 | + package java.lang; |
| 938 | + public class Object {} |
| 939 | + """); |
| 940 | + |
| 941 | + Files.createDirectories(javaBaseClasses); |
| 942 | + |
| 943 | + new JavacTask(tb) |
| 944 | + .options("--patch-module", "java.base=" + src.toString()) |
| 945 | + .outdir(javaBaseClasses) |
| 946 | + .files(tb.findJavaFiles(src)) |
| 947 | + .run(Task.Expect.SUCCESS) |
| 948 | + .writeAll() |
| 949 | + .getOutputLines(Task.OutputKind.DIRECT); |
| 950 | + |
| 951 | + Path test = current.resolve("test"); |
| 952 | + tb.writeJavaFiles(test, |
| 953 | + """ |
| 954 | + module test { |
| 955 | + requires java.se; |
| 956 | + } |
| 957 | + """); |
| 958 | + |
| 959 | + Path classes = current.resolve("classes"); |
| 960 | + Files.createDirectories(classes); |
| 961 | + |
| 962 | + new JavacTask(tb) |
| 963 | + .options("--patch-module", "java.base=" + javaBaseClasses.toString()) |
| 964 | + .outdir(classes) |
| 965 | + .files(tb.findJavaFiles(test)) |
| 966 | + .run(Task.Expect.SUCCESS) |
| 967 | + .writeAll(); |
| 968 | + } |
922 | 969 | }
|
0 commit comments