mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 18:44:38 +02:00
8158224: NullPointerException in com.sun.tools.javac.comp.Modules.checkCyclicDependencies when module missing
Reviewed-by: jlahoda
This commit is contained in:
parent
00275bd95e
commit
90a4b8ab1a
5 changed files with 84 additions and 3 deletions
|
@ -757,7 +757,9 @@ public class Modules extends JCTree.Visitor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitRequires(JCRequires tree) {
|
public void visitRequires(JCRequires tree) {
|
||||||
msym.directives = msym.directives.prepend(tree.directive);
|
if (tree.directive != null) {
|
||||||
|
msym.directives = msym.directives.prepend(tree.directive);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1214,9 +1216,9 @@ public class Modules extends JCTree.Visitor {
|
||||||
|
|
||||||
private void checkCyclicDependencies(JCModuleDecl mod) {
|
private void checkCyclicDependencies(JCModuleDecl mod) {
|
||||||
for (JCDirective d : mod.directives) {
|
for (JCDirective d : mod.directives) {
|
||||||
if (!d.hasTag(Tag.REQUIRES))
|
JCRequires rd;
|
||||||
|
if (!d.hasTag(Tag.REQUIRES) || (rd = (JCRequires) d).directive == null)
|
||||||
continue;
|
continue;
|
||||||
JCRequires rd = (JCRequires) d;
|
|
||||||
Set<ModuleSymbol> nonSyntheticDeps = new HashSet<>();
|
Set<ModuleSymbol> nonSyntheticDeps = new HashSet<>();
|
||||||
List<ModuleSymbol> queue = List.of(rd.directive.module);
|
List<ModuleSymbol> queue = List.of(rd.directive.module);
|
||||||
while (queue.nonEmpty()) {
|
while (queue.nonEmpty()) {
|
||||||
|
|
40
langtools/test/tools/javac/modules/T8158224/Processor.java
Normal file
40
langtools/test/tools/javac/modules/T8158224/Processor.java
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.annotation.processing.AbstractProcessor;
|
||||||
|
import javax.annotation.processing.RoundEnvironment;
|
||||||
|
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||||
|
import javax.annotation.processing.SupportedSourceVersion;
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
|
||||||
|
@SupportedAnnotationTypes("Blah")
|
||||||
|
@SupportedSourceVersion(SourceVersion.RELEASE_6)
|
||||||
|
public class Processor extends AbstractProcessor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean process(Set<? extends TypeElement> tE, RoundEnvironment env) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
32
langtools/test/tools/javac/modules/T8158224/T8158224.java
Normal file
32
langtools/test/tools/javac/modules/T8158224/T8158224.java
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8158224
|
||||||
|
* @summary NullPointerException in com.sun.tools.javac.comp.Modules.checkCyclicDependencies when module missing
|
||||||
|
* @build Processor
|
||||||
|
* @compile/fail/ref=T8158224.out -XDrawDiagnostics -processor Processor mods/foo/module-info.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No code here, this file is just to host test description.
|
2
langtools/test/tools/javac/modules/T8158224/T8158224.out
Normal file
2
langtools/test/tools/javac/modules/T8158224/T8158224.out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
module-info.java:4:14: compiler.err.module.not.found: nonexistent
|
||||||
|
1 error
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* /nodynamiccopyright/ */
|
||||||
|
|
||||||
|
module foo {
|
||||||
|
requires nonexistent;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue