8004893: the javadoc/doclet needs to be updated to accommodate lambda changes

Tue, 25 Dec 2012 17:23:59 -0800

author
bpatel
date
Tue, 25 Dec 2012 17:23:59 -0800
changeset 1468
690c41cdab55
parent 1467
189b26e3818f
child 1469
467e4d9281bc
child 1472
0c244701188e

8004893: the javadoc/doclet needs to be updated to accommodate lambda changes
Reviewed-by: jjg

src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testLambdaFeature/pkg/A.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testLambdaFeature/pkg/B.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Fri Dec 21 15:27:55 2012 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Tue Dec 25 17:23:59 2012 -0800
     1.3 @@ -239,7 +239,14 @@
     1.4          if ((member.isField() || member.isMethod()) &&
     1.5              writer instanceof ClassWriterImpl &&
     1.6              ((ClassWriterImpl) writer).getClassDoc().isInterface()) {
     1.7 -            mod = Util.replaceText(mod, "public", "").trim();
     1.8 +            // This check for isDefault() and the default modifier needs to be
     1.9 +            // added for it to appear on the method details section. Once the
    1.10 +            // default modifier is added to the Modifier list on DocEnv and once
    1.11 +            // it is updated to use the javax.lang.model.element.Modifier, we
    1.12 +            // will need to remove this.
    1.13 +            mod = (member.isMethod() && ((MethodDoc)member).isDefault()) ?
    1.14 +                    Util.replaceText(mod, "public", "default").trim() :
    1.15 +                    Util.replaceText(mod, "public", "").trim();
    1.16          }
    1.17          if(mod.length() > 0) {
    1.18              htmltree.addContent(mod);
    1.19 @@ -313,8 +320,18 @@
    1.20              code.addContent(configuration.getText("doclet.Package_private"));
    1.21              code.addContent(" ");
    1.22          }
    1.23 -        if (member.isMethod() && ((MethodDoc)member).isAbstract()) {
    1.24 -            code.addContent("abstract ");
    1.25 +        if (member.isMethod()) {
    1.26 +            if (((MethodDoc)member).isAbstract()) {
    1.27 +                code.addContent("abstract ");
    1.28 +            }
    1.29 +            // This check for isDefault() and the default modifier needs to be
    1.30 +            // added for it to appear on the "Modifier and Type" column in the
    1.31 +            // method summary section. Once the default modifier is added
    1.32 +            // to the Modifier list on DocEnv and once it is updated to use the
    1.33 +            // javax.lang.model.element.Modifier, we will need to remove this.
    1.34 +            else if (((MethodDoc)member).isDefault()) {
    1.35 +                code.addContent("default ");
    1.36 +            }
    1.37          }
    1.38          if (member.isStatic()) {
    1.39              code.addContent("static ");
    1.40 @@ -547,6 +564,9 @@
    1.41              methodType = (classdoc.isInterface() || ((MethodDoc)member).isAbstract()) ?
    1.42                      methodType | MethodTypes.ABSTRACT.value() :
    1.43                      methodType | MethodTypes.CONCRETE.value();
    1.44 +            if (((MethodDoc)member).isDefault()) {
    1.45 +                methodType = methodType | MethodTypes.DEFAULT.value();
    1.46 +            }
    1.47              if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) {
    1.48                  methodType = methodType | MethodTypes.DEPRECATED.value();
    1.49              }
     2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java	Fri Dec 21 15:27:55 2012 +0000
     2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java	Tue Dec 25 17:23:59 2012 -0800
     2.3 @@ -516,6 +516,20 @@
     2.4      /**
     2.5       * {@inheritDoc}
     2.6       */
     2.7 +    public void addFunctionalInterfaceInfo (Content classInfoTree) {
     2.8 +        if (classDoc.isFunctionalInterface()) {
     2.9 +            Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
    2.10 +            Content dl = HtmlTree.DL(dt);
    2.11 +            Content dd = new HtmlTree(HtmlTag.DD);
    2.12 +            dd.addContent(getResource("doclet.Functional_Interface_Message"));
    2.13 +            dl.addContent(dd);
    2.14 +            classInfoTree.addContent(dl);
    2.15 +        }
    2.16 +    }
    2.17 +
    2.18 +    /**
    2.19 +     * {@inheritDoc}
    2.20 +     */
    2.21      public void addClassDeprecationInfo(Content classInfoTree) {
    2.22          Content hr = new HtmlTree(HtmlTag.HR);
    2.23          classInfoTree.addContent(hr);
     3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Fri Dec 21 15:27:55 2012 +0000
     3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Tue Dec 25 17:23:59 2012 -0800
     3.3 @@ -90,6 +90,8 @@
     3.4  doclet.Subclasses=Direct Known Subclasses:
     3.5  doclet.Subinterfaces=All Known Subinterfaces:
     3.6  doclet.Implementing_Classes=All Known Implementing Classes:
     3.7 +doclet.Functional_Interface=Functional Interface:
     3.8 +doclet.Functional_Interface_Message=This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference. 
     3.9  doclet.also=also
    3.10  doclet.Frames=Frames
    3.11  doclet.No_Frames=No Frames
     4.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java	Fri Dec 21 15:27:55 2012 +0000
     4.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java	Tue Dec 25 17:23:59 2012 -0800
     4.3 @@ -117,6 +117,13 @@
     4.4      public void addInterfaceUsageInfo(Content classInfoTree);
     4.5  
     4.6      /**
     4.7 +     * If this is an functional interface, display appropriate message.
     4.8 +     *
     4.9 +     * @param classInfoTree content tree to which the documentation will be added
    4.10 +     */
    4.11 +    public void addFunctionalInterfaceInfo(Content classInfoTree);
    4.12 +
    4.13 +    /**
    4.14       * If this is an inner class or interface, add the enclosing class or
    4.15       * interface.
    4.16       *
     5.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java	Fri Dec 21 15:27:55 2012 +0000
     5.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java	Tue Dec 25 17:23:59 2012 -0800
     5.3 @@ -236,6 +236,16 @@
     5.4      }
     5.5  
     5.6      /**
     5.7 +     * If this is an functional interface, display appropriate message.
     5.8 +     *
     5.9 +     * @param node the XML element that specifies which components to document
    5.10 +     * @param classInfoTree the content tree to which the documentation will be added
    5.11 +     */
    5.12 +    public void buildFunctionalInterfaceInfo(XMLNode node, Content classInfoTree) {
    5.13 +        writer.addFunctionalInterfaceInfo(classInfoTree);
    5.14 +    }
    5.15 +
    5.16 +    /**
    5.17       * If this class is deprecated, build the appropriate information.
    5.18       *
    5.19       * @param node the XML element that specifies which components to document
     6.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml	Fri Dec 21 15:27:55 2012 +0000
     6.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml	Tue Dec 25 17:23:59 2012 -0800
     6.3 @@ -85,6 +85,7 @@
     6.4              <SubInterfacesInfo/>
     6.5              <InterfaceUsageInfo/>
     6.6              <NestedClassInfo/>
     6.7 +            <FunctionalInterfaceInfo/>
     6.8              <DeprecationInfo/>
     6.9              <ClassSignature/>
    6.10              <ClassDescription/>
     7.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java	Fri Dec 21 15:27:55 2012 +0000
     7.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java	Tue Dec 25 17:23:59 2012 -0800
     7.3 @@ -36,7 +36,8 @@
     7.4      INSTANCE(0x2, "Instance Methods", "t2", false),
     7.5      ABSTRACT(0x4, "Abstract Methods", "t3", false),
     7.6      CONCRETE(0x8, "Concrete Methods", "t4", false),
     7.7 -    DEPRECATED(0x10, "Deprecated Methods", "t5", false);
     7.8 +    DEFAULT(0x10, "Default Methods", "t5", false),
     7.9 +    DEPRECATED(0x20, "Deprecated Methods", "t6", false);
    7.10  
    7.11      private final int value;
    7.12      private final String text;
     8.1 --- a/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java	Fri Dec 21 15:27:55 2012 +0000
     8.2 +++ b/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java	Tue Dec 25 17:23:59 2012 -0800
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -207,7 +207,7 @@
    8.11              "Instance Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
    8.12              "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
    8.13              "Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
    8.14 -            "<span id=\"t5\" class=\"tableTab\"><span><a href=\"javascript:show(16);\">" +
    8.15 +            "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">" +
    8.16              "Deprecated Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
    8.17              "</caption>"
    8.18          },
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java	Tue Dec 25 17:23:59 2012 -0800
     9.3 @@ -0,0 +1,102 @@
     9.4 +/*
     9.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 + *
     9.8 + * This code is free software; you can redistribute it and/or modify it
     9.9 + * under the terms of the GNU General Public License version 2 only, as
    9.10 + * published by the Free Software Foundation.
    9.11 + *
    9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    9.15 + * version 2 for more details (a copy is included in the LICENSE file that
    9.16 + * accompanied this code).
    9.17 + *
    9.18 + * You should have received a copy of the GNU General Public License version
    9.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    9.21 + *
    9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    9.23 + * or visit www.oracle.com if you need additional information or have any
    9.24 + * questions.
    9.25 + */
    9.26 +
    9.27 +/*
    9.28 + * @test
    9.29 + * @bug      8004893
    9.30 + * @summary  Make sure that the lambda feature changes work fine in
    9.31 + *           javadoc.
    9.32 + * @author   bpatel
    9.33 + * @library  ../lib/
    9.34 + * @build    JavadocTester TestLambdaFeature
    9.35 + * @run main TestLambdaFeature
    9.36 + */
    9.37 +
    9.38 +public class TestLambdaFeature extends JavadocTester {
    9.39 +
    9.40 +    //Test information.
    9.41 +    private static final String BUG_ID = "8004893";
    9.42 +
    9.43 +    //Javadoc arguments.
    9.44 +    private static final String[] ARGS = new String[] {
    9.45 +        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
    9.46 +    };
    9.47 +
    9.48 +    //Input for string search tests.
    9.49 +    private static final String[][] TEST = {
    9.50 +        {BUG_ID + FS + "pkg" + FS + "A.html",
    9.51 +            "<td class=\"colFirst\"><code>default void</code></td>"},
    9.52 +        {BUG_ID + FS + "pkg" + FS + "A.html",
    9.53 +            "<pre>default&nbsp;void&nbsp;defaultMethod()</pre>"},
    9.54 +        {BUG_ID + FS + "pkg" + FS + "A.html",
    9.55 +            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
    9.56 +            "All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
    9.57 +            "<span id=\"t2\" class=\"tableTab\"><span>" +
    9.58 +            "<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
    9.59 +            "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" " +
    9.60 +            "class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
    9.61 +            "Abstract Methods</a></span><span class=\"tabEnd\">&nbsp;</span>" +
    9.62 +            "</span><span id=\"t5\" class=\"tableTab\"><span>" +
    9.63 +            "<a href=\"javascript:show(16);\">Default Methods</a></span>" +
    9.64 +            "<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
    9.65 +        {BUG_ID + FS + "pkg" + FS + "A.html",
    9.66 +            "<dl>" + NL + "<dt>Functional Interface:</dt>" + NL +
    9.67 +            "<dd>This is a functional interface and can therefore be used as " +
    9.68 +            "the assignment target for a lambda expression or method " +
    9.69 +            "reference. </dd>" + NL + "</dl>"}
    9.70 +    };
    9.71 +    private static final String[][] NEGATED_TEST = {
    9.72 +        {BUG_ID + FS + "pkg" + FS + "A.html",
    9.73 +            "<td class=\"colFirst\"><code>default default void</code></td>"},
    9.74 +        {BUG_ID + FS + "pkg" + FS + "A.html",
    9.75 +            "<pre>default&nbsp;default&nbsp;void&nbsp;defaultMethod()</pre>"},
    9.76 +        {BUG_ID + FS + "pkg" + FS + "B.html",
    9.77 +            "<td class=\"colFirst\"><code>default void</code></td>"},
    9.78 +        {BUG_ID + FS + "pkg" + FS + "B.html",
    9.79 +            "<dl>" + NL + "<dt>Functional Interface:</dt>"}
    9.80 +    };
    9.81 +
    9.82 +    /**
    9.83 +     * The entry point of the test.
    9.84 +     * @param args the array of command line arguments.
    9.85 +     */
    9.86 +    public static void main(String[] args) {
    9.87 +        TestLambdaFeature tester = new TestLambdaFeature();
    9.88 +        run(tester, ARGS, TEST, NEGATED_TEST);
    9.89 +        tester.printSummary();
    9.90 +    }
    9.91 +
    9.92 +    /**
    9.93 +     * {@inheritDoc}
    9.94 +     */
    9.95 +    public String getBugId() {
    9.96 +        return BUG_ID;
    9.97 +    }
    9.98 +
    9.99 +    /**
   9.100 +     * {@inheritDoc}
   9.101 +     */
   9.102 +    public String getBugName() {
   9.103 +        return getClass().getName();
   9.104 +    }
   9.105 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/com/sun/javadoc/testLambdaFeature/pkg/A.java	Tue Dec 25 17:23:59 2012 -0800
    10.3 @@ -0,0 +1,31 @@
    10.4 +/*
    10.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 + *
    10.8 + * This code is free software; you can redistribute it and/or modify it
    10.9 + * under the terms of the GNU General Public License version 2 only, as
   10.10 + * published by the Free Software Foundation.
   10.11 + *
   10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.15 + * version 2 for more details (a copy is included in the LICENSE file that
   10.16 + * accompanied this code).
   10.17 + *
   10.18 + * You should have received a copy of the GNU General Public License version
   10.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.21 + *
   10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   10.23 + * or visit www.oracle.com if you need additional information or have any
   10.24 + * questions.
   10.25 + */
   10.26 +
   10.27 +package pkg;
   10.28 +
   10.29 +public interface A {
   10.30 +
   10.31 +    public void method1();
   10.32 +
   10.33 +    public default void defaultMethod() { }
   10.34 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/com/sun/javadoc/testLambdaFeature/pkg/B.java	Tue Dec 25 17:23:59 2012 -0800
    11.3 @@ -0,0 +1,31 @@
    11.4 +/*
    11.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 + *
    11.8 + * This code is free software; you can redistribute it and/or modify it
    11.9 + * under the terms of the GNU General Public License version 2 only, as
   11.10 + * published by the Free Software Foundation.
   11.11 + *
   11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 + * version 2 for more details (a copy is included in the LICENSE file that
   11.16 + * accompanied this code).
   11.17 + *
   11.18 + * You should have received a copy of the GNU General Public License version
   11.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 + *
   11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 + * or visit www.oracle.com if you need additional information or have any
   11.24 + * questions.
   11.25 + */
   11.26 +
   11.27 +package pkg;
   11.28 +
   11.29 +public abstract class B {
   11.30 +
   11.31 +    public abstract void method1();
   11.32 +
   11.33 +    public void method2() { }
   11.34 +}
    12.1 --- a/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java	Fri Dec 21 15:27:55 2012 +0000
    12.2 +++ b/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java	Tue Dec 25 17:23:59 2012 -0800
    12.3 @@ -55,7 +55,7 @@
    12.4              "Instance Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
    12.5              "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
    12.6              "Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
    12.7 -            "<span id=\"t5\" class=\"tableTab\"><span><a href=\"javascript:show(16);\">" +
    12.8 +            "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">" +
    12.9              "Deprecated Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
   12.10              "</caption>"
   12.11          },
   12.12 @@ -87,7 +87,7 @@
   12.13              "Abstract Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
   12.14              "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
   12.15              "Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
   12.16 -            "<span id=\"t5\" class=\"tableTab\"><span><a href=\"javascript:show(16);\">" +
   12.17 +            "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">" +
   12.18              "Deprecated Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
   12.19              "</caption>"
   12.20          },

mercurial