8167320: Trying to document only java.base causes a NPE in javac
Summary: Ensure ModuleSymbol.getDirectives completes the Symbol
Reviewed-by: ksrini, jjg
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Tue Oct 11 09:50:44 2016 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Tue Oct 11 10:31:10 2016 +0200
@@ -949,6 +949,7 @@
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public java.util.List<Directive> getDirectives() {
+ complete();
completeUsesProvides();
return Collections.unmodifiableList(directives);
}
--- a/langtools/test/tools/javac/modules/EdgeCases.java Tue Oct 11 09:50:44 2016 +0200
+++ b/langtools/test/tools/javac/modules/EdgeCases.java Tue Oct 11 10:31:10 2016 +0200
@@ -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.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 @@
}
}
+ @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();
+ }
}