8167320: Trying to document only java.base causes a NPE in javac

Ensure ModuleSymbol.getDirectives completes the Symbol

Reviewed-by: ksrini, jjg
This commit is contained in:
Jan Lahoda 2016-10-11 10:31:10 +02:00
parent 24a4e49180
commit 5794656914
2 changed files with 11 additions and 1 deletions

View File

@ -949,6 +949,7 @@ public abstract class Symbol extends AnnoConstruct implements Element {
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public java.util.List<Directive> getDirectives() {
complete();
completeUsesProvides();
return Collections.unmodifiableList(directives);
}

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 8154283
* @bug 8154283 8167320
* @summary tests for multi-module mode compilation
* @library /tools/lib
* @modules
@ -54,6 +54,7 @@ import com.sun.source.tree.CompilationUnitTree;
//import com.sun.source.util.JavacTask; // conflicts with toolbox.JavacTask
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.code.Symbol.ModuleSymbol;
import com.sun.tools.javac.code.Symtab;
import toolbox.JarTask;
import toolbox.JavacTask;
@ -449,4 +450,12 @@ public class EdgeCases extends ModuleTestBase {
}
}
@Test
public void testGetDirectivesComplete(Path base) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, null, null, null, null, null);
Symtab syms = Symtab.instance(task.getContext());
syms.java_base.getDirectives();
}
}