Fri, 04 Mar 2011 19:53:03 -0800
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
Reviewed-by: bpatel
1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Fri Mar 04 11:33:37 2011 -0800 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Fri Mar 04 19:53:03 2011 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -156,7 +156,7 @@ 1.11 if (index < 0) { 1.12 return htmlstr; 1.13 } 1.14 - StringBuffer buf = new StringBuffer(); 1.15 + StringBuilder buf = new StringBuilder(); 1.16 int previndex = 0; 1.17 while (true) { 1.18 // Search for lowercase version of {@docRoot} 1.19 @@ -2279,7 +2279,7 @@ 1.20 */ 1.21 public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags, 1.22 boolean isFirstSentence) { 1.23 - StringBuffer result = new StringBuffer(); 1.24 + StringBuilder result = new StringBuilder(); 1.25 // Array of all possible inline tags for this javadoc run 1.26 configuration.tagletManager.checkTags(doc, tags, true); 1.27 for (int i = 0; i < tags.length; i++) { 1.28 @@ -2315,7 +2315,7 @@ 1.29 StringTokenizer lines = new StringTokenizer(text, "\r\n", true); 1.30 StringBuffer textBuff = new StringBuffer(); 1.31 while (lines.hasMoreTokens()) { 1.32 - StringBuffer line = new StringBuffer(lines.nextToken()); 1.33 + StringBuilder line = new StringBuilder(lines.nextToken()); 1.34 Util.replaceTabs(configuration.sourcetab, line); 1.35 textBuff.append(line.toString()); 1.36 } 1.37 @@ -2473,7 +2473,7 @@ 1.38 return text; 1.39 } 1.40 int endindex = startindex + tobe.length(); 1.41 - StringBuffer replaced = new StringBuffer(); 1.42 + StringBuilder replaced = new StringBuilder(); 1.43 if (startindex > 0) { 1.44 replaced.append(text.substring(0, startindex)); 1.45 }
2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java Fri Mar 04 11:33:37 2011 -0800 2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java Fri Mar 04 19:53:03 2011 -0800 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -30,7 +30,6 @@ 2.11 import com.sun.javadoc.*; 2.12 import com.sun.tools.doclets.internal.toolkit.*; 2.13 import com.sun.tools.doclets.internal.toolkit.taglets.*; 2.14 -import com.sun.tools.doclets.internal.toolkit.util.*; 2.15 import com.sun.tools.doclets.formats.html.markup.*; 2.16 2.17 /** 2.18 @@ -53,7 +52,7 @@ 2.19 } 2.20 2.21 public List<FieldDoc> members(ClassDoc cd) { 2.22 - return Util.asList(cd.serializableFields()); 2.23 + return Arrays.asList(cd.serializableFields()); 2.24 } 2.25 2.26 protected void printTypeLinkNoDimension(Type type) {
3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java Fri Mar 04 11:33:37 2011 -0800 3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java Fri Mar 04 19:53:03 2011 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -266,7 +266,7 @@ 3.11 private static void addLine(Content pre, String line, int tabLength, 3.12 int currentLineNo) { 3.13 if (line != null) { 3.14 - StringBuffer lineBuffer = new StringBuffer(Util.escapeHtmlChars(line)); 3.15 + StringBuilder lineBuffer = new StringBuilder(Util.escapeHtmlChars(line)); 3.16 Util.replaceTabs(tabLength, lineBuffer); 3.17 pre.addContent(new RawHtml(lineBuffer.toString())); 3.18 Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo));
4.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Fri Mar 04 11:33:37 2011 -0800 4.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Fri Mar 04 19:53:03 2011 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -375,8 +375,7 @@ 4.11 */ 4.12 public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) { 4.13 if (classDoc.definesSerializableFields()) { 4.14 - FieldDoc serialPersistentField = 4.15 - Util.asList(classDoc.serializableFields()).get(0); 4.16 + FieldDoc serialPersistentField = classDoc.serializableFields()[0]; 4.17 // Check to see if there are inline comments, tags or deprecation 4.18 // information to be printed. 4.19 if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
5.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Fri Mar 04 11:33:37 2011 -0800 5.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Fri Mar 04 19:53:03 2011 -0800 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -382,7 +382,7 @@ 5.11 out.close(); 5.12 } 5.13 } catch (IOException ie) { 5.14 - ie.printStackTrace(); 5.15 + ie.printStackTrace(System.err); 5.16 throw new DocletAbortException(); 5.17 } 5.18 } 5.19 @@ -399,12 +399,12 @@ 5.20 String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc); 5.21 String completePath = new SourcePath(configuration.sourcepath). 5.22 getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR; 5.23 - //Make sure that both paths are using the same seperators. 5.24 + //Make sure that both paths are using the same separators. 5.25 completePath = Util.replaceText(completePath, File.separator, 5.26 DirectoryManager.URL_FILE_SEPARATOR); 5.27 pkgPath = Util.replaceText(pkgPath, File.separator, 5.28 DirectoryManager.URL_FILE_SEPARATOR); 5.29 - return completePath.substring(0, completePath.indexOf(pkgPath)); 5.30 + return completePath.substring(0, completePath.lastIndexOf(pkgPath)); 5.31 } catch (Exception e){ 5.32 return ""; 5.33 } 5.34 @@ -536,15 +536,6 @@ 5.35 findAllInterfaceTypes(results, (ClassDoc) type, true, configuration); 5.36 } 5.37 5.38 - 5.39 - public static <T extends ProgramElementDoc> List<T> asList(T[] members) { 5.40 - List<T> list = new ArrayList<T>(); 5.41 - for (int i = 0; i < members.length; i++) { 5.42 - list.add(members[i]); 5.43 - } 5.44 - return list; 5.45 - } 5.46 - 5.47 /** 5.48 * Enclose in quotes, used for paths and filenames that contains spaces 5.49 */ 5.50 @@ -583,14 +574,7 @@ 5.51 if (oldStr == null || newStr == null || oldStr.equals(newStr)) { 5.52 return originalStr; 5.53 } 5.54 - StringBuffer result = new StringBuffer(originalStr); 5.55 - int startIndex = 0; 5.56 - while ((startIndex = result.indexOf(oldStr, startIndex)) != -1) { 5.57 - result = result.replace(startIndex, startIndex + oldStr.length(), 5.58 - newStr); 5.59 - startIndex += newStr.length(); 5.60 - } 5.61 - return result.toString(); 5.62 + return originalStr.replace(oldStr, newStr); 5.63 } 5.64 5.65 /** 5.66 @@ -833,19 +817,17 @@ 5.67 * @param tabLength the length of each tab. 5.68 * @param s the String to scan. 5.69 */ 5.70 - public static void replaceTabs(int tabLength, StringBuffer s) { 5.71 - int index, col; 5.72 - StringBuffer whitespace; 5.73 - while ((index = s.indexOf("\t")) != -1) { 5.74 - whitespace = new StringBuffer(); 5.75 - col = index; 5.76 - do { 5.77 - whitespace.append(" "); 5.78 - col++; 5.79 - } while ((col%tabLength) != 0); 5.80 - s.replace(index, index+1, whitespace.toString()); 5.81 + public static void replaceTabs(int tabLength, StringBuilder s) { 5.82 + if (whitespace == null || whitespace.length() < tabLength) 5.83 + whitespace = String.format("%" + tabLength + "s", " "); 5.84 + int index = 0; 5.85 + while ((index = s.indexOf("\t", index)) != -1) { 5.86 + int spaceCount = tabLength - index % tabLength; 5.87 + s.replace(index, index+1, whitespace.substring(0, spaceCount)); 5.88 + index += spaceCount; 5.89 } 5.90 } 5.91 + private static String whitespace; 5.92 5.93 /** 5.94 * The documentation for values() and valueOf() in Enums are set by the
6.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java Fri Mar 04 11:33:37 2011 -0800 6.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java Fri Mar 04 19:53:03 2011 -0800 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -92,8 +92,9 @@ 6.11 * @com.example.foo 6.12 * Omit parens for marker annotations, and omit "value=" when allowed. 6.13 */ 6.14 + @Override 6.15 public String toString() { 6.16 - StringBuffer sb = new StringBuffer("@"); 6.17 + StringBuilder sb = new StringBuilder("@"); 6.18 sb.append(annotation.type.tsym); 6.19 6.20 ElementValuePair vals[] = elementValues(); 6.21 @@ -153,6 +154,7 @@ 6.22 * Returns a string representation of this pair 6.23 * of the form "name=value". 6.24 */ 6.25 + @Override 6.26 public String toString() { 6.27 return meth.name + "=" + value(); 6.28 }
7.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java Fri Mar 04 11:33:37 2011 -0800 7.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java Fri Mar 04 19:53:03 2011 -0800 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -30,7 +30,6 @@ 7.11 7.12 import com.sun.tools.javac.code.Attribute; 7.13 import com.sun.tools.javac.code.Symbol.*; 7.14 -import com.sun.tools.javac.code.Type; 7.15 import com.sun.tools.javac.code.TypeTags; 7.16 7.17 7.18 @@ -114,6 +113,7 @@ 7.19 * @return the text of a Java language annotation value expression 7.20 * whose value is the value of this annotation type element. 7.21 */ 7.22 + @Override 7.23 public String toString() { 7.24 ToStringVisitor tv = new ToStringVisitor(); 7.25 attr.accept(tv); 7.26 @@ -121,8 +121,9 @@ 7.27 } 7.28 7.29 private class ToStringVisitor implements Attribute.Visitor { 7.30 - private final StringBuffer sb = new StringBuffer(); 7.31 + private final StringBuilder sb = new StringBuilder(); 7.32 7.33 + @Override 7.34 public String toString() { 7.35 return sb.toString(); 7.36 }
8.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Mar 04 11:33:37 2011 -0800 8.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Mar 04 19:53:03 2011 -0800 8.3 @@ -1,5 +1,5 @@ 8.4 /* 8.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 8.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 8.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.8 * 8.9 * This code is free software; you can redistribute it and/or modify it 8.10 @@ -64,7 +64,6 @@ 8.11 import com.sun.tools.javac.util.Names; 8.12 import com.sun.tools.javac.util.Position; 8.13 8.14 -import static com.sun.tools.javac.code.Flags.*; 8.15 import static com.sun.tools.javac.code.Kinds.*; 8.16 8.17 /** 8.18 @@ -147,6 +146,7 @@ 8.19 /** 8.20 * Return true if this is a class, not an interface. 8.21 */ 8.22 + @Override 8.23 public boolean isClass() { 8.24 return !Modifier.isInterface(getModifiers()); 8.25 } 8.26 @@ -155,6 +155,7 @@ 8.27 * Return true if this is a ordinary class, 8.28 * not an enumeration, exception, an error, or an interface. 8.29 */ 8.30 + @Override 8.31 public boolean isOrdinaryClass() { 8.32 if (isEnum() || isInterface() || isAnnotationType()) { 8.33 return false; 8.34 @@ -172,6 +173,7 @@ 8.35 * Return true if this is an enumeration. 8.36 * (For legacy doclets, return false.) 8.37 */ 8.38 + @Override 8.39 public boolean isEnum() { 8.40 return (getFlags() & Flags.ENUM) != 0 8.41 && 8.42 @@ -182,6 +184,7 @@ 8.43 * Return true if this is an interface, but not an annotation type. 8.44 * Overridden by AnnotationTypeDocImpl. 8.45 */ 8.46 + @Override 8.47 public boolean isInterface() { 8.48 return Modifier.isInterface(getModifiers()); 8.49 } 8.50 @@ -189,6 +192,7 @@ 8.51 /** 8.52 * Return true if this is an exception class 8.53 */ 8.54 + @Override 8.55 public boolean isException() { 8.56 if (isEnum() || isInterface() || isAnnotationType()) { 8.57 return false; 8.58 @@ -204,6 +208,7 @@ 8.59 /** 8.60 * Return true if this is an error class 8.61 */ 8.62 + @Override 8.63 public boolean isError() { 8.64 if (isEnum() || isInterface() || isAnnotationType()) { 8.65 return false; 8.66 @@ -275,6 +280,7 @@ 8.67 /** 8.68 * Return the package that this class is contained in. 8.69 */ 8.70 + @Override 8.71 public PackageDoc containingPackage() { 8.72 PackageDocImpl p = env.getPackageDoc(tsym.packge()); 8.73 if (p.setDocPath == false) { 8.74 @@ -374,6 +380,7 @@ 8.75 * Return the qualified name and any type parameters. 8.76 * Each parameter is a type variable with optional bounds. 8.77 */ 8.78 + @Override 8.79 public String toString() { 8.80 return classToString(env, tsym, true); 8.81 } 8.82 @@ -401,7 +408,7 @@ 8.83 * qualified by their enclosing class(es) only. 8.84 */ 8.85 static String classToString(DocEnv env, ClassSymbol c, boolean full) { 8.86 - StringBuffer s = new StringBuffer(); 8.87 + StringBuilder s = new StringBuilder(); 8.88 if (!c.isInner()) { // if c is not an inner class 8.89 s.append(getClassName(c, full)); 8.90 } else { 8.91 @@ -449,10 +456,12 @@ 8.92 * Return the modifier string for this class. If it's an interface 8.93 * exclude 'abstract' keyword from the modifier string 8.94 */ 8.95 + @Override 8.96 public String modifiers() { 8.97 return Modifier.toString(modifierSpecifier()); 8.98 } 8.99 8.100 + @Override 8.101 public int modifierSpecifier() { 8.102 int modifiers = getModifiers(); 8.103 return (isInterface() || isAnnotationType()) 8.104 @@ -1285,6 +1294,7 @@ 8.105 * Return the source position of the entity, or null if 8.106 * no position is available. 8.107 */ 8.108 + @Override 8.109 public SourcePosition position() { 8.110 if (tsym.sourcefile == null) return null; 8.111 return SourcePositionImpl.make(tsym.sourcefile,
9.1 --- a/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java Fri Mar 04 11:33:37 2011 -0800 9.2 +++ b/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java Fri Mar 04 19:53:03 2011 -0800 9.3 @@ -1,5 +1,5 @@ 9.4 /* 9.5 - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. 9.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 9.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.8 * 9.9 * This code is free software; you can redistribute it and/or modify it 9.10 @@ -226,7 +226,7 @@ 9.11 } 9.12 9.13 private String makeSignature(boolean full) { 9.14 - StringBuffer result = new StringBuffer(); 9.15 + StringBuilder result = new StringBuilder(); 9.16 result.append("("); 9.17 for (List<Type> types = sym.type.getParameterTypes(); types.nonEmpty(); ) { 9.18 Type t = types.head; 9.19 @@ -251,6 +251,7 @@ 9.20 /** 9.21 * Generate a key for sorting. 9.22 */ 9.23 + @Override 9.24 CollationKey generateKey() { 9.25 String k = name() + flatSignature() + typeParametersString(); 9.26 // ',' and '&' are between '$' and 'a': normalize to spaces. 9.27 @@ -263,6 +264,7 @@ 9.28 * Return the source position of the entity, or null if 9.29 * no position is available. 9.30 */ 9.31 + @Override 9.32 public SourcePosition position() { 9.33 if (sym.enclClass().sourcefile == null) return null; 9.34 return SourcePositionImpl.make(sym.enclClass().sourcefile,
10.1 --- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java Fri Mar 04 11:33:37 2011 -0800 10.2 +++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java Fri Mar 04 19:53:03 2011 -0800 10.3 @@ -1,5 +1,5 @@ 10.4 /* 10.5 - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. 10.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 10.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.8 * 10.9 * This code is free software; you can redistribute it and/or modify it 10.10 @@ -142,7 +142,7 @@ 10.11 return v + (suffix == 'f' || suffix == 'F' ? "" + suffix : ""); 10.12 } 10.13 private static String sourceForm(char c) { 10.14 - StringBuffer buf = new StringBuffer(8); 10.15 + StringBuilder buf = new StringBuilder(8); 10.16 buf.append('\''); 10.17 sourceChar(c, buf); 10.18 buf.append('\''); 10.19 @@ -152,7 +152,7 @@ 10.20 return "0x" + Integer.toString(c & 0xff, 16); 10.21 } 10.22 private static String sourceForm(String s) { 10.23 - StringBuffer buf = new StringBuffer(s.length() + 5); 10.24 + StringBuilder buf = new StringBuilder(s.length() + 5); 10.25 buf.append('\"'); 10.26 for (int i=0; i<s.length(); i++) { 10.27 char c = s.charAt(i); 10.28 @@ -161,7 +161,7 @@ 10.29 buf.append('\"'); 10.30 return buf.toString(); 10.31 } 10.32 - private static void sourceChar(char c, StringBuffer buf) { 10.33 + private static void sourceChar(char c, StringBuilder buf) { 10.34 switch (c) { 10.35 case '\b': buf.append("\\b"); return; 10.36 case '\t': buf.append("\\t"); return; 10.37 @@ -179,7 +179,7 @@ 10.38 return; 10.39 } 10.40 } 10.41 - private static void unicodeEscape(char c, StringBuffer buf) { 10.42 + private static void unicodeEscape(char c, StringBuilder buf) { 10.43 final String chars = "0123456789abcdef"; 10.44 buf.append("\\u"); 10.45 buf.append(chars.charAt(15 & (c>>12))); 10.46 @@ -201,6 +201,7 @@ 10.47 /** 10.48 * Is this Doc item a field (but not an enum constant? 10.49 */ 10.50 + @Override 10.51 public boolean isField() { 10.52 return !isEnumConstant(); 10.53 } 10.54 @@ -209,6 +210,7 @@ 10.55 * Is this Doc item an enum constant? 10.56 * (For legacy doclets, return false.) 10.57 */ 10.58 + @Override 10.59 public boolean isEnumConstant() { 10.60 return (getFlags() & Flags.ENUM) != 0 && 10.61 !env.legacyDoclet; 10.62 @@ -257,6 +259,7 @@ 10.63 * Return the source position of the entity, or null if 10.64 * no position is available. 10.65 */ 10.66 + @Override 10.67 public SourcePosition position() { 10.68 if (sym.enclClass().sourcefile == null) return null; 10.69 return SourcePositionImpl.make(sym.enclClass().sourcefile,
11.1 --- a/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java Fri Mar 04 11:33:37 2011 -0800 11.2 +++ b/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java Fri Mar 04 19:53:03 2011 -0800 11.3 @@ -1,5 +1,5 @@ 11.4 /* 11.5 - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. 11.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 11.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.8 * 11.9 * This code is free software; you can redistribute it and/or modify it 11.10 @@ -25,15 +25,11 @@ 11.11 11.12 package com.sun.tools.javadoc; 11.13 11.14 - 11.15 import com.sun.javadoc.*; 11.16 11.17 -import static com.sun.javadoc.LanguageVersion.*; 11.18 - 11.19 import com.sun.tools.javac.code.Symbol.ClassSymbol; 11.20 import com.sun.tools.javac.code.Type; 11.21 import com.sun.tools.javac.code.Type.ClassType; 11.22 -import com.sun.tools.javac.util.List; 11.23 11.24 import static com.sun.tools.javac.code.TypeTags.*; 11.25 11.26 @@ -55,6 +51,7 @@ 11.27 /** 11.28 * Return the generic class or interface that declared this type. 11.29 */ 11.30 + @Override 11.31 public ClassDoc asClassDoc() { 11.32 return env.getClassDoc((ClassSymbol)type.tsym); 11.33 } 11.34 @@ -111,14 +108,17 @@ 11.35 // Asking for the "name" of a parameterized type doesn't exactly make 11.36 // sense. It's a type expression. Return the name of its generic 11.37 // type. 11.38 + @Override 11.39 public String typeName() { 11.40 return TypeMaker.getTypeName(type, false); 11.41 } 11.42 11.43 + @Override 11.44 public ParameterizedType asParameterizedType() { 11.45 return this; 11.46 } 11.47 11.48 + @Override 11.49 public String toString() { 11.50 return parameterizedTypeToString(env, (ClassType)type, true); 11.51 } 11.52 @@ -128,7 +128,7 @@ 11.53 if (env.legacyDoclet) { 11.54 return TypeMaker.getTypeName(cl, full); 11.55 } 11.56 - StringBuffer s = new StringBuffer(); 11.57 + StringBuilder s = new StringBuilder(); 11.58 if (cl.getEnclosingType().tag != CLASS) { // if not an inner class... 11.59 s.append(TypeMaker.getTypeName(cl, full)); 11.60 } else {
12.1 --- a/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java Fri Mar 04 11:33:37 2011 -0800 12.2 +++ b/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java Fri Mar 04 19:53:03 2011 -0800 12.3 @@ -1,5 +1,5 @@ 12.4 /* 12.5 - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. 12.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 12.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.8 * 12.9 * This code is free software; you can redistribute it and/or modify it 12.10 @@ -358,14 +358,14 @@ 12.11 12.12 String parameters; 12.13 12.14 - StringBuffer typeId; 12.15 + StringBuilder typeId; 12.16 12.17 ListBuffer<String> paramList; 12.18 12.19 ParameterParseMachine(String parameters) { 12.20 this.parameters = parameters; 12.21 this.paramList = new ListBuffer<String>(); 12.22 - typeId = new StringBuffer(); 12.23 + typeId = new StringBuilder(); 12.24 } 12.25 12.26 public String[] parseParameters() { 12.27 @@ -464,6 +464,7 @@ 12.28 /** 12.29 * Return the kind of this tag. 12.30 */ 12.31 + @Override 12.32 public String kind() { 12.33 return "@see"; 12.34 }
13.1 --- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Fri Mar 04 11:33:37 2011 -0800 13.2 +++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Fri Mar 04 19:53:03 2011 -0800 13.3 @@ -1,5 +1,5 @@ 13.4 /* 13.5 - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. 13.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 13.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.8 * 13.9 * This code is free software; you can redistribute it and/or modify it 13.10 @@ -27,15 +27,12 @@ 13.11 13.12 import com.sun.javadoc.*; 13.13 13.14 -import static com.sun.javadoc.LanguageVersion.*; 13.15 - 13.16 import com.sun.tools.javac.code.Symbol; 13.17 import com.sun.tools.javac.code.Symbol.ClassSymbol; 13.18 import com.sun.tools.javac.code.Type; 13.19 import com.sun.tools.javac.code.Type.ClassType; 13.20 import com.sun.tools.javac.code.Type.TypeVar; 13.21 import com.sun.tools.javac.code.Type.ArrayType; 13.22 -import com.sun.tools.javac.code.Types; 13.23 import com.sun.tools.javac.util.List; 13.24 13.25 import static com.sun.tools.javac.code.TypeTags.*; 13.26 @@ -109,12 +106,13 @@ 13.27 public static String getTypeName(Type t, boolean full) { 13.28 switch (t.tag) { 13.29 case ARRAY: 13.30 - StringBuffer dimension = new StringBuffer(); 13.31 + StringBuilder s = new StringBuilder(); 13.32 while (t.tag == ARRAY) { 13.33 - dimension = dimension.append("[]"); 13.34 + s.append("[]"); 13.35 t = ((ArrayType)t).elemtype; 13.36 } 13.37 - return getTypeName(t, full) + dimension; 13.38 + s.insert(0, getTypeName(t, full)); 13.39 + return s.toString(); 13.40 case CLASS: 13.41 return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full); 13.42 default: 13.43 @@ -130,12 +128,13 @@ 13.44 static String getTypeString(DocEnv env, Type t, boolean full) { 13.45 switch (t.tag) { 13.46 case ARRAY: 13.47 - StringBuffer dimension = new StringBuffer(); 13.48 + StringBuilder s = new StringBuilder(); 13.49 while (t.tag == ARRAY) { 13.50 - dimension = dimension.append("[]"); 13.51 + s.append("[]"); 13.52 t = env.types.elemtype(t); 13.53 } 13.54 - return getTypeString(env, t, full) + dimension; 13.55 + s.insert(0, getTypeString(env, t, full)); 13.56 + return s.toString(); 13.57 case CLASS: 13.58 return ParameterizedTypeImpl. 13.59 parameterizedTypeToString(env, (ClassType)t, full); 13.60 @@ -157,7 +156,7 @@ 13.61 if (env.legacyDoclet || sym.type.getTypeArguments().isEmpty()) { 13.62 return ""; 13.63 } 13.64 - StringBuffer s = new StringBuffer(); 13.65 + StringBuilder s = new StringBuilder(); 13.66 for (Type t : sym.type.getTypeArguments()) { 13.67 s.append(s.length() == 0 ? "<" : ", "); 13.68 s.append(TypeVariableImpl.typeVarToString(env, (TypeVar)t, full)); 13.69 @@ -175,7 +174,7 @@ 13.70 if (env.legacyDoclet || cl.getTypeArguments().isEmpty()) { 13.71 return ""; 13.72 } 13.73 - StringBuffer s = new StringBuffer(); 13.74 + StringBuilder s = new StringBuilder(); 13.75 for (Type t : cl.getTypeArguments()) { 13.76 s.append(s.length() == 0 ? "<" : ", "); 13.77 s.append(getTypeString(env, t, full)); 13.78 @@ -213,9 +212,9 @@ 13.79 * For example, a two dimensional array of String returns '[][]'. 13.80 */ 13.81 public String dimension() { 13.82 - StringBuffer dimension = new StringBuffer(); 13.83 + StringBuilder dimension = new StringBuilder(); 13.84 for (Type t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) { 13.85 - dimension = dimension.append("[]"); 13.86 + dimension.append("[]"); 13.87 } 13.88 return dimension.toString(); 13.89 } 13.90 @@ -304,6 +303,7 @@ 13.91 * 13.92 * @return name of type including any dimension information. 13.93 */ 13.94 + @Override 13.95 public String toString() { 13.96 return qualifiedTypeName() + dimension(); 13.97 }
14.1 --- a/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java Fri Mar 04 11:33:37 2011 -0800 14.2 +++ b/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java Fri Mar 04 19:53:03 2011 -0800 14.3 @@ -1,5 +1,5 @@ 14.4 /* 14.5 - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. 14.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 14.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.8 * 14.9 * This code is free software; you can redistribute it and/or modify it 14.10 @@ -78,14 +78,17 @@ 14.11 /** 14.12 * Return the ClassDoc of the erasure of this type variable. 14.13 */ 14.14 + @Override 14.15 public ClassDoc asClassDoc() { 14.16 return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym); 14.17 } 14.18 14.19 + @Override 14.20 public TypeVariable asTypeVariable() { 14.21 return this; 14.22 } 14.23 14.24 + @Override 14.25 public String toString() { 14.26 return typeVarToString(env, (TypeVar)type, true); 14.27 } 14.28 @@ -96,7 +99,7 @@ 14.29 * "extends" clause. Class names are qualified if "full" is true. 14.30 */ 14.31 static String typeVarToString(DocEnv env, TypeVar v, boolean full) { 14.32 - StringBuffer s = new StringBuffer(v.toString()); 14.33 + StringBuilder s = new StringBuilder(v.toString()); 14.34 List<Type> bounds = getBounds(v, env); 14.35 if (bounds.nonEmpty()) { 14.36 boolean first = true;
15.1 --- a/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java Fri Mar 04 11:33:37 2011 -0800 15.2 +++ b/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java Fri Mar 04 19:53:03 2011 -0800 15.3 @@ -1,5 +1,5 @@ 15.4 /* 15.5 - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. 15.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 15.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.8 * 15.9 * This code is free software; you can redistribute it and/or modify it 15.10 @@ -28,8 +28,6 @@ 15.11 15.12 import com.sun.javadoc.*; 15.13 15.14 -import static com.sun.javadoc.LanguageVersion.*; 15.15 - 15.16 import com.sun.tools.javac.code.Symbol.ClassSymbol; 15.17 import com.sun.tools.javac.code.Type; 15.18 import com.sun.tools.javac.util.List; 15.19 @@ -69,18 +67,24 @@ 15.20 /** 15.21 * Return the ClassDoc of the erasure of this wildcard type. 15.22 */ 15.23 + @Override 15.24 public ClassDoc asClassDoc() { 15.25 return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym); 15.26 } 15.27 15.28 + @Override 15.29 public WildcardType asWildcardType() { 15.30 return this; 15.31 } 15.32 15.33 + @Override 15.34 public String typeName() { return "?"; } 15.35 + @Override 15.36 public String qualifiedTypeName() { return "?"; } 15.37 + @Override 15.38 public String simpleTypeName() { return "?"; } 15.39 15.40 + @Override 15.41 public String toString() { 15.42 return wildcardTypeToString(env, (Type.WildcardType)type, true); 15.43 } 15.44 @@ -96,7 +100,7 @@ 15.45 if (env.legacyDoclet) { 15.46 return TypeMaker.getTypeName(env.types.erasure(wildThing), full); 15.47 } 15.48 - StringBuffer s = new StringBuffer("?"); 15.49 + StringBuilder s = new StringBuilder("?"); 15.50 List<Type> bounds = getExtendsBounds(wildThing); 15.51 if (bounds.nonEmpty()) { 15.52 s.append(" extends ");