8020278: NPE in javadoc
authorjjg
Fri, 12 Jul 2013 13:11:12 -0700
changeset 18908 f76cab33bee3
parent 18907 7b19e121cdea
child 18909 8f9fc5d876e4
8020278: NPE in javadoc Reviewed-by: mcimadamore, vromero
langtools/src/share/classes/com/sun/tools/doclint/DocLint.java
langtools/src/share/classes/com/sun/tools/doclint/Env.java
langtools/test/tools/doclint/BadPackageCommentTest.java
langtools/test/tools/doclint/BadPackageCommentTest.out
--- a/langtools/src/share/classes/com/sun/tools/doclint/DocLint.java	Thu Jul 11 15:37:02 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/doclint/DocLint.java	Fri Jul 12 13:11:12 2013 -0700
@@ -328,6 +328,14 @@
         abstract void visitDecl(Tree tree, Name name);
 
         @Override
+        public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) {
+            if (tree.getPackageName() != null) {
+                visitDecl(tree, null);
+            }
+            return super.visitCompilationUnit(tree, ignore);
+        }
+
+        @Override
         public Void visitClass(ClassTree tree, Void ignore) {
             visitDecl(tree, tree.getSimpleName());
             return super.visitClass(tree, ignore);
--- a/langtools/src/share/classes/com/sun/tools/doclint/Env.java	Thu Jul 11 15:37:02 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/doclint/Env.java	Fri Jul 12 13:11:12 2013 -0700
@@ -142,7 +142,7 @@
         currElement = trees.getElement(currPath);
         currOverriddenMethods = ((JavacTypes) types).getOverriddenMethods(currElement);
 
-        AccessKind ak = null;
+        AccessKind ak = AccessKind.PUBLIC;
         for (TreePath p = path; p != null; p = p.getParentPath()) {
             Element e = trees.getElement(p);
             if (e != null && e.getKind() != ElementKind.PACKAGE) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/BadPackageCommentTest.java	Fri Jul 12 13:11:12 2013 -0700
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8020278
+ * @summary NPE in javadoc (bad handling of bad tag in package-info.java)
+ * @build DocLintTester
+ * @run main DocLintTester -ref BadPackageCommentTest.out BadPackageCommentTest.java
+ */
+
+/**
+ * abc.
+ * @@@
+ */
+package p;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/BadPackageCommentTest.out	Fri Jul 12 13:11:12 2013 -0700
@@ -0,0 +1,10 @@
+BadPackageCommentTest.java:11: error: no tag name after @
+ * @@@
+   ^
+BadPackageCommentTest.java:11: error: no tag name after @
+ * @@@
+    ^
+BadPackageCommentTest.java:11: error: no tag name after @
+ * @@@
+     ^
+3 errors