# HG changeset patch # User bpatel # Date 1356485039 28800 # Node ID bb1eb01b8c4195e643cf0986143387ce42a3af97 # Parent 391288e42c6735664c7e1b5eb41f92982e1e8908 8004893: the javadoc/doclet needs to be updated to accommodate lambda changes Reviewed-by: jjg diff -r 391288e42c67 -r bb1eb01b8c41 langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java --- 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(); } diff -r 391288e42c67 -r bb1eb01b8c41 langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java --- 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); diff -r 391288e42c67 -r bb1eb01b8c41 langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties --- 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 diff -r 391288e42c67 -r bb1eb01b8c41 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java --- 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. * diff -r 391288e42c67 -r bb1eb01b8c41 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java --- 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 diff -r 391288e42c67 -r bb1eb01b8c41 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml --- 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 @@ + diff -r 391288e42c67 -r bb1eb01b8c41 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java --- 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; diff -r 391288e42c67 -r bb1eb01b8c41 langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java --- 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 " + "" + "Concrete Methods " + - "" + + "" + "Deprecated Methods " + "" }, diff -r 391288e42c67 -r bb1eb01b8c41 langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java --- /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", + "default void"}, + {BUG_ID + FS + "pkg" + FS + "A.html", + "
default void defaultMethod()
"}, + {BUG_ID + FS + "pkg" + FS + "A.html", + "" + + "All Methods " + + "" + + "Instance Methods" + + " " + + "Abstract Methods " + + "" + + "Default Methods" + + " "}, + {BUG_ID + FS + "pkg" + FS + "A.html", + "
" + NL + "
Functional Interface:
" + NL + + "
This is a functional interface and can therefore be used as " + + "the assignment target for a lambda expression or method " + + "reference.
" + NL + "
"} + }; + private static final String[][] NEGATED_TEST = { + {BUG_ID + FS + "pkg" + FS + "A.html", + "default default void"}, + {BUG_ID + FS + "pkg" + FS + "A.html", + "
default default void defaultMethod()
"}, + {BUG_ID + FS + "pkg" + FS + "B.html", + "default void"}, + {BUG_ID + FS + "pkg" + FS + "B.html", + "
" + NL + "
Functional Interface:
"} + }; + + /** + * 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(); + } +} diff -r 391288e42c67 -r bb1eb01b8c41 langtools/test/com/sun/javadoc/testLambdaFeature/pkg/A.java --- /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() { } +} diff -r 391288e42c67 -r bb1eb01b8c41 langtools/test/com/sun/javadoc/testLambdaFeature/pkg/B.java --- /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() { } +} diff -r 391288e42c67 -r bb1eb01b8c41 langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java --- 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 " + "" + "Concrete Methods " + - "" + + "" + "Deprecated Methods " + "" }, @@ -87,7 +87,7 @@ "Abstract Methods " + "" + "Concrete Methods " + - "" + + "" + "Deprecated Methods " + "" },