6469561: javadoc for annotation types should not display "public abstract" modifiers on methods
authordarcy
Mon, 15 Feb 2016 17:17:58 -0800
changeset 36038 39c5445924b9
parent 36037 688096b6bcc4
child 36039 add34c39d882
6469561: javadoc for annotation types should not display "public abstract" modifiers on methods 6469562: Use compact notation to display annotation values Reviewed-by: jjg
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
langtools/test/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java
langtools/test/jdk/javadoc/doclet/testAnnotationTypes/pkg/AnnotationType.java
langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/TestRepeatedAnnotations.java
langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/C.java
langtools/test/jdk/javadoc/doclet/testRepeatedAnnotations/pkg/D.java
langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java
langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Throws.java
langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/Wildcards.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);
             }
--- 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<? extends ExecutableElement> 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<AnnotationValue> annotationTypeValues = new ArrayList<>();
                 new SimpleAnnotationValueVisitor9<Void, AnnotationValue>() {
--- 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 @@
                 + "</code>&nbsp;</td>",
                 "<!-- ============ ANNOTATION TYPE FIELD DETAIL =========== -->",
                 "<h4>DEFAULT_NAME</h4>\n"
-                + "<pre>public static final&nbsp;java."
+                + "<pre>static final&nbsp;java."
                 + "lang.String&nbsp;DEFAULT_NAME</pre>");
 
         checkOutput("pkg/AnnotationType.html", true,
@@ -70,6 +70,21 @@
                 "<li>Detail:&nbsp;</li>\n"
                 + "<li>Field&nbsp;|&nbsp;</li>");
 
+        checkOutput("pkg/AnnotationType.html", true,
+                    "<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->",
+                    "<ul class=\"blockList\">",
+                    "<li class=\"blockList\"><a name=\"annotation.type.element.detail\">",
+                    "<!--   -->",
+                    "</a>",
+                    "<h3>Element Detail</h3>",
+                    "<a name=\"value--\">",
+                    "<!--   -->",
+                    "</a>",
+                    "<ul class=\"blockListLast\">",
+                    "<li class=\"blockList\">",
+                    "<h4>value</h4>",
+                    "<pre>int&nbsp;value</pre>" );
+
         checkOutput("pkg/AnnotationType.html", false,
                 "<HR>\n\n"
                 + "<P>\n\n"
--- 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();
 }
--- 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</a>",
                 "<a href=\"../pkg/RegContainerDoc.html\" "
                 + "title=\"annotation in pkg\">@RegContainerDoc</a>"
-                + "(<a href=\"../pkg/RegContainerDoc.html#value--\">value</a>={"
+                + "({"
                 + "<a href=\"../pkg/RegContaineeNotDoc.html\" "
                 + "title=\"annotation in pkg\">@RegContaineeNotDoc</a>,"
                 + "<a href=\"../pkg/RegContaineeNotDoc.html\" "
@@ -70,7 +70,7 @@
                 + "title=\"annotation in pkg\">@ContaineeSynthDoc</a>",
                 "<a href=\"../pkg/ContainerSynthDoc.html\" "
                 + "title=\"annotation in pkg\">@ContainerSynthDoc</a>("
-                + "<a href=\"../pkg/ContainerSynthDoc.html#value--\">value</a>="
+                + ""
                 + "<a href=\"../pkg/ContaineeSynthDoc.html\" "
                 + "title=\"annotation in pkg\">@ContaineeSynthDoc</a>)",
                 "<a href=\"../pkg/ContaineeSynthDoc.html\" "
@@ -87,7 +87,7 @@
                 + "(<a href=\"../pkg/RegArryDoc.html#y--\">y</a>={1,2})",
                 "<a href=\"../pkg/NonSynthDocContainer.html\" "
                 + "title=\"annotation in pkg\">@NonSynthDocContainer</a>"
-                + "(<a href=\"../pkg/NonSynthDocContainer.html#value--\">value</a>="
+                + "("
                 + "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>)");
 
         checkOutput("pkg1/C.html", true,
--- 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
--- 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() {}
 }
--- 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,
                 "<pre>void&nbsp;oneException()\n"
                 + "           throws <a href=\"../typeannos/ThrB.html\" title=\""
-                + "annotation in typeannos\">@ThrB</a>(<a href=\"../typeannos/"
-                + "ThrB.html#value--\">value</a>=\"m\") java.lang.Exception</pre>",
+                + "annotation in typeannos\">@ThrB</a>("
+                + "\"m\") java.lang.Exception</pre>",
 
                 "<pre>void&nbsp;twoExceptions()\n"
                 + "            throws <a href=\"../typeannos/ThrB.html\" title=\""
-                + "annotation in typeannos\">@ThrB</a>(<a href=\"../typeannos/"
-                + "ThrB.html#value--\">value</a>=\"m\") java.lang.RuntimeException,\n"
+                + "annotation in typeannos\">@ThrB</a>("
+                + "\"m\") java.lang.RuntimeException,\n"
                 + "                   <a href=\"../typeannos/ThrA.html\" title=\""
                 + "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>");
 
@@ -293,14 +293,14 @@
         checkOutput("typeannos/BoundWithValue.html", true,
                 "<pre>void&nbsp;wcSuper(<a href=\"../typeannos/MyList.html\" title=\""
                 + "class in typeannos\">MyList</a>&lt;? super <a href=\"../typeannos/"
-                + "WldB.html\" title=\"annotation in typeannos\">@WldB</a>(<a href=\""
-                + "../typeannos/WldB.html#value--\">value</a>=\"m\") java.lang."
+                + "WldB.html\" title=\"annotation in typeannos\">@WldB</a>("
+                + "\"m\") java.lang."
                 + "String&gt;&nbsp;l)</pre>",
 
                 "<pre><a href=\"../typeannos/MyList.html\" title=\"class in "
                 + "typeannos\">MyList</a>&lt;? extends <a href=\"../typeannos/WldB."
-                + "html\" title=\"annotation in typeannos\">@WldB</a>(<a href=\"../"
-                + "typeannos/WldB.html#value--\">value</a>=\"m\") java.lang.String"
+                + "html\" title=\"annotation in typeannos\">@WldB</a>("
+                + "\"m\") java.lang.String"
                 + "&gt;&nbsp;returnWcExtends()</pre>");
 
         // Test for receiver annotations (Receivers.java).
@@ -314,7 +314,7 @@
                 "<pre>java.lang.String&nbsp;nonVoid(<a href=\"../typeannos/RcvrA."
                 + "html\" title=\"annotation in typeannos\">@RcvrA</a> <a href=\"../"
                 + "typeannos/RcvrB.html\" title=\"annotation in typeannos\">@RcvrB"
-                + "</a>(<a href=\"../typeannos/RcvrB.html#value--\">value</a>=\"m\")"
+                + "</a>(\"m\")"
                 + "&nbsp;DefaultUnmodified&nbsp;this)</pre>",
 
                 "<pre>&lt;T extends java.lang.Runnable&gt;&nbsp;void&nbsp;accept("
@@ -337,15 +337,15 @@
         checkOutput("typeannos/WithValue.html", true,
                 "<pre>&lt;T extends java.lang.Runnable&gt;&nbsp;void&nbsp;accept("
                 + "<a href=\"../typeannos/RcvrB.html\" title=\"annotation in "
-                + "typeannos\">@RcvrB</a>(<a href=\"../typeannos/RcvrB.html#value--\">"
-                + "value</a>=\"m\")&nbsp;WithValue&nbsp;this,\n"
+                + "typeannos\">@RcvrB</a>("
+                + "\"m\")&nbsp;WithValue&nbsp;this,\n"
                 + "                                           T&nbsp;r)\n"
                 + "                                    throws java.lang.Exception</pre>");
 
         checkOutput("typeannos/WithFinal.html", true,
                 "<pre>java.lang.String&nbsp;nonVoid(<a href=\"../typeannos/RcvrB."
-                + "html\" title=\"annotation in typeannos\">@RcvrB</a>(<a href=\"../"
-                + "typeannos/RcvrB.html#value--\">value</a>=\"m\")&nbsp;WithFinal"
+                + "html\" title=\"annotation in typeannos\">@RcvrB</a>("
+                + "\"m\")&nbsp;WithFinal"
                 + "&nbsp;this)</pre>");
 
         checkOutput("typeannos/WithBody.html", true,
--- 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})
--- 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<? extends @WldB("m") String> l) { }
-    void wcSuper(MyList<? super @WldB(value="m") String> l) { }
+    void wcSuper(MyList<? super @WldB("m") String> l) { }
 
     MyList<? extends @WldB("m") String> returnWcExtends() { return null; }
-    MyList<? super @WldB(value="m") String> returnWcSuper() { return null; }
+    MyList<? super @WldB("m") String> returnWcSuper() { return null; }
     MyList<? extends @WldB("m") MyList<? super @WldB("m") String>> 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; }
 }