8139101: javadoc emits "specified by" clause when class has a method that matches a static interface method
authorbpatel
Mon, 05 Dec 2016 15:08:24 -0800
changeset 42417 8e1573096052
parent 42416 1cfad0990b99
child 42418 4330273ee80c
8139101: javadoc emits "specified by" clause when class has a method that matches a static interface method Reviewed-by: jjg, ksrini
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java
langtools/test/jdk/javadoc/doclet/testInterface/TestInterface.java
langtools/test/jdk/javadoc/doclet/testInterface/pkg/ClassWithStaticMethod.java
langtools/test/jdk/javadoc/doclet/testInterface/pkg/InterfaceWithStaticMethod.java
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Mon Dec 05 19:00:56 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Mon Dec 05 15:08:24 2016 -0800
@@ -364,10 +364,10 @@
      */
     protected static void addImplementsInfo(HtmlDocletWriter writer,
             ExecutableElement method, Content dl) {
-        if (writer.configuration.nocomment) {
+        Utils utils = writer.utils;
+        if (utils.isStatic(method) || writer.configuration.nocomment) {
             return;
         }
-        Utils utils = writer.utils;
         Contents contents = writer.contents;
         ImplementedMethods implementedMethodsFinder =
                 new ImplementedMethods(method, writer.configuration);
--- a/langtools/test/jdk/javadoc/doclet/testInterface/TestInterface.java	Mon Dec 05 19:00:56 2016 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testInterface/TestInterface.java	Mon Dec 05 15:08:24 2016 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4682448 4947464 5029946 8025633 8026567 8035473
+ * @bug      4682448 4947464 5029946 8025633 8026567 8035473 8139101
  * @summary  Verify that the public modifier does not show up in the
  *           documentation for public methods, as recommended by the JLS.
  *           If A implements I and B extends A, B should be in the list of
@@ -121,6 +121,11 @@
         checkOutput("pkg/Interface.html", false,
                 "public int method()",
                 "public static final int field");
+
+        checkOutput("pkg/ClassWithStaticMethod.html", false,
+                //Make sure "Specified By" does not appear on class documentation when
+                //the method is a static method in the interface.
+                "<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n");
     }
 
     @Test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testInterface/pkg/ClassWithStaticMethod.java	Mon Dec 05 15:08:24 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+public class ClassWithStaticMethod implements InterfaceWithStaticMethod {
+
+    public static void staticMethod() {
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testInterface/pkg/InterfaceWithStaticMethod.java	Mon Dec 05 15:08:24 2016 -0800
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+public interface InterfaceWithStaticMethod {
+
+    /**
+     * A static method
+     */
+    static void staticMethod() { }
+}