summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShigeru Chiba <chibash@users.noreply.github.com>2022-05-13 02:45:42 +0900
committerGitHub <noreply@github.com>2022-05-13 02:45:42 +0900
commit8fc31b8ea3eaadd4f8e80fa06208cbf19e991b3c (patch)
treec678631763bf4862e26845edb0ddbdb0b5f11002
parentdf3f4b7641d39558465a17514bffce657f2a27da (diff)
parent0827c539b765d73c952bb56454f7dd3faf2b0879 (diff)
downloadjavassist-8fc31b8ea3eaadd4f8e80fa06208cbf19e991b3c.tar.gz
javassist-8fc31b8ea3eaadd4f8e80fa06208cbf19e991b3c.zip
Merge pull request #382 from tim-hoffman/PR_RemoveStringBuffer
Replace StringBuffer with StringBuilder, other minor String optimizations
-rw-r--r--src/main/javassist/ClassPoolTail.java6
-rw-r--r--src/main/javassist/CtBehavior.java2
-rw-r--r--src/main/javassist/CtClass.java10
-rw-r--r--src/main/javassist/CtClassType.java6
-rw-r--r--src/main/javassist/CtField.java2
-rw-r--r--src/main/javassist/CtMember.java12
-rw-r--r--src/main/javassist/CtNewClass.java2
-rw-r--r--src/main/javassist/bytecode/Descriptor.java24
-rw-r--r--src/main/javassist/bytecode/InstructionPrinter.java12
-rw-r--r--src/main/javassist/bytecode/ParameterAnnotationsAttribute.java2
-rw-r--r--src/main/javassist/bytecode/SignatureAttribute.java40
-rw-r--r--src/main/javassist/bytecode/analysis/ControlFlow.java6
-rw-r--r--src/main/javassist/bytecode/analysis/Frame.java4
-rw-r--r--src/main/javassist/bytecode/analysis/MultiType.java7
-rw-r--r--src/main/javassist/bytecode/annotation/Annotation.java9
-rw-r--r--src/main/javassist/bytecode/annotation/ArrayMemberValue.java5
-rw-r--r--src/main/javassist/bytecode/annotation/MemberValue.java4
-rw-r--r--src/main/javassist/bytecode/stackmap/BasicBlock.java14
-rw-r--r--src/main/javassist/bytecode/stackmap/TypeData.java2
-rw-r--r--src/main/javassist/bytecode/stackmap/TypedBlock.java4
-rw-r--r--src/main/javassist/compiler/CodeGen.java8
-rw-r--r--src/main/javassist/compiler/JvstCodeGen.java4
-rw-r--r--src/main/javassist/compiler/Lex.java14
-rw-r--r--src/main/javassist/compiler/MemberResolver.java2
-rw-r--r--src/main/javassist/compiler/Parser.java6
-rw-r--r--src/main/javassist/compiler/TypeChecker.java4
-rw-r--r--src/main/javassist/compiler/ast/ASTList.java2
-rw-r--r--src/main/javassist/compiler/ast/ASTree.java2
-rw-r--r--src/main/javassist/compiler/ast/Declarator.java4
-rw-r--r--src/main/javassist/compiler/ast/Pair.java2
-rw-r--r--src/main/javassist/convert/TransformAccessArrayField.java2
-rw-r--r--src/main/javassist/tools/rmi/StubGenerator.java2
-rw-r--r--src/main/javassist/tools/web/Webserver.java2
-rw-r--r--src/main/javassist/util/proxy/ProxyFactory.java6
-rw-r--r--src/main/javassist/util/proxy/RuntimeSupport.java6
35 files changed, 121 insertions, 118 deletions
diff --git a/src/main/javassist/ClassPoolTail.java b/src/main/javassist/ClassPoolTail.java
index 1aa948f7..d86cd768 100644
--- a/src/main/javassist/ClassPoolTail.java
+++ b/src/main/javassist/ClassPoolTail.java
@@ -54,7 +54,7 @@ final class DirClassPath implements ClassPath {
char sep = File.separatorChar;
String filename = directory + sep
+ classname.replace('.', sep) + ".class";
- return new FileInputStream(filename.toString());
+ return new FileInputStream(filename);
}
catch (FileNotFoundException e) {}
catch (SecurityException e) {}
@@ -187,7 +187,7 @@ final class JarClassPath implements ClassPath {
@Override
public String toString() {
- return jarfileURL == null ? "<null>" : jarfileURL.toString();
+ return jarfileURL == null ? "<null>" : jarfileURL;
}
}
@@ -200,7 +200,7 @@ final class ClassPoolTail {
@Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append("[class path: ");
ClassPathList list = pathList;
while (list != null) {
diff --git a/src/main/javassist/CtBehavior.java b/src/main/javassist/CtBehavior.java
index da7cff04..595da505 100644
--- a/src/main/javassist/CtBehavior.java
+++ b/src/main/javassist/CtBehavior.java
@@ -100,7 +100,7 @@ public abstract class CtBehavior extends CtMember {
}
@Override
- protected void extendToString(StringBuffer buffer) {
+ protected void extendToString(StringBuilder buffer) {
buffer.append(' ');
buffer.append(getName());
buffer.append(' ');
diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java
index f1a47342..cba708ae 100644
--- a/src/main/javassist/CtClass.java
+++ b/src/main/javassist/CtClass.java
@@ -200,12 +200,12 @@ public abstract class CtClass {
*/
@Override
public String toString() {
- StringBuffer buf = new StringBuffer(getClass().getName());
- buf.append("@");
+ StringBuilder buf = new StringBuilder(getClass().getName());
+ buf.append('@');
buf.append(Integer.toHexString(hashCode()));
- buf.append("[");
+ buf.append('[');
extendToString(buf);
- buf.append("]");
+ buf.append(']');
return buf.toString();
}
@@ -213,7 +213,7 @@ public abstract class CtClass {
* Implemented in subclasses to add to the {@link #toString()} result.
* Subclasses should put a space before each token added to the buffer.
*/
- protected void extendToString(StringBuffer buffer) {
+ protected void extendToString(StringBuilder buffer) {
buffer.append(getName());
}
diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java
index 959ec302..22b873a6 100644
--- a/src/main/javassist/CtClassType.java
+++ b/src/main/javassist/CtClassType.java
@@ -106,7 +106,7 @@ class CtClassType extends CtClass {
}
@Override
- protected void extendToString(StringBuffer buffer) {
+ protected void extendToString(StringBuilder buffer) {
if (wasChanged)
buffer.append("changed ");
@@ -125,7 +125,7 @@ class CtClassType extends CtClass {
if (ext != null) {
String name = ext.getName();
if (!name.equals("java.lang.Object"))
- buffer.append(" extends " + ext.getName());
+ buffer.append(" extends ").append(ext.getName());
}
}
catch (NotFoundException e) {
@@ -155,7 +155,7 @@ class CtClassType extends CtClass {
memCache.methodHead(), memCache.lastMethod());
}
- private void exToString(StringBuffer buffer, String msg,
+ private void exToString(StringBuilder buffer, String msg,
CtMember head, CtMember tail) {
buffer.append(msg);
while (head != tail) {
diff --git a/src/main/javassist/CtField.java b/src/main/javassist/CtField.java
index 892fff82..dbcd82d5 100644
--- a/src/main/javassist/CtField.java
+++ b/src/main/javassist/CtField.java
@@ -128,7 +128,7 @@ public class CtField extends CtMember {
}
@Override
- protected void extendToString(StringBuffer buffer) {
+ protected void extendToString(StringBuilder buffer) {
buffer.append(' ');
buffer.append(getName());
buffer.append(' ');
diff --git a/src/main/javassist/CtMember.java b/src/main/javassist/CtMember.java
index 8de480c9..bacfead8 100644
--- a/src/main/javassist/CtMember.java
+++ b/src/main/javassist/CtMember.java
@@ -30,7 +30,7 @@ public abstract class CtMember {
*/
static class Cache extends CtMember {
@Override
- protected void extendToString(StringBuffer buffer) {}
+ protected void extendToString(StringBuilder buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
@@ -155,13 +155,13 @@ public abstract class CtMember {
@Override
public String toString() {
- StringBuffer buffer = new StringBuffer(getClass().getName());
- buffer.append("@");
+ StringBuilder buffer = new StringBuilder(getClass().getName());
+ buffer.append('@');
buffer.append(Integer.toHexString(hashCode()));
- buffer.append("[");
+ buffer.append('[');
buffer.append(Modifier.toString(getModifiers()));
extendToString(buffer);
- buffer.append("]");
+ buffer.append(']');
return buffer.toString();
}
@@ -172,7 +172,7 @@ public abstract class CtMember {
* provided first; subclasses should provide additional data such
* as return type, field or method name, etc.
*/
- protected abstract void extendToString(StringBuffer buffer);
+ protected abstract void extendToString(StringBuilder buffer);
/**
* Returns the class that declares this member.
diff --git a/src/main/javassist/CtNewClass.java b/src/main/javassist/CtNewClass.java
index b0a14806..496eaec7 100644
--- a/src/main/javassist/CtNewClass.java
+++ b/src/main/javassist/CtNewClass.java
@@ -45,7 +45,7 @@ class CtNewClass extends CtClassType {
}
@Override
- protected void extendToString(StringBuffer buffer) {
+ protected void extendToString(StringBuilder buffer) {
if (hasConstructor)
buffer.append("hasConstructor ");
diff --git a/src/main/javassist/bytecode/Descriptor.java b/src/main/javassist/bytecode/Descriptor.java
index fc49b876..4e4fd863 100644
--- a/src/main/javassist/bytecode/Descriptor.java
+++ b/src/main/javassist/bytecode/Descriptor.java
@@ -109,7 +109,7 @@ public class Descriptor {
if (arrayDim == 0)
return name;
- StringBuffer sbuf = new StringBuffer(name);
+ StringBuilder sbuf = new StringBuilder(name);
do {
sbuf.append("[]");
} while (--arrayDim > 0);
@@ -157,7 +157,7 @@ public class Descriptor {
if (desc.indexOf(oldname) < 0)
return desc;
- StringBuffer newdesc = new StringBuffer();
+ StringBuilder newdesc = new StringBuilder();
int head = 0;
int i = 0;
for (;;) {
@@ -200,7 +200,7 @@ public class Descriptor {
if (map == null)
return desc;
- StringBuffer newdesc = new StringBuffer();
+ StringBuilder newdesc = new StringBuilder();
int head = 0;
int i = 0;
for (;;) {
@@ -237,12 +237,12 @@ public class Descriptor {
* Returns the descriptor representing the given type.
*/
public static String of(CtClass type) {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
toDescriptor(sbuf, type);
return sbuf.toString();
}
- private static void toDescriptor(StringBuffer desc, CtClass type) {
+ private static void toDescriptor(StringBuilder desc, CtClass type) {
if (type.isArray()) {
desc.append('[');
try {
@@ -284,7 +284,7 @@ public class Descriptor {
* @param paramTypes parameter types
*/
public static String ofMethod(CtClass returnType, CtClass[] paramTypes) {
- StringBuffer desc = new StringBuffer();
+ StringBuilder desc = new StringBuilder();
desc.append('(');
if (paramTypes != null) {
int n = paramTypes.length;
@@ -323,7 +323,7 @@ public class Descriptor {
int i = desc.indexOf(')');
if (i < 0)
return desc;
- StringBuffer newdesc = new StringBuffer();
+ StringBuilder newdesc = new StringBuilder();
newdesc.append(desc.substring(0, i));
newdesc.append('L');
newdesc.append(classname.replace('.', '/'));
@@ -361,7 +361,7 @@ public class Descriptor {
int i = descriptor.indexOf(')');
if (i < 0)
return descriptor;
- StringBuffer newdesc = new StringBuffer();
+ StringBuilder newdesc = new StringBuilder();
newdesc.append(descriptor.substring(0, i));
toDescriptor(newdesc, type);
newdesc.append(descriptor.substring(i));
@@ -395,7 +395,7 @@ public class Descriptor {
int i = desc.indexOf(')');
if (i < 0)
return desc;
- StringBuffer newdesc = new StringBuffer();
+ StringBuilder newdesc = new StringBuilder();
newdesc.append(desc.substring(0, i + 1));
newdesc.append('L');
newdesc.append(classname.replace('.', '/'));
@@ -561,7 +561,7 @@ public class Descriptor {
}
if (arrayDim > 0) {
- StringBuffer sbuf = new StringBuffer(name);
+ StringBuilder sbuf = new StringBuilder(name);
while (arrayDim-- > 0)
sbuf.append("[]");
@@ -719,7 +719,7 @@ public class Descriptor {
static class PrettyPrinter {
static String toString(String desc) {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
if (desc.charAt(0) == '(') {
int pos = 1;
sbuf.append('(');
@@ -738,7 +738,7 @@ public class Descriptor {
return sbuf.toString();
}
- static int readType(StringBuffer sbuf, int pos, String desc) {
+ static int readType(StringBuilder sbuf, int pos, String desc) {
char c = desc.charAt(pos);
int arrayDim = 0;
while (c == '[') {
diff --git a/src/main/javassist/bytecode/InstructionPrinter.java b/src/main/javassist/bytecode/InstructionPrinter.java
index 6d18a4d4..ae853294 100644
--- a/src/main/javassist/bytecode/InstructionPrinter.java
+++ b/src/main/javassist/bytecode/InstructionPrinter.java
@@ -235,17 +235,17 @@ public class InstructionPrinter implements Opcode {
private static String lookupSwitch(CodeIterator iter, int pos) {
- StringBuffer buffer = new StringBuffer("lookupswitch {\n");
+ StringBuilder buffer = new StringBuilder("lookupswitch {\n");
int index = (pos & ~3) + 4;
// default
- buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n");
+ buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append('\n');
int npairs = iter.s32bitAt(index += 4);
int end = npairs * 8 + (index += 4);
for (; index < end; index += 8) {
int match = iter.s32bitAt(index);
int target = iter.s32bitAt(index + 4) + pos;
- buffer.append("\t\t").append(match).append(": ").append(target).append("\n");
+ buffer.append("\t\t").append(match).append(": ").append(target).append('\n');
}
buffer.setCharAt(buffer.length() - 1, '}');
@@ -254,10 +254,10 @@ public class InstructionPrinter implements Opcode {
private static String tableSwitch(CodeIterator iter, int pos) {
- StringBuffer buffer = new StringBuffer("tableswitch {\n");
+ StringBuilder buffer = new StringBuilder("tableswitch {\n");
int index = (pos & ~3) + 4;
// default
- buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n");
+ buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append('\n');
int low = iter.s32bitAt(index += 4);
int high = iter.s32bitAt(index += 4);
int end = (high - low + 1) * 4 + (index += 4);
@@ -265,7 +265,7 @@ public class InstructionPrinter implements Opcode {
// Offset table
for (int key = low; index < end; index += 4, key++) {
int target = iter.s32bitAt(index) + pos;
- buffer.append("\t\t").append(key).append(": ").append(target).append("\n");
+ buffer.append("\t\t").append(key).append(": ").append(target).append('\n');
}
buffer.setCharAt(buffer.length() - 1, '}');
diff --git a/src/main/javassist/bytecode/ParameterAnnotationsAttribute.java b/src/main/javassist/bytecode/ParameterAnnotationsAttribute.java
index 49e2646f..ec97d18f 100644
--- a/src/main/javassist/bytecode/ParameterAnnotationsAttribute.java
+++ b/src/main/javassist/bytecode/ParameterAnnotationsAttribute.java
@@ -201,7 +201,7 @@ public class ParameterAnnotationsAttribute extends AttributeInfo {
StringBuilder sbuf = new StringBuilder();
for (Annotation[] a : aa) {
for (Annotation i : a)
- sbuf.append(i.toString()).append(" ");
+ sbuf.append(i.toString()).append(' ');
sbuf.append(", ");
}
diff --git a/src/main/javassist/bytecode/SignatureAttribute.java b/src/main/javassist/bytecode/SignatureAttribute.java
index ff160f82..93f72864 100644
--- a/src/main/javassist/bytecode/SignatureAttribute.java
+++ b/src/main/javassist/bytecode/SignatureAttribute.java
@@ -344,7 +344,7 @@ public class SignatureAttribute extends AttributeInfo {
*/
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
TypeParameter.toString(sbuf, params);
sbuf.append(" extends ").append(superClass);
@@ -360,7 +360,7 @@ public class SignatureAttribute extends AttributeInfo {
* Returns the encoded string representing the method type signature.
*/
public String encode() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
if (params.length > 0) {
sbuf.append('<');
for (int i = 0; i < params.length; i++)
@@ -434,7 +434,7 @@ public class SignatureAttribute extends AttributeInfo {
*/
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
TypeParameter.toString(sbuf, typeParams);
sbuf.append(" (");
@@ -453,7 +453,7 @@ public class SignatureAttribute extends AttributeInfo {
* Returns the encoded string representing the method type signature.
*/
public String encode() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
if (typeParams.length > 0) {
sbuf.append('<');
for (int i = 0; i < typeParams.length; i++)
@@ -545,7 +545,7 @@ public class SignatureAttribute extends AttributeInfo {
*/
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer(getName());
+ StringBuilder sbuf = new StringBuilder(getName());
if (superClass != null)
sbuf.append(" extends ").append(superClass.toString());
@@ -564,7 +564,7 @@ public class SignatureAttribute extends AttributeInfo {
return sbuf.toString();
}
- static void toString(StringBuffer sbuf, TypeParameter[] tp) {
+ static void toString(StringBuilder sbuf, TypeParameter[] tp) {
sbuf.append('<');
for (int i = 0; i < tp.length; i++) {
if (i > 0)
@@ -576,7 +576,7 @@ public class SignatureAttribute extends AttributeInfo {
sbuf.append('>');
}
- void encode(StringBuffer sb) {
+ void encode(StringBuilder sb) {
sb.append(name);
if (superClass == null)
sb.append(":Ljava/lang/Object;");
@@ -684,7 +684,7 @@ public class SignatureAttribute extends AttributeInfo {
return "? super " + type;
}
- static void encode(StringBuffer sb, TypeArgument[] args) {
+ static void encode(StringBuilder sb, TypeArgument[] args) {
sb.append('<');
for (int i = 0; i < args.length; i++) {
TypeArgument ta = args[i];
@@ -703,8 +703,8 @@ public class SignatureAttribute extends AttributeInfo {
* Primitive types and object types.
*/
public static abstract class Type {
- abstract void encode(StringBuffer sb);
- static void toString(StringBuffer sbuf, Type[] ts) {
+ abstract void encode(StringBuilder sb);
+ static void toString(StringBuilder sbuf, Type[] ts) {
for (int i = 0; i < ts.length; i++) {
if (i > 0)
sbuf.append(", ");
@@ -761,7 +761,7 @@ public class SignatureAttribute extends AttributeInfo {
}
@Override
- void encode(StringBuffer sb) {
+ void encode(StringBuilder sb) {
sb.append(descriptor);
}
}
@@ -775,7 +775,7 @@ public class SignatureAttribute extends AttributeInfo {
* Returns the encoded string representing the object type signature.
*/
public String encode() {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
encode(sb);
return sb.toString();
}
@@ -854,7 +854,7 @@ public class SignatureAttribute extends AttributeInfo {
*/
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
ClassType parent = getDeclaringClass();
if (parent != null)
sbuf.append(parent.toString()).append('.');
@@ -862,7 +862,7 @@ public class SignatureAttribute extends AttributeInfo {
return toString2(sbuf);
}
- private String toString2(StringBuffer sbuf) {
+ private String toString2(StringBuilder sbuf) {
sbuf.append(name);
if (arguments != null) {
sbuf.append('<');
@@ -887,7 +887,7 @@ public class SignatureAttribute extends AttributeInfo {
*/
@Override
public String jvmTypeName() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
ClassType parent = getDeclaringClass();
if (parent != null)
sbuf.append(parent.jvmTypeName()).append('$');
@@ -896,13 +896,13 @@ public class SignatureAttribute extends AttributeInfo {
}
@Override
- void encode(StringBuffer sb) {
+ void encode(StringBuilder sb) {
sb.append('L');
encode2(sb);
sb.append(';');
}
- void encode2(StringBuffer sb) {
+ void encode2(StringBuilder sb) {
ClassType parent = getDeclaringClass();
if (parent != null) {
parent.encode2(sb);
@@ -982,7 +982,7 @@ public class SignatureAttribute extends AttributeInfo {
*/
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer(componentType.toString());
+ StringBuilder sbuf = new StringBuilder(componentType.toString());
for (int i = 0; i < dim; i++)
sbuf.append("[]");
@@ -990,7 +990,7 @@ public class SignatureAttribute extends AttributeInfo {
}
@Override
- void encode(StringBuffer sb) {
+ void encode(StringBuilder sb) {
for (int i = 0; i < dim; i++)
sb.append('[');
@@ -1033,7 +1033,7 @@ public class SignatureAttribute extends AttributeInfo {
}
@Override
- void encode(StringBuffer sb) {
+ void encode(StringBuilder sb) {
sb.append('T').append(name).append(';');
}
}
diff --git a/src/main/javassist/bytecode/analysis/ControlFlow.java b/src/main/javassist/bytecode/analysis/ControlFlow.java
index e47c00d3..46b82dbf 100644
--- a/src/main/javassist/bytecode/analysis/ControlFlow.java
+++ b/src/main/javassist/bytecode/analysis/ControlFlow.java
@@ -261,13 +261,13 @@ public class ControlFlow {
}
@Override
- protected void toString2(StringBuffer sbuf) {
+ protected void toString2(StringBuilder sbuf) {
super.toString2(sbuf);
sbuf.append(", incoming{");
for (int i = 0; i < entrances.length; i++)
sbuf.append(entrances[i].position).append(", ");
- sbuf.append("}");
+ sbuf.append('}');
}
BasicBlock[] getExit() { return exit; }
@@ -360,7 +360,7 @@ public class ControlFlow {
*/
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
sbuf.append("Node[pos=").append(block().position());
sbuf.append(", parent=");
sbuf.append(parent == null ? "*" : Integer.toString(parent.block().position()));
diff --git a/src/main/javassist/bytecode/analysis/Frame.java b/src/main/javassist/bytecode/analysis/Frame.java
index 28c62e35..916988c2 100644
--- a/src/main/javassist/bytecode/analysis/Frame.java
+++ b/src/main/javassist/bytecode/analysis/Frame.java
@@ -231,7 +231,7 @@ public class Frame {
@Override
public String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
buffer.append("locals = [");
for (int i = 0; i < locals.length; i++) {
@@ -245,7 +245,7 @@ public class Frame {
if (i < top - 1)
buffer.append(", ");
}
- buffer.append("]");
+ buffer.append(']');
return buffer.toString();
}
diff --git a/src/main/javassist/bytecode/analysis/MultiType.java b/src/main/javassist/bytecode/analysis/MultiType.java
index a8f6fc67..90a50843 100644
--- a/src/main/javassist/bytecode/analysis/MultiType.java
+++ b/src/main/javassist/bytecode/analysis/MultiType.java
@@ -312,14 +312,15 @@ public class MultiType extends Type {
if (resolved != null)
return resolved.toString();
- StringBuffer buffer = new StringBuffer("{");
+ StringBuilder buffer = new StringBuilder();
+ buffer.append('{');
for (String key:interfaces.keySet())
buffer.append(key).append(", ");
if (potentialClass != null)
- buffer.append("*").append(potentialClass.toString());
+ buffer.append('*').append(potentialClass.toString());
else
buffer.setLength(buffer.length() - 2);
- buffer.append("}");
+ buffer.append('}');
return buffer.toString();
}
}
diff --git a/src/main/javassist/bytecode/annotation/Annotation.java b/src/main/javassist/bytecode/annotation/Annotation.java
index 1cec468b..f700f036 100644
--- a/src/main/javassist/bytecode/annotation/Annotation.java
+++ b/src/main/javassist/bytecode/annotation/Annotation.java
@@ -210,17 +210,18 @@ public class Annotation {
*/
@Override
public String toString() {
- StringBuffer buf = new StringBuffer("@");
+ StringBuilder buf = new StringBuilder();
+ buf.append('@');
buf.append(getTypeName());
if (members != null) {
- buf.append("(");
+ buf.append('(');
for (String name:members.keySet()) {
- buf.append(name).append("=")
+ buf.append(name).append('=')
.append(getMemberValue(name))
.append(", ");
}
buf.setLength(buf.length()-2);
- buf.append(")");
+ buf.append(')');
}
return buf.toString();
diff --git a/src/main/javassist/bytecode/annotation/ArrayMemberValue.java b/src/main/javassist/bytecode/annotation/ArrayMemberValue.java
index f6bc6150..8b73d26a 100644
--- a/src/main/javassist/bytecode/annotation/ArrayMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/ArrayMemberValue.java
@@ -142,7 +142,8 @@ public class ArrayMemberValue extends MemberValue {
*/
@Override
public String toString() {
- StringBuffer buf = new StringBuffer("{");
+ StringBuilder buf = new StringBuilder();
+ buf.append('{');
if (values != null) {
for (int i = 0; i < values.length; i++) {
buf.append(values[i].toString());
@@ -151,7 +152,7 @@ public class ArrayMemberValue extends MemberValue {
}
}
- buf.append("}");
+ buf.append('}');
return buf.toString();
}
diff --git a/src/main/javassist/bytecode/annotation/MemberValue.java b/src/main/javassist/bytecode/annotation/MemberValue.java
index 0f132a83..787ee8f3 100644
--- a/src/main/javassist/bytecode/annotation/MemberValue.java
+++ b/src/main/javassist/bytecode/annotation/MemberValue.java
@@ -65,9 +65,9 @@ public abstract class MemberValue {
int index = classname.indexOf("[]");
if (index != -1) {
String rawType = classname.substring(0, index);
- StringBuffer sb = new StringBuffer(Descriptor.of(rawType));
+ StringBuilder sb = new StringBuilder(Descriptor.of(rawType));
while (index != -1) {
- sb.insert(0, "[");
+ sb.insert(0, '[');
index = classname.indexOf("[]", index + 1);
}
return sb.toString().replace('/', '.');
diff --git a/src/main/javassist/bytecode/stackmap/BasicBlock.java b/src/main/javassist/bytecode/stackmap/BasicBlock.java
index 231ffc3a..2b32a296 100644
--- a/src/main/javassist/bytecode/stackmap/BasicBlock.java
+++ b/src/main/javassist/bytecode/stackmap/BasicBlock.java
@@ -78,33 +78,33 @@ public class BasicBlock {
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
String cname = this.getClass().getName();
int i = cname.lastIndexOf('.');
sbuf.append(i < 0 ? cname : cname.substring(i + 1));
- sbuf.append("[");
+ sbuf.append('[');
toString2(sbuf);
- sbuf.append("]");
+ sbuf.append(']');
return sbuf.toString();
}
- protected void toString2(StringBuffer sbuf) {
+ protected void toString2(StringBuilder sbuf) {
sbuf.append("pos=").append(position).append(", len=")
.append(length).append(", in=").append(incoming)
.append(", exit{");
if (exit != null)
for (BasicBlock b:exit)
- sbuf.append(b.position).append(",");
+ sbuf.append(b.position).append(',');
sbuf.append("}, {");
Catch th = toCatch;
while (th != null) {
- sbuf.append("(").append(th.body.position).append(", ")
+ sbuf.append('(').append(th.body.position).append(", ")
.append(th.typeIndex).append("), ");
th = th.next;
}
- sbuf.append("}");
+ sbuf.append('}');
}
/**
diff --git a/src/main/javassist/bytecode/stackmap/TypeData.java b/src/main/javassist/bytecode/stackmap/TypeData.java
index 4762eb85..c676ac79 100644
--- a/src/main/javassist/bytecode/stackmap/TypeData.java
+++ b/src/main/javassist/bytecode/stackmap/TypeData.java
@@ -434,7 +434,7 @@ public abstract class TypeData {
private String fixTypes2(List<TypeData> scc, Set<String> lowersSet, ClassPool cp) throws NotFoundException {
Iterator<String> it = lowersSet.iterator();
- if (lowersSet.size() == 0)
+ if (lowersSet.isEmpty())
return null; // only NullType
else if (lowersSet.size() == 1)
return it.next();
diff --git a/src/main/javassist/bytecode/stackmap/TypedBlock.java b/src/main/javassist/bytecode/stackmap/TypedBlock.java
index 14fa7f22..634c8dd0 100644
--- a/src/main/javassist/bytecode/stackmap/TypedBlock.java
+++ b/src/main/javassist/bytecode/stackmap/TypedBlock.java
@@ -59,7 +59,7 @@ public class TypedBlock extends BasicBlock {
}
@Override
- protected void toString2(StringBuffer sbuf) {
+ protected void toString2(StringBuilder sbuf) {
super.toString2(sbuf);
sbuf.append(",\n stack={");
printTypes(sbuf, stackTop, stackTypes);
@@ -68,7 +68,7 @@ public class TypedBlock extends BasicBlock {
sbuf.append('}');
}
- private void printTypes(StringBuffer sbuf, int size,
+ private void printTypes(StringBuilder sbuf, int size,
TypeData[] types) {
if (types == null)
return;
diff --git a/src/main/javassist/compiler/CodeGen.java b/src/main/javassist/compiler/CodeGen.java
index 3cb11719..e3115617 100644
--- a/src/main/javassist/compiler/CodeGen.java
+++ b/src/main/javassist/compiler/CodeGen.java
@@ -197,7 +197,7 @@ public abstract class CodeGen extends Visitor implements Opcode, TokenId {
if (dim == 0)
return name;
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
int d = dim;
while (d-- > 0)
sbuf.append('[');
@@ -241,7 +241,7 @@ public abstract class CodeGen extends Visitor implements Opcode, TokenId {
break;
}
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
while (dim-- > 0)
sbuf.append('[');
@@ -473,7 +473,7 @@ public abstract class CodeGen extends Visitor implements Opcode, TokenId {
boolean alwaysBranch = compileBooleanExpr(true, expr);
if (alwaysBranch) {
bytecode.addOpcode(Opcode.GOTO);
- alwaysBranch = breakList.size() == 0;
+ alwaysBranch = breakList.isEmpty();
}
bytecode.addIndex(pc2 - bytecode.currentPc() + 1);
@@ -1663,7 +1663,7 @@ public abstract class CodeGen extends Visitor implements Opcode, TokenId {
* must be passed to Class.forName().
*/
name2 = MemberResolver.jvmToJavaName(name2);
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
while (i-- >= 0)
sbuf.append('[');
diff --git a/src/main/javassist/compiler/JvstCodeGen.java b/src/main/javassist/compiler/JvstCodeGen.java
index 5a43d65e..714b9699 100644
--- a/src/main/javassist/compiler/JvstCodeGen.java
+++ b/src/main/javassist/compiler/JvstCodeGen.java
@@ -264,7 +264,7 @@ public class JvstCodeGen extends MemberCodeGen {
/* To support $cflow().
*/
protected void atCflow(ASTList cname) throws CompileError {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
if (cname == null || cname.tail() != null)
throw new CompileError("bad " + cflowName);
@@ -288,7 +288,7 @@ public class JvstCodeGen extends MemberCodeGen {
* <cflow> : $cflow '(' <cflow name> ')'
* <cflow name> : <identifier> ('.' <identifier>)*
*/
- private static void makeCflowName(StringBuffer sbuf, ASTree name)
+ private static void makeCflowName(StringBuilder sbuf, ASTree name)
throws CompileError
{
if (name instanceof Symbol) {
diff --git a/src/main/javassist/compiler/Lex.java b/src/main/javassist/compiler/Lex.java
index 498b22fb..b7c39a98 100644
--- a/src/main/javassist/compiler/Lex.java
+++ b/src/main/javassist/compiler/Lex.java
@@ -27,7 +27,7 @@ class Token {
public class Lex implements TokenId {
private int lastChar;
- private StringBuffer textBuffer;
+ private StringBuilder textBuffer;
private Token currentToken;
private Token lookAheadTokens;
@@ -40,7 +40,7 @@ public class Lex implements TokenId {
*/
public Lex(String s) {
lastChar = -1;
- textBuffer = new StringBuffer();
+ textBuffer = new StringBuilder();
currentToken = new Token();
lookAheadTokens = null;
@@ -123,7 +123,7 @@ public class Lex implements TokenId {
else if(c == '.'){
c = getc();
if ('0' <= c && c <= '9') {
- StringBuffer tbuf = textBuffer;
+ StringBuilder tbuf = textBuffer;
tbuf.setLength(0);
tbuf.append('.');
return readDouble(tbuf, c, token);
@@ -205,7 +205,7 @@ public class Lex implements TokenId {
private int readStringL(Token token) {
int c;
- StringBuffer tbuf = textBuffer;
+ StringBuilder tbuf = textBuffer;
tbuf.setLength(0);
for (;;) {
while ((c = getc()) != '"') {
@@ -287,7 +287,7 @@ public class Lex implements TokenId {
}
else if (c2 == 'E' || c2 == 'e'
|| c2 == 'D' || c2 == 'd' || c2 == '.') {
- StringBuffer tbuf = textBuffer;
+ StringBuilder tbuf = textBuffer;
tbuf.setLength(0);
tbuf.append(value);
return readDouble(tbuf, c2, token);
@@ -300,7 +300,7 @@ public class Lex implements TokenId {
}
}
- private int readDouble(StringBuffer sbuf, int c, Token token) {
+ private int readDouble(StringBuilder sbuf, int c, Token token) {
if (c != 'E' && c != 'e' && c != 'D' && c != 'd') {
sbuf.append((char)c);
for (;;) {
@@ -412,7 +412,7 @@ public class Lex implements TokenId {
}
private int readIdentifier(int c, Token token) {
- StringBuffer tbuf = textBuffer;
+ StringBuilder tbuf = textBuffer;
tbuf.setLength(0);
do {
diff --git a/src/main/javassist/compiler/MemberResolver.java b/src/main/javassist/compiler/MemberResolver.java
index 7fcd5d8a..c01974df 100644
--- a/src/main/javassist/compiler/MemberResolver.java
+++ b/src/main/javassist/compiler/MemberResolver.java
@@ -491,7 +491,7 @@ public class MemberResolver implements TokenId {
int i = classname.lastIndexOf('.');
if (notCheckInner || i < 0)
throw e;
- StringBuffer sbuf = new StringBuffer(classname);
+ StringBuilder sbuf = new StringBuilder(classname);
sbuf.setCharAt(i, '$');
classname = sbuf.toString();
}
diff --git a/src/main/javassist/compiler/Parser.java b/src/main/javassist/compiler/Parser.java
index ae73fb29..2b0dfd69 100644
--- a/src/main/javassist/compiler/Parser.java
+++ b/src/main/javassist/compiler/Parser.java
@@ -1113,7 +1113,7 @@ public final class Parser implements TokenId {
{
String cname = toClassName(className);
if (dim > 0) {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
while (dim-- > 0)
sbuf.append('[');
@@ -1199,12 +1199,12 @@ public final class Parser implements TokenId {
private String toClassName(ASTree name)
throws CompileError
{
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
toClassName(name, sbuf);
return sbuf.toString();
}
- private void toClassName(ASTree name, StringBuffer sbuf)
+ private void toClassName(ASTree name, StringBuilder sbuf)
throws CompileError
{
if (name instanceof Symbol) {
diff --git a/src/main/javassist/compiler/TypeChecker.java b/src/main/javassist/compiler/TypeChecker.java
index ec7e3cf3..bceba419 100644
--- a/src/main/javassist/compiler/TypeChecker.java
+++ b/src/main/javassist/compiler/TypeChecker.java
@@ -74,7 +74,7 @@ public class TypeChecker extends Visitor implements Opcode, TokenId {
*/
protected static String argTypesToString(int[] types, int[] dims,
String[] cnames) {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
sbuf.append('(');
int n = types.length;
if (n > 0) {
@@ -96,7 +96,7 @@ public class TypeChecker extends Visitor implements Opcode, TokenId {
* Converts a tuple of exprType, arrayDim, and className
* into a String object.
*/
- protected static StringBuffer typeToString(StringBuffer sbuf,
+ protected static StringBuilder typeToString(StringBuilder sbuf,
int type, int dim, String cname) {
String s;
if (type == CLASS)
diff --git a/src/main/javassist/compiler/ast/ASTList.java b/src/main/javassist/compiler/ast/ASTList.java
index 67fbd97a..d9232ca0 100644
--- a/src/main/javassist/compiler/ast/ASTList.java
+++ b/src/main/javassist/compiler/ast/ASTList.java
@@ -79,7 +79,7 @@ public class ASTList extends ASTree {
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
sbuf.append("(<");
sbuf.append(getTag());
sbuf.append('>');
diff --git a/src/main/javassist/compiler/ast/ASTree.java b/src/main/javassist/compiler/ast/ASTree.java
index 7fd05fd4..3d4dd842 100644
--- a/src/main/javassist/compiler/ast/ASTree.java
+++ b/src/main/javassist/compiler/ast/ASTree.java
@@ -46,7 +46,7 @@ public abstract class ASTree implements Serializable {
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
sbuf.append('<');
sbuf.append(getTag());
sbuf.append('>');
diff --git a/src/main/javassist/compiler/ast/Declarator.java b/src/main/javassist/compiler/ast/Declarator.java
index 24170db0..c29f6740 100644
--- a/src/main/javassist/compiler/ast/Declarator.java
+++ b/src/main/javassist/compiler/ast/Declarator.java
@@ -107,12 +107,12 @@ public class Declarator extends ASTList implements TokenId {
if (name == null)
return null;
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
astToClassName(sbuf, name, sep);
return sbuf.toString();
}
- private static void astToClassName(StringBuffer sbuf, ASTList name,
+ private static void astToClassName(StringBuilder sbuf, ASTList name,
char sep) {
for (;;) {
ASTree h = name.head();
diff --git a/src/main/javassist/compiler/ast/Pair.java b/src/main/javassist/compiler/ast/Pair.java
index 840c1145..949028a4 100644
--- a/src/main/javassist/compiler/ast/Pair.java
+++ b/src/main/javassist/compiler/ast/Pair.java
@@ -37,7 +37,7 @@ public class Pair extends ASTree {
@Override
public String toString() {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
sbuf.append("(<Pair> ");
sbuf.append(left == null ? "<null>" : left.toString());
sbuf.append(" . ");
diff --git a/src/main/javassist/convert/TransformAccessArrayField.java b/src/main/javassist/convert/TransformAccessArrayField.java
index 6dab42a5..b80ed0c3 100644
--- a/src/main/javassist/convert/TransformAccessArrayField.java
+++ b/src/main/javassist/convert/TransformAccessArrayField.java
@@ -218,7 +218,7 @@ public final class TransformAccessArrayField extends Transformer {
break;
}
- if (methodName.equals(""))
+ if ("".equals(methodName))
methodName = null;
return methodName;
diff --git a/src/main/javassist/tools/rmi/StubGenerator.java b/src/main/javassist/tools/rmi/StubGenerator.java
index b0817ab5..a06ebc60 100644
--- a/src/main/javassist/tools/rmi/StubGenerator.java
+++ b/src/main/javassist/tools/rmi/StubGenerator.java
@@ -183,7 +183,7 @@ public class StubGenerator implements Translator {
if (!rtclass.isArray())
name = rtclass.getName();
else {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
do {
sbuf.append("[]");
rtclass = rtclass.getComponentType();
diff --git a/src/main/javassist/tools/web/Webserver.java b/src/main/javassist/tools/web/Webserver.java
index d90e8e34..99e15faf 100644
--- a/src/main/javassist/tools/web/Webserver.java
+++ b/src/main/javassist/tools/web/Webserver.java
@@ -222,7 +222,7 @@ public class Webserver {
}
private String readLine(InputStream in) throws IOException {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
int c;
while ((c = in.read()) >= 0 && c != 0x0d)
buf.append((char)c);
diff --git a/src/main/javassist/util/proxy/ProxyFactory.java b/src/main/javassist/util/proxy/ProxyFactory.java
index 7d88e07a..2a20b2ca 100644
--- a/src/main/javassist/util/proxy/ProxyFactory.java
+++ b/src/main/javassist/util/proxy/ProxyFactory.java
@@ -576,14 +576,14 @@ public class ProxyFactory {
public String getKey(Class<?> superClass, Class<?>[] interfaces, byte[] signature, boolean useWriteReplace)
{
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
if (superClass != null){
sbuf.append(superClass.getName());
}
- sbuf.append(":");
+ sbuf.append(':');
for (int i = 0; i < interfaces.length; i++) {
sbuf.append(interfaces[i].getName());
- sbuf.append(":");
+ sbuf.append(':');
}
for (int i = 0; i < signature.length; i++) {
byte b = signature[i];
diff --git a/src/main/javassist/util/proxy/RuntimeSupport.java b/src/main/javassist/util/proxy/RuntimeSupport.java
index 0bd0cce9..9eb1c49e 100644
--- a/src/main/javassist/util/proxy/RuntimeSupport.java
+++ b/src/main/javassist/util/proxy/RuntimeSupport.java
@@ -198,7 +198,7 @@ public class RuntimeSupport {
* @param retType return type.
*/
public static String makeDescriptor(Class<?>[] params, Class<?> retType) {
- StringBuffer sbuf = new StringBuffer();
+ StringBuilder sbuf = new StringBuilder();
sbuf.append('(');
for (int i = 0; i < params.length; i++)
makeDesc(sbuf, params[i]);
@@ -217,12 +217,12 @@ public class RuntimeSupport {
* @param retType return type.
*/
public static String makeDescriptor(String params, Class<?> retType) {
- StringBuffer sbuf = new StringBuffer(params);
+ StringBuilder sbuf = new StringBuilder(params);
makeDesc(sbuf, retType);
return sbuf.toString();
}
- private static void makeDesc(StringBuffer sbuf, Class<?> type) {
+ private static void makeDesc(StringBuilder sbuf, Class<?> type) {
if (type.isArray()) {
sbuf.append('[');
makeDesc(sbuf, type.getComponentType());