diff options
author | Andrey Turbanov <turbanoff@gmail.com> | 2021-11-20 17:16:22 +0300 |
---|---|---|
committer | Andrey Turbanov <turbanoff@gmail.com> | 2021-11-20 17:22:06 +0300 |
commit | b1c52e2f5eb624037b8c799c20fbd1b4fd611d9a (patch) | |
tree | 33d7b6e8f733f20514f46e7871b29e26de47913d /bcel-builder | |
parent | 0f85ca109b9e6ab849e201e76f62d5023cbfcb98 (diff) | |
download | aspectj-b1c52e2f5eb624037b8c799c20fbd1b4fd611d9a.tar.gz aspectj-b1c52e2f5eb624037b8c799c20fbd1b4fd611d9a.zip |
Replace uses of StringBuffer with StringBuilder.
StringBuffer is a legacy synchronized class. StringBuilder is a direct replacement to StringBuffer which generally have better performance.
Diffstat (limited to 'bcel-builder')
37 files changed, 245 insertions, 245 deletions
diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/BootstrapMethods.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/BootstrapMethods.java index 699cdc3ef..a1178fbfa 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/BootstrapMethods.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/BootstrapMethods.java @@ -63,7 +63,7 @@ import org.aspectj.apache.bcel.Constants; /** * Represents the BootstrapMethods attribute in Java 7 classes. - * + * * @author Andy Clement */ public final class BootstrapMethods extends Attribute { @@ -98,7 +98,7 @@ public final class BootstrapMethods extends Attribute { file.readFully(data); isInPackedState = true; } - + public static class BootstrapMethod { private int bootstrapMethodRef; private int[] bootstrapArguments; @@ -106,7 +106,7 @@ public final class BootstrapMethods extends Attribute { BootstrapMethod(DataInputStream file) throws IOException { this(file.readUnsignedShort(), readBootstrapArguments(file)); } - + private static int[] readBootstrapArguments(DataInputStream dis) throws IOException { int numBootstrapMethods = dis.readUnsignedShort(); int[] bootstrapArguments = new int[numBootstrapMethods]; @@ -115,16 +115,16 @@ public final class BootstrapMethods extends Attribute { } return bootstrapArguments; } - + public BootstrapMethod(int bootstrapMethodRef, int[] bootstrapArguments) { this.bootstrapMethodRef = bootstrapMethodRef; this.bootstrapArguments = bootstrapArguments; } - + public int getBootstrapMethodRef() { return bootstrapMethodRef; } - + public int[] getBootstrapArguments() { return bootstrapArguments; } @@ -137,15 +137,15 @@ public final class BootstrapMethods extends Attribute { file.writeShort(bootstrapArgument); } } - + public final int getLength() { return 2 /*bootstrapMethodRef*/+ 2 /*number of arguments*/+ 2 * bootstrapArguments.length; } - + } - + // Unpacks the byte array into the table private void unpack() { if (isInPackedState) { @@ -169,7 +169,7 @@ public final class BootstrapMethods extends Attribute { /** * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the * hierarchy of methods, fields, attributes, etc. spawns a tree of objects. - * + * * @param v Visitor object */ @Override @@ -180,7 +180,7 @@ public final class BootstrapMethods extends Attribute { /** * Dump line number table attribute to file stream in binary format. - * + * * @param file Output file stream * @throws IOException */ @@ -210,8 +210,8 @@ public final class BootstrapMethods extends Attribute { @Override public final String toString() { unpack(); - StringBuffer buf = new StringBuffer(); - StringBuffer line = new StringBuffer(); + StringBuilder buf = new StringBuilder(); + StringBuilder line = new StringBuilder(); for (int i = 0; i < numBootstrapMethods; i++) { BootstrapMethod bm = bootstrapMethods[i]; @@ -228,8 +228,8 @@ public final class BootstrapMethods extends Attribute { line.append(arg).append("(").append(getConstantPool().getConstant(arg)).append(") "); } } - - + + if (i < numBootstrapMethods - 1) { line.append(", "); } diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Code.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Code.java index 10dbf8ffc..5f6af4518 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Code.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Code.java @@ -64,10 +64,10 @@ import org.aspectj.apache.bcel.Constants; * This class represents a chunk of Java byte code contained in a method. It is instantiated by the * <em>Attribute.readAttribute()</em> method. A <em>Code</em> attribute contains informations about operand stack, local variables, * byte code and the exceptions handled within this method. - * + * * This attribute has attributes itself, namely <em>LineNumberTable</em> which is used for debugging purposes and * <em>LocalVariableTable</em> which contains information about the local variables. - * + * * @version $Id: Code.java,v 1.9 2009/10/05 17:35:36 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute @@ -149,7 +149,7 @@ public final class Code extends Attribute { /** * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the * hierarchy of methods, fields, attributes, etc. spawns a tree of objects. - * + * * @param v Visitor object */ @Override @@ -159,7 +159,7 @@ public final class Code extends Attribute { /** * Dump code attribute to file stream in binary format. - * + * * @param file Output file stream * @throws IOException */ @@ -309,9 +309,9 @@ public final class Code extends Attribute { * @return String representation of code chunk. */ public final String toString(boolean verbose) { - StringBuffer buf; + StringBuilder buf; - buf = new StringBuffer("Code(max_stack = " + maxStack + ", max_locals = " + maxLocals + ", code_length = " + code.length + buf = new StringBuilder("Code(max_stack = " + maxStack + ", max_locals = " + maxLocals + ", code_length = " + code.length + ")\n" + Utility.codeToString(code, cpool, 0, -1, verbose)); if (exceptionTable.length > 0) { @@ -348,7 +348,7 @@ public final class Code extends Attribute { // Code c = (Code)clone(); // c.code = (byte[])code.clone(); // c.cpool = constant_pool; - // + // // c.exceptionTable = new CodeException[exceptionTable.length]; // for(int i=0; i < exceptionTable.length; i++) // c.exceptionTable[i] = exceptionTable[i].copy(); @@ -365,7 +365,7 @@ public final class Code extends Attribute { * whether two pieces of code are equivalent. */ public String getCodeString() { - StringBuffer codeString = new StringBuffer(); + StringBuilder codeString = new StringBuilder(); codeString.append("Code(max_stack = ").append(maxStack); codeString.append(", max_locals = ").append(maxLocals); codeString.append(", code_length = ").append(code.length).append(")\n"); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java index 4609a3e09..2066b4569 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java @@ -136,7 +136,7 @@ public class ConstantPool implements Node { /** * Get string from constant pool and bypass the indirection of `ConstantClass' and `ConstantString' objects. I.e. these classes * have an index field that points to another entry of the constant pool of type `ConstantUtf8' which contains the real data. - * + * * @param index Index in constant pool * @param tag Tag of expected constant, either ConstantClass or ConstantString * @return Contents of string reference @@ -207,7 +207,7 @@ public class ConstantPool implements Node { str = (constantToString(((ConstantCP) c).getClassIndex(), Constants.CONSTANT_Class) + "." + constantToString( ((ConstantCP) c).getNameAndTypeIndex(), Constants.CONSTANT_NameAndType)); break; - + case Constants.CONSTANT_InvokeDynamic: ConstantInvokeDynamic cID = ((ConstantInvokeDynamic)c); return "#"+cID.getBootstrapMethodAttrIndex()+"."+constantToString(cID.getNameAndTypeIndex(), Constants.CONSTANT_NameAndType); @@ -237,7 +237,7 @@ public class ConstantPool implements Node { private static final String escape(String str) { int len = str.length(); - StringBuffer buf = new StringBuffer(len + 5); + StringBuilder buf = new StringBuilder(len + 5); char[] ch = str.toCharArray(); for (int i = 0; i < len; i++) { @@ -296,7 +296,7 @@ public class ConstantPool implements Node { assert c.tag == Constants.CONSTANT_Utf8; return (ConstantUtf8) c; } - + public ConstantModule getConstantModule(int index) { Constant c = getConstant(index); assert c != null; @@ -323,7 +323,7 @@ public class ConstantPool implements Node { @Override public String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (int i = 1; i < poolSize; i++) buf.append(i + ")" + pool[i] + "\n"); @@ -441,7 +441,7 @@ public class ConstantPool implements Node { public int lookupFieldref(String searchClassname, String searchFieldname, String searchSignature) { searchClassname = searchClassname.replace('.', '/'); - String k = new StringBuffer().append(searchClassname).append(searchFieldname).append(searchSignature).toString(); + String k = new StringBuilder().append(searchClassname).append(searchFieldname).append(searchSignature).toString(); Integer pos = fieldCache.get(k); if (pos != null) return pos; @@ -621,7 +621,7 @@ public class ConstantPool implements Node { return addNameAndType(u8.getValue(), u8_2.getValue()); } - + case Constants.CONSTANT_InvokeDynamic: { ConstantInvokeDynamic cid = (ConstantInvokeDynamic)c; int index1 = cid.getBootstrapMethodAttrIndex(); @@ -631,7 +631,7 @@ public class ConstantPool implements Node { int index2 = addNameAndType(name.getValue(), signature.getValue()); return addInvokeDynamic(index1,index2); } - + case Constants.CONSTANT_MethodHandle: ConstantMethodHandle cmh = (ConstantMethodHandle)c; return addMethodHandle(cmh.getReferenceKind(),addConstant(constants[cmh.getReferenceIndex()],cp)); @@ -650,7 +650,7 @@ public class ConstantPool implements Node { case Constants.CONSTANT_Integer: return addInteger(((ConstantInteger) c).getValue()); - + case Constants.CONSTANT_MethodType: ConstantMethodType cmt = (ConstantMethodType)c; return addMethodType(addConstant(constants[cmt.getDescriptorIndex()],cp)); @@ -689,14 +689,14 @@ public class ConstantPool implements Node { throw new RuntimeException("Unknown constant type " + c); } } - + public int addMethodHandle(byte referenceKind, int referenceIndex) { adjustSize(); int ret = poolSize; pool[poolSize++] = new ConstantMethodHandle(referenceKind, referenceIndex); return ret; } - + public int addMethodType(int descriptorIndex) { adjustSize(); int ret = poolSize; @@ -718,7 +718,7 @@ public class ConstantPool implements Node { pool[poolSize++] = new ConstantMethodref(class_index, name_and_type_index); return ret; } - + public int addInvokeDynamic(int bootstrapMethodIndex, int constantNameAndTypeIndex) { adjustSize(); int ret = poolSize; @@ -768,7 +768,7 @@ public class ConstantPool implements Node { } public int lookupMethodref(String searchClassname, String searchMethodName, String searchSignature) { - String key = new StringBuffer().append(searchClassname).append(searchMethodName).append(searchSignature).toString(); + String key = new StringBuilder().append(searchClassname).append(searchMethodName).append(searchSignature).toString(); Integer cached = methodCache.get(key); if (cached != null) return cached; @@ -813,4 +813,4 @@ public class ConstantPool implements Node { public String getPackageName(int packageIndex) { return getConstantPackage(packageIndex).getPackageName(this); } -}
\ No newline at end of file +} diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ExceptionTable.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ExceptionTable.java index ad7d43f2e..adb796249 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ExceptionTable.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ExceptionTable.java @@ -64,7 +64,7 @@ import org.aspectj.apache.bcel.Constants; * This class represents the table of exceptions that are thrown by a method. This attribute may be used once per method. The name * of this class is <em>ExceptionTable</em> for historical reasons; The Java Virtual Machine Specification, Second Edition defines * this attribute using the name <em>Exceptions</em> (which is inconsistent with the other classes). - * + * * @version $Id: ExceptionTable.java,v 1.5 2009/09/15 19:40:12 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Code @@ -94,7 +94,7 @@ public final class ExceptionTable extends Attribute { /** * Construct object from file stream. - * + * * @param name_index Index in constant pool * @param length Content length in bytes * @param file Input stream @@ -114,7 +114,7 @@ public final class ExceptionTable extends Attribute { /** * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the * hierarchy of methods, fields, attributes, etc. spawns a tree of objects. - * + * * @param v Visitor object */ @Override @@ -124,7 +124,7 @@ public final class ExceptionTable extends Attribute { /** * Dump exceptions attribute to file stream in binary format. - * + * * @param file Output file stream * @throws IOException */ @@ -173,7 +173,7 @@ public final class ExceptionTable extends Attribute { */ @Override public final String toString() { - StringBuffer buf = new StringBuffer(""); + StringBuilder buf = new StringBuilder(""); String str; for (int i = 0; i < number_of_exceptions; i++) { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Field.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Field.java index f34464375..2d3c276b5 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Field.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Field.java @@ -61,7 +61,7 @@ import org.aspectj.apache.bcel.generic.Type; /** * This class represents the field info structure, i.e., the representation for a variable in the class. See JVM specification for * details. - * + * * @version $Id: Field.java,v 1.6 2009/09/15 03:33:52 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ @@ -103,7 +103,7 @@ public final class Field extends FieldOrMethod { @Override public final String toString() { // Get names from constant pool - StringBuffer buf = new StringBuffer(Utility.accessToString(modifiers)); + StringBuilder buf = new StringBuilder(Utility.accessToString(modifiers)); if (buf.length() > 0) { buf.append(" "); } diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/InnerClasses.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/InnerClasses.java index 0078156ed..16a609814 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/InnerClasses.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/InnerClasses.java @@ -63,7 +63,7 @@ import org.aspectj.apache.bcel.Constants; /** * This class is derived from <em>Attribute</em> and denotes that this class is an Inner class of another. to the source file of * this class. It is instantiated from the <em>Attribute.readAttribute()</em> method. - * + * * @version $Id: InnerClasses.java,v 1.5 2009/09/15 19:40:12 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute @@ -94,7 +94,7 @@ public final class InnerClasses extends Attribute { /** * Construct object from file stream. - * + * * @param name_index Index in constant pool to CONSTANT_Utf8 * @param length Content length in bytes * @param file Input stream @@ -114,7 +114,7 @@ public final class InnerClasses extends Attribute { /** * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the * hierarchy of methods, fields, attributes, etc. spawns a tree of objects. - * + * * @param v Visitor object */ @Override @@ -124,7 +124,7 @@ public final class InnerClasses extends Attribute { /** * Dump source file attribute to file stream in binary format. - * + * * @param file Output file stream * @throws IOException */ @@ -157,7 +157,7 @@ public final class InnerClasses extends Attribute { */ @Override public final String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (int i = 0; i < number_of_classes; i++) buf.append(inner_classes[i].toString(cpool) + "\n"); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java index a1a7a57de..0be2b8ae5 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java @@ -77,10 +77,10 @@ import org.aspectj.apache.bcel.util.SyntheticRepository; /** * Represents a Java class, i.e., the data structures, constant pool, fields, methods and commands contained in a Java .class file. * See <a href="ftp://java.sun.com/docs/specs/">JVM specification</a> for details. - * + * * The intent of this class is to represent a parsed or otherwise existing class file. Those interested in programatically * generating classes should see the <a href="../generic/ClassGen.html">ClassGen</a> class. - * + * * @version $Id: JavaClass.java,v 1.22 2009/09/15 19:40:14 aclement Exp $ * @see org.aspectj.apache.bcel.generic.ClassGen * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> @@ -185,7 +185,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { /** * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the * hierarchy of methods, fields, attributes, etc. spawns a tree of objects. - * + * * @param v Visitor object */ public void accept(ClassVisitor v) { @@ -194,7 +194,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { /** * Dump class to a file. - * + * * @param file Output file * @throws IOException */ @@ -209,7 +209,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { /** * Dump class to a file named file_name. - * + * * @param file_name Output file name * @exception IOException */ @@ -523,7 +523,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { String access = Utility.accessToString(modifiers, true); access = access.equals("") ? "" : access + " "; - StringBuffer buf = new StringBuffer(access + Utility.classOrInterface(modifiers) + " " + classname + " extends " + StringBuilder buf = new StringBuilder(access + Utility.classOrInterface(modifiers) + " " + classname + " extends " + Utility.compactClassName(superclassname, false) + '\n'); int size = interfaces.length; @@ -580,7 +580,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { private static final String indent(Object obj) { StringTokenizer tok = new StringTokenizer(obj.toString(), "\n"); - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); while (tok.hasMoreTokens()) { buf.append("\t" + tok.nextToken() + "\n"); @@ -671,7 +671,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { /** * Equivalent to runtime "instanceof" operator. - * + * * @return true if this JavaClass is derived from teh super class */ public final boolean instanceOf(JavaClass super_class) { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LineNumberTable.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LineNumberTable.java index 871bfe6bf..ee852cf23 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LineNumberTable.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LineNumberTable.java @@ -64,7 +64,7 @@ import org.aspectj.apache.bcel.Constants; /** * This class represents a table of line numbers for debugging purposes. This attribute is used by the <em>Code</em> attribute. It * contains pairs of PCs and line numbers. - * + * * @version $Id: LineNumberTable.java,v 1.8 2009/09/15 19:40:12 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Code changes: asc Feb06 Made unpacking lazy @@ -94,7 +94,7 @@ public final class LineNumberTable extends Attribute { /** * Construct object from file stream. - * + * * @param name_index Index of name * @param length Content length in bytes * @param file Input stream @@ -132,7 +132,7 @@ public final class LineNumberTable extends Attribute { /** * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the * hierarchy of methods, fields, attributes, etc. spawns a tree of objects. - * + * * @param v Visitor object */ @Override @@ -143,7 +143,7 @@ public final class LineNumberTable extends Attribute { /** * Dump line number table attribute to file stream in binary format. - * + * * @param file Output file stream * @throws IOException */ @@ -184,8 +184,8 @@ public final class LineNumberTable extends Attribute { @Override public final String toString() { unpack(); - StringBuffer buf = new StringBuffer(); - StringBuffer line = new StringBuffer(); + StringBuilder buf = new StringBuilder(); + StringBuilder line = new StringBuilder(); for (int i = 0; i < tableLength; i++) { line.append(table[i].toString()); @@ -208,7 +208,7 @@ public final class LineNumberTable extends Attribute { /** * Map byte code positions to source code lines. - * + * * @param pos byte code offset * @return corresponding line in source code */ diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LocalVariableTable.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LocalVariableTable.java index 96c52d20f..b32ca7179 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LocalVariableTable.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LocalVariableTable.java @@ -177,7 +177,7 @@ public class LocalVariableTable extends Attribute { */ @Override public final String toString() { - StringBuffer buf = new StringBuffer(""); + StringBuilder buf = new StringBuilder(""); unpack(); for (int i = 0; i < localVariableTableLength; i++) { buf.append(localVariableTable[i].toString()); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java index 93951faf8..2258652ce 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java @@ -104,7 +104,7 @@ public class LocalVariableTypeTable extends Attribute { */ @Override public final String toString() { - StringBuffer buf = new StringBuffer(""); + StringBuilder buf = new StringBuilder(""); for (int i = 0; i < local_variable_type_table_length; i++) { buf.append(local_variable_type_table[i].toString()); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Method.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Method.java index 12608940a..316eaa4c9 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Method.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Method.java @@ -67,7 +67,7 @@ import org.aspectj.apache.bcel.generic.Type; /** * This class represents the method info structure, i.e., the representation for a method in the class. See JVM specification for * details. A method has access flags, a name, a signature and a number of attributes. - * + * * @version $Id: Method.java,v 1.11 2009/09/15 19:40:12 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ @@ -151,7 +151,7 @@ public final class Method extends FieldOrMethod { public final String toString() { ConstantUtf8 c; String name, signature, access; // Short cuts to constant pool - StringBuffer buf; + StringBuilder buf; access = Utility.accessToString(modifiers); @@ -163,7 +163,7 @@ public final class Method extends FieldOrMethod { name = c.getValue(); signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable()); - buf = new StringBuffer(signature); + buf = new StringBuilder(signature); for (Attribute a : attributes) { if (!((a instanceof Code) || (a instanceof ExceptionTable))) diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ModulePackages.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ModulePackages.java index 6f96ae0fd..1ce96a8ba 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ModulePackages.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ModulePackages.java @@ -62,7 +62,7 @@ import org.aspectj.apache.bcel.Constants; /** * Indicates all the packages of a module that are exported or opened by the module attribute. * http://cr.openjdk.java.net/~mr/jigsaw/spec/java-se-9-jvms-diffs.pdf 4.7.26 - * + * * @author Andy Clement */ public final class ModulePackages extends Attribute { @@ -116,7 +116,7 @@ public final class ModulePackages extends Attribute { @Override public final String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (int packageIndex : packageIndices) { buf.append(cpool.getPackageName(packageIndex) + "\n"); } diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/NestHost.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/NestHost.java index 52d312659..547b71dae 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/NestHost.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/NestHost.java @@ -62,7 +62,7 @@ import org.aspectj.apache.bcel.Constants; /** * https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.28 - * + * * @see Attribute */ public final class NestHost extends Attribute { @@ -100,7 +100,7 @@ public final class NestHost extends Attribute { public final void setHostClassIndex(int hostClassIndex) { this.hostClassIndex = hostClassIndex; } - + public final String getHostClassName() { ConstantClass constantClass = (ConstantClass)cpool.getConstant(hostClassIndex,Constants.CONSTANT_Class); return constantClass.getClassname(cpool); @@ -108,7 +108,7 @@ public final class NestHost extends Attribute { @Override public final String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append("NestHost("); ConstantClass constantClass = (ConstantClass)cpool.getConstant(hostClassIndex,Constants.CONSTANT_Class); buf.append(constantClass.getClassname(cpool)); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/NestMembers.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/NestMembers.java index 9d273966f..8179aaf18 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/NestMembers.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/NestMembers.java @@ -62,7 +62,7 @@ import org.aspectj.apache.bcel.Constants; /** * https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.29 - * + * * @see Attribute */ public final class NestMembers extends Attribute { @@ -109,7 +109,7 @@ public final class NestMembers extends Attribute { this.classes = inner_classes; numberOfClasses = (inner_classes == null) ? 0 : inner_classes.length; } - + public final String[] getClassesNames() { String[] result = new String[numberOfClasses]; for (int i = 0; i < numberOfClasses; i++) { @@ -121,7 +121,7 @@ public final class NestMembers extends Attribute { @Override public final String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (int i = 0; i < numberOfClasses; i++) { ConstantClass constantClass = (ConstantClass)cpool.getConstant(classes[i],Constants.CONSTANT_Class); buf.append(constantClass.getClassname(cpool)).append(" "); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Signature.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Signature.java index b7488e9a4..96236c8f3 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Signature.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Signature.java @@ -52,7 +52,7 @@ package org.aspectj.apache.bcel.classfile; * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. - * + * * Extended by Adrian Colyer, June 2005 to support unpacking of Signature * attribute */ @@ -67,7 +67,7 @@ import org.aspectj.apache.bcel.Constants; /** * This class is derived from <em>Attribute</em> and represents a reference to a <href="http://wwwipd.ira.uka.de/~pizza/gj/">GJ</a> * attribute. - * + * * @version $Id: Signature.java,v 1.11 2009/09/15 19:40:12 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute @@ -85,7 +85,7 @@ public final class Signature extends Attribute { /** * Construct object from file stream. - * + * * @param name_index Index in constant pool to CONSTANT_Utf8 * @param length Content length in bytes * @param file Input stream @@ -110,7 +110,7 @@ public final class Signature extends Attribute { /** * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the * hierarchy of methods, fields, attributes, etc. spawns a tree of objects. - * + * * @param v Visitor object */ @Override @@ -121,7 +121,7 @@ public final class Signature extends Attribute { /** * Dump source file attribute to file stream in binary format. - * + * * @param file Output file stream * @throws IOException */ @@ -192,7 +192,7 @@ public final class Signature extends Attribute { // System.out.println("return from ident:" + (char)ch); if (!identStart(ch)) { - StringBuffer buf2 = new StringBuffer(); + StringBuilder buf2 = new StringBuilder(); int count = 1; while (Character.isJavaIdentifierPart((char) ch)) { @@ -216,7 +216,7 @@ public final class Signature extends Attribute { return; } - StringBuffer buf2 = new StringBuffer(); + StringBuilder buf2 = new StringBuilder(); ch = in.read(); do { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/StackMap.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/StackMap.java index 29f9c1535..263cda9af 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/StackMap.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/StackMap.java @@ -64,7 +64,7 @@ import org.aspectj.apache.bcel.Constants; * This class represents a stack map attribute used for preverification of Java classes for the <a href="http://java.sun.com/j2me/"> * Java 2 Micro Edition</a> (J2ME). This attribute is used by the <a href="http://java.sun.com/products/cldc/">KVM</a> and contained * within the Code attribute of a method. See CLDC specification 5.3.1.2 - * + * * @version $Id: StackMap.java,v 1.6 2009/09/15 19:40:12 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Code @@ -77,11 +77,11 @@ public final class StackMap extends Attribute { /* * @param name_index Index of name - * + * * @param length Content length in bytes - * + * * @param map Table of stack map entries - * + * * @param constant_pool Array of constants */ public StackMap(int name_index, int length, StackMapEntry[] map, ConstantPool constant_pool) { @@ -92,7 +92,7 @@ public final class StackMap extends Attribute { /** * Construct object from file stream. - * + * * @param name_index Index of name * @param length Content length in bytes * @param file Input stream @@ -111,7 +111,7 @@ public final class StackMap extends Attribute { /** * Dump line number table attribute to file stream in binary format. - * + * * @param file Output file stream * @throws IOException */ @@ -144,7 +144,7 @@ public final class StackMap extends Attribute { */ @Override public final String toString() { - StringBuffer buf = new StringBuffer("StackMap("); + StringBuilder buf = new StringBuilder("StackMap("); for (int i = 0; i < map_length; i++) { buf.append(map[i].toString()); @@ -176,7 +176,7 @@ public final class StackMap extends Attribute { /** * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the * hierarchy of methods, fields, attributes, etc. spawns a tree of objects. - * + * * @param v Visitor object */ @Override diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/StackMapEntry.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/StackMapEntry.java index 76bb2ab79..1ed14cd01 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/StackMapEntry.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/StackMapEntry.java @@ -113,7 +113,7 @@ public final class StackMapEntry implements Cloneable { * * @param file Output file stream * @throws IOException - */ + */ public final void dump(DataOutputStream file) throws IOException { file.writeShort(byte_code_offset); @@ -129,9 +129,9 @@ public final class StackMapEntry implements Cloneable { /** * @return String representation. - */ + */ public final String toString() { - StringBuffer buf = new StringBuffer("(offset=" + byte_code_offset); + StringBuilder buf = new StringBuilder("(offset=" + byte_code_offset); if(number_of_locals > 0) { buf.append(", locals={"); @@ -159,7 +159,7 @@ public final class StackMapEntry implements Cloneable { buf.append(")"); - return buf.toString(); + return buf.toString(); } @@ -198,12 +198,12 @@ public final class StackMapEntry implements Cloneable { /** * @return Constant pool used by this object. - */ + */ public final ConstantPool getConstantPool() { return constant_pool; } /** * @param constant_pool Constant pool to be used for this object. - */ + */ public final void setConstantPool(ConstantPool constant_pool) { this.constant_pool = constant_pool; } diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Synthetic.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Synthetic.java index 57fe97468..3c63f1131 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Synthetic.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Synthetic.java @@ -65,7 +65,7 @@ import org.aspectj.apache.bcel.Constants; * specification states "A class member that does not appear in the source code must be marked using a Synthetic attribute." It may * appear in the ClassFile attribute table, a field_info table or a method_info table. This class is intended to be instantiated * from the <em>Attribute.readAttribute()</em> method. - * + * * @version $Id: Synthetic.java,v 1.5 2009/09/15 19:40:12 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute @@ -81,7 +81,7 @@ public final class Synthetic extends Attribute { this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); } - // + // // public Synthetic(ConstantPoolGen cpool) { // super(Constants.ATTR_SYNTHETIC, cpool.addUtf8("Synthetic"), 0, cpool); // ConstantPoolGen cpg = myGen.getConstantPool(); @@ -102,7 +102,7 @@ public final class Synthetic extends Attribute { /** * Construct object from file stream. - * + * * @param name_index Index in constant pool to CONSTANT_Utf8 * @param length Content length in bytes * @param file Input stream @@ -122,7 +122,7 @@ public final class Synthetic extends Attribute { /** * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the * hierarchy of methods, fields, attributes, etc. spawns a tree of objects. - * + * * @param v Visitor object */ @Override @@ -132,7 +132,7 @@ public final class Synthetic extends Attribute { /** * Dump source file attribute to file stream in binary format. - * + * * @param file Output file stream * @throws IOException */ @@ -162,7 +162,7 @@ public final class Synthetic extends Attribute { */ @Override public final String toString() { - StringBuffer buf = new StringBuffer("Synthetic"); + StringBuilder buf = new StringBuilder("Synthetic"); if (length > 0) buf.append(" " + Utility.toHexString(bytes)); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java index 71573a311..921570515 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/Utility.java @@ -74,10 +74,10 @@ import org.aspectj.apache.bcel.util.ByteSequence; /** * Utility functions that do not really belong to any class in particular. - * + * * @version $Id: Utility.java,v 1.14 2009/09/28 16:39:46 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * + * * modified: Andy Clement 2-mar-05 Removed unnecessary static and optimized */ public abstract class Utility { @@ -91,7 +91,7 @@ public abstract class Utility { /** * Convert bit field of flags into string such as 'static final'. - * + * * @param access_flags Access flags * @return String representation of flags */ @@ -101,16 +101,16 @@ public abstract class Utility { /** * Convert bit field of flags into string such as 'static final'. - * + * * Special case: Classes compiled with new compilers and with the 'ACC_SUPER' flag would be said to be "synchronized". This is * because SUN used the same value for the flags 'ACC_SUPER' and 'ACC_SYNCHRONIZED'. - * + * * @param access_flags Access flags * @param for_class access flags are for class qualifiers ? * @return String representation of flags */ public static final String accessToString(int access_flags, boolean for_class) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); int p = 0; for (int i = 0; p < Constants.MAX_ACC_FLAG; i++) { // Loop through known flags @@ -136,7 +136,7 @@ public abstract class Utility { /** * Disassemble a byte array of JVM byte codes starting from code line 'index' and return the disassembled string representation. * Decode only 'num' opcodes (including their operands), use -1 if you want to decompile everything. - * + * * @param code byte code array * @param constant_pool Array of constants * @param index offset in `code' array <EM>(number of opcodes, not bytes!)</EM> @@ -145,7 +145,7 @@ public abstract class Utility { * @return String representation of byte codes */ public static final String codeToString(byte[] code, ConstantPool constant_pool, int index, int length, boolean verbose) { - StringBuffer buf = new StringBuffer(code.length * 20); // Should be sufficient + StringBuilder buf = new StringBuilder(code.length * 20); // Should be sufficient ByteSequence stream = new ByteSequence(code); try { @@ -182,7 +182,7 @@ public abstract class Utility { /** * Shorten long class names, <em>java/lang/String</em> becomes <em>String</em>. - * + * * @param str The long class name * @return Compacted class name */ @@ -193,7 +193,7 @@ public abstract class Utility { /** * Shorten long class name <em>str</em>, i.e., chop off the <em>prefix</em>, if the class name starts with this string and the * flag <em>chopit</em> is true. Slashes <em>/</em> are converted to dots <em>.</em>. - * + * * @param str The long class name * @param prefix The prefix the get rid off * @param chopit Flag that determines whether chopping is executed or not @@ -217,7 +217,7 @@ public abstract class Utility { /** * Shorten long class names, <em>java/lang/String</em> becomes <em>java.lang.String</em>, e.g.. If <em>chopit</em> is * <em>true</em> the prefix <em>java.lang</em> is also removed. - * + * * @param str The long class name * @param chopit Flag that determines whether chopping is executed or not * @return Compacted class name @@ -240,7 +240,7 @@ public abstract class Utility { */ public static final String methodSignatureToString(String signature, String name, String access, boolean chopit, LocalVariableTable vars) throws ClassFormatException { - StringBuffer buf = new StringBuffer("("); + StringBuilder buf = new StringBuilder("("); String type; int index; int var_index = (access.contains("static")) ? 0 : 1; @@ -298,7 +298,7 @@ public abstract class Utility { /** * Replace all occurences of <em>old</em> in <em>str</em> with <em>new</em>. - * + * * @param str String to permute * @param old String to be replaced * @param new Replacement string @@ -306,7 +306,7 @@ public abstract class Utility { */ public static final String replace(String str, String old, String new_) { int index, old_index; - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); try { index = str.indexOf(old); @@ -332,7 +332,7 @@ public abstract class Utility { /** * Converts signature to string with all class names compacted. - * + * * @param signature to convert * @return Human readable signature */ @@ -381,7 +381,7 @@ public abstract class Utility { int genericEnd = signature.indexOf('>'); // FIXME asc going to need a lot more work in here for generics ResultHolder rh = signatureToStringInternal(signature.substring(genericStart + 1, genericEnd), chopit); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(signature.substring(1, genericStart)); sb.append("<").append(rh.getResult()).append(">"); ResultHolder retval = new ResultHolder(compactClassName(sb.toString(), chopit), genericEnd + 1); @@ -399,10 +399,10 @@ public abstract class Utility { return ResultHolder.BOOLEAN; case '[': { // Array declaration - StringBuffer brackets; + StringBuilder brackets; int consumedChars, n; - brackets = new StringBuffer(); // Accumulate []'s + brackets = new StringBuilder(); // Accumulate []'s // Count opening brackets and look for optional size argument for (n = 0; signature.charAt(n) == '['; n++) { brackets.append("[]"); @@ -426,7 +426,7 @@ public abstract class Utility { /** * Return type of method signature as a byte value as defined in <em>Constants</em> - * + * * @param signature in format described above * @return type of method signature * @see Constants @@ -453,11 +453,11 @@ public abstract class Utility { /** * Convert bytes into hexidecimal string - * + * * @return bytes as hexidecimal string, e.g. 00 FA 12 ... */ public static final String toHexString(byte[] bytes) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { short b = byteToShort(bytes[i]); @@ -480,7 +480,7 @@ public abstract class Utility { /** * Return a string for an integer justified left or right and filled up with 'fill' characters if necessary. - * + * * @param i integer to format * @param length length of desired string * @param left_justify format left or right @@ -493,7 +493,7 @@ public abstract class Utility { /** * Fillup char with up to length characters with char `fill' and justify it left or right. - * + * * @param str string to format * @param length length of desired string * @param left_justify format left or right @@ -520,7 +520,7 @@ public abstract class Utility { */ public static final String convertString(String label) { char[] ch = label.toCharArray(); - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (char c : ch) { switch (c) { @@ -550,7 +550,7 @@ public abstract class Utility { /** * Converts a list of AnnotationGen objects into a set of attributes that can be attached to the class file. - * + * * @param cp The constant pool gen where we can create the necessary name refs * @param annotations A list of AnnotationGen objects */ @@ -747,7 +747,7 @@ public abstract class Utility { /** * Return type of signature as a byte value as defined in <em>Constants</em> - * + * * @param signature in format described above * @return type of signature * @see Constants @@ -816,7 +816,7 @@ public abstract class Utility { /** * Disassemble a stream of byte codes and return the string representation. - * + * * @param bytes stream of bytes * @param constant_pool Array of constants * @param verbose be verbose, e.g. print constant pool index @@ -828,7 +828,7 @@ public abstract class Utility { int index, vindex, constant; int[] match, jump_table; int no_pad_bytes = 0, offset; - StringBuffer buf = new StringBuffer(Constants.OPCODE_NAMES[opcode]); + StringBuilder buf = new StringBuilder(Constants.OPCODE_NAMES[opcode]); /* * Special case: Skip (0-3) padding bytes, i.e., the following bytes are 4-byte-aligned @@ -995,13 +995,13 @@ public abstract class Utility { + bytes.readUnsignedByte()); // Last byte is a reserved // space break; - + case Constants.INVOKEDYNAMIC://http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.invokedynamic index = bytes.readUnsignedShort(); bytes.readUnsignedShort(); // zeroes buf.append("\t" + constant_pool.constantToString(index) + (verbose ? " (" + index + ")" : "")); break; - + // Operands are references to items in constant pool case Constants.LDC_W: case Constants.LDC2_W: @@ -1076,13 +1076,13 @@ public abstract class Utility { /** * Convert type to Java method signature, e.g. int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I - * + * * @param returnType what the method returns * @param argTypes what are the argument types * @return method signature for given type(s). */ public static String toMethodSignature(Type returnType, Type[] argTypes) { - StringBuffer buf = new StringBuffer("("); + StringBuilder buf = new StringBuilder("("); int length = (argTypes == null) ? 0 : argTypes.length; for (int i = 0; i < length; i++) { buf.append(argTypes[i].getSignature()); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java index d5995b274..3fb6de6d7 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java @@ -48,7 +48,7 @@ public class AnnotationElementValue extends ElementValue { @Override public String stringifyValue() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(a.getTypeIndex(), Constants.CONSTANT_Utf8); sb.append(cu8.getValue()); // haven't really tested this values section: diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java index 93c875d4c..b05a02705 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java @@ -113,7 +113,7 @@ public class AnnotationGen { @Override public String toString() { - StringBuffer s = new StringBuffer(); + StringBuilder s = new StringBuilder(); s.append("AnnotationGen:[" + getTypeName() + " #" + pairs.size() + " {"); for (int i = 0; i < pairs.size(); i++) { s.append(pairs.get(i)); @@ -125,7 +125,7 @@ public class AnnotationGen { } public String toShortString() { - StringBuffer s = new StringBuffer(); + StringBuilder s = new StringBuilder(); s.append("@").append(getTypeName()); if (pairs.size()!=0) { s.append("("); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java index 3481f64a8..68b7db7c8 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java @@ -62,7 +62,7 @@ public class ArrayElementValue extends ElementValue { @Override public String stringifyValue() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < evalues.length; i++) { ElementValue element = evalues[i]; diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java index 6d16ff732..29e4d8710 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java @@ -76,7 +76,7 @@ public class EnumElementValue extends ElementValue { */ @Override public String stringifyValue() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(typeIdx, Constants.CONSTANT_Utf8); sb.append(cu8.getValue()); cu8 = (ConstantUtf8) cpool.getConstant(valueIdx, Constants.CONSTANT_Utf8); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/NameValuePair.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/NameValuePair.java index 0140b34cb..8da630400 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/NameValuePair.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/NameValuePair.java @@ -68,7 +68,7 @@ public class NameValuePair { @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getNameString()).append("=").append(value.stringifyValue()); return sb.toString(); } diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ArrayType.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ArrayType.java index d9599289b..63f6db57b 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ArrayType.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ArrayType.java @@ -55,7 +55,7 @@ package org.aspectj.apache.bcel.generic; */ import org.aspectj.apache.bcel.Constants; -/** +/** * Denotes array type, such as int[][] * * @version $Id: ArrayType.java,v 1.4 2008/08/26 15:02:04 aclement Exp $ @@ -69,7 +69,7 @@ public final class ArrayType extends ReferenceType { * Convenience constructor for array type, e.g. int[] * * @param type array type, e.g. T_INT - */ + */ public ArrayType(byte type, int dimensions) { this(BasicType.getType(type), dimensions); } @@ -78,7 +78,7 @@ public final class ArrayType extends ReferenceType { * Convenience constructor for reference array type, e.g. Object[] * * @param class_name complete name of class (java.lang.String, e.g.) - */ + */ public ArrayType(String class_name, int dimensions) { this(new ObjectType(class_name), dimensions); } @@ -87,7 +87,7 @@ public final class ArrayType extends ReferenceType { * Constructor for array of given type * * @param type type of array (may be an array itself) - */ + */ public ArrayType(Type type, int dimensions) { super(Constants.T_ARRAY, "<dummy>"); @@ -100,7 +100,7 @@ public final class ArrayType extends ReferenceType { this.dimensions = dimensions + array.dimensions; basic_type = array.basic_type; break; - + case Constants.T_VOID: throw new ClassGenException("Invalid type: void[]"); @@ -110,7 +110,7 @@ public final class ArrayType extends ReferenceType { break; } - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for(int i=0; i < this.dimensions; i++) buf.append('['); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java index 454b74203..78ba1f465 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java @@ -75,7 +75,7 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnos; /** * Template class for building up a field. The only extraordinary thing one can do is to add a constant value attribute to a field * (which must of course be compatible with the declared type). - * + * * @version $Id: FieldGen.java,v 1.11 2011/10/03 22:41:24 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Field @@ -86,7 +86,7 @@ public class FieldGen extends FieldGenOrMethodGen { /** * Declare a field. If it is static (isStatic() == true) and has a basic type like int or String it may have an initial value * associated with it as defined by setInitValue(). - * + * * @param modifiers access qualifiers * @param type field type * @param name field name @@ -101,7 +101,7 @@ public class FieldGen extends FieldGenOrMethodGen { /** * Instantiate from existing field. - * + * * @param field Field object * @param cp constant pool (must contain the same entries as the field's constant pool) */ @@ -230,7 +230,7 @@ public class FieldGen extends FieldGenOrMethodGen { String signature = type.toString(); String name = getName(); - StringBuffer buf = new StringBuffer(access).append(signature).append(" ").append(name); + StringBuilder buf = new StringBuilder(access).append(signature).append(" ").append(name); String value = getInitialValue(); if (value != null) { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Instruction.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Instruction.java index 3fa40ac0f..3754e47b9 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Instruction.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Instruction.java @@ -64,7 +64,7 @@ import org.aspectj.apache.bcel.util.ByteSequence; /** * Abstract super class for all Java byte codes. - * + * * @version $Id: Instruction.java,v 1.10 2011/04/05 15:15:33 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ @@ -86,7 +86,7 @@ public class Instruction implements Cloneable, Serializable, Constants { /** * Use with caution, since 'BranchInstruction's have a 'target' reference which is not copied correctly (only basic types are). * This also applies for 'Select' instructions with their multiple branch targets. - * + * * @return (shallow) copy of an instruction */ // GET RID OF THIS - make it throw an exception and track the callers @@ -107,7 +107,7 @@ public class Instruction implements Cloneable, Serializable, Constants { /** * Read an instruction bytecode from an input stream and return the appropriate object. - * + * * @param file file to read from * @return instruction object being read */ @@ -439,7 +439,7 @@ public class Instruction implements Cloneable, Serializable, Constants { */ public String toString(boolean verbose) { if (verbose) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getName()).append("[").append(opcode).append("](size").append(Constants.iLen[opcode]).append(")"); return sb.toString(); } else { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionCP.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionCP.java index 09222d6a4..77fadcf26 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionCP.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionCP.java @@ -70,7 +70,7 @@ import org.aspectj.apache.bcel.classfile.ConstantUtf8; /** * Class for instructions that use an index into the constant pool such as LDC, INVOKEVIRTUAL, etc. - * + * * @version $Id: InstructionCP.java,v 1.6 2009/10/05 17:35:36 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ @@ -111,10 +111,10 @@ public class InstructionCP extends Instruction { /** * Long output format: - * + * * <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< constant pool * index>">" - * + * * @param verbose long/short format switch * @return mnemonic for instruction */ @@ -172,7 +172,7 @@ public class InstructionCP extends Instruction { // ConstantPool cp = cpg.getConstantPool(); // String name = cp.getConstantString(index, CONSTANT_Class); if (!name.startsWith("[")) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("L").append(name).append(";"); return Type.getType(sb.toString()); } else { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java index 690c9f600..cb580de26 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java @@ -74,9 +74,9 @@ import org.aspectj.apache.bcel.util.ByteSequence; * inserted, moved, deleted, etc.. Instructions are being wrapped into <a href="InstructionHandle.html">InstructionHandles</a> * objects that are returned upon append/insert operations. They give the user (read only) access to the list structure, such that * it can be traversed and manipulated in a controlled way. - * + * * A list is finally dumped to a byte code array with <a href="#getByteCode()">getByteCode</a>. - * + * * @version $Id: InstructionList.java,v 1.12 2011/09/02 22:33:04 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author Abraham Nevado @@ -106,7 +106,7 @@ public class InstructionList implements Serializable { /** * Find the target instruction (handle) that corresponds to the given target position (byte code offset). - * + * * @param ihs array of instruction handles, i.e. il.getInstructionHandles() * @param pos array of positions corresponding to ihs, i.e. il.getInstructionPositions() * @param count length of arrays @@ -143,7 +143,7 @@ public class InstructionList implements Serializable { /** * Get instruction handle for instruction at byte code position pos. This only works properly, if the list is freshly * initialized from a byte array or setPositions() has been called before this method. - * + * * @param pos byte code position to search for * @return target position's instruction handle if available */ @@ -166,7 +166,7 @@ public class InstructionList implements Serializable { /** * Initialize instruction list from byte array. - * + * * @param code byte array containing the instructions */ public InstructionList(byte[] code) { @@ -248,7 +248,7 @@ public class InstructionList implements Serializable { /** * Append another list after instruction (handle) ih contained in this list. Consumes argument list, i.e., it becomes empty. - * + * * @param appendTo where to append the instruction list * @param appendee Instruction list to append to this one * @return instruction handle pointing to the <B>first</B> appended instruction @@ -283,7 +283,7 @@ public class InstructionList implements Serializable { /** * Append another list after instruction i contained in this list. Consumes argument list, i.e., it becomes empty. - * + * * @param i where to append the instruction list * @param il Instruction list to append to this one * @return instruction handle pointing to the <B>first</B> appended instruction @@ -300,7 +300,7 @@ public class InstructionList implements Serializable { /** * Append another list to this one. Consumes argument list, i.e., it becomes empty. - * + * * @param il list to append to end of this list * @return instruction handle of the <B>first</B> appended instruction */ @@ -326,7 +326,7 @@ public class InstructionList implements Serializable { /** * Append an instruction to the end of this list. - * + * * @param ih instruction to append */ private void append(InstructionHandle ih) { @@ -345,7 +345,7 @@ public class InstructionList implements Serializable { /** * Append an instruction to the end of this list. - * + * * @param i instruction to append * @return instruction handle of the appended instruction */ @@ -376,7 +376,7 @@ public class InstructionList implements Serializable { /** * Append a branch instruction to the end of this list. - * + * * @param i branch instruction to append * @return branch instruction handle of the appended instruction */ @@ -389,7 +389,7 @@ public class InstructionList implements Serializable { /** * Append a single instruction j after another instruction i, which must be in this list of course! - * + * * @param i Instruction in list * @param j Instruction to append after i in list * @return instruction handle of the first appended instruction @@ -400,7 +400,7 @@ public class InstructionList implements Serializable { /** * Append an instruction after instruction (handle) ih contained in this list. - * + * * @param ih where to append the instruction list * @param i Instruction to append * @return instruction handle pointing to the <B>first</B> appended instruction @@ -411,7 +411,7 @@ public class InstructionList implements Serializable { /** * Append an instruction after instruction (handle) ih contained in this list. - * + * * @param ih where to append the instruction list * @param i Instruction to append * @return instruction handle pointing to the <B>first</B> appended instruction @@ -428,7 +428,7 @@ public class InstructionList implements Serializable { /** * Insert another list before Instruction handle ih contained in this list. Consumes argument list, i.e., it becomes empty. - * + * * @param i where to append the instruction list * @param il Instruction list to insert * @return instruction handle of the first inserted instruction @@ -464,7 +464,7 @@ public class InstructionList implements Serializable { /** * Insert another list. - * + * * @param il list to insert before start of this list * @return instruction handle of the first inserted instruction */ @@ -479,7 +479,7 @@ public class InstructionList implements Serializable { /** * Insert an instruction at start of this list. - * + * * @param ih instruction to insert */ private void insert(InstructionHandle ih) { @@ -498,7 +498,7 @@ public class InstructionList implements Serializable { /** * Insert another list before Instruction i contained in this list. Consumes argument list, i.e., it becomes empty. - * + * * @param i where to append the instruction list * @param il Instruction list to insert * @return instruction handle pointing to the first inserted instruction, i.e., il.getStart() @@ -515,7 +515,7 @@ public class InstructionList implements Serializable { /** * Insert an instruction at start of this list. - * + * * @param i instruction to insert * @return instruction handle of the inserted instruction */ @@ -528,7 +528,7 @@ public class InstructionList implements Serializable { /** * Insert a branch instruction at start of this list. - * + * * @param i branch instruction to insert * @return branch instruction handle of the appended instruction */ @@ -540,7 +540,7 @@ public class InstructionList implements Serializable { /** * Insert a single instruction j before another instruction i, which must be in this list of course! - * + * * @param i Instruction in list * @param j Instruction to insert before i in list * @return instruction handle of the first inserted instruction @@ -551,7 +551,7 @@ public class InstructionList implements Serializable { /** * Insert an instruction before instruction (handle) ih contained in this list. - * + * * @param ih where to insert to the instruction list * @param i Instruction to insert * @return instruction handle of the first inserted instruction @@ -562,7 +562,7 @@ public class InstructionList implements Serializable { /** * Insert an instruction before instruction (handle) ih contained in this list. - * + * * @param ih where to insert to the instruction list * @param i Instruction to insert * @return instruction handle of the first inserted instruction @@ -582,7 +582,7 @@ public class InstructionList implements Serializable { * be after "start" and target must not be located withing this range. If you want to move something to the start of the list * use null as value for target.<br> * Any instruction targeters pointing to handles within the block, keep their targets. - * + * * @param start of moved block * @param end of moved block * @param target of moved block @@ -644,7 +644,7 @@ public class InstructionList implements Serializable { /** * Move a single instruction (handle) to a new location. - * + * * @param ih moved instruction * @param target new location of moved instruction */ @@ -654,10 +654,10 @@ public class InstructionList implements Serializable { /** * Remove from instruction 'prev' to instruction 'next' both contained in this list. - * + * * If careAboutLostTargeters is true then this method will throw a TargetLostException when one of the removed instruction * handles is still being targeted. - * + * * @param prev where to start deleting (predecessor, exclusive) * @param next where to end deleting (successor, exclusive) */ @@ -697,7 +697,7 @@ public class InstructionList implements Serializable { ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets } - StringBuffer buf = new StringBuffer("{ "); + StringBuilder buf = new StringBuilder("{ "); for (InstructionHandle ih = first; ih != null; ih = next) { next = ih.next; length--; @@ -757,7 +757,7 @@ public class InstructionList implements Serializable { /** * Remove instruction from this list. The corresponding Instruction handles must not be reused! - * + * * @param ih instruction (handle) to remove */ public void delete(InstructionHandle ih) throws TargetLostException { @@ -766,7 +766,7 @@ public class InstructionList implements Serializable { /** * Remove instruction from this list. The corresponding Instruction handles must not be reused! - * + * * @param i instruction to remove */ // public void delete(Instruction i) throws TargetLostException { @@ -780,7 +780,7 @@ public class InstructionList implements Serializable { /** * Remove instructions from instruction `from' to instruction `to' contained in this list. The user must ensure that `from' is * an instruction before `to', or risk havoc. The corresponding Instruction handles must not be reused! - * + * * @param from where to start deleting (inclusive) * @param to where to end deleting (inclusive) */ @@ -791,7 +791,7 @@ public class InstructionList implements Serializable { /** * Remove instructions from instruction `from' to instruction `to' contained in this list. The user must ensure that `from' is * an instruction before `to', or risk havoc. The corresponding Instruction handles must not be reused! - * + * * @param from where to start deleting (inclusive) * @param to where to end deleting (inclusive) */ @@ -810,7 +810,7 @@ public class InstructionList implements Serializable { /** * Search for given Instruction reference, start at beginning of list. - * + * * @param i instruction to search for * @return instruction found on success, null otherwise */ @@ -826,7 +826,7 @@ public class InstructionList implements Serializable { /** * Search for given Instruction reference, start at end of list - * + * * @param i instruction to search for * @return instruction found on success, null otherwise */ @@ -864,7 +864,7 @@ public class InstructionList implements Serializable { /** * Give all instructions their position number (offset in byte stream), i.e., make the list ready to be dumped. - * + * * @param check Perform sanity checks, e.g. if all targeted instructions really belong to this list */ public void setPositions(boolean check) { @@ -972,7 +972,7 @@ public class InstructionList implements Serializable { /** * When everything is finished, use this method to convert the instruction list into an array of bytes. - * + * * @return the byte code ready to be dumped */ public byte[] getByteCode() { @@ -1029,7 +1029,7 @@ public class InstructionList implements Serializable { * @return String containing all instructions in this list. */ public String toString(boolean verbose) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (InstructionHandle ih = start; ih != null; ih = ih.next) { buf.append(ih.toString(verbose) + "\n"); @@ -1079,7 +1079,7 @@ public class InstructionList implements Serializable { /** * Get positions (offsets) of all instructions in the list. This relies on that the list has been freshly created from an byte * code array, or that setPositions() has been called. Otherwise this may be inaccurate. - * + * * @return array containing all instruction's offset in byte code */ public int[] getInstructionPositions() { @@ -1208,7 +1208,7 @@ public class InstructionList implements Serializable { /** * Redirect all references from old_target to new_target, i.e., update targets of branch instructions. - * + * * @param old_target the old target instruction handle * @param new_target the new target instruction handle */ @@ -1239,7 +1239,7 @@ public class InstructionList implements Serializable { /** * Redirect all references of local variables from old_target to new_target. - * + * * @param lg array of local variables * @param old_target the old target instruction handle * @param new_target the new target instruction handle @@ -1261,7 +1261,7 @@ public class InstructionList implements Serializable { /** * Redirect all references of exception handlers from old_target to new_target. - * + * * @param exceptions array of exception handlers * @param old_target the old target instruction handle * @param new_target the new target instruction handle diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionSelect.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionSelect.java index 408f801ff..771461ab5 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionSelect.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionSelect.java @@ -60,7 +60,7 @@ import org.aspectj.apache.bcel.util.ByteSequence; /** * Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions. - * + * * @version $Id: InstructionSelect.java,v 1.4 2009/10/05 17:35:36 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see LOOKUPSWITCH @@ -79,7 +79,7 @@ public abstract class InstructionSelect extends InstructionBranch { /** * (Match, target) pairs for switch. `Match' and `targets' must have the same length of course. - * + * * @param match array of matching values * @param targets instruction targets * @param target default instruction target @@ -119,11 +119,11 @@ public abstract class InstructionSelect extends InstructionBranch { /** * Since this is a variable length instruction, it may shift the following instructions which then need to update their * position. - * + * * Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable length * instructions `setPositions' performs multiple passes over the instruction list to calculate the correct (byte) positions and * offsets by calling this function. - * + * * @param offset additional offset caused by preceding (variable length) instructions * @param max_offset the maximum offset that may be caused by these instructions * @return additional offset caused by possible change of this instruction's length @@ -146,7 +146,7 @@ public abstract class InstructionSelect extends InstructionBranch { /** * Dump instruction as byte code to stream out. - * + * * @param out Output stream */ public void dump(DataOutputStream out) throws IOException { @@ -177,7 +177,7 @@ public abstract class InstructionSelect extends InstructionBranch { * @return mnemonic for instruction */ public String toString(boolean verbose) { - StringBuffer buf = new StringBuffer(super.toString(verbose)); + StringBuilder buf = new StringBuilder(super.toString(verbose)); if (verbose) { for (int i = 0; i < matchLength; i++) { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java index 6bc66480f..ced5e3be5 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java @@ -79,10 +79,10 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeParamAnnos; * Template class for building up a method. This is done by defining exception handlers, adding thrown exceptions, local variables * and attributes, whereas the 'LocalVariableTable' and 'LineNumberTable' attributes will be set automatically for the code. Use * stripAttributes() if you don't like this. - * + * * While generating code it may be necessary to insert NOP operations. You can use the `removeNOPs' method to get rid off them. The * resulting method object can be obtained via the `getMethod()' method. - * + * * @version $Id: MethodGen.java,v 1.17 2011/05/19 23:23:46 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author <A HREF="http://www.vmeng.com/beard">Patrick C. Beard</A> [setMaxStack()] @@ -115,10 +115,10 @@ public class MethodGen extends FieldGenOrMethodGen { * Declare method. If the method is non-static the constructor automatically declares a local variable `$this' in slot 0. The * actual code is contained in the `il' parameter, which may further manipulated by the user. But he must take care not to * remove any instruction (handles) that are still referenced from this object. - * + * * For example one may not add a local variable and later remove the instructions it refers to without causing havoc. It is safe * however if you remove that local variable, too. - * + * * @param access_flags access qualifiers * @param return_type method type * @param arg_types argument types @@ -164,7 +164,7 @@ public class MethodGen extends FieldGenOrMethodGen { // throw new ClassGenException("'void' is an illegal argument type for a method"); // } // } - // + // // if(arg_names != null) { // Names for variables provided? // if(size != arg_names.length) // throw new ClassGenException("Mismatch in argument array lengths: " + @@ -192,7 +192,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Instantiate from existing method. - * + * * @param m method * @param class_name class name containing this method * @param cp constant pool @@ -362,7 +362,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Adds a local variable to this method and assigns an index automatically. - * + * * @param name variable name * @param type variable type * @param start from where the variable is valid, if this is null, it is valid from the start @@ -424,7 +424,7 @@ public class MethodGen extends FieldGenOrMethodGen { /* * If the range of the variable has not been set yet, it will be set to be valid from the start to the end of the instruction * list. - * + * * @return array of declared local variables sorted by index */ public LocalVariableGen[] getLocalVariables() { @@ -466,7 +466,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Give an instruction a line number corresponding to the source code line. - * + * * @param ih instruction to tag * @return new line number object * @see LineNumber @@ -517,7 +517,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Add an exception handler, i.e., specify region where a handler is active and an instruction where the actual handling is * done. - * + * * @param start_pc Start of region (inclusive) * @param end_pc End of region (inclusive) * @param handler_pc Where handling is done @@ -578,7 +578,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Add an exception possibly thrown by this method. - * + * * @param class_name (fully qualified) name of exception */ public void addException(String class_name) { @@ -629,7 +629,7 @@ public class MethodGen extends FieldGenOrMethodGen { * Add an attribute to the code. Currently, the JVM knows about the LineNumberTable, LocalVariableTable and StackMap attributes, * where the former two will be generated automatically and the latter is used for the MIDP only. Other attributes will be * ignored by the JVM but do no harm. - * + * * @param a attribute to be added */ public void addCodeAttribute(Attribute a) { @@ -674,7 +674,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Get method object. Never forget to call setMaxStack() or setMaxStack(max), respectively, before calling this method (the same * applies for max locals). - * + * * @return method object */ public Method getMethod() { @@ -879,10 +879,10 @@ public class MethodGen extends FieldGenOrMethodGen { public void setMaxLocals() { setMaxLocals(false); } - + /** * Compute maximum number of local variables. - * + * * @param respectLocalVariableTable if true and the local variable table indicates more are in use * than the code suggests, respect the higher value from the local variable table data. */ @@ -966,7 +966,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Computes stack usage of an instruction list by performing control flow analysis. - * + * * @return maximum stack depth used by method */ public static int getMaxStack(ConstantPool cp, InstructionList il, CodeExceptionGen[] et) { @@ -1050,7 +1050,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Return string representation close to declaration format, `public static void main(String[]) throws IOException', e.g. - * + * * @return String representation of the method. */ @Override @@ -1060,7 +1060,7 @@ public class MethodGen extends FieldGenOrMethodGen { signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable(cp)); - StringBuffer buf = new StringBuffer(signature); + StringBuilder buf = new StringBuilder(signature); if (exceptionsThrown.size() > 0) { for (String s : exceptionsThrown) { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ObjectType.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ObjectType.java index 544363f16..d7282122c 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ObjectType.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ObjectType.java @@ -59,7 +59,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; /** * Denotes reference such as java.lang.String. - * + * * @version $Id: ObjectType.java,v 1.7 2009/09/28 16:39:46 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ @@ -84,7 +84,7 @@ public class ObjectType extends ReferenceType { } private static String toSignature(String classname) { - StringBuffer sig = new StringBuffer(); + StringBuilder sig = new StringBuilder(); sig.append("L").append(classname.replace('.', '/')); sig.append(";"); return sig.toString(); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Type.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Type.java index ed8995ef0..79361a7ed 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Type.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/Type.java @@ -67,10 +67,10 @@ import org.aspectj.apache.bcel.classfile.Utility; /** * Abstract super class for all possible java types, namely basic types such as int, object types like String and array types, e.g. * int[] - * + * * @version $Id: Type.java,v 1.14 2011/09/28 01:14:54 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * + * * modified: AndyClement 2-mar-05: Removed unnecessary static and optimized */ public abstract class Type { @@ -233,7 +233,7 @@ public abstract class Type { /** * Convert signature to a Type object. - * + * * @param signature signature string such as Ljava/lang/String; * @return type object */ @@ -292,7 +292,7 @@ public abstract class Type { /** * Convert return value of a method (signature) to a Type object. - * + * * @param signature signature string such as (Ljava/lang/String;)V * @return return type */ @@ -308,7 +308,7 @@ public abstract class Type { /** * Convert arguments of a method (signature) to an array of Type objects. - * + * * @param signature signature string such as (Ljava/lang/String;)V * @return array of argument types */ @@ -419,7 +419,7 @@ public abstract class Type { /** * Convert runtime java.lang.Class to BCEL Type object. - * + * * @param cl Java class * @return corresponding Type object */ @@ -463,7 +463,7 @@ public abstract class Type { } public static String getSignature(java.lang.reflect.Method meth) { - StringBuffer sb = new StringBuffer("("); + StringBuilder sb = new StringBuilder("("); Class[] params = meth.getParameterTypes(); // avoid clone for (Class param : params) { @@ -476,7 +476,7 @@ public abstract class Type { } public static String getSignature(java.lang.reflect.Constructor<?> cons) { - StringBuffer sb = new StringBuffer("("); + StringBuilder sb = new StringBuilder("("); Class<?>[] params = cons.getParameterTypes(); // avoid clone for (Class<?> param : params) { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassLoaderRepository.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassLoaderRepository.java index be9aa0b45..e16d0efff 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassLoaderRepository.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassLoaderRepository.java @@ -73,11 +73,11 @@ import org.aspectj.apache.bcel.classfile.JavaClass; /** * The repository maintains information about which classes have been loaded. - * + * * It loads its data from the ClassLoader implementation passed into its constructor. - * + * * @see org.aspectj.apache.bcel.Repository - * + * * @version $Id: ClassLoaderRepository.java,v 1.13 2009/09/09 19:56:20 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author David Dixon-Peugh @@ -334,7 +334,7 @@ public class ClassLoaderRepository implements Repository { * Produce a report on cache usage. */ public String report() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("BCEL repository report."); if (useSharedCache) sb.append(" (shared cache)"); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java index 29f8f6d6d..942364b92 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java @@ -217,7 +217,7 @@ public class ClassPath implements Serializable { list.add(ext_dir.toString() + File.separatorChar + extension); } - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (Iterator<String> e = list.iterator(); e.hasNext();) { buf.append(e.next()); diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java index a67eaca0a..17d24d272 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java @@ -116,7 +116,7 @@ public abstract class BcelTestCase extends TestCase { } protected String dumpAnnotations(AnnotationGen[] as) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append("["); for (int i = 0; i < as.length; i++) { AnnotationGen annotation = as[i]; @@ -129,7 +129,7 @@ public abstract class BcelTestCase extends TestCase { } protected String dumpAnnotations(List<AnnotationGen> as) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append("["); for (int i = 0; i < as.size(); i++) { AnnotationGen annotation = as.get(i); @@ -142,7 +142,7 @@ public abstract class BcelTestCase extends TestCase { } protected String dumpAttributes(Attribute[] as) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append("AttributeArray:["); for (int i = 0; i < as.length; i++) { Attribute attr = as[i]; diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java index d5f53c98d..f1d06c265 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java @@ -324,7 +324,7 @@ public class GenericSignatureParsingTest extends BcelTestCase { * @return byte code signature */ public static String getSignature(String type) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); char[] chars = type.toCharArray(); boolean char_found = false, delim = false; int index = -1; @@ -451,7 +451,7 @@ public class GenericSignatureParsingTest extends BcelTestCase { */ public final static String methodTypeToSignature(String returnType, String[] methodArgs) throws ClassFormatException { - StringBuffer buf = new StringBuffer("("); + StringBuilder buf = new StringBuilder("("); if (methodArgs != null) { for (String methodArg : methodArgs) { |