# HG changeset patch # User jjg # Date 1486770137 28800 # Node ID 25ddac537bb554305515ae13d7aa6d09cab87970 # Parent a321bed020009b88f455d8918859c192acb8b110 8174104: Compiler does not allow non-existent module path entry Reviewed-by: jlahoda diff -r a321bed02000 -r 25ddac537bb5 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Fri Feb 10 13:49:42 2017 -0800 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Fri Feb 10 15:42:17 2017 -0800 @@ -985,6 +985,11 @@ } private void checkValidModulePathEntry(Path p) { + if (!Files.exists(p)) { + // warning may be generated later + return; + } + if (Files.isDirectory(p)) { // either an exploded module or a directory of modules return; diff -r a321bed02000 -r 25ddac537bb5 langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java --- a/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java Fri Feb 10 13:49:42 2017 -0800 +++ b/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java Fri Feb 10 15:42:17 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ // key: compiler.err.illegal.argument.for.option -// options: --module-path doesNotExist +// options: --module-source-path=abc*def // run: simple class X {} diff -r a321bed02000 -r 25ddac537bb5 langtools/test/tools/javac/modules/ModulePathTest.java --- a/langtools/test/tools/javac/modules/ModulePathTest.java Fri Feb 10 13:49:42 2017 -0800 +++ b/langtools/test/tools/javac/modules/ModulePathTest.java Fri Feb 10 15:42:17 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test + * @bug 8142968 8174104 * @summary tests for --module-path * @library /tools/lib * @modules @@ -57,7 +58,7 @@ } @Test - public void testNotExistsOnPath(Path base) throws Exception { + public void testNotExistsOnPath_noWarn(Path base) throws Exception { Path src = base.resolve("src"); tb.writeJavaFiles(src, "class C { }"); @@ -65,11 +66,29 @@ .options("-XDrawDiagnostics", "--module-path", "doesNotExist") .files(findJavaFiles(src)) - .run(Task.Expect.FAIL) + .run(Task.Expect.SUCCESS) .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, doesNotExist")) + if (!log.isEmpty()) + throw new Exception("unexpected output"); + } + + @Test + public void testNotExistsOnPath_warn(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, "class C { }"); + + String log = new JavacTask(tb, Task.Mode.CMDLINE) + .options("-XDrawDiagnostics", + "-Xlint:path", + "--module-path", "doesNotExist") + .files(findJavaFiles(src)) + .run(Task.Expect.SUCCESS) + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + + if (!log.contains("- compiler.warn.path.element.not.found: doesNotExist")) throw new Exception("expected output not found"); }