8193671: Default Methods tab under Method Summary includes static methods
authorksrini
Thu, 04 Jan 2018 13:32:10 -0800
changeset 48442 3b00541635f9
parent 48441 9c37fbceb579
child 48443 8935285e8759
8193671: Default Methods tab under Method Summary includes static methods Reviewed-by: jjg
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java
test/langtools/jdk/javadoc/doclet/testMethodTypes/TestMethodTypes.java
test/langtools/jdk/javadoc/doclet/testMethodTypes/pkg1/A.java
test/langtools/jdk/javadoc/doclet/testMethodTypes/pkg1/B.java
test/langtools/jdk/javadoc/doclet/testMethodTypes/pkg1/D.java
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Thu Jan 04 12:55:06 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Thu Jan 04 13:32:10 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -264,8 +264,7 @@
                 .addTab(resources.getText("doclet.Abstract_Methods"), utils::isAbstract)
                 .addTab(resources.getText("doclet.Concrete_Methods"),
                         e -> !utils.isAbstract(e) && !utils.isInterface(e.getEnclosingElement()))
-                .addTab(resources.getText("doclet.Default_Methods"),
-                        e -> !utils.isAbstract(e) && utils.isInterface(e.getEnclosingElement()))
+                .addTab(resources.getText("doclet.Default_Methods"), utils::isDefault)
                 .addTab(resources.getText("doclet.Deprecated_Methods"),
                         e -> utils.isDeprecated(e) || utils.isDeprecated(typeElement))
                 .setTabScriptVariable("methods")
--- a/test/langtools/jdk/javadoc/doclet/testMethodTypes/TestMethodTypes.java	Thu Jan 04 12:55:06 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testMethodTypes/TestMethodTypes.java	Thu Jan 04 13:32:10 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -23,8 +23,8 @@
 
 /*
  * @test
- * @bug      8002304 8024096
- * @summary  Test for various method types in the method summary table
+ * @bug      8002304 8024096 8193671
+ * @summary  Test for various method type tabs in the method summary table
  * @author   Bhavesh Patel
  * @library  ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -62,13 +62,18 @@
                 "<tr id=\"i0\" class=\"altColor\">");
 
         checkOutput("pkg1/B.html", true,
-                "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All "
-                + "Methods</span><span class=\"tabEnd\">&nbsp;</span></span>"
-                + "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">"
-                + "Instance Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
-                + "<span id=\"t3\" class=\"tableTab\"><span><a href=\"javascript:show(4);\">"
-                + "Abstract Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
-                + "</caption>");
+                "var methods = {\"i0\":6,\"i1\":18,\"i2\":18,\"i3\":1,\"i4\":1,"
+                + "\"i5\":6,\"i6\":6,\"i7\":6,\"i8\":6};\n",
+                "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Methods</span>"
+                + "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t1\" class=\"tableTab\">"
+                + "<span><a href=\"javascript:show(1);\">Static Methods</a></span>"
+                + "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t2\" class=\"tableTab\">"
+                + "<span><a href=\"javascript:show(2);\">Instance Methods</a></span>"
+                + "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" class=\"tableTab\">"
+                + "<span><a href=\"javascript:show(4);\">Abstract Methods</a></span>"
+                + "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t5\" class=\"tableTab\">"
+                + "<span><a href=\"javascript:show(16);\">Default Methods</a></span>"
+                + "<span class=\"tabEnd\">&nbsp;</span></span></caption>\n");
 
         checkOutput("pkg1/D.html", true,
                 "var methods = {",
--- a/test/langtools/jdk/javadoc/doclet/testMethodTypes/pkg1/A.java	Thu Jan 04 12:55:06 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testMethodTypes/pkg1/A.java	Thu Jan 04 13:32:10 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -44,6 +44,7 @@
 
     /**
      * This is the third concrete instance method.
+     * @return a string
      */
     public String getParameter() {
          return "test";
--- a/test/langtools/jdk/javadoc/doclet/testMethodTypes/pkg1/B.java	Thu Jan 04 12:55:06 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testMethodTypes/pkg1/B.java	Thu Jan 04 13:32:10 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -24,8 +24,8 @@
 package pkg1;
 
 /**
- * This interface has different types of methods such as "Instance Methods" and
- * "Abstract Methods". All the tabs will display same list of methods.
+ * This interface has different types of methods such as "Static Methods",
+ * "Instance Methods", "Abstract Methods", "Default Methods".
  */
 public interface B {
 
@@ -36,21 +36,45 @@
 
     /**
      * This is the second abstract instance method.
+     * @return a string
      */
     public String getName();
 
     /**
      * This is the third abstract instance method.
+     * @return a boolean value
      */
     public boolean addEntry();
 
     /**
      * This is the fourth abstract instance method.
+     * @return a boolean value
      */
     public boolean removeEntry();
 
     /**
      * This is the fifth abstract instance method.
+     * @return a string
      */
     public String getPermissions();
+
+    /**
+     * A static interface method.
+     */
+    public static void aStaticMethod() {}
+
+    /**
+     * Another static interface method.
+     */
+    public static void anotherStaticMethod() {}
+
+    /**
+     * A default method.
+     */
+    public default void aDefaultMethod() {}
+
+    /**
+     * Another default method.
+     */
+    public default void anotherDefaultMethod() {}
 }
--- a/test/langtools/jdk/javadoc/doclet/testMethodTypes/pkg1/D.java	Thu Jan 04 12:55:06 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testMethodTypes/pkg1/D.java	Thu Jan 04 13:32:10 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -46,6 +46,7 @@
 
     /**
      * This is the second concrete instance method.
+     * @return a string
      */
     public String getParameter() {
          return "test";