8004893: the javadoc/doclet needs to be updated to accommodate lambda changes
Reviewed-by: jjg
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java Fri Dec 21 15:27:55 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java Tue Dec 25 17:23:59 2012 -0800
@@ -239,7 +239,14 @@
if ((member.isField() || member.isMethod()) &&
writer instanceof ClassWriterImpl &&
((ClassWriterImpl) writer).getClassDoc().isInterface()) {
- mod = Util.replaceText(mod, "public", "").trim();
+ // This check for isDefault() and the default modifier needs to be
+ // added for it to appear on the method details section. Once the
+ // default modifier is added to the Modifier list on DocEnv and once
+ // it is updated to use the javax.lang.model.element.Modifier, we
+ // will need to remove this.
+ mod = (member.isMethod() && ((MethodDoc)member).isDefault()) ?
+ Util.replaceText(mod, "public", "default").trim() :
+ Util.replaceText(mod, "public", "").trim();
}
if(mod.length() > 0) {
htmltree.addContent(mod);
@@ -313,8 +320,18 @@
code.addContent(configuration.getText("doclet.Package_private"));
code.addContent(" ");
}
- if (member.isMethod() && ((MethodDoc)member).isAbstract()) {
- code.addContent("abstract ");
+ if (member.isMethod()) {
+ if (((MethodDoc)member).isAbstract()) {
+ code.addContent("abstract ");
+ }
+ // This check for isDefault() and the default modifier needs to be
+ // added for it to appear on the "Modifier and Type" column in the
+ // method summary section. Once the default modifier is added
+ // to the Modifier list on DocEnv and once it is updated to use the
+ // javax.lang.model.element.Modifier, we will need to remove this.
+ else if (((MethodDoc)member).isDefault()) {
+ code.addContent("default ");
+ }
}
if (member.isStatic()) {
code.addContent("static ");
@@ -547,6 +564,9 @@
methodType = (classdoc.isInterface() || ((MethodDoc)member).isAbstract()) ?
methodType | MethodTypes.ABSTRACT.value() :
methodType | MethodTypes.CONCRETE.value();
+ if (((MethodDoc)member).isDefault()) {
+ methodType = methodType | MethodTypes.DEFAULT.value();
+ }
if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) {
methodType = methodType | MethodTypes.DEPRECATED.value();
}
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Fri Dec 21 15:27:55 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Tue Dec 25 17:23:59 2012 -0800
@@ -516,6 +516,20 @@
/**
* {@inheritDoc}
*/
+ public void addFunctionalInterfaceInfo (Content classInfoTree) {
+ if (classDoc.isFunctionalInterface()) {
+ Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
+ Content dl = HtmlTree.DL(dt);
+ Content dd = new HtmlTree(HtmlTag.DD);
+ dd.addContent(getResource("doclet.Functional_Interface_Message"));
+ dl.addContent(dd);
+ classInfoTree.addContent(dl);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void addClassDeprecationInfo(Content classInfoTree) {
Content hr = new HtmlTree(HtmlTag.HR);
classInfoTree.addContent(hr);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Fri Dec 21 15:27:55 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Tue Dec 25 17:23:59 2012 -0800
@@ -90,6 +90,8 @@
doclet.Subclasses=Direct Known Subclasses:
doclet.Subinterfaces=All Known Subinterfaces:
doclet.Implementing_Classes=All Known Implementing Classes:
+doclet.Functional_Interface=Functional Interface:
+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.
doclet.also=also
doclet.Frames=Frames
doclet.No_Frames=No Frames
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java Fri Dec 21 15:27:55 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java Tue Dec 25 17:23:59 2012 -0800
@@ -117,6 +117,13 @@
public void addInterfaceUsageInfo(Content classInfoTree);
/**
+ * If this is an functional interface, display appropriate message.
+ *
+ * @param classInfoTree content tree to which the documentation will be added
+ */
+ public void addFunctionalInterfaceInfo(Content classInfoTree);
+
+ /**
* If this is an inner class or interface, add the enclosing class or
* interface.
*
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java Fri Dec 21 15:27:55 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java Tue Dec 25 17:23:59 2012 -0800
@@ -236,6 +236,16 @@
}
/**
+ * If this is an functional interface, display appropriate message.
+ *
+ * @param node the XML element that specifies which components to document
+ * @param classInfoTree the content tree to which the documentation will be added
+ */
+ public void buildFunctionalInterfaceInfo(XMLNode node, Content classInfoTree) {
+ writer.addFunctionalInterfaceInfo(classInfoTree);
+ }
+
+ /**
* If this class is deprecated, build the appropriate information.
*
* @param node the XML element that specifies which components to document
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml Fri Dec 21 15:27:55 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml Tue Dec 25 17:23:59 2012 -0800
@@ -85,6 +85,7 @@
<SubInterfacesInfo/>
<InterfaceUsageInfo/>
<NestedClassInfo/>
+ <FunctionalInterfaceInfo/>
<DeprecationInfo/>
<ClassSignature/>
<ClassDescription/>
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java Fri Dec 21 15:27:55 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java Tue Dec 25 17:23:59 2012 -0800
@@ -36,7 +36,8 @@
INSTANCE(0x2, "Instance Methods", "t2", false),
ABSTRACT(0x4, "Abstract Methods", "t3", false),
CONCRETE(0x8, "Concrete Methods", "t4", false),
- DEPRECATED(0x10, "Deprecated Methods", "t5", false);
+ DEFAULT(0x10, "Default Methods", "t5", false),
+ DEPRECATED(0x20, "Deprecated Methods", "t6", false);
private final int value;
private final String text;
--- a/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java Fri Dec 21 15:27:55 2012 +0000
+++ b/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java Tue Dec 25 17:23:59 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, 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
@@ -207,7 +207,7 @@
"Instance Methods</a></span><span class=\"tabEnd\"> </span></span>" +
"<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
"Concrete Methods</a></span><span class=\"tabEnd\"> </span></span>" +
- "<span id=\"t5\" class=\"tableTab\"><span><a href=\"javascript:show(16);\">" +
+ "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">" +
"Deprecated Methods</a></span><span class=\"tabEnd\"> </span></span>" +
"</caption>"
},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java Tue Dec 25 17:23:59 2012 -0800
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2012, 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 8004893
+ * @summary Make sure that the lambda feature changes work fine in
+ * javadoc.
+ * @author bpatel
+ * @library ../lib/
+ * @build JavadocTester TestLambdaFeature
+ * @run main TestLambdaFeature
+ */
+
+public class TestLambdaFeature extends JavadocTester {
+
+ //Test information.
+ private static final String BUG_ID = "8004893";
+
+ //Javadoc arguments.
+ private static final String[] ARGS = new String[] {
+ "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
+ };
+
+ //Input for string search tests.
+ private static final String[][] TEST = {
+ {BUG_ID + FS + "pkg" + FS + "A.html",
+ "<td class=\"colFirst\"><code>default void</code></td>"},
+ {BUG_ID + FS + "pkg" + FS + "A.html",
+ "<pre>default void defaultMethod()</pre>"},
+ {BUG_ID + FS + "pkg" + FS + "A.html",
+ "<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
+ "All Methods</span><span class=\"tabEnd\"> </span></span>" +
+ "<span id=\"t2\" class=\"tableTab\"><span>" +
+ "<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
+ "<span class=\"tabEnd\"> </span></span><span id=\"t3\" " +
+ "class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
+ "Abstract Methods</a></span><span class=\"tabEnd\"> </span>" +
+ "</span><span id=\"t5\" class=\"tableTab\"><span>" +
+ "<a href=\"javascript:show(16);\">Default Methods</a></span>" +
+ "<span class=\"tabEnd\"> </span></span></caption>"},
+ {BUG_ID + FS + "pkg" + FS + "A.html",
+ "<dl>" + NL + "<dt>Functional Interface:</dt>" + NL +
+ "<dd>This is a functional interface and can therefore be used as " +
+ "the assignment target for a lambda expression or method " +
+ "reference. </dd>" + NL + "</dl>"}
+ };
+ private static final String[][] NEGATED_TEST = {
+ {BUG_ID + FS + "pkg" + FS + "A.html",
+ "<td class=\"colFirst\"><code>default default void</code></td>"},
+ {BUG_ID + FS + "pkg" + FS + "A.html",
+ "<pre>default default void defaultMethod()</pre>"},
+ {BUG_ID + FS + "pkg" + FS + "B.html",
+ "<td class=\"colFirst\"><code>default void</code></td>"},
+ {BUG_ID + FS + "pkg" + FS + "B.html",
+ "<dl>" + NL + "<dt>Functional Interface:</dt>"}
+ };
+
+ /**
+ * The entry point of the test.
+ * @param args the array of command line arguments.
+ */
+ public static void main(String[] args) {
+ TestLambdaFeature tester = new TestLambdaFeature();
+ run(tester, ARGS, TEST, NEGATED_TEST);
+ tester.printSummary();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getBugId() {
+ return BUG_ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getBugName() {
+ return getClass().getName();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testLambdaFeature/pkg/A.java Tue Dec 25 17:23:59 2012 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012, 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 A {
+
+ public void method1();
+
+ public default void defaultMethod() { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testLambdaFeature/pkg/B.java Tue Dec 25 17:23:59 2012 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012, 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 abstract class B {
+
+ public abstract void method1();
+
+ public void method2() { }
+}
--- a/langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java Fri Dec 21 15:27:55 2012 +0000
+++ b/langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java Tue Dec 25 17:23:59 2012 -0800
@@ -55,7 +55,7 @@
"Instance Methods</a></span><span class=\"tabEnd\"> </span></span>" +
"<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
"Concrete Methods</a></span><span class=\"tabEnd\"> </span></span>" +
- "<span id=\"t5\" class=\"tableTab\"><span><a href=\"javascript:show(16);\">" +
+ "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">" +
"Deprecated Methods</a></span><span class=\"tabEnd\"> </span></span>" +
"</caption>"
},
@@ -87,7 +87,7 @@
"Abstract Methods</a></span><span class=\"tabEnd\"> </span></span>" +
"<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
"Concrete Methods</a></span><span class=\"tabEnd\"> </span></span>" +
- "<span id=\"t5\" class=\"tableTab\"><span><a href=\"javascript:show(16);\">" +
+ "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">" +
"Deprecated Methods</a></span><span class=\"tabEnd\"> </span></span>" +
"</caption>"
},