# HG changeset patch # User jlahoda # Date 1523517814 -7200 # Node ID fce4252d52276ba041476e6277b1e47848a21cda # Parent 0c3e252cea44f06aef570ef464950ab97c669970 8189765: Improve error reporting for compiling against package not visible due to modules Summary: When looking in other modules for an undefined Symbol, also look into the unnamed module. Reviewed-by: mcimadamore diff -r 0c3e252cea44 -r fce4252d5227 src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Apr 12 10:19:31 2018 +0800 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Apr 12 09:23:34 2018 +0200 @@ -2120,6 +2120,7 @@ Set recoverableModules = new HashSet<>(syms.getAllModules()); + recoverableModules.add(syms.unnamedModule); recoverableModules.remove(env.toplevel.modle); for (ModuleSymbol ms : recoverableModules) { diff -r 0c3e252cea44 -r fce4252d5227 test/langtools/tools/javac/modules/CompileModulePatchTest.java --- a/test/langtools/tools/javac/modules/CompileModulePatchTest.java Thu Apr 12 10:19:31 2018 +0800 +++ b/test/langtools/tools/javac/modules/CompileModulePatchTest.java Thu Apr 12 09:23:34 2018 +0200 @@ -252,7 +252,7 @@ .getOutputLines(Task.OutputKind.DIRECT); List expectedOut = Arrays.asList( - "Extra.java:1:76: compiler.err.doesnt.exist: p", + "Extra.java:1:75: compiler.err.package.not.visible: p, (compiler.misc.not.def.access.does.not.read.unnamed: p, java.compiler)", "1 error" ); diff -r 0c3e252cea44 -r fce4252d5227 test/langtools/tools/javac/modules/ConvenientAccessErrorsTest.java --- a/test/langtools/tools/javac/modules/ConvenientAccessErrorsTest.java Thu Apr 12 10:19:31 2018 +0800 +++ b/test/langtools/tools/javac/modules/ConvenientAccessErrorsTest.java Thu Apr 12 09:23:34 2018 +0200 @@ -23,7 +23,7 @@ /* * @test - * @bug 8169197 8172668 8173117 8175007 + * @bug 8169197 8172668 8173117 8175007 8189765 * @summary Check convenient errors are produced for inaccessible classes. * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api @@ -199,7 +199,7 @@ throw new Exception("expected output not found; actual: " + log); } -// @Test + @Test public void testInaccessibleUnnamedModule(Path base) throws Exception { Path jar = prepareTestJar(base, "package api; class Api { public static class Foo {} }"); @@ -224,8 +224,8 @@ .getOutputLines(Task.OutputKind.DIRECT); List expected = Arrays.asList( - "Test.java:1:38: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)", - "Test.java:1:51: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)", + "Test.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)", + "Test.java:1:48: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)", "2 errors"); if (!expected.equals(log)) diff -r 0c3e252cea44 -r fce4252d5227 test/langtools/tools/javac/modules/ModulesAndClassPathTest.java --- a/test/langtools/tools/javac/modules/ModulesAndClassPathTest.java Thu Apr 12 10:19:31 2018 +0800 +++ b/test/langtools/tools/javac/modules/ModulesAndClassPathTest.java Thu Apr 12 09:23:34 2018 +0200 @@ -77,7 +77,7 @@ .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected = Arrays.asList("Impl.java:1:38: compiler.err.doesnt.exist: api", + List expected = Arrays.asList("Impl.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m)", "1 error"); if (!expected.equals(modLog)) { @@ -129,7 +129,7 @@ .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected = Arrays.asList("Impl.java:1:38: compiler.err.doesnt.exist: api", + List expected = Arrays.asList("Impl.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m)", "1 error"); if (!expected.equals(modLog)) { @@ -170,7 +170,7 @@ .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected = Arrays.asList("Impl.java:1:38: compiler.err.doesnt.exist: api", + List expected = Arrays.asList("Impl.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m)", "1 error"); if (!expected.equals(modLog)) {