# HG changeset patch # User bpatel # Date 1396116393 25200 # Node ID daa645653200b6ecc9d0c38029fe7719de42c8ce # Parent ca0f803911823a10309c572deed01670e13b1724 8029143: javadoc standard doclet should add Functional Interface blurb when @FunctionalInterface annotation is present Reviewed-by: ksrini diff -r ca0f80391182 -r daa645653200 langtools/src/share/classes/com/sun/javadoc/ClassDoc.java --- a/langtools/src/share/classes/com/sun/javadoc/ClassDoc.java Thu Mar 27 18:41:28 2014 -0400 +++ b/langtools/src/share/classes/com/sun/javadoc/ClassDoc.java Sat Mar 29 11:06:33 2014 -0700 @@ -75,15 +75,6 @@ boolean isExternalizable(); /** - * Return true if this class can be used as a target type of a lambda expression - * or method reference. - * - * @return true if this class can be used as a target type of a lambda expression - * or method reference. - */ - boolean isFunctionalInterface(); - - /** * Return the serialization methods for this class or * interface. * diff -r ca0f80391182 -r daa645653200 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 Thu Mar 27 18:41:28 2014 -0400 +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Sat Mar 29 11:06:33 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, 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 @@ -29,6 +29,7 @@ import com.sun.javadoc.*; import com.sun.tools.javac.jvm.Profile; +import com.sun.tools.javadoc.RootDocImpl; import com.sun.tools.doclets.formats.html.markup.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.builders.*; @@ -528,7 +529,7 @@ * {@inheritDoc} */ public void addFunctionalInterfaceInfo (Content classInfoTree) { - if (classDoc.isFunctionalInterface()) { + if (isFunctionalInterface()) { Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface")); Content dl = HtmlTree.DL(dt); Content dd = new HtmlTree(HtmlTag.DD); @@ -538,6 +539,19 @@ } } + public boolean isFunctionalInterface() { + if (configuration.root instanceof RootDocImpl) { + RootDocImpl root = (RootDocImpl) configuration.root; + AnnotationDesc[] annotationDescList = classDoc.annotations(); + for (AnnotationDesc annoDesc : annotationDescList) { + if (root.isFunctionalInterface(annoDesc)) { + return true; + } + } + } + return false; + } + /** * {@inheritDoc} */ diff -r ca0f80391182 -r daa645653200 langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java --- a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Thu Mar 27 18:41:28 2014 -0400 +++ b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Sat Mar 29 11:06:33 2014 -0700 @@ -288,10 +288,6 @@ return false; } - public boolean isFunctionalInterface() { - return env.types.isFunctionalInterface(tsym) && env.source.allowLambda(); - } - /** * Return the package that this class is contained in. */ diff -r ca0f80391182 -r daa645653200 langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java --- a/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java Thu Mar 27 18:41:28 2014 -0400 +++ b/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java Sat Mar 29 11:06:33 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, 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 @@ -381,6 +381,11 @@ env.initDoclint(opts, customTagNames); } + public boolean isFunctionalInterface(AnnotationDesc annotationDesc) { + return annotationDesc.annotationType().qualifiedName().equals( + env.syms.functionalInterfaceType.toString()) && env.source.allowLambda(); + } + public boolean showTagMessages() { return env.showTagMessages(); } diff -r ca0f80391182 -r daa645653200 langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java --- a/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java Thu Mar 27 18:41:28 2014 -0400 +++ b/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java Sat Mar 29 11:06:33 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, 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,7 +23,7 @@ /* * @test - * @bug 8004893 8022738 + * @bug 8004893 8022738 8029143 * @summary Make sure that the lambda feature changes work fine in * javadoc. * @author bpatel @@ -87,6 +87,11 @@ "
default default void defaultMethod()"}, {BUG_ID + FS + "pkg" + FS + "B.html", "
default void