6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
Reviewed-by: bpatel
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -156,7 +156,7 @@
if (index < 0) {
return htmlstr;
}
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
int previndex = 0;
while (true) {
// Search for lowercase version of {@docRoot}
@@ -2279,7 +2279,7 @@
*/
public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags,
boolean isFirstSentence) {
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
// Array of all possible inline tags for this javadoc run
configuration.tagletManager.checkTags(doc, tags, true);
for (int i = 0; i < tags.length; i++) {
@@ -2315,7 +2315,7 @@
StringTokenizer lines = new StringTokenizer(text, "\r\n", true);
StringBuffer textBuff = new StringBuffer();
while (lines.hasMoreTokens()) {
- StringBuffer line = new StringBuffer(lines.nextToken());
+ StringBuilder line = new StringBuilder(lines.nextToken());
Util.replaceTabs(configuration.sourcetab, line);
textBuff.append(line.toString());
}
@@ -2473,7 +2473,7 @@
return text;
}
int endindex = startindex + tobe.length();
- StringBuffer replaced = new StringBuffer();
+ StringBuilder replaced = new StringBuilder();
if (startindex > 0) {
replaced.append(text.substring(0, startindex));
}
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -30,7 +30,6 @@
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.doclets.formats.html.markup.*;
/**
@@ -53,7 +52,7 @@
}
public List<FieldDoc> members(ClassDoc cd) {
- return Util.asList(cd.serializableFields());
+ return Arrays.asList(cd.serializableFields());
}
protected void printTypeLinkNoDimension(Type type) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -266,7 +266,7 @@
private static void addLine(Content pre, String line, int tabLength,
int currentLineNo) {
if (line != null) {
- StringBuffer lineBuffer = new StringBuffer(Util.escapeHtmlChars(line));
+ StringBuilder lineBuffer = new StringBuilder(Util.escapeHtmlChars(line));
Util.replaceTabs(tabLength, lineBuffer);
pre.addContent(new RawHtml(lineBuffer.toString()));
Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo));
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -375,8 +375,7 @@
*/
public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) {
if (classDoc.definesSerializableFields()) {
- FieldDoc serialPersistentField =
- Util.asList(classDoc.serializableFields()).get(0);
+ FieldDoc serialPersistentField = classDoc.serializableFields()[0];
// Check to see if there are inline comments, tags or deprecation
// information to be printed.
if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, 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
@@ -382,7 +382,7 @@
out.close();
}
} catch (IOException ie) {
- ie.printStackTrace();
+ ie.printStackTrace(System.err);
throw new DocletAbortException();
}
}
@@ -399,12 +399,12 @@
String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc);
String completePath = new SourcePath(configuration.sourcepath).
getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR;
- //Make sure that both paths are using the same seperators.
+ //Make sure that both paths are using the same separators.
completePath = Util.replaceText(completePath, File.separator,
DirectoryManager.URL_FILE_SEPARATOR);
pkgPath = Util.replaceText(pkgPath, File.separator,
DirectoryManager.URL_FILE_SEPARATOR);
- return completePath.substring(0, completePath.indexOf(pkgPath));
+ return completePath.substring(0, completePath.lastIndexOf(pkgPath));
} catch (Exception e){
return "";
}
@@ -536,15 +536,6 @@
findAllInterfaceTypes(results, (ClassDoc) type, true, configuration);
}
-
- public static <T extends ProgramElementDoc> List<T> asList(T[] members) {
- List<T> list = new ArrayList<T>();
- for (int i = 0; i < members.length; i++) {
- list.add(members[i]);
- }
- return list;
- }
-
/**
* Enclose in quotes, used for paths and filenames that contains spaces
*/
@@ -583,14 +574,7 @@
if (oldStr == null || newStr == null || oldStr.equals(newStr)) {
return originalStr;
}
- StringBuffer result = new StringBuffer(originalStr);
- int startIndex = 0;
- while ((startIndex = result.indexOf(oldStr, startIndex)) != -1) {
- result = result.replace(startIndex, startIndex + oldStr.length(),
- newStr);
- startIndex += newStr.length();
- }
- return result.toString();
+ return originalStr.replace(oldStr, newStr);
}
/**
@@ -833,19 +817,17 @@
* @param tabLength the length of each tab.
* @param s the String to scan.
*/
- public static void replaceTabs(int tabLength, StringBuffer s) {
- int index, col;
- StringBuffer whitespace;
- while ((index = s.indexOf("\t")) != -1) {
- whitespace = new StringBuffer();
- col = index;
- do {
- whitespace.append(" ");
- col++;
- } while ((col%tabLength) != 0);
- s.replace(index, index+1, whitespace.toString());
+ public static void replaceTabs(int tabLength, StringBuilder s) {
+ if (whitespace == null || whitespace.length() < tabLength)
+ whitespace = String.format("%" + tabLength + "s", " ");
+ int index = 0;
+ while ((index = s.indexOf("\t", index)) != -1) {
+ int spaceCount = tabLength - index % tabLength;
+ s.replace(index, index+1, whitespace.substring(0, spaceCount));
+ index += spaceCount;
}
}
+ private static String whitespace;
/**
* The documentation for values() and valueOf() in Enums are set by the
--- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -92,8 +92,9 @@
* @com.example.foo
* Omit parens for marker annotations, and omit "value=" when allowed.
*/
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer("@");
+ StringBuilder sb = new StringBuilder("@");
sb.append(annotation.type.tsym);
ElementValuePair vals[] = elementValues();
@@ -153,6 +154,7 @@
* Returns a string representation of this pair
* of the form "name=value".
*/
+ @Override
public String toString() {
return meth.name + "=" + value();
}
--- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -30,7 +30,6 @@
import com.sun.tools.javac.code.Attribute;
import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.TypeTags;
@@ -114,6 +113,7 @@
* @return the text of a Java language annotation value expression
* whose value is the value of this annotation type element.
*/
+ @Override
public String toString() {
ToStringVisitor tv = new ToStringVisitor();
attr.accept(tv);
@@ -121,8 +121,9 @@
}
private class ToStringVisitor implements Attribute.Visitor {
- private final StringBuffer sb = new StringBuffer();
+ private final StringBuilder sb = new StringBuilder();
+ @Override
public String toString() {
return sb.toString();
}
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -64,7 +64,6 @@
import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Position;
-import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Kinds.*;
/**
@@ -147,6 +146,7 @@
/**
* Return true if this is a class, not an interface.
*/
+ @Override
public boolean isClass() {
return !Modifier.isInterface(getModifiers());
}
@@ -155,6 +155,7 @@
* Return true if this is a ordinary class,
* not an enumeration, exception, an error, or an interface.
*/
+ @Override
public boolean isOrdinaryClass() {
if (isEnum() || isInterface() || isAnnotationType()) {
return false;
@@ -172,6 +173,7 @@
* Return true if this is an enumeration.
* (For legacy doclets, return false.)
*/
+ @Override
public boolean isEnum() {
return (getFlags() & Flags.ENUM) != 0
&&
@@ -182,6 +184,7 @@
* Return true if this is an interface, but not an annotation type.
* Overridden by AnnotationTypeDocImpl.
*/
+ @Override
public boolean isInterface() {
return Modifier.isInterface(getModifiers());
}
@@ -189,6 +192,7 @@
/**
* Return true if this is an exception class
*/
+ @Override
public boolean isException() {
if (isEnum() || isInterface() || isAnnotationType()) {
return false;
@@ -204,6 +208,7 @@
/**
* Return true if this is an error class
*/
+ @Override
public boolean isError() {
if (isEnum() || isInterface() || isAnnotationType()) {
return false;
@@ -275,6 +280,7 @@
/**
* Return the package that this class is contained in.
*/
+ @Override
public PackageDoc containingPackage() {
PackageDocImpl p = env.getPackageDoc(tsym.packge());
if (p.setDocPath == false) {
@@ -374,6 +380,7 @@
* Return the qualified name and any type parameters.
* Each parameter is a type variable with optional bounds.
*/
+ @Override
public String toString() {
return classToString(env, tsym, true);
}
@@ -401,7 +408,7 @@
* qualified by their enclosing class(es) only.
*/
static String classToString(DocEnv env, ClassSymbol c, boolean full) {
- StringBuffer s = new StringBuffer();
+ StringBuilder s = new StringBuilder();
if (!c.isInner()) { // if c is not an inner class
s.append(getClassName(c, full));
} else {
@@ -449,10 +456,12 @@
* Return the modifier string for this class. If it's an interface
* exclude 'abstract' keyword from the modifier string
*/
+ @Override
public String modifiers() {
return Modifier.toString(modifierSpecifier());
}
+ @Override
public int modifierSpecifier() {
int modifiers = getModifiers();
return (isInterface() || isAnnotationType())
@@ -1285,6 +1294,7 @@
* Return the source position of the entity, or null if
* no position is available.
*/
+ @Override
public SourcePosition position() {
if (tsym.sourcefile == null) return null;
return SourcePositionImpl.make(tsym.sourcefile,
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -226,7 +226,7 @@
}
private String makeSignature(boolean full) {
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
result.append("(");
for (List<Type> types = sym.type.getParameterTypes(); types.nonEmpty(); ) {
Type t = types.head;
@@ -251,6 +251,7 @@
/**
* Generate a key for sorting.
*/
+ @Override
CollationKey generateKey() {
String k = name() + flatSignature() + typeParametersString();
// ',' and '&' are between '$' and 'a': normalize to spaces.
@@ -263,6 +264,7 @@
* Return the source position of the entity, or null if
* no position is available.
*/
+ @Override
public SourcePosition position() {
if (sym.enclClass().sourcefile == null) return null;
return SourcePositionImpl.make(sym.enclClass().sourcefile,
--- a/langtools/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -142,7 +142,7 @@
return v + (suffix == 'f' || suffix == 'F' ? "" + suffix : "");
}
private static String sourceForm(char c) {
- StringBuffer buf = new StringBuffer(8);
+ StringBuilder buf = new StringBuilder(8);
buf.append('\'');
sourceChar(c, buf);
buf.append('\'');
@@ -152,7 +152,7 @@
return "0x" + Integer.toString(c & 0xff, 16);
}
private static String sourceForm(String s) {
- StringBuffer buf = new StringBuffer(s.length() + 5);
+ StringBuilder buf = new StringBuilder(s.length() + 5);
buf.append('\"');
for (int i=0; i<s.length(); i++) {
char c = s.charAt(i);
@@ -161,7 +161,7 @@
buf.append('\"');
return buf.toString();
}
- private static void sourceChar(char c, StringBuffer buf) {
+ private static void sourceChar(char c, StringBuilder buf) {
switch (c) {
case '\b': buf.append("\\b"); return;
case '\t': buf.append("\\t"); return;
@@ -179,7 +179,7 @@
return;
}
}
- private static void unicodeEscape(char c, StringBuffer buf) {
+ private static void unicodeEscape(char c, StringBuilder buf) {
final String chars = "0123456789abcdef";
buf.append("\\u");
buf.append(chars.charAt(15 & (c>>12)));
@@ -201,6 +201,7 @@
/**
* Is this Doc item a field (but not an enum constant?
*/
+ @Override
public boolean isField() {
return !isEnumConstant();
}
@@ -209,6 +210,7 @@
* Is this Doc item an enum constant?
* (For legacy doclets, return false.)
*/
+ @Override
public boolean isEnumConstant() {
return (getFlags() & Flags.ENUM) != 0 &&
!env.legacyDoclet;
@@ -257,6 +259,7 @@
* Return the source position of the entity, or null if
* no position is available.
*/
+ @Override
public SourcePosition position() {
if (sym.enclClass().sourcefile == null) return null;
return SourcePositionImpl.make(sym.enclClass().sourcefile,
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -25,15 +25,11 @@
package com.sun.tools.javadoc;
-
import com.sun.javadoc.*;
-import static com.sun.javadoc.LanguageVersion.*;
-
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.Type.ClassType;
-import com.sun.tools.javac.util.List;
import static com.sun.tools.javac.code.TypeTags.*;
@@ -55,6 +51,7 @@
/**
* Return the generic class or interface that declared this type.
*/
+ @Override
public ClassDoc asClassDoc() {
return env.getClassDoc((ClassSymbol)type.tsym);
}
@@ -111,14 +108,17 @@
// Asking for the "name" of a parameterized type doesn't exactly make
// sense. It's a type expression. Return the name of its generic
// type.
+ @Override
public String typeName() {
return TypeMaker.getTypeName(type, false);
}
+ @Override
public ParameterizedType asParameterizedType() {
return this;
}
+ @Override
public String toString() {
return parameterizedTypeToString(env, (ClassType)type, true);
}
@@ -128,7 +128,7 @@
if (env.legacyDoclet) {
return TypeMaker.getTypeName(cl, full);
}
- StringBuffer s = new StringBuffer();
+ StringBuilder s = new StringBuilder();
if (cl.getEnclosingType().tag != CLASS) { // if not an inner class...
s.append(TypeMaker.getTypeName(cl, full));
} else {
--- a/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -358,14 +358,14 @@
String parameters;
- StringBuffer typeId;
+ StringBuilder typeId;
ListBuffer<String> paramList;
ParameterParseMachine(String parameters) {
this.parameters = parameters;
this.paramList = new ListBuffer<String>();
- typeId = new StringBuffer();
+ typeId = new StringBuilder();
}
public String[] parseParameters() {
@@ -464,6 +464,7 @@
/**
* Return the kind of this tag.
*/
+ @Override
public String kind() {
return "@see";
}
--- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -27,15 +27,12 @@
import com.sun.javadoc.*;
-import static com.sun.javadoc.LanguageVersion.*;
-
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.Type.ClassType;
import com.sun.tools.javac.code.Type.TypeVar;
import com.sun.tools.javac.code.Type.ArrayType;
-import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.util.List;
import static com.sun.tools.javac.code.TypeTags.*;
@@ -109,12 +106,13 @@
public static String getTypeName(Type t, boolean full) {
switch (t.tag) {
case ARRAY:
- StringBuffer dimension = new StringBuffer();
+ StringBuilder s = new StringBuilder();
while (t.tag == ARRAY) {
- dimension = dimension.append("[]");
+ s.append("[]");
t = ((ArrayType)t).elemtype;
}
- return getTypeName(t, full) + dimension;
+ s.insert(0, getTypeName(t, full));
+ return s.toString();
case CLASS:
return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
default:
@@ -130,12 +128,13 @@
static String getTypeString(DocEnv env, Type t, boolean full) {
switch (t.tag) {
case ARRAY:
- StringBuffer dimension = new StringBuffer();
+ StringBuilder s = new StringBuilder();
while (t.tag == ARRAY) {
- dimension = dimension.append("[]");
+ s.append("[]");
t = env.types.elemtype(t);
}
- return getTypeString(env, t, full) + dimension;
+ s.insert(0, getTypeString(env, t, full));
+ return s.toString();
case CLASS:
return ParameterizedTypeImpl.
parameterizedTypeToString(env, (ClassType)t, full);
@@ -157,7 +156,7 @@
if (env.legacyDoclet || sym.type.getTypeArguments().isEmpty()) {
return "";
}
- StringBuffer s = new StringBuffer();
+ StringBuilder s = new StringBuilder();
for (Type t : sym.type.getTypeArguments()) {
s.append(s.length() == 0 ? "<" : ", ");
s.append(TypeVariableImpl.typeVarToString(env, (TypeVar)t, full));
@@ -175,7 +174,7 @@
if (env.legacyDoclet || cl.getTypeArguments().isEmpty()) {
return "";
}
- StringBuffer s = new StringBuffer();
+ StringBuilder s = new StringBuilder();
for (Type t : cl.getTypeArguments()) {
s.append(s.length() == 0 ? "<" : ", ");
s.append(getTypeString(env, t, full));
@@ -213,9 +212,9 @@
* For example, a two dimensional array of String returns '[][]'.
*/
public String dimension() {
- StringBuffer dimension = new StringBuffer();
+ StringBuilder dimension = new StringBuilder();
for (Type t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) {
- dimension = dimension.append("[]");
+ dimension.append("[]");
}
return dimension.toString();
}
@@ -304,6 +303,7 @@
*
* @return name of type including any dimension information.
*/
+ @Override
public String toString() {
return qualifiedTypeName() + dimension();
}
--- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -78,14 +78,17 @@
/**
* Return the ClassDoc of the erasure of this type variable.
*/
+ @Override
public ClassDoc asClassDoc() {
return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym);
}
+ @Override
public TypeVariable asTypeVariable() {
return this;
}
+ @Override
public String toString() {
return typeVarToString(env, (TypeVar)type, true);
}
@@ -96,7 +99,7 @@
* "extends" clause. Class names are qualified if "full" is true.
*/
static String typeVarToString(DocEnv env, TypeVar v, boolean full) {
- StringBuffer s = new StringBuffer(v.toString());
+ StringBuilder s = new StringBuilder(v.toString());
List<Type> bounds = getBounds(v, env);
if (bounds.nonEmpty()) {
boolean first = true;
--- a/langtools/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java Fri Mar 04 11:33:37 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java Fri Mar 04 19:53:03 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -28,8 +28,6 @@
import com.sun.javadoc.*;
-import static com.sun.javadoc.LanguageVersion.*;
-
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.util.List;
@@ -69,18 +67,24 @@
/**
* Return the ClassDoc of the erasure of this wildcard type.
*/
+ @Override
public ClassDoc asClassDoc() {
return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym);
}
+ @Override
public WildcardType asWildcardType() {
return this;
}
+ @Override
public String typeName() { return "?"; }
+ @Override
public String qualifiedTypeName() { return "?"; }
+ @Override
public String simpleTypeName() { return "?"; }
+ @Override
public String toString() {
return wildcardTypeToString(env, (Type.WildcardType)type, true);
}
@@ -96,7 +100,7 @@
if (env.legacyDoclet) {
return TypeMaker.getTypeName(env.types.erasure(wildThing), full);
}
- StringBuffer s = new StringBuffer("?");
+ StringBuilder s = new StringBuilder("?");
List<Type> bounds = getExtendsBounds(wildThing);
if (bounds.nonEmpty()) {
s.append(" extends ");