diff --git a/langtools/src/share/classes/com/sun/javadoc/ClassDoc.java b/langtools/src/share/classes/com/sun/javadoc/ClassDoc.java index 092f79bf528..b6e89031270 100644 --- a/langtools/src/share/classes/com/sun/javadoc/ClassDoc.java +++ b/langtools/src/share/classes/com/sun/javadoc/ClassDoc.java @@ -74,15 +74,6 @@ public interface ClassDoc extends ProgramElementDoc, Type { */ 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 --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java index a1ac09529d7..ebcb7b64cf3 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java @@ -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 java.util.*; 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 @@ public class ClassWriterImpl extends SubWriterHolderWriter * {@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 class ClassWriterImpl extends SubWriterHolderWriter } } + 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 --git a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java index 7428b97e0f6..f9fcaa74864 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java @@ -288,10 +288,6 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { return false; } - public boolean isFunctionalInterface() { - return env.types.isFunctionalInterface(tsym) && env.source.allowLambda(); - } - /** * Return the package that this class is contained in. */ diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java index 9046bc02a6b..25ab5561dee 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java @@ -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 @@ public class RootDocImpl extends DocImpl implements RootDoc { 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 --git a/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java b/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java index 0fb47c1eddc..dc0a04db0b5 100644 --- a/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java +++ b/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java @@ -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 @@ public class TestLambdaFeature extends JavadocTester { "
default default void defaultMethod()"}, {BUG_ID + FS + "pkg" + FS + "B.html", "
default void