changeset 3802:586c93260d3b jdk-9+148

8139101: javadoc emits "specified by" clause when class has a method that matches a static interface method Reviewed-by: jjg, ksrini
author bpatel
date Mon, 05 Dec 2016 15:08:24 -0800
parents 8fc0a7bf47a9
children ab97dcc875ac 0bdb7cb95c68
files src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java test/jdk/javadoc/doclet/testInterface/TestInterface.java test/jdk/javadoc/doclet/testInterface/pkg/ClassWithStaticMethod.java test/jdk/javadoc/doclet/testInterface/pkg/InterfaceWithStaticMethod.java
diffstat 4 files changed, 71 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Mon Dec 05 19:00:56 2016 +0000
+++ b/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/test/jdk/javadoc/doclet/testInterface/TestInterface.java	Mon Dec 05 19:00:56 2016 +0000
+++ b/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/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/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() { }
+}