changeset 1894:37031963493e

8020278: NPE in javadoc Reviewed-by: mcimadamore, vromero
author jjg
date Fri, 12 Jul 2013 13:11:12 -0700
parents 87a951c88a33
children 44e27378f523
files src/share/classes/com/sun/tools/doclint/DocLint.java src/share/classes/com/sun/tools/doclint/Env.java test/tools/doclint/BadPackageCommentTest.java test/tools/doclint/BadPackageCommentTest.out
diffstat 4 files changed, 32 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/doclint/DocLint.java	Thu Jul 11 15:37:02 2013 +0100
+++ b/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/src/share/classes/com/sun/tools/doclint/Env.java	Thu Jul 11 15:37:02 2013 +0100
+++ b/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/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/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