From: markt Date: Mon, 10 Oct 2011 18:37:14 +0000 (+0000) Subject: Sync with Commons BCEL (moved from Jakarta) X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4598270f7ecf1a0101b06fe20562be7376c1afc1;p=tomcat7.0 Sync with Commons BCEL (moved from Jakarta) git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1181123 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java b/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java index 0965ea0ee..d9888c042 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java +++ b/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java @@ -45,9 +45,7 @@ public class AnnotationElementValue extends ElementValue @Override public String stringifyValue() { - StringBuffer sb = new StringBuffer(); - sb.append(annotationEntry.toString()); - return sb.toString(); + return annotationEntry.toString(); } @Override diff --git a/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java b/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java index b633bc21b..9ec1a8503 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java +++ b/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java @@ -37,8 +37,8 @@ public class AnnotationEntry implements Constants, Serializable { private static final long serialVersionUID = 1L; - private int type_index; - private ConstantPool constant_pool; + private final int type_index; + private final ConstantPool constant_pool; private List element_value_pairs; @@ -47,6 +47,7 @@ public class AnnotationEntry implements Constants, Serializable { * * @param file * @param constant_pool + * @return the entry * @throws IOException */ public static AnnotationEntry read(DataInputStream file, ConstantPool constant_pool) throws IOException { @@ -78,19 +79,17 @@ public class AnnotationEntry implements Constants, Serializable { * @return the element value pairs in this annotation entry */ public ElementValuePair[] getElementValuePairs() { - // TOFO return List + // TODO return List return element_value_pairs.toArray(new ElementValuePair[element_value_pairs.size()]); } - - public void dump(DataOutputStream dos) throws IOException - { - dos.writeShort(type_index); // u2 index of type name in cpool - dos.writeShort(element_value_pairs.size()); // u2 element_value pair count - for (int i = 0 ; i= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) { buf.append("SAME"); @@ -209,6 +209,4 @@ public final class StackMapTableEntry implements Cloneable, Serializable { } return null; } - - } diff --git a/java/org/apache/tomcat/util/bcel/classfile/Synthetic.java b/java/org/apache/tomcat/util/bcel/classfile/Synthetic.java index 89b4d2632..71066ac91 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/Synthetic.java +++ b/java/org/apache/tomcat/util/bcel/classfile/Synthetic.java @@ -95,7 +95,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(" ").append(Utility.toHexString(bytes)); } diff --git a/java/org/apache/tomcat/util/bcel/classfile/Utility.java b/java/org/apache/tomcat/util/bcel/classfile/Utility.java index 5525763cc..f83b04aa8 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/Utility.java +++ b/java/org/apache/tomcat/util/bcel/classfile/Utility.java @@ -36,14 +36,14 @@ public abstract class Utility { private static void wrap( ThreadLocal tl, int value ) { - tl.set(new Integer(value)); + tl.set(Integer.valueOf(value)); } private static ThreadLocal consumed_chars = new ThreadLocal() { @Override protected Integer initialValue() { - return new Integer(0); + return Integer.valueOf(0); } };/* How many chars have been consumed * during parsing in signatureToString(). @@ -85,7 +85,7 @@ public abstract class Utility { * @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 p = pow2(i); @@ -131,7 +131,7 @@ public abstract class Utility { */ 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 { for (int i = 0; i < index; i++) { @@ -171,7 +171,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 */ @@ -489,7 +489,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.indexOf("static") >= 0) ? 0 : 1; @@ -646,10 +646,10 @@ public abstract class Utility { return "boolean"; case '[': { // Array declaration int n; - StringBuffer brackets; + StringBuilder brackets; String type; int consumed_chars; // Shadows global var - 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("[]"); @@ -689,7 +689,7 @@ public abstract class Utility { * @return bytes as hexadecimal 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]); String hex = Integer.toString(b, 0x10); @@ -753,7 +753,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 (int i = 0; i < ch.length; i++) { switch (ch[i]) { case '\n': @@ -778,6 +778,4 @@ public abstract class Utility { } return buf.toString(); } - - } diff --git a/java/org/apache/tomcat/util/bcel/util/BCELComparator.java b/java/org/apache/tomcat/util/bcel/util/BCELComparator.java index 14204d589..2d68865c5 100644 --- a/java/org/apache/tomcat/util/bcel/util/BCELComparator.java +++ b/java/org/apache/tomcat/util/bcel/util/BCELComparator.java @@ -33,7 +33,7 @@ public interface BCELComparator { * @param THAT * @return true if and only if THIS equals THAT */ - public boolean equals( Object THIS, Object THAT ); + boolean equals( Object THIS, Object THAT ); /** @@ -42,5 +42,5 @@ public interface BCELComparator { * @param THIS * @return hashcode for THIS.hashCode() */ - public int hashCode( Object THIS ); + int hashCode( Object THIS ); }