changeset 3696:fe8352e43bdb

8167320: Trying to document only java.base causes a NPE in javac Summary: Ensure ModuleSymbol.getDirectives completes the Symbol Reviewed-by: ksrini, jjg
author jlahoda
date Tue, 11 Oct 2016 10:31:10 +0200
parents a7bd119da966
children 5adb61e143dc
files src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java test/tools/javac/modules/EdgeCases.java
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Oct 11 09:50:44 2016 +0200
+++ b/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/test/tools/javac/modules/EdgeCases.java	Tue Oct 11 09:50:44 2016 +0200
+++ b/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();
+    }
 }