OpenJDK / portola / portola
changeset 54011:05d35241e1e9
8217868: Crash for overlap between source path and patch module path
Summary: When analyzing implicit files, do not look for containing module, but rather use the already known one.
Reviewed-by: jjg
author | jlahoda |
---|---|
date | Mon, 04 Mar 2019 10:19:35 +0100 |
parents | d489081c5650 |
children | 7935353a466a |
files | src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java test/langtools/tools/javac/modules/PatchModulesTest.java |
diffstat | 3 files changed, 30 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java Sat Mar 02 18:09:18 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java Mon Mar 04 10:19:35 2019 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2019, 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 @@ -504,12 +504,8 @@ module.completer = sym -> completeModule((ModuleSymbol) sym); } else { Assert.check(rootModules.isEmpty()); - String moduleOverride = singleModuleOverride(trees); - if (moduleOverride != null) { - module = moduleFinder.findModule(names.fromString(moduleOverride)); - } else { - module = defaultModule; - } + Assert.checkNonNull(c); + module = c.packge().modle; rootModules.add(module); } @@ -1796,6 +1792,7 @@ public void newRound() { allModules = null; rootModules = null; + defaultModule = null; warnedMissing.clear(); }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java Sat Mar 02 18:09:18 2019 -0500 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java Mon Mar 04 10:19:35 2019 +0100 @@ -197,9 +197,11 @@ } // Parse the files in the packages and subpackages to be documented - ListBuffer<JCCompilationUnit> packageTrees = new ListBuffer<>(); - parse(etable.getFilesToParse(), packageTrees, false); - modules.enter(packageTrees.toList(), null); + ListBuffer<JCCompilationUnit> allTrees = new ListBuffer<>(); + allTrees.addAll(classTrees); + parse(etable.getFilesToParse(), allTrees, false); + modules.newRound(); + modules.initModules(allTrees.toList()); if (messager.hasErrors()) { return null; @@ -207,7 +209,7 @@ // Enter symbols for all files toolEnv.notice("main.Building_tree"); - javadocEnter.main(classTrees.toList().appendList(packageTrees)); + javadocEnter.main(allTrees.toList()); if (messager.hasErrors()) { return null;
--- a/test/langtools/tools/javac/modules/PatchModulesTest.java Sat Mar 02 18:09:18 2019 -0500 +++ b/test/langtools/tools/javac/modules/PatchModulesTest.java Mon Mar 04 10:19:35 2019 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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,7 +23,7 @@ /* * @test - * @bug 8160489 + * @bug 8160489 8217868 * @summary tests for --patch-modules * @library /tools/lib * @modules @@ -192,5 +192,23 @@ throw new AssertionError(); } } + + @Test + public void testPatchModuleSourcePathClash(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "module m { uses test.Test; }", + "package test; public class Test { }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + new toolbox.JavacTask(tb) + .options("--patch-module", "other=" + src.toString(), + "-sourcepath", src.toString()) + .outdir(classes) + .files(findJavaFiles(src.resolve("module-info.java"))) + .run() + .writeAll(); + } }