8149139: [javadoc] Modify Content to accept CharSequence
authorksrini
Wed, 24 Feb 2016 15:31:36 -0800
changeset 36500 d31e4986dc8b
parent 36499 9d823cc0fe98
child 36501 93915076a341
8149139: [javadoc] Modify Content to accept CharSequence Reviewed-by: jjg
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java
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/ClassWriterImpl.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/DocType.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocument.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java	Wed Feb 24 15:31:36 2016 -0800
@@ -104,11 +104,11 @@
         sb.append(utils.getFullyQualifiedName(member));
         if (!utils.isConstructor(member)) {
             sb.append(".");
-            sb.append(member.getSimpleName().toString());
+            sb.append(member.getSimpleName());
         }
         sb.append(utils.flatSignature((ExecutableElement) member));
 
-        return writer.getDocLink(MEMBER, member, sb.toString());
+        return writer.getDocLink(MEMBER, member, sb);
     }
 
     /**
@@ -204,7 +204,7 @@
         htmltree.addContent("(");
         String sep = "";
         List<? extends VariableElement> parameters = member.getParameters();
-        String indent = makeSpace(indentSize + 1);
+        CharSequence indent = makeSpace(indentSize + 1);
         TypeMirror rcvrType = member.getReceiverType();
         if (includeAnnotations && rcvrType != null && utils.isAnnotated(rcvrType)) {
             List<? extends AnnotationMirror> annotationMirrors = rcvrType.getAnnotationMirrors();
@@ -260,7 +260,7 @@
     protected void addExceptions(ExecutableElement member, Content htmltree, int indentSize) {
         List<? extends TypeMirror> exceptions = member.getThrownTypes();
         if (!exceptions.isEmpty()) {
-            String indent = makeSpace(indentSize + 1 - 7);
+            CharSequence indent = makeSpace(indentSize + 1 - 7);
             htmltree.addContent(DocletConstants.NL);
             htmltree.addContent(indent);
             htmltree.addContent("throws ");
@@ -336,7 +336,7 @@
 
                 @Override @DefinedBy(Api.LANGUAGE_MODEL)
                 protected Boolean defaultAction(TypeMirror e, Void p) {
-                    buf.append(e.toString());
+                    buf.append(e);
                     return foundTypeVariable;
                 }
             };
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Wed Feb 24 15:31:36 2016 -0800
@@ -223,26 +223,6 @@
         htmltree.addContent(name);
     }
 
-    protected String typeString(Element member) {
-        return new SimpleElementVisitor9<String, Void>() {
-
-            @Override @DefinedBy(Api.LANGUAGE_MODEL)
-            public String visitExecutable(ExecutableElement e, Void p) {
-               return utils.isMethod(e) ? e.getReturnType().toString() : "";
-            }
-
-            @Override @DefinedBy(Api.LANGUAGE_MODEL)
-            public String visitVariable(VariableElement e, Void p) {
-                return e.toString();
-            }
-
-            @Override @DefinedBy(Api.LANGUAGE_MODEL)
-            protected String defaultAction(Element e, Void p) {
-                return "";
-            }
-        }.visit(member);
-    }
-
     /**
      * Add the modifier for the member. The modifiers are ordered as specified
      * by <em>The Java Language Specification</em>.
@@ -282,7 +262,7 @@
         }
     }
 
-    protected String makeSpace(int len) {
+    protected CharSequence makeSpace(int len) {
         if (len <= 0) {
             return "";
         }
@@ -290,7 +270,7 @@
         for (int i = 0; i < len; i++) {
             sb.append(' ');
         }
-        return sb.toString();
+        return sb;
     }
 
     /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Wed Feb 24 15:31:36 2016 -0800
@@ -199,8 +199,7 @@
             Content classPackageLabel = HtmlTree.SPAN(HtmlStyle.packageLabelInClass, packageLabel);
             Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classPackageLabel);
             pkgNameDiv.addContent(getSpace());
-            Content pkgNameContent = getPackageLink(pkg,
-                    new StringContent(pkg.getQualifiedName().toString()));
+            Content pkgNameContent = getPackageLink(pkg, new StringContent(pkg.getQualifiedName()));
             pkgNameDiv.addContent(pkgNameContent);
             div.addContent(pkgNameDiv);
         }
@@ -395,10 +394,10 @@
                     new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE,
                     typeElement));
             if (configuration.shouldExcludeQualifier(utils.containingPackage(typeElement).toString())) {
-                li.addContent(utils.asTypeElement(type).getSimpleName().toString());
+                li.addContent(utils.asTypeElement(type).getSimpleName());
                 li.addContent(typeParameters);
             } else {
-                li.addContent(utils.asTypeElement(type).getQualifiedName().toString());
+                li.addContent(utils.asTypeElement(type).getQualifiedName());
                 li.addContent(typeParameters);
             }
         } else {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Wed Feb 24 15:31:36 2016 -0800
@@ -244,7 +244,7 @@
         PackageElement enclosingPackage  = utils.containingPackage(typeElement);
         if (!enclosingPackage.isUnnamed()) {
             Content cb = new ContentBuilder();
-            cb.addContent(enclosingPackage.getQualifiedName().toString());
+            cb.addContent(enclosingPackage.getQualifiedName());
             cb.addContent(".");
             cb.addContent(classlink);
             return getClassName(cb);
@@ -332,7 +332,7 @@
      */
     private Content getNameColumn(VariableElement member) {
         Content nameContent = getDocLink(LinkInfoImpl.Kind.CONSTANT_SUMMARY,
-                member, member.getSimpleName().toString(), false);
+                member, member.getSimpleName(), false);
         Content code = HtmlTree.CODE(nameContent);
         return HtmlTree.TD(code);
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Wed Feb 24 15:31:36 2016 -0800
@@ -166,6 +166,8 @@
 
     HtmlTree fixedNavDiv = new HtmlTree(HtmlTag.DIV);
 
+    final static Pattern IMPROPER_HTML_CHARS = Pattern.compile(".*[&<>].*");
+
     /**
      * Constructor to construct the HtmlStandardWriter object.
      *
@@ -945,7 +947,7 @@
     public Content getPackageName(PackageElement packageElement) {
         return packageElement == null || packageElement.isUnnamed()
                 ? defaultPackageLabel
-                : getPackageLabel(packageElement.getQualifiedName().toString());
+                : getPackageLabel(packageElement.getQualifiedName());
     }
 
     /**
@@ -954,7 +956,7 @@
      * @param packageName the package name
      * @return the package name content
      */
-    public Content getPackageLabel(String packageName) {
+    public Content getPackageLabel(CharSequence packageName) {
         return new StringContent(packageName);
     }
 
@@ -1038,7 +1040,7 @@
      * @param label the label for the link.
      * @return a content tree for the package link.
      */
-    public Content getPackageLink(PackageElement packageElement, String label) {
+    public Content getPackageLink(PackageElement packageElement, CharSequence label) {
         return getPackageLink(packageElement, new StringContent(label));
     }
 
@@ -1081,7 +1083,7 @@
 
     public Content interfaceName(TypeElement typeElement, boolean qual) {
         Content name = new StringContent((qual)
-                ? typeElement.getQualifiedName().toString()
+                ? typeElement.getQualifiedName()
                 : utils.getSimpleName(typeElement));
         return (utils.isInterface(typeElement)) ?  HtmlTree.SPAN(HtmlStyle.interfaceName, name) : name;
     }
@@ -1279,7 +1281,7 @@
      * @param label the label for the link
      * @return a content tree for the element link
      */
-    public Content getDocLink(LinkInfoImpl.Kind context, Element element, String label) {
+    public Content getDocLink(LinkInfoImpl.Kind context, Element element, CharSequence label) {
         return getDocLink(context, utils.getEnclosingTypeElement(element), element,
                 new StringContent(label));
     }
@@ -1293,7 +1295,7 @@
      * @param strong true if the link should be strong.
      * @return the link for the given member.
      */
-    public Content getDocLink(LinkInfoImpl.Kind context, Element element, String label,
+    public Content getDocLink(LinkInfoImpl.Kind context, Element element, CharSequence label,
             boolean strong) {
         return getDocLink(context, utils.getEnclosingTypeElement(element), element, label, strong);
     }
@@ -1311,7 +1313,7 @@
      * @return the link for the given member.
      */
     public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
-            String label, boolean strong) {
+            CharSequence label, boolean strong) {
         return getDocLink(context, typeElement, element, label, strong, false);
     }
 
@@ -1334,13 +1336,14 @@
      * @return the link for the given member.
      */
     public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
-            String label, boolean strong, boolean isProperty) {
+            CharSequence label, boolean strong, boolean isProperty) {
         return getDocLink(context, typeElement, element, new StringContent(check(label)), strong, isProperty);
     }
 
-    String check(String s) {
-        if (s.matches(".*[&<>].*")) {
-            throw new IllegalArgumentException(s);
+    CharSequence check(CharSequence s) {
+        Matcher m = IMPROPER_HTML_CHARS.matcher(s);
+        if (m.matches()) {
+            throw new IllegalArgumentException(s.toString());
         }
         return s;
     }
@@ -1426,7 +1429,7 @@
 
         CommentHelper ch = utils.getCommentHelper(element);
         String tagName = ch.getTagName(see);
-        String seetext = replaceDocRootDir(utils.normalizeNewlines(ch.getText(see)));
+        String seetext = replaceDocRootDir(utils.normalizeNewlines(ch.getText(see)).toString());
         // Check if @see is an href or "string"
         if (seetext.startsWith("<") || seetext.startsWith("\"")) {
             return new RawHtml(seetext);
@@ -1452,7 +1455,7 @@
                 //@see is referencing an included package
                 if (label.isEmpty())
                     label = plainOrCode(isLinkPlain,
-                            new StringContent(refPackage.getQualifiedName().toString()));
+                            new StringContent(refPackage.getQualifiedName()));
                 return getPackageLink(refPackage, label);
             } else {
                 // @see is not referencing an included class or package.  Check for cross links.
@@ -1695,7 +1698,7 @@
 
         final Content result = new ContentBuilder() {
             @Override
-            public void addContent(String text) {
+            public void addContent(CharSequence text) {
                 super.addContent(utils.normalizeNewlines(text));
             }
         };
@@ -1741,7 +1744,7 @@
                 public Boolean visitAttribute(AttributeTree node, Content c) {
                     StringBuilder sb = new StringBuilder(SPACER).append(node.getName());
                     if (node.getValueKind() == ValueKind.EMPTY) {
-                        result.addContent(sb.toString());
+                        result.addContent(sb);
                         return false;
                     }
                     sb.append("=");
@@ -1758,7 +1761,7 @@
                             break;
                     }
                     sb.append(quote);
-                    result.addContent(sb.toString());
+                    result.addContent(sb);
                     Content docRootContent = new ContentBuilder();
 
                     for (DocTree dt : node.getValue()) {
@@ -1767,16 +1770,15 @@
                             if (text.startsWith("/..") && !configuration.docrootparent.isEmpty()) {
                                 result.addContent(configuration.docrootparent);
                                 docRootContent = new ContentBuilder();
-                                text = textCleanup(text.substring(3), isLast(node));
+                                result.addContent(textCleanup(text.substring(3), isLast(node)));
                             } else {
                                 if (!docRootContent.isEmpty()) {
                                     docRootContent = copyDocRootContent(docRootContent);
                                 } else {
                                     text = redirectRelativeLinks(element, (TextTree) dt);
                                 }
-                                text = textCleanup(text, isLast(node));
+                                result.addContent(textCleanup(text, isLast(node)));
                             }
-                            result.addContent(text);
                         } else {
                             docRootContent = copyDocRootContent(docRootContent);
                             dt.accept(this, docRootContent);
@@ -1889,8 +1891,7 @@
                 @Override @DefinedBy(Api.COMPILER_TREE)
                 public Boolean visitStartElement(StartElementTree node, Content c) {
                     String text = "<" + node.getName();
-                    text = utils.normalizeNewlines(text);
-                    RawHtml rawHtml = new RawHtml(text);
+                    RawHtml rawHtml = new RawHtml(utils.normalizeNewlines(text));
                     result.addContent(rawHtml);
 
                     for (DocTree dt : node.getAttributes()) {
@@ -1900,11 +1901,11 @@
                     return false;
                 }
 
-                private String textCleanup(String text, boolean isLast) {
+                private CharSequence textCleanup(String text, boolean isLast) {
                     return textCleanup(text, isLast, false);
                 }
 
-                private String textCleanup(String text, boolean isLast, boolean trimLeader) {
+                private CharSequence textCleanup(String text, boolean isLast, boolean trimLeader) {
                     if (trimLeader) {
                         text = removeLeadingWhitespace(text);
                     }
@@ -1912,16 +1913,14 @@
                         text = removeTrailingWhitespace(text);
                     }
                     text = utils.replaceTabs(text);
-                    text = utils.normalizeNewlines(text);
-                    return text;
+                    return utils.normalizeNewlines(text);
                 }
 
                 @Override @DefinedBy(Api.COMPILER_TREE)
                 public Boolean visitText(TextTree node, Content c) {
                     String text = node.getBody();
-                    text = textCleanup(text, isLast(node), commentRemoved);
+                    result.addContent(new RawHtml(textCleanup(text, isLast(node), commentRemoved)));
                     commentRemoved = false;
-                    result.addContent(new RawHtml(text));
                     return false;
                 }
 
@@ -2358,7 +2357,8 @@
     private void addAnnotations(TypeElement annotationDoc, LinkInfoImpl linkInfo,
         ContentBuilder annotation, Map<? extends ExecutableElement,? extends AnnotationValue>map,
         int indent, boolean linkBreak) {
-        linkInfo.label = new StringContent("@" + annotationDoc.getSimpleName().toString());
+        linkInfo.label = new StringContent("@");
+        linkInfo.label.addContent(annotationDoc.getSimpleName());
         annotation.addContent(getLink(linkInfo));
         if (!map.isEmpty()) {
             annotation.addContent("(");
@@ -2372,7 +2372,7 @@
                     annotation.addContent(",");
                     if (linkBreak) {
                         annotation.addContent(DocletConstants.NL);
-                        int spaces = annotationDoc.getSimpleName().toString().length() + 2;
+                        int spaces = annotationDoc.getSimpleName().length() + 2;
                         for (int k = 0; k < (spaces + indent); k++) {
                             annotation.addContent(" ");
                         }
@@ -2496,7 +2496,7 @@
             @Override @DefinedBy(Api.LANGUAGE_MODEL)
             public Content visitEnumConstant(VariableElement c, Void p) {
                 return getDocLink(LinkInfoImpl.Kind.ANNOTATION,
-                        c, c.getSimpleName().toString(), false);
+                        c, c.getSimpleName(), false);
             }
             @Override @DefinedBy(Api.LANGUAGE_MODEL)
             public Content visitArray(List<? extends AnnotationValue> vals, Void p) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java	Wed Feb 24 15:31:36 2016 -0800
@@ -294,7 +294,7 @@
      * Set the label for the link.
      * @param label plain-text label for the link
      */
-    public LinkInfoImpl label(String label) {
+    public LinkInfoImpl label(CharSequence label) {
         this.label = new StringContent(label);
         return this;
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Wed Feb 24 15:31:36 2016 -0800
@@ -356,11 +356,10 @@
             Content overriddenTypeLink =
                     writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType));
             Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink);
-            String name = method.getSimpleName().toString();
             Content methlink = writer.getLink(
                     new LinkInfoImpl(writer.configuration, LinkInfoImpl.Kind.MEMBER,
                     holder)
-                    .where(writer.getName(writer.getAnchor(method))).label(name));
+                    .where(writer.getName(writer.getAnchor(method))).label(method.getSimpleName()));
             Content codeMethLink = HtmlTree.CODE(methlink);
             Content dd = HtmlTree.DD(codeMethLink);
             dd.addContent(writer.getSpace());
@@ -395,7 +394,7 @@
             dl.addContent(dt);
             Content methlink = writer.getDocLink(
                     LinkInfoImpl.Kind.MEMBER, implementedMeth,
-                    implementedMeth.getSimpleName().toString(), false);
+                    implementedMeth.getSimpleName(), false);
             Content codeMethLink = HtmlTree.CODE(methlink);
             Content dd = HtmlTree.DD(codeMethLink);
             dd.addContent(writer.getSpace());
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java	Wed Feb 24 15:31:36 2016 -0800
@@ -123,7 +123,7 @@
             packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
                     packageLabel, "", "packageFrame");
         } else {
-            packageLabel = getPackageLabel(pe.getQualifiedName().toString());
+            packageLabel = getPackageLabel(pe.getQualifiedName());
             packageLinkContent = getHyperLink(pathString(pe,
                      DocPaths.PACKAGE_FRAME), packageLabel, "",
                     "packageFrame");
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java	Wed Feb 24 15:31:36 2016 -0800
@@ -158,7 +158,7 @@
                         writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_COPY,
                         holder, property,
                         utils.isIncluded(holder)
-                                ? holder.toString() : utils.getFullyQualifiedName(holder),
+                                ? holder.getSimpleName() : holder.getQualifiedName(),
                             false);
                 Content codeLink = HtmlTree.CODE(link);
                 Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel,
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Wed Feb 24 15:31:36 2016 -0800
@@ -91,8 +91,7 @@
      */
     protected Content codeTagOutput(Element element, DocTree tag) {
         CommentHelper ch = utils.getCommentHelper(element);
-        String str = utils.normalizeNewlines(ch.getText(tag));
-        StringContent content = new StringContent(str);
+        StringContent content = new StringContent(utils.normalizeNewlines(ch.getText(tag)));
         Content result = HtmlTree.CODE(content);
         return result;
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java	Wed Feb 24 15:31:36 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -75,7 +75,8 @@
      *                              DocletAbortException because it
      *                              is not supported.
      */
-    public void addContent(String stringContent) {
+    @Override
+    public void addContent(CharSequence stringContent) {
         throw new DocletAbortException("not supported");
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java	Wed Feb 24 15:31:36 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -50,8 +50,8 @@
     }
 
     @Override
-    public void addContent(String text) {
-        if (text.isEmpty())
+    public void addContent(CharSequence text) {
+        if (text.length() == 0)
             return;
         ensureMutableContents();
         Content c = contents.isEmpty() ? null : contents.get(contents.size() - 1);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/DocType.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/DocType.java	Wed Feb 24 15:31:36 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -89,7 +89,8 @@
      *                              DocletAbortException because it
      *                              is not supported.
      */
-    public void addContent(String stringContent) {
+    @Override
+    public void addContent(CharSequence stringContent) {
         throw new DocletAbortException("not supported");
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocument.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocument.java	Wed Feb 24 15:31:36 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -90,7 +90,8 @@
      *                              DocletAbortException because it
      *                              is not supported.
      */
-    public void addContent(String stringContent) {
+    @Override
+    public void addContent(CharSequence stringContent) {
         throw new DocletAbortException("not supported");
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java	Wed Feb 24 15:31:36 2016 -0800
@@ -132,7 +132,8 @@
      *
      * @param stringContent string content that needs to be added
      */
-    public void addContent(String stringContent) {
+    @Override
+    public void addContent(CharSequence stringContent) {
         if (!content.isEmpty()) {
             Content lastContent = content.get(content.size() - 1);
             if (lastContent instanceof StringContent)
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java	Wed Feb 24 15:31:36 2016 -0800
@@ -475,7 +475,7 @@
         addStyles(HtmlStyle.rowColor, vars);
         addStyles(HtmlStyle.tableTab, vars);
         addStyles(HtmlStyle.activeTableTab, vars);
-        script.addContent(new RawHtml(vars.toString()));
+        script.addContent(new RawHtml(vars));
     }
 
     /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java	Wed Feb 24 15:31:36 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -53,8 +53,8 @@
      *
      * @param rawHtml raw HTML text to be added
      */
-    public RawHtml(String rawHtml) {
-        rawHtmlContent = nullCheck(rawHtml);
+    public RawHtml(CharSequence rawHtml) {
+        rawHtmlContent = rawHtml.toString();
     }
 
     /**
@@ -77,7 +77,8 @@
      *                              DocletAbortException because it
      *                              is not supported.
      */
-    public void addContent(String stringContent) {
+    @Override
+    public void addContent(CharSequence stringContent) {
         throw new DocletAbortException("not supported");
     }
 
@@ -103,7 +104,7 @@
         return charCount(rawHtmlContent);
     }
 
-    static int charCount(String htmlText) {
+    static int charCount(CharSequence htmlText) {
         State state = State.TEXT;
         int count = 0;
         for (int i = 0; i < htmlText.length(); i++) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java	Wed Feb 24 15:31:36 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -58,7 +58,7 @@
      *
      * @param initialContent initial content for the object
      */
-    public StringContent(String initialContent) {
+    public StringContent(CharSequence initialContent) {
         stringContent = new StringBuilder();
         appendChars(initialContent);
     }
@@ -83,7 +83,7 @@
      * @param strContent string content to be added
      */
     @Override
-    public void addContent(String strContent) {
+    public void addContent(CharSequence strContent) {
         appendChars(strContent);
     }
 
@@ -118,7 +118,7 @@
         return s.endsWith(DocletConstants.NL);
     }
 
-    private void appendChars(String s) {
+    private void appendChars(CharSequence s) {
         for (int i = 0; i < s.length(); i++) {
             char ch = s.charAt(i);
             switch (ch) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java	Wed Feb 24 15:31:36 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -74,7 +74,7 @@
      *
      * @param stringContent the string content to be added
      */
-    public abstract void addContent(String stringContent);
+    public abstract void addContent(CharSequence stringContent);
 
     /**
      * Writes content to a writer.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Thu Mar 10 14:47:14 2016 -0800
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Wed Feb 24 15:31:36 2016 -0800
@@ -1356,7 +1356,7 @@
         return result.toString();
     }
 
-    public String normalizeNewlines(String text) {
+    public CharSequence normalizeNewlines(CharSequence text) {
         StringBuilder sb = new StringBuilder();
         final int textLength = text.length();
         final String NL = DocletConstants.NL;
@@ -1379,7 +1379,7 @@
             }
         }
         sb.append(text, pos, textLength);
-        return sb.toString();
+        return sb;
     }
 
     /**
@@ -1746,6 +1746,8 @@
      * A generic utility which returns the fully qualified names of an entity,
      * if the entity is not qualifiable then its enclosing entity, it is upto
      * the caller to add the elements name as required.
+     * @param e the element to get FQN for.
+     * @return the name
      */
     public String getFullyQualifiedName(Element e) {
         return getFullyQualifiedName(e, true);