changeset 3472:fb1ccb29bf7f

8149842: javadoc incorrectly tries to get the documentation for inherited methods. Reviewed-by: jjg
author ksrini
date Wed, 17 Feb 2016 11:19:07 -0800
parents 28bc1393dbdc
children 028ef371113f
files src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/DocEnv.java test/jdk/javadoc/doclet/testIncluded/TestIncluded.java test/jdk/javadoc/doclet/testIncluded/parent/A.java test/jdk/javadoc/doclet/testIncluded/pkg/B.java
diffstat 4 files changed, 126 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/DocEnv.java	Wed Feb 17 19:29:25 2016 +0300
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/DocEnv.java	Wed Feb 17 11:19:07 2016 -0800
@@ -706,21 +706,18 @@
                 }
 
                 @Override @DefinedBy(Api.LANGUAGE_MODEL)
-                public Boolean defaultAction(Element e, Void p) {
-                    if (includedSet.contains(e) || shouldDocument(e)) {
-                        return true;
-                    }
-                    return false;
-                }
-
-                @Override @DefinedBy(Api.LANGUAGE_MODEL)
                 public Boolean visitPackage(PackageElement e, Void p) {
                     return includedSet.contains(e);
                 }
 
                 @Override @DefinedBy(Api.LANGUAGE_MODEL)
                 public Boolean visitUnknown(Element e, Void p) {
-                    throw new AssertionError("got element: " + e);
+                    throw new AssertionError("unknown element: " + e);
+                }
+
+                @Override @DefinedBy(Api.LANGUAGE_MODEL)
+                public Boolean defaultAction(Element e, Void p) {
+                    return visit(e.getEnclosingElement()) && shouldDocument(e);
                 }
             };
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javadoc/doclet/testIncluded/TestIncluded.java	Wed Feb 17 11:19:07 2016 -0800
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug      8149468
+ * @summary  Verify that non included classes are not inspected.
+ * @library  ../lib
+ * @modules  jdk.javadoc/jdk.javadoc.internal.tool
+ * @build    JavadocTester
+ * @run main TestIncluded
+ */
+
+public class TestIncluded extends JavadocTester {
+
+    public static void main(String... args) throws Exception {
+        TestIncluded tester = new TestIncluded();
+        tester.runTests();
+    }
+
+    /*
+     * The arguments specify only "pkg" but "parent" sources are on the path.
+     * The class parent.A utilizes a non existent taglet, that will trigger
+     * an error, if doc comments are inspected.
+     */
+    @Test
+    void test() {
+        javadoc("-d", "out",
+                "-Xdoclint:all",
+                "-sourcepath", testSrc,
+                "pkg");
+        checkExit(Exit.OK);
+        checkFiles(false, "parent/A.html");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javadoc/doclet/testIncluded/parent/A.java	Wed Feb 17 11:19:07 2016 -0800
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package parent;
+public class A {
+    /**
+     * Does nothing. Uses an non existent taglet {@enoexist no errors please}.
+     */
+    public void method(){}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javadoc/doclet/testIncluded/pkg/B.java	Wed Feb 17 11:19:07 2016 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg;
+
+/**
+ * Just a lonesome class.
+ */
+public class B extends parent.A {
+    /**
+     * The main method.
+     * @param args the aaaaargs
+     */
+    public static void main(String... args) {}
+}