# HG changeset patch # User pmuthuswamy # Date 1531826395 -19800 # Node ID c2e676c2cf7ba18e15c0b0686ff8301b2e02ae51 # Parent a25c48c0a1ab9d536b21ddfcfbbb83c7acd0e1fa 8207190: JDK 11 javadoc generates bad code example Reviewed-by: sundar diff -r a25c48c0a1ab -r c2e676c2cf7b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java Mon Jul 16 15:09:19 2018 -0700 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java Tue Jul 17 16:49:55 2018 +0530 @@ -140,7 +140,8 @@ */ @Override public Content getSignature(ExecutableElement method) { - Content pre = new HtmlTree(HtmlTag.PRE); + HtmlTree pre = new HtmlTree(HtmlTag.PRE); + pre.setStyle(HtmlStyle.methodSignature); writer.addAnnotationInfo(method, pre); int annotationLength = pre.charCount(); addModifiers(method, pre); diff -r a25c48c0a1ab -r c2e676c2cf7b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java Mon Jul 16 15:09:19 2018 -0700 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java Tue Jul 17 16:49:55 2018 +0530 @@ -83,6 +83,7 @@ memberNameLabel, memberNameLink, memberSummary, + methodSignature, moduleLabelInPackage, moduleLabelInType, nameValue, diff -r a25c48c0a1ab -r c2e676c2cf7b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Mon Jul 16 15:09:19 2018 -0700 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Tue Jul 17 16:49:55 2018 +0530 @@ -822,7 +822,7 @@ margin: -100px 0 0 100px; z-index: 1; } -.details pre { +.methodSignature { white-space:normal; } diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java --- a/test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java Tue Jul 17 16:49:55 2018 +0530 @@ -86,7 +86,7 @@ "
@Deprecated(forRemoval=true)\n"
                 + "public DeprecatedClassByAnnotation()
\n" + "
Deprecated, for removal: This API element is subject to removal in a future version.
", - "
@Deprecated\n"
+                "
@Deprecated\n"
                 + "public void method()
\n" + "
Deprecated.
"); diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java --- a/test/langtools/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java Tue Jul 17 16:49:55 2018 +0530 @@ -567,7 +567,7 @@ // Test with -nocomment and -nodeprecated options. The ClassDocs whould // not display definition lists for any member details. checkOutput("pkg1/C1.html", expectFound, - "
public void readObject()\n" +
+                "
public void readObject()\n" +
                 "                throws java.io.IOException
\n" + ""); diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java --- a/test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java Tue Jul 17 16:49:55 2018 +0530 @@ -46,7 +46,7 @@ checkExit(Exit.OK); checkOutput("p/Indent.html", true, - "
public <T> void m​(T t1,",
+                "
public <T> void m​(T t1,",
                 "\n"
                 + "                  T t2)",
                 "\n"
diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java
--- a/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java	Mon Jul 16 15:09:19 2018 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java	Tue Jul 17 16:49:55 2018 +0530
@@ -65,7 +65,7 @@
         checkExit(Exit.OK);
 
         checkOutput("pkg/Interface.html", true,
-                "
int method()
", + "
int method()
", "
static final int field
", // Make sure known implementing class list is correct and omits type parameters. "
\n" @@ -141,7 +141,7 @@ + "\n", "

staticMethod

\n" - + "
public static void staticMethod()
\n" + + "
public static void staticMethod()
\n" + "
" + "Description copied from interface: " + "" @@ -187,7 +187,7 @@ + "\n", "

staticMethod

\n" - + "
public static void staticMethod()
\n" + + "
public static void staticMethod()
\n" + "
" + "Description copied from interface: " + "" diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java --- a/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java Tue Jul 17 16:49:55 2018 +0530 @@ -54,11 +54,11 @@ "
See Also:
\n" + "
getRate(), \n" + "setRate(double)
", - "
public final void setRate​(double value)
\n" + "
public final void setRate​(double value)
\n" + "
Sets the value of the property rate.
\n" + "
\n" + "
Property description:
", - "
public final double getRate()
\n" + "
public final double getRate()
\n" + "
Gets the value of the property rate.
\n" + "
\n" + "
Property description:
", @@ -88,10 +88,10 @@ + "title=\"class in pkg1\">C.BooleanProperty pausedProperty
\n" + "
Defines if paused. The second line.
", "

isPaused

\n" - + "
public final double isPaused()
\n" + + "
public final double isPaused()
\n" + "
Gets the value of the property paused.
", "

setPaused

\n" - + "
public final void setPaused​(boolean value)
\n" + + "
public final void setPaused​(boolean value)
\n" + "
Sets the value of the property paused.
\n" + "
\n" + "
Property description:
\n" @@ -99,7 +99,7 @@ + "
Default value:
\n" + "
false
", "

isPaused

\n" - + "
public final double isPaused()
\n" + + "
public final double isPaused()
\n" + "
Gets the value of the property paused.
\n" + "
\n" + "
Property description:
\n" @@ -113,7 +113,7 @@ + "Timeline is expected to\n" + " be played. This is the second line.", "

setRate

\n" - + "
public final void setRate​(double value)
\n" + + "
public final void setRate​(double value)
\n" + "
Sets the value of the property rate.
\n" + "
\n" + "
Property description:
\n" @@ -124,7 +124,7 @@ + "
Since:
\n" + "
JavaFX 8.0
", "

getRate

\n" - + "
public final double getRate()
\n" + + "
public final double getRate()
\n" + "
Gets the value of the property rate.
\n" + "
\n" + "
Property description:
\n" diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java --- a/test/langtools/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java Tue Jul 17 16:49:55 2018 +0530 @@ -55,7 +55,7 @@ checkOutput("pkg/A.html", true, "default void", - "
default void defaultMethod()
", + "
default void defaultMethod()
", "" + "All Methods " + "" diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testLiteralCodeInPre/TestLiteralCodeInPre.java --- a/test/langtools/jdk/javadoc/doclet/testLiteralCodeInPre/TestLiteralCodeInPre.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testLiteralCodeInPre/TestLiteralCodeInPre.java Tue Jul 17 16:49:55 2018 +0530 @@ -89,7 +89,7 @@ + "
\n"
                 + " id           \n"
                 + " 
", - "
public void htmlAttrInPre1()
\n" + "
public void htmlAttrInPre1()
\n" + "
More html tag outliers.\n" + "
\n"
                 + " @Override\n"
diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java
--- a/test/langtools/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java	Mon Jul 16 15:09:19 2018 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java	Tue Jul 17 16:49:55 2018 +0530
@@ -55,7 +55,7 @@
                 + ""
                 + "returnTypeTest()",
                 // Check return type in member detail.
-                "
public "
+                "
public "
                 + "PublicChild returnTypeTest()
", "" + "PublicChild()"); diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java --- a/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java Tue Jul 17 16:49:55 2018 +0530 @@ -96,7 +96,7 @@ "for (Coin c : Coin.values())", "Overloaded valueOf() method has correct documentation.", "Overloaded values method has correct documentation.", - "
public static Coin" +
+                "
public static Coin" +
                 " valueOf​(java.lang.String name)
\n" + "
Returns the enum constant of this type with the specified name.\n" + "The string must match exactly an identifier used to declare an\n" + @@ -155,7 +155,7 @@ + "" + "methodThatReturnsTypeParameterA​(E[] e)", - "
public public E[] "
                 + "methodThatReturnsTypeParameterA​(E[] e)
\n", @@ -695,7 +695,7 @@ + "required=1994)\n" + "public AnnotationTypeUsage()
", // METHOD - "
@AnnotationType("
                 + "optional"
                 + "=\"Method Annotation\",\n"
@@ -703,7 +703,7 @@
                 + "required=1994)\n"
                 + "public void method()
", // METHOD PARAMS - "
public void methodWithParams​("
+                "
public void methodWithParams​("
                 + ""
                 + "@AnnotationType("
                 + "optional=\"Parameter Annotation\",=1994)\n"
                 + "public AnnotationTypeUsage()
", // METHOD - "
@AnnotationType("
                 + "optional"
                 + "=\"Method Annotation\",\n"
@@ -866,7 +866,7 @@
                 + "required=1994)\n"
                 + "public void method()
", // METHOD PARAMS - "
public void methodWithParams​("
+                "
public void methodWithParams​("
                 + ""
                 + "@AnnotationType("
                 + "optional=\"Parameter Annotation\",",
                 "
public java.lang.Object someProperty
", - "
public java.lang.Object public java.lang.Object someProperty()
"); checkOutput("src-html/linksource/Properties.html", true, @@ -222,7 +222,7 @@ + "field
", "
public "
                 + "SomeClass()
", - "
public int "
+                "
public int "
                 + "method()
"); checkOutput("src-html/linksource/SomeClass.html", true, diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java --- a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java Tue Jul 17 16:49:55 2018 +0530 @@ -52,7 +52,7 @@ checkOutput("pkg4/Foo.html", true, "
  • \n" + "

    toString

    \n" - + "
    public void toString()
    \n" + + "
    public void toString()
    \n" + "
    Why can't I do this ?
    \n" + "
  • "); } diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java --- a/test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java Tue Jul 17 16:49:55 2018 +0530 @@ -73,7 +73,7 @@ + "\n" + "", // Method is documented as though it is declared in the inheriting method. - "
    public void methodInheritedFromParent​(int p1)",
    +                "
    public void methodInheritedFromParent​(int p1)",
                     "
    \n" + "
    All Implemented Interfaces:
    \n" + "
    " diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testSerializedFormWithClassFile/TestSerializedFormWithClassFile.java --- a/test/langtools/jdk/javadoc/doclet/testSerializedFormWithClassFile/TestSerializedFormWithClassFile.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testSerializedFormWithClassFile/TestSerializedFormWithClassFile.java Tue Jul 17 16:49:55 2018 +0530 @@ -71,7 +71,7 @@ checkExit(Exit.OK); checkOutput("serialized-form.html", true, - "
    public void readObject​"
    +                "
    public void readObject​"
                     + "(java.io.ObjectInputStream arg0)\n"
                     + "                throws java.lang.ClassNotFoundException,\n"
                     + "                       java.io.IOException
    \n"); diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java --- a/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java Tue Jul 17 16:49:55 2018 +0530 @@ -87,7 +87,7 @@ checkOutput("p1/A.html", true, "
  • \n" + "

    m3

    \n" - + "
    public void m3()
    \n" + + "
    public void m3()
    \n" + "
    First sentence some text maybe second sentence.
    \n" + "
  • \n" ); diff -r a25c48c0a1ab -r c2e676c2cf7b test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java --- a/test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java Mon Jul 16 15:09:19 2018 -0700 +++ b/test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java Tue Jul 17 16:49:55 2018 +0530 @@ -154,22 +154,22 @@ // Test for type annotations on method return types (MethodReturnType.java). checkOutput("typeannos/MtdDefaultScope.html", true, - "
    public <T> public <T> @MRtnA java.lang.String"
                     + " method()
    ", // When JDK-8068737 is fixed, we should change the order - "
    "
    +                "
    "
                     + "@MRtnA java.lang.String "
                     + "@MRtnB [] "
                     + "@MRtnA []"
                     + " array2Deep()
    ", - "
    @MRtnA java.lang.String[][] array2()
    "); checkOutput("typeannos/MtdModifiedScoped.html", true, - "
    public final public final MtdParameterized<@MRtnA "
                     + "<K extends <K extends @MTyParamA java.lang.String>"
                     + " void methodExtends()
    ", - "
    <K extends <K extends @MTyParamA "
                     + "MtdTyParameterized<");
     
             checkOutput("typeannos/PublicModifiedMethods.html", true,
    -                "
    public final <K extends public final <K extends @MTyParamA "
                     + "java.lang.String> void methodExtends()
    ", - "
    public final <K extends public final <K extends @MTyParamA "
                     + "java.lang.String,​V extends @MTyParamA void unannotated​(void unannotated​("
                     + "ParaParameterized<java.lang.String,​java.lang.String>"
                     + " a)
    ", - "
    void nestedParaParameterized​(void nestedParaParameterized​("
                     + "ParaParameterized<@ParamA  java.lang.String> a)
    ", // When JDK-8068737 is fixed, we should change the order - "
    void array2Deep​(void array2Deep​(@ParamA java.lang.String "
                     + ""
                     + "@ParamB [] "
    @@ -237,34 +237,34 @@
     
             // Test for type annotations on throws (Throws.java).
             checkOutput("typeannos/ThrDefaultUnmodified.html", true,
    -                "
    void oneException()\n"
    +                "
    void oneException()\n"
                     + "           throws @ThrA java.lang.Exception
    ", - "
    void twoExceptions()\n"
    +                "
    void twoExceptions()\n"
                     + "            throws @ThrA java.lang.RuntimeException,\n"
                     + "                   @ThrA java.lang.Exception
    "); checkOutput("typeannos/ThrPublicModified.html", true, - "
    public final void oneException​(java.lang.String a)\n"
    -                + "                        throws public final void oneException​"
    +                + "(java.lang.String a)\n                        throws @ThrA java.lang.Exception
    ", - "
    public final void twoExceptions​(java.lang.String a)\n"
    -                + "                         throws public final void twoExceptions​"
    +                + "(java.lang.String a)\n                         throws @ThrA java.lang.RuntimeException,\n"
                     + "                                @ThrA java.lang.Exception
    "); checkOutput("typeannos/ThrWithValue.html", true, - "
    void oneException()\n"
    +                "
    void oneException()\n"
                     + "           throws @ThrB("
                     + "\"m\") java.lang.Exception
    ", - "
    void twoExceptions()\n"
    +                "
    void twoExceptions()\n"
                     + "            throws @ThrB("
                     + "\"m\") java.lang.RuntimeException,\n"
    @@ -273,32 +273,32 @@
     
             // Test for type annotations on type parameters (TypeParameters.java).
             checkOutput("typeannos/TestMethods.html", true,
    -                "
    <K,​"
    -                + "@TyParaA V extends <K,​@TyParaA V extends @TyParaA "
                     + "java.lang.String> void secondAnnotated()
    " ); // Test for type annotations on wildcard type (Wildcards.java). checkOutput("typeannos/BoundTest.html", true, - "
    void wcExtends​(void wcExtends​(MyList<? extends @WldA"
                     + " java.lang.String> l)
    ", - "
    MyList<? super @WldA java.lang.String>"
                     + " returnWcSuper()
    "); checkOutput("typeannos/BoundWithValue.html", true, - "
    void wcSuper​(MyList<? super void wcSuper​(MyList<? super @WldB("
                     + "\"m\") java.lang."
                     + "String> l)
    ", - "
    MyList<? extends @WldB("
                     + "\"m\") java.lang.String"
    @@ -306,37 +306,37 @@
     
             // Test for receiver annotations (Receivers.java).
             checkOutput("typeannos/DefaultUnmodified.html", true,
    -                "
    void withException​(void withException​(@RcvrA "
                     + "DefaultUnmodified this)\n"
                     + "            throws java."
                     + "lang.Exception
    ", - "
    java.lang.String nonVoid​(java.lang.String nonVoid​(@RcvrA @RcvrB"
                     + "(\"m\")"
                     + " DefaultUnmodified this)
    ", - "
    <T extends java.lang.Runnable> void accept​("
    +                "
    <T extends java.lang.Runnable> void accept​("
                     + "@RcvrA DefaultUnmodified this,\n"
                     + "                                           T r)\n"
                     + "                                    throws java.lang.Exception
    "); checkOutput("typeannos/PublicModified.html", true, - "
    public final java.lang.String nonVoid​("
    +                "
    public final java.lang.String nonVoid​"
    +                + "("
                     + "@RcvrA PublicModified this)
    ", - "
    public final <T extends java.lang.Runnable> "
    +                "
    public final <T extends java.lang.Runnable> "
                     + "void accept​(@RcvrA PublicModified this,\n"
                     + "                                                        T r)\n"
                     + "                                                 throws java.lang.Exception
    "); checkOutput("typeannos/WithValue.html", true, - "
    <T extends java.lang.Runnable> void accept​("
    +                "
    <T extends java.lang.Runnable> void accept​("
                     + "@RcvrB("
                     + "\"m\") WithValue this,\n"
    @@ -344,17 +344,17 @@
                     + "                                    throws java.lang.Exception
    "); checkOutput("typeannos/WithFinal.html", true, - "
    java.lang.String nonVoid​(java.lang.String nonVoid​(@RcvrB(\"m\") "
                     + ""
                     + "WithFinal afield)
    "); checkOutput("typeannos/WithBody.html", true, - "
    void field​(void field​(@RcvrA WithBody this)
    "); checkOutput("typeannos/Generic2.html", true, - "
    void test2​(void test2​(@RcvrA Generic2<X> this)
    ");