# HG changeset patch # User darcy # Date 1455585478 28800 # Node ID 39c5445924b956f751e6723ab8b752abeedb734c # Parent 688096b6bcc40aa5679d0763df4624ff8f6bd484 6469561: javadoc for annotation types should not display "public abstract" modifiers on methods 6469562: Use compact notation to display annotation values Reviewed-by: jjg diff -r 688096b6bcc4 -r 39c5445924b9 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java Mon Feb 15 14:02:57 2016 -0800 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java Mon Feb 15 17:17:58 2016 -0800 @@ -261,10 +261,13 @@ // According to JLS, we should not be showing public modifier for // interface methods. if ((utils.isField(member) || utils.isMethod(member)) - && writer instanceof ClassWriterImpl - && utils.isInterface(((ClassWriterImpl) writer).getTypeElement())) { + && ((writer instanceof ClassWriterImpl + && utils.isInterface(((ClassWriterImpl) writer).getTypeElement()) || + writer instanceof AnnotationTypeWriterImpl) )) { // Remove the implicit abstract and public modifiers - if (utils.isMethod(member) && utils.isInterface(member.getEnclosingElement())) { + if (utils.isMethod(member) && + (utils.isInterface(member.getEnclosingElement()) || + utils.isAnnotationType(member.getEnclosingElement()))) { set.remove(ABSTRACT); set.remove(PUBLIC); } diff -r 688096b6bcc4 -r 39c5445924b9 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Mon Feb 15 14:02:57 2016 -0800 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Mon Feb 15 17:17:58 2016 -0800 @@ -2363,7 +2363,9 @@ if (!map.isEmpty()) { annotation.addContent("("); boolean isFirst = true; - for (ExecutableElement element : map.keySet()) { + Set keys = map.keySet(); + boolean multipleValues = keys.size() > 1; + for (ExecutableElement element : keys) { if (isFirst) { isFirst = false; } else { @@ -2376,9 +2378,12 @@ } } } - annotation.addContent(getDocLink(LinkInfoImpl.Kind.ANNOTATION, - element, element.getSimpleName().toString(), false)); - annotation.addContent("="); + String simpleName = element.getSimpleName().toString(); + if (multipleValues || !"value".equals(simpleName)) { // Omit "value=" where unnecessary + annotation.addContent(getDocLink(LinkInfoImpl.Kind.ANNOTATION, + element, simpleName, false)); + annotation.addContent("="); + } AnnotationValue annotationValue = map.get(element); List annotationTypeValues = new ArrayList<>(); new SimpleAnnotationValueVisitor9() { diff -r 688096b6bcc4 -r 39c5445924b9 langtools/test/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java --- a/langtools/test/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java Mon Feb 15 14:02:57 2016 -0800 +++ b/langtools/test/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java Mon Feb 15 17:17:58 2016 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, 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 4973609 8015249 8025633 8026567 + * @bug 4973609 8015249 8025633 8026567 6469561 * @summary Make sure that annotation types with 0 members does not have * extra HR tags. * @author jamieh @@ -61,7 +61,7 @@ + " ", "", "

DEFAULT_NAME

\n" - + "
public static final java."
+                + "
static final java."
                 + "lang.String DEFAULT_NAME
"); checkOutput("pkg/AnnotationType.html", true, @@ -70,6 +70,21 @@ "
  • Detail: 
  • \n" + "
  • Field | 
  • "); + checkOutput("pkg/AnnotationType.html", true, + "", + "
      ", + "
    • ", + "", + "", + "

      Element Detail

      ", + "", + "", + "", + "
        ", + "
      • ", + "

        value

        ", + "
        int value
        " ); + checkOutput("pkg/AnnotationType.html", false, "
        \n\n" + "

        \n\n" diff -r 688096b6bcc4 -r 39c5445924b9 langtools/test/jdk/javadoc/doclet/testAnnotationTypes/pkg/AnnotationType.java --- a/langtools/test/jdk/javadoc/doclet/testAnnotationTypes/pkg/AnnotationType.java Mon Feb 15 14:02:57 2016 -0800 +++ b/langtools/test/jdk/javadoc/doclet/testAnnotationTypes/pkg/AnnotationType.java Mon Feb 15 17:17:58 2016 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, 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 @@ -32,5 +32,5 @@ * @since 1.5 */ @Documented public @interface AnnotationType { - + int value(); } diff -r 688096b6bcc4 -r 39c5445924b9 langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java --- a/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java Mon Feb 15 14:02:57 2016 -0800 +++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java Mon Feb 15 17:17:58 2016 -0800 @@ -23,7 +23,7 @@ /* * @test - * @bug 8005092 + * @bug 8005092 6469562 * @summary Test repeated annotations output. * @author bpatel * @library ../lib @@ -57,7 +57,7 @@ + "title=\"annotation in pkg\">@ContaineeRegDoc", "@RegContainerDoc" - + "(value={" + + "({" + "@RegContaineeNotDoc," + "@ContaineeSynthDoc", "@ContainerSynthDoc(" - + "value=" + + "" + "@ContaineeSynthDoc)", "y={1,2})", "@NonSynthDocContainer" - + "(value=" + + "(" + "@RegArryDoc)"); checkOutput("pkg1/C.html", true, diff -r 688096b6bcc4 -r 39c5445924b9 langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/C.java --- a/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/C.java Mon Feb 15 14:02:57 2016 -0800 +++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/C.java Mon Feb 15 17:17:58 2016 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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,15 +23,15 @@ package pkg; -@ContainerSynthDoc(value={@ContaineeSynthDoc,@ContaineeSynthDoc}) -@ContainerRegDoc(value={@ContaineeRegDoc,@ContaineeRegDoc}) -@RegContainerDoc(value={@RegContaineeNotDoc,@RegContaineeNotDoc}) -@ContainerRegNotDoc(value={@RegContaineeDoc,@RegContaineeDoc}) -@RegContainerNotDoc(value={@RegContaineeNotDoc,@RegContaineeNotDoc}) +@ContainerSynthDoc({@ContaineeSynthDoc,@ContaineeSynthDoc}) +@ContainerRegDoc({@ContaineeRegDoc,@ContaineeRegDoc}) +@RegContainerDoc({@RegContaineeNotDoc,@RegContaineeNotDoc}) +@ContainerRegNotDoc({@RegContaineeDoc,@RegContaineeDoc}) +@RegContainerNotDoc({@RegContaineeNotDoc,@RegContaineeNotDoc}) @ContaineeSynthDoc @ContaineeSynthDoc @ContaineeSynthDoc public class C { - @ContainerSynthDoc(value={@ContaineeSynthDoc}) + @ContainerSynthDoc({@ContaineeSynthDoc}) public void test1() {} @ContaineeSynthDoc @ContaineeSynthDoc diff -r 688096b6bcc4 -r 39c5445924b9 langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/D.java --- a/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/D.java Mon Feb 15 14:02:57 2016 -0800 +++ b/langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/D.java Mon Feb 15 17:17:58 2016 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -32,6 +32,6 @@ @RegArryDoc(y={1,2}) public void test2() {} - @NonSynthDocContainer(value={@RegArryDoc}) + @NonSynthDocContainer({@RegArryDoc}) public void test3() {} } diff -r 688096b6bcc4 -r 39c5445924b9 langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java --- a/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java Mon Feb 15 14:02:57 2016 -0800 +++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java Mon Feb 15 17:17:58 2016 -0800 @@ -23,7 +23,7 @@ /* * @test - * @bug 8005091 8009686 8025633 8026567 + * @bug 8005091 8009686 8025633 8026567 6469562 * @summary Make sure that type annotations are displayed correctly * @author Bhavesh Patel * @library ../lib @@ -260,13 +260,13 @@ checkOutput("typeannos/ThrWithValue.html", true, "

        void oneException()\n"
                         + "           throws @ThrB(value=\"m\") java.lang.Exception
        ", + + "annotation in typeannos\">@ThrB(" + + "\"m\") java.lang.Exception
    ", "
    void twoExceptions()\n"
                     + "            throws @ThrB(value=\"m\") java.lang.RuntimeException,\n"
    +                + "annotation in typeannos\">@ThrB("
    +                + "\"m\") java.lang.RuntimeException,\n"
                     + "                   @ThrA java.lang.Exception
    "); @@ -293,14 +293,14 @@ checkOutput("typeannos/BoundWithValue.html", true, "
    void wcSuper(MyList<? super @WldB(value=\"m\") java.lang."
    +                + "WldB.html\" title=\"annotation in typeannos\">@WldB("
    +                + "\"m\") java.lang."
                     + "String> l)
    ", "
    MyList<? extends @WldB(value=\"m\") java.lang.String"
    +                + "html\" title=\"annotation in typeannos\">@WldB("
    +                + "\"m\") java.lang.String"
                     + "> returnWcExtends()
    "); // Test for receiver annotations (Receivers.java). @@ -314,7 +314,7 @@ "
    java.lang.String nonVoid(@RcvrA @RcvrB"
    -                + "(value=\"m\")"
    +                + "(\"m\")"
                     + " DefaultUnmodified this)
    ", "
    <T extends java.lang.Runnable> void accept("
    @@ -337,15 +337,15 @@
             checkOutput("typeannos/WithValue.html", true,
                     "
    <T extends java.lang.Runnable> void accept("
                     + "@RcvrB("
    -                + "value=\"m\") WithValue this,\n"
    +                + "typeannos\">@RcvrB("
    +                + "\"m\") WithValue this,\n"
                     + "                                           T r)\n"
                     + "                                    throws java.lang.Exception
    "); checkOutput("typeannos/WithFinal.html", true, "
    java.lang.String nonVoid(@RcvrB(value=\"m\") WithFinal"
    +                + "html\" title=\"annotation in typeannos\">@RcvrB("
    +                + "\"m\") WithFinal"
                     + " this)
    "); checkOutput("typeannos/WithBody.html", true, diff -r 688096b6bcc4 -r 39c5445924b9 langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Throws.java --- a/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Throws.java Mon Feb 15 14:02:57 2016 -0800 +++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Throws.java Mon Feb 15 17:17:58 2016 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -40,7 +40,7 @@ class ThrWithValue { void oneException() throws @ThrB("m") Exception {} - void twoExceptions() throws @ThrB(value="m") RuntimeException, @ThrA Exception {} + void twoExceptions() throws @ThrB("m") RuntimeException, @ThrA Exception {} } @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) diff -r 688096b6bcc4 -r 39c5445924b9 langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Wildcards.java --- a/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Wildcards.java Mon Feb 15 14:02:57 2016 -0800 +++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Wildcards.java Mon Feb 15 17:17:58 2016 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -39,10 +39,10 @@ class BoundWithValue { void wcExtends(MyList l) { } - void wcSuper(MyList l) { } + void wcSuper(MyList l) { } MyList returnWcExtends() { return null; } - MyList returnWcSuper() { return null; } + MyList returnWcSuper() { return null; } MyList> complex() { return null; } } @@ -57,10 +57,10 @@ class SelfWithValue { void wcExtends(MyList<@WldB("m") ?> l) { } - void wcSuper(MyList<@WldB(value="m") ?> l) { } + void wcSuper(MyList<@WldB("m") ?> l) { } MyList<@WldB("m") ?> returnWcExtends() { return null; } - MyList<@WldB(value="m") ?> returnWcSuper() { return null; } + MyList<@WldB("m") ?> returnWcSuper() { return null; } MyList<@WldB("m") ? extends MyList<@WldB("m") ? super String>> complex() { return null; } }