8158224: NullPointerException in com.sun.tools.javac.comp.Modules.checkCyclicDependencies when module missing

Reviewed-by: jlahoda
This commit is contained in:
Srikanth Adayapalam 2016-07-28 10:13:34 +05:30
parent 00275bd95e
commit 90a4b8ab1a
5 changed files with 84 additions and 3 deletions

View file

@ -757,7 +757,9 @@ public class Modules extends JCTree.Visitor {
@Override
public void visitRequires(JCRequires tree) {
msym.directives = msym.directives.prepend(tree.directive);
if (tree.directive != null) {
msym.directives = msym.directives.prepend(tree.directive);
}
}
@Override
@ -1214,9 +1216,9 @@ public class Modules extends JCTree.Visitor {
private void checkCyclicDependencies(JCModuleDecl mod) {
for (JCDirective d : mod.directives) {
if (!d.hasTag(Tag.REQUIRES))
JCRequires rd;
if (!d.hasTag(Tag.REQUIRES) || (rd = (JCRequires) d).directive == null)
continue;
JCRequires rd = (JCRequires) d;
Set<ModuleSymbol> nonSyntheticDeps = new HashSet<>();
List<ModuleSymbol> queue = List.of(rd.directive.module);
while (queue.nonEmpty()) {

View 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;
}
}

View 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.

View file

@ -0,0 +1,2 @@
module-info.java:4:14: compiler.err.module.not.found: nonexistent
1 error

View file

@ -0,0 +1,5 @@
/* /nodynamiccopyright/ */
module foo {
requires nonexistent;
}