From 64186e6ef1f1b91cad085b9d8960edc5c15e4b32 Mon Sep 17 00:00:00 2001 From: bpatel Date: Wed, 26 Jun 2013 20:42:43 -0700 Subject: [PATCH] 8014017: extra space in javadoc class heading Reviewed-by: jjg --- .../toolkit/builders/ClassBuilder.java | 3 ++- .../TestPrivateClasses.java | 25 ++++++++++++++----- .../TestTypeAnnotations.java | 4 +-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java index b0d64d59..719aace1 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java @@ -289,7 +289,8 @@ public class ClassBuilder extends AbstractBuilder { * @param classInfoTree the content tree to which the documentation will be added */ public void buildClassSignature(XMLNode node, Content classInfoTree) { - StringBuilder modifiers = new StringBuilder(classDoc.modifiers() + " "); + StringBuilder modifiers = new StringBuilder(classDoc.modifiers()); + modifiers.append(modifiers.length() == 0 ? "" : " "); if (isEnum) { modifiers.append("enum "); int index; diff --git a/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java b/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java index f0cf05dc..9ff91c2d 100644 --- a/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java +++ b/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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 4780441 4874845 4978816 + * @bug 4780441 4874845 4978816 8014017 * @summary Make sure that when the -private flag is not used, members * inherited from package private class are documented in the child. * @@ -33,17 +33,19 @@ * * Make sure that when a private interface method with generic parameters * is implemented, the comments can be inherited properly. + * + * Make sure when no modifier appear in the class signature, the + * signature is displayed correctly without extra space at the beginning. * @author jamieh * @library ../lib/ - * @build JavadocTester - * @build TestPrivateClasses + * @build JavadocTester TestPrivateClasses * @run main TestPrivateClasses */ public class TestPrivateClasses extends JavadocTester { //Test information. - private static final String BUG_ID = "4780441-4874845-4978816"; + private static final String BUG_ID = "4780441-4874845-4978816-8014017"; //Javadoc arguments. private static final String[] ARGS1 = new String[] { @@ -234,8 +236,19 @@ public class TestPrivateClasses extends JavadocTester { " in interface " + "I" + "<java.lang.String>"}, + + //Make sure when no modifier appear in the class signature, the + //signature is displayed correctly without extra space at the beginning. + {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateParent.html", + "
class PrivateParent"},
+
+      {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+            "
public class PublicChild"},
+    };
+    private static final String[][] NEGATED_TEST2 = {
+        {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateParent.html",
+            "
 class PrivateParent"},
     };
-    private static final String[][] NEGATED_TEST2 = NO_TEST;
 
     /**
      * The entry point of the test.
diff --git a/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java b/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java
index 1d3baaa0..61d5758b 100644
--- a/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java
+++ b/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java
@@ -78,7 +78,7 @@ public class TestTypeAnnotations extends JavadocTester {
             "typeannos\">@ClassParamA java.lang.String>"
         },
         {BUG_ID + FS + "typeannos" + FS + "ExtendsGeneric.html",
-            "
 class ExtendsGeneric<K extends " +
+            "
class ExtendsGeneric<K extends " +
             "@ClassParamA Unannotated< java.lang.String>>"
         },
         {BUG_ID + FS + "typeannos" + FS + "TwoBounds.html",
-            "
 class TwoBounds<K extends class TwoBounds<K extends " +
             "@ClassParamA java.lang.String,V extends @ClassParamB" +
-- 
GitLab