Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java Tue Jun 21 20:50:19 2016 @@ -64,15 +64,15 @@ public class ClassGen extends AccessFlag @Override public boolean equals( final Object o1, final Object o2 ) { - ClassGen THIS = (ClassGen) o1; - ClassGen THAT = (ClassGen) o2; + final ClassGen THIS = (ClassGen) o1; + final ClassGen THAT = (ClassGen) o2; return THIS.getClassName().equals(THAT.getClassName()); } @Override public int hashCode( final Object o ) { - ClassGen THIS = (ClassGen) o; + final ClassGen THIS = (ClassGen) o; return THIS.getClassName().hashCode(); } }; @@ -102,7 +102,7 @@ public class ClassGen extends AccessFlag class_name_index = cp.addClass(class_name); superclass_name_index = cp.addClass(super_class_name); if (interfaces != null) { - for (String interface1 : interfaces) { + for (final String interface1 : interfaces) { addInterface(interface1); } } @@ -138,27 +138,27 @@ public class ClassGen extends AccessFlag cp = new ConstantPoolGen(clazz.getConstantPool()); major = clazz.getMajor(); minor = clazz.getMinor(); - Attribute[] attributes = clazz.getAttributes(); + final Attribute[] attributes = clazz.getAttributes(); // J5TODO: Could make unpacking lazy, done on first reference - AnnotationEntryGen[] annotations = unpackAnnotations(attributes); - Method[] methods = clazz.getMethods(); - Field[] fields = clazz.getFields(); - String[] interfaces = clazz.getInterfaceNames(); - for (String interface1 : interfaces) { + final AnnotationEntryGen[] annotations = unpackAnnotations(attributes); + final Method[] methods = clazz.getMethods(); + final Field[] fields = clazz.getFields(); + final String[] interfaces = clazz.getInterfaceNames(); + for (final String interface1 : interfaces) { addInterface(interface1); } - for (Attribute attribute : attributes) { + for (final Attribute attribute : attributes) { if (!(attribute instanceof Annotations)) { addAttribute(attribute); } } - for (AnnotationEntryGen annotation : annotations) { + for (final AnnotationEntryGen annotation : annotations) { addAnnotationEntry(annotation); } - for (Method method : methods) { + for (final Method method : methods) { addMethod(method); } - for (Field field : fields) { + for (final Field field : fields) { addField(field); } } @@ -168,13 +168,13 @@ public class ClassGen extends AccessFlag */ private AnnotationEntryGen[] unpackAnnotations(final Attribute[] attrs) { - List<AnnotationEntryGen> annotationGenObjs = new ArrayList<>(); - for (Attribute attr : attrs) { + final List<AnnotationEntryGen> annotationGenObjs = new ArrayList<>(); + for (final Attribute attr : attrs) { if (attr instanceof RuntimeVisibleAnnotations) { - RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr; - AnnotationEntry[] annos = rva.getAnnotationEntries(); - for (AnnotationEntry a : annos) { + final RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr; + final AnnotationEntry[] annos = rva.getAnnotationEntries(); + for (final AnnotationEntry a : annos) { annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false)); } @@ -182,9 +182,9 @@ public class ClassGen extends AccessFlag else if (attr instanceof RuntimeInvisibleAnnotations) { - RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations) attr; - AnnotationEntry[] annos = ria.getAnnotationEntries(); - for (AnnotationEntry a : annos) { + final RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations) attr; + final AnnotationEntry[] annos = ria.getAnnotationEntries(); + for (final AnnotationEntry a : annos) { annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false)); } @@ -198,21 +198,21 @@ public class ClassGen extends AccessFlag * @return the (finally) built up Java class object. */ public JavaClass getJavaClass() { - int[] interfaces = getInterfaces(); - Field[] fields = getFields(); - Method[] methods = getMethods(); + final int[] interfaces = getInterfaces(); + final Field[] fields = getFields(); + final Method[] methods = getMethods(); Attribute[] attributes = null; if (annotation_vec.isEmpty()) { attributes = getAttributes(); } else { // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations' - Attribute[] annAttributes = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries()); + final Attribute[] annAttributes = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries()); attributes = new Attribute[attribute_vec.size()+annAttributes.length]; attribute_vec.toArray(attributes); System.arraycopy(annAttributes,0,attributes,attribute_vec.size(),annAttributes.length); } // Must be last since the above calls may still add something to it - ConstantPool _cp = this.cp.getFinalConstantPool(); + final ConstantPool _cp = this.cp.getFinalConstantPool(); return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor, super.getAccessFlags(), _cp, interfaces, fields, methods, attributes); } @@ -296,11 +296,11 @@ public class ClassGen extends AccessFlag * @param access_flags rights for constructor */ public void addEmptyConstructor( final int access_flags ) { - InstructionList il = new InstructionList(); + final InstructionList il = new InstructionList(); il.append(InstructionConst.THIS); // Push `this' il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name, "<init>", "()V"))); il.append(InstructionConst.RETURN); - MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, "<init>", + final MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, "<init>", class_name, il, cp); mg.setMaxStack(1); addMethod(mg.getMethod()); @@ -324,7 +324,7 @@ public class ClassGen extends AccessFlag /** @return field object with given name, or null */ public Field containsField( final String name ) { - for (Field f : field_vec) { + for (final Field f : field_vec) { if (f.getName().equals(name)) { return f; } @@ -336,7 +336,7 @@ public class ClassGen extends AccessFlag /** @return method object with given name and signature, or null */ public Method containsMethod( final String name, final String signature ) { - for (Method m : method_vec) { + for (final Method m : method_vec) { if (m.getName().equals(name) && m.getSignature().equals(signature)) { return m; } @@ -370,7 +370,7 @@ public class ClassGen extends AccessFlag if (new_ == null) { throw new ClassGenException("Replacement method must not be null"); } - int i = method_vec.indexOf(old); + final int i = method_vec.indexOf(old); if (i < 0) { method_vec.add(new_); } else { @@ -386,7 +386,7 @@ public class ClassGen extends AccessFlag if (new_ == null) { throw new ClassGenException("Replacement method must not be null"); } - int i = field_vec.indexOf(old); + final int i = field_vec.indexOf(old); if (i < 0) { field_vec.add(new_); } else { @@ -438,7 +438,7 @@ public class ClassGen extends AccessFlag public void setMethods( final Method[] methods ) { method_vec.clear(); - for (Method method : methods) { + for (final Method method : methods) { addMethod(method); } } @@ -455,16 +455,16 @@ public class ClassGen extends AccessFlag public String[] getInterfaceNames() { - int size = interface_vec.size(); - String[] interfaces = new String[size]; + final int size = interface_vec.size(); + final String[] interfaces = new String[size]; interface_vec.toArray(interfaces); return interfaces; } public int[] getInterfaces() { - int size = interface_vec.size(); - int[] interfaces = new int[size]; + final int size = interface_vec.size(); + final int[] interfaces = new int[size]; for (int i = 0; i < size; i++) { interfaces[i] = cp.addClass(interface_vec.get(i)); } @@ -548,7 +548,7 @@ public class ClassGen extends AccessFlag */ public void update() { if (observers != null) { - for (ClassObserver observer : observers) { + for (final ClassObserver observer : observers) { observer.notify(this); } } @@ -559,7 +559,7 @@ public class ClassGen extends AccessFlag public Object clone() { try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch (final CloneNotSupportedException e) { throw new Error("Clone Not Supported"); // never happens } }
Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java Tue Jun 21 20:50:19 2016 @@ -180,7 +180,7 @@ public final class CodeExceptionGen impl public Object clone() { try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch (final CloneNotSupportedException e) { throw new Error("Clone Not Supported"); // never happens } } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java Tue Jun 21 20:50:19 2016 @@ -94,7 +94,7 @@ public class ConstantPoolGen { * @param cs array of given constants, new ones will be appended */ public ConstantPoolGen(final Constant[] cs) { - StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); + final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); size = Math.max(DEFAULT_BUFFER_SIZE, cs.length + 64); constants = new Constant[size]; @@ -106,43 +106,43 @@ public class ConstantPoolGen { for (int i = 1; i < index; i++) { - Constant c = constants[i]; + final Constant c = constants[i]; if (c instanceof ConstantString) { - ConstantString s = (ConstantString) c; - ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; - String key = u8.getBytes(); + final ConstantString s = (ConstantString) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; + final String key = u8.getBytes(); if (!string_table.containsKey(key)) { string_table.put(key, new Index(i)); } } else if (c instanceof ConstantClass) { - ConstantClass s = (ConstantClass) c; - ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; - String key = u8.getBytes(); + final ConstantClass s = (ConstantClass) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; + final String key = u8.getBytes(); if (!class_table.containsKey(key)) { class_table.put(key, new Index(i)); } } else if (c instanceof ConstantNameAndType) { - ConstantNameAndType n = (ConstantNameAndType) c; - ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()]; - ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()]; + final ConstantNameAndType n = (ConstantNameAndType) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()]; sb.append(u8.getBytes()); sb.append(NAT_DELIM); sb.append(u8_2.getBytes()); - String key = sb.toString(); + final String key = sb.toString(); sb.delete(0, sb.length()); if (!n_a_t_table.containsKey(key)) { n_a_t_table.put(key, new Index(i)); } } else if (c instanceof ConstantUtf8) { - ConstantUtf8 u = (ConstantUtf8) c; - String key = u.getBytes(); + final ConstantUtf8 u = (ConstantUtf8) c; + final String key = u.getBytes(); if (!utf8_table.containsKey(key)) { utf8_table.put(key, new Index(i)); } } else if (c instanceof ConstantCP) { - ConstantCP m = (ConstantCP) c; + final ConstantCP m = (ConstantCP) c; String class_name; ConstantUtf8 u8; @@ -151,16 +151,16 @@ public class ConstantPoolGen { // since name can't begin with digit, can use // METHODREF_DELIM with out fear of duplicates. } else { - ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; + final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; u8 = (ConstantUtf8) constants[clazz.getNameIndex()]; class_name = u8.getBytes().replace('/', '.'); } - ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; + final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; u8 = (ConstantUtf8) constants[n.getNameIndex()]; - String method_name = u8.getBytes(); + final String method_name = u8.getBytes(); u8 = (ConstantUtf8) constants[n.getSignatureIndex()]; - String signature = u8.getBytes(); + final String signature = u8.getBytes(); String delim = METHODREF_DELIM; if (c instanceof ConstantInterfaceMethodref) { @@ -174,7 +174,7 @@ public class ConstantPoolGen { sb.append(method_name); sb.append(delim); sb.append(signature); - String key = sb.toString(); + final String key = sb.toString(); sb.delete(0, sb.length()); if (!cp_table.containsKey(key)) { @@ -222,7 +222,7 @@ public class ConstantPoolGen { */ protected void adjustSize() { if (index + 3 >= size) { - Constant[] cs = constants; + final Constant[] cs = constants; size *= 2; constants = new Constant[size]; System.arraycopy(cs, 0, constants, 0, index); @@ -239,7 +239,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupString( final String str ) { - Index index = string_table.get(str); + final Index index = string_table.get(str); return (index != null) ? index.index : -1; } @@ -255,9 +255,9 @@ public class ConstantPoolGen { if ((ret = lookupString(str)) != -1) { return ret; // Already in CP } - int utf8 = addUtf8(str); + final int utf8 = addUtf8(str); adjustSize(); - ConstantString s = new ConstantString(utf8); + final ConstantString s = new ConstantString(utf8); ret = index; constants[index++] = s; if (!string_table.containsKey(str)) { @@ -276,7 +276,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupClass( final String str ) { - Index index = class_table.get(str.replace('.', '/')); + final Index index = class_table.get(str.replace('.', '/')); return (index != null) ? index.index : -1; } @@ -287,7 +287,7 @@ public class ConstantPoolGen { return ret; // Already in CP } adjustSize(); - ConstantClass c = new ConstantClass(addUtf8(clazz)); + final ConstantClass c = new ConstantClass(addUtf8(clazz)); ret = index; constants[index++] = c; if (!class_table.containsKey(clazz)) { @@ -340,7 +340,7 @@ public class ConstantPoolGen { public int lookupInteger( final int n ) { for (int i = 1; i < index; i++) { if (constants[i] instanceof ConstantInteger) { - ConstantInteger c = (ConstantInteger) constants[i]; + final ConstantInteger c = (ConstantInteger) constants[i]; if (c.getBytes() == n) { return i; } @@ -375,10 +375,10 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupFloat( final float n ) { - int bits = Float.floatToIntBits(n); + final int bits = Float.floatToIntBits(n); for (int i = 1; i < index; i++) { if (constants[i] instanceof ConstantFloat) { - ConstantFloat c = (ConstantFloat) constants[i]; + final ConstantFloat c = (ConstantFloat) constants[i]; if (Float.floatToIntBits(c.getBytes()) == bits) { return i; } @@ -415,7 +415,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupUtf8( final String n ) { - Index index = utf8_table.get(n); + final Index index = utf8_table.get(n); return (index != null) ? index.index : -1; } @@ -450,7 +450,7 @@ public class ConstantPoolGen { public int lookupLong( final long n ) { for (int i = 1; i < index; i++) { if (constants[i] instanceof ConstantLong) { - ConstantLong c = (ConstantLong) constants[i]; + final ConstantLong c = (ConstantLong) constants[i]; if (c.getBytes() == n) { return i; } @@ -486,10 +486,10 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupDouble( final double n ) { - long bits = Double.doubleToLongBits(n); + final long bits = Double.doubleToLongBits(n); for (int i = 1; i < index; i++) { if (constants[i] instanceof ConstantDouble) { - ConstantDouble c = (ConstantDouble) constants[i]; + final ConstantDouble c = (ConstantDouble) constants[i]; if (Double.doubleToLongBits(c.getBytes()) == bits) { return i; } @@ -528,7 +528,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupNameAndType( final String name, final String signature ) { - Index _index = n_a_t_table.get(name + NAT_DELIM + signature); + final Index _index = n_a_t_table.get(name + NAT_DELIM + signature); return (_index != null) ? _index.index : -1; } @@ -553,7 +553,7 @@ public class ConstantPoolGen { signature_index = addUtf8(signature); ret = index; constants[index++] = new ConstantNameAndType(name_index, signature_index); - String key = name + NAT_DELIM + signature; + final String key = name + NAT_DELIM + signature; if (!n_a_t_table.containsKey(key)) { n_a_t_table.put(key, new Index(ret)); } @@ -572,7 +572,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupMethodref( final String class_name, final String method_name, final String signature ) { - Index index = cp_table.get(class_name + METHODREF_DELIM + method_name + final Index index = cp_table.get(class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature); return (index != null) ? index.index : -1; } @@ -604,7 +604,7 @@ public class ConstantPoolGen { class_index = addClass(class_name); ret = index; constants[index++] = new ConstantMethodref(class_index, name_and_type_index); - String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature; + final String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature; if (!cp_table.containsKey(key)) { cp_table.put(key, new Index(ret)); } @@ -626,7 +626,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupInterfaceMethodref( final String class_name, final String method_name, final String signature ) { - Index index = cp_table.get(class_name + IMETHODREF_DELIM + method_name + final Index index = cp_table.get(class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature); return (index != null) ? index.index : -1; } @@ -659,7 +659,7 @@ public class ConstantPoolGen { name_and_type_index = addNameAndType(method_name, signature); ret = index; constants[index++] = new ConstantInterfaceMethodref(class_index, name_and_type_index); - String key = class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature; + final String key = class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature; if (!cp_table.containsKey(key)) { cp_table.put(key, new Index(ret)); } @@ -681,7 +681,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupFieldref( final String class_name, final String field_name, final String signature ) { - Index index = cp_table.get(class_name + FIELDREF_DELIM + field_name + final Index index = cp_table.get(class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature); return (index != null) ? index.index : -1; } @@ -708,7 +708,7 @@ public class ConstantPoolGen { name_and_type_index = addNameAndType(field_name, signature); ret = index; constants[index++] = new ConstantFieldref(class_index, name_and_type_index); - String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature; + final String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature; if (!cp_table.containsKey(key)) { cp_table.put(key, new Index(ret)); } @@ -756,7 +756,7 @@ public class ConstantPoolGen { * @return constant pool with proper length */ public ConstantPool getFinalConstantPool() { - Constant[] cs = new Constant[index]; + final Constant[] cs = new Constant[index]; System.arraycopy(constants, 0, cs, 0, index); return new ConstantPool(cs); } @@ -767,7 +767,7 @@ public class ConstantPoolGen { */ @Override public String toString() { - StringBuilder buf = new StringBuilder(); + final StringBuilder buf = new StringBuilder(); for (int i = 1; i < index; i++) { buf.append(i).append(")").append(constants[i]).append("\n"); } @@ -778,22 +778,22 @@ public class ConstantPoolGen { /** Import constant from another ConstantPool and return new index. */ public int addConstant( final Constant c, final ConstantPoolGen cp ) { - Constant[] constants = cp.getConstantPool().getConstantPool(); + final Constant[] constants = cp.getConstantPool().getConstantPool(); switch (c.getTag()) { case Const.CONSTANT_String: { - ConstantString s = (ConstantString) c; - ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; + final ConstantString s = (ConstantString) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; return addString(u8.getBytes()); } case Const.CONSTANT_Class: { - ConstantClass s = (ConstantClass) c; - ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; + final ConstantClass s = (ConstantClass) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; return addClass(u8.getBytes()); } case Const.CONSTANT_NameAndType: { - ConstantNameAndType n = (ConstantNameAndType) c; - ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()]; - ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()]; + final ConstantNameAndType n = (ConstantNameAndType) c; + final ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()]; + final ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()]; return addNameAndType(u8.getBytes(), u8_2.getBytes()); } case Const.CONSTANT_Utf8: @@ -809,15 +809,15 @@ public class ConstantPoolGen { case Const.CONSTANT_InterfaceMethodref: case Const.CONSTANT_Methodref: case Const.CONSTANT_Fieldref: { - ConstantCP m = (ConstantCP) c; - ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; - ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; + final ConstantCP m = (ConstantCP) c; + final ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; + final ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()]; - String class_name = u8.getBytes().replace('/', '.'); + final String class_name = u8.getBytes().replace('/', '.'); u8 = (ConstantUtf8) constants[n.getNameIndex()]; - String name = u8.getBytes(); + final String name = u8.getBytes(); u8 = (ConstantUtf8) constants[n.getSignatureIndex()]; - String signature = u8.getBytes(); + final String signature = u8.getBytes(); switch (c.getTag()) { case Const.CONSTANT_InterfaceMethodref: return addInterfaceMethodref(class_name, name, signature); Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ElementValueGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ElementValueGen.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ElementValueGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ElementValueGen.java Tue Jun 21 20:50:19 2016 @@ -95,7 +95,7 @@ public abstract class ElementValueGen public static ElementValueGen readElementValue(final DataInput dis, final ConstantPoolGen cpGen) throws IOException { - int type = dis.readUnsignedByte(); + final int type = dis.readUnsignedByte(); switch (type) { case 'B': // byte @@ -137,8 +137,8 @@ public abstract class ElementValueGen new AnnotationEntryGen(AnnotationEntry.read(dis, cpGen .getConstantPool(), true), cpGen, false), cpGen); case '[': // Array - int numArrayVals = dis.readUnsignedShort(); - ElementValue[] evalues = new ElementValue[numArrayVals]; + final int numArrayVals = dis.readUnsignedShort(); + final ElementValue[] evalues = new ElementValue[numArrayVals]; for (int j = 0; j < numArrayVals; j++) { evalues[j] = ElementValue.readElementValue(dis, cpGen Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java Tue Jun 21 20:50:19 2016 @@ -63,7 +63,7 @@ public class ElementValuePairGen */ public ElementValuePair getElementNameValuePair() { - ElementValue immutableValue = value.getElementValue(); + final ElementValue immutableValue = value.getElementValue(); return new ElementValuePair(nameIdx, immutableValue, cpool .getConstantPool()); } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java Tue Jun 21 20:50:19 2016 @@ -99,7 +99,7 @@ public class EnumElementValueGen extends @Override public String stringifyValue() { - ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(valueIdx); + final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(valueIdx); return cu8.getBytes(); // ConstantString cu8 = // (ConstantString)getConstantPool().getConstant(valueIdx); Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGen.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGen.java Tue Jun 21 20:50:19 2016 @@ -47,8 +47,8 @@ public class FieldGen extends FieldGenOr @Override public boolean equals( final Object o1, final Object o2 ) { - FieldGen THIS = (FieldGen) o1; - FieldGen THAT = (FieldGen) o2; + final FieldGen THIS = (FieldGen) o1; + final FieldGen THAT = (FieldGen) o2; return THIS.getName().equals(THAT.getName()) && THIS.getSignature().equals(THAT.getSignature()); } @@ -56,7 +56,7 @@ public class FieldGen extends FieldGenOr @Override public int hashCode( final Object o ) { - FieldGen THIS = (FieldGen) o; + final FieldGen THIS = (FieldGen) o; return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); } }; @@ -88,14 +88,14 @@ public class FieldGen extends FieldGenOr */ public FieldGen(final Field field, final ConstantPoolGen cp) { this(field.getAccessFlags(), Type.getType(field.getSignature()), field.getName(), cp); - Attribute[] attrs = field.getAttributes(); - for (Attribute attr : attrs) { + final Attribute[] attrs = field.getAttributes(); + for (final Attribute attr : attrs) { if (attr instanceof ConstantValue) { setValue(((ConstantValue) attr).getConstantValueIndex()); } else if (attr instanceof Annotations) { - Annotations runtimeAnnotations = (Annotations)attr; - AnnotationEntry[] annotationEntries = runtimeAnnotations.getAnnotationEntries(); - for (AnnotationEntry element : annotationEntries) { + final Annotations runtimeAnnotations = (Annotations)attr; + final AnnotationEntry[] annotationEntries = runtimeAnnotations.getAnnotationEntries(); + for (final AnnotationEntry element : annotationEntries) { addAnnotationEntry(new AnnotationEntryGen(element,cp,false)); } } else { @@ -106,8 +106,8 @@ public class FieldGen extends FieldGenOr private void setValue( final int index ) { - ConstantPool cp = super.getConstantPool().getConstantPool(); - Constant c = cp.getConstant(index); + final ConstantPool cp = super.getConstantPool().getConstantPool(); + final Constant c = cp.getConstant(index); value = ((ConstantObject) c).getConstantValue(cp); } @@ -213,12 +213,12 @@ public class FieldGen extends FieldGenOr * Get field object after having set up all necessary values. */ public Field getField() { - String signature = getSignature(); - int name_index = super.getConstantPool().addUtf8(super.getName()); - int signature_index = super.getConstantPool().addUtf8(signature); + final String signature = getSignature(); + final int name_index = super.getConstantPool().addUtf8(super.getName()); + final int signature_index = super.getConstantPool().addUtf8(signature); if (value != null) { checkType(super.getType()); - int index = addConstant(); + final int index = addConstant(); addAttribute(new ConstantValue(super.getConstantPool().addUtf8("ConstantValue"), 2, index, super.getConstantPool().getConstantPool())); // sic } @@ -228,8 +228,8 @@ public class FieldGen extends FieldGenOr } private void addAnnotationsAsAttribute(final ConstantPoolGen cp) { - Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries()); - for (Attribute attr : attrs) { + final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries()); + for (final Attribute attr : attrs) { addAttribute(attr); } } @@ -290,7 +290,7 @@ public class FieldGen extends FieldGenOr */ public void update() { if (observers != null) { - for (FieldObserver observer : observers ) { + for (final FieldObserver observer : observers ) { observer.notify(this); } } @@ -320,9 +320,9 @@ public class FieldGen extends FieldGenOr access = access.isEmpty() ? "" : (access + " "); signature = super.getType().toString(); name = getName(); - StringBuilder buf = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber + final StringBuilder buf = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber buf.append(access).append(signature).append(" ").append(name); - String value = getInitValue(); + final String value = getInitValue(); if (value != null) { buf.append(" = ").append(value); } @@ -333,7 +333,7 @@ public class FieldGen extends FieldGenOr /** @return deep copy of this field */ public FieldGen copy( final ConstantPoolGen cp ) { - FieldGen fg = (FieldGen) clone(); + final FieldGen fg = (FieldGen) clone(); fg.setConstantPool(cp); return fg; } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java Tue Jun 21 20:50:19 2016 @@ -163,13 +163,13 @@ public abstract class FieldGenOrMethodGe * @return all attributes of this method. */ public Attribute[] getAttributes() { - Attribute[] attributes = new Attribute[attribute_vec.size()]; + final Attribute[] attributes = new Attribute[attribute_vec.size()]; attribute_vec.toArray(attributes); return attributes; } public AnnotationEntryGen[] getAnnotationEntries() { - AnnotationEntryGen[] annotations = new AnnotationEntryGen[annotation_vec.size()]; + final AnnotationEntryGen[] annotations = new AnnotationEntryGen[annotation_vec.size()]; annotation_vec.toArray(annotations); return annotations; } @@ -184,7 +184,7 @@ public abstract class FieldGenOrMethodGe public Object clone() { try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch (final CloneNotSupportedException e) { throw new Error("Clone Not Supported"); // never happens } } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldOrMethod.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldOrMethod.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldOrMethod.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldOrMethod.java Tue Jun 21 20:50:19 2016 @@ -50,9 +50,9 @@ public abstract class FieldOrMethod exte /** @return signature of referenced method/field. */ public String getSignature( final ConstantPoolGen cpg ) { - ConstantPool cp = cpg.getConstantPool(); - ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); - ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex()); + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex()); return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes(); } @@ -60,9 +60,9 @@ public abstract class FieldOrMethod exte /** @return name of referenced method/field. */ public String getName( final ConstantPoolGen cpg ) { - ConstantPool cp = cpg.getConstantPool(); - ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); - ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex()); + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex()); return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes(); } @@ -80,9 +80,9 @@ public abstract class FieldOrMethod exte */ @Deprecated public String getClassName( final ConstantPoolGen cpg ) { - ConstantPool cp = cpg.getConstantPool(); - ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); - String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class); + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class); if (className.startsWith("[")) { // Turn array classes into java.lang.Object. return "java.lang.Object"; @@ -111,8 +111,8 @@ public abstract class FieldOrMethod exte * type is an array class) */ public ReferenceType getReferenceType( final ConstantPoolGen cpg ) { - ConstantPool cp = cpg.getConstantPool(); - ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); + final ConstantPool cp = cpg.getConstantPool(); + final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex()); String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class); if (className.startsWith("[")) { return (ArrayType) Type.getType(className); @@ -130,7 +130,7 @@ public abstract class FieldOrMethod exte */ @Override public ObjectType getLoadClassType( final ConstantPoolGen cpg ) { - ReferenceType rt = getReferenceType(cpg); + final ReferenceType rt = getReferenceType(cpg); if(rt instanceof ObjectType) { return (ObjectType)rt; } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GOTO.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GOTO.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GOTO.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GOTO.java Tue Jun 21 20:50:19 2016 @@ -68,11 +68,11 @@ public class GOTO extends GotoInstructio */ @Override protected int updatePosition( final int offset, final int max_offset ) { - int i = getTargetOffset(); // Depending on old position value + final int i = getTargetOffset(); // Depending on old position value setPosition(getPosition() + offset); // Position may be shifted by preceding expansions if (Math.abs(i) >= (Short.MAX_VALUE - max_offset)) { // to large for short (estimate) super.setOpcode(org.apache.bcel.Const.GOTO_W); - short old_length = (short) super.getLength(); + final short old_length = (short) super.getLength(); super.setLength(5); return super.getLength() - old_length; } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java Tue Jun 21 20:50:19 2016 @@ -123,8 +123,8 @@ public class INVOKEDYNAMIC extends Invok */ @Override public String getClassName( final ConstantPoolGen cpg ) { - ConstantPool cp = cpg.getConstantPool(); - ConstantInvokeDynamic cid = (ConstantInvokeDynamic) cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic); + final ConstantPool cp = cpg.getConstantPool(); + final ConstantInvokeDynamic cid = (ConstantInvokeDynamic) cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic); return ((ConstantNameAndType) cp.getConstant(cid.getNameAndTypeIndex())).getName(cp); } } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/Instruction.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/Instruction.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/Instruction.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/Instruction.java Tue Jun 21 20:50:19 2016 @@ -126,7 +126,7 @@ public abstract class Instruction implem } else { try { i = (Instruction) clone(); - } catch (CloneNotSupportedException e) { + } catch (final CloneNotSupportedException e) { System.err.println(e); } } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionFactory.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionFactory.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionFactory.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionFactory.java Tue Jun 21 20:50:19 2016 @@ -86,8 +86,8 @@ public class InstructionFactory implemen final Type[] arg_types, final short kind ) { int index; int nargs = 0; - String signature = Type.getMethodSignature(ret_type, arg_types); - for (Type arg_type : arg_types) { + final String signature = Type.getMethodSignature(ret_type, arg_types); + for (final Type arg_type : arg_types) { nargs += arg_type.getSize(); } if (kind == Const.INVOKEINTERFACE) { @@ -143,9 +143,9 @@ public class InstructionFactory implemen * @param s the string to print */ public InstructionList createPrintln( final String s ) { - InstructionList il = new InstructionList(); - int out = cp.addFieldref("java.lang.System", "out", "Ljava/io/PrintStream;"); - int println = cp.addMethodref("java.io.PrintStream", "println", "(Ljava/lang/String;)V"); + final InstructionList il = new InstructionList(); + final int out = cp.addFieldref("java.lang.System", "out", "Ljava/io/PrintStream;"); + final int println = cp.addMethodref("java.io.PrintStream", "println", "(Ljava/lang/String;)V"); il.append(new GETSTATIC(out)); il.append(new PUSH(cp, s)); il.append(new INVOKEVIRTUAL(println)); @@ -238,7 +238,7 @@ public class InstructionFactory implemen public Instruction createAppend( final Type type ) { - byte t = type.getType(); + final byte t = type.getType(); if (isString(type)) { return createInvoke(append_mos[0], Const.INVOKEVIRTUAL); } @@ -271,7 +271,7 @@ public class InstructionFactory implemen */ public FieldInstruction createFieldAccess( final String class_name, final String name, final Type type, final short kind ) { int index; - String signature = type.getSignature(); + final String signature = type.getSignature(); index = cp.addFieldref(class_name, name, signature); switch (kind) { case Const.GETFIELD: @@ -420,7 +420,7 @@ public class InstructionFactory implemen * @param op operation, such as "+", "*", "<<", etc. */ public static ArithmeticInstruction createBinaryOperation( final String op, final Type type ) { - char first = op.charAt(0); + final char first = op.charAt(0); switch (type.getType()) { case Const.T_BYTE: case Const.T_SHORT: @@ -586,18 +586,18 @@ public class InstructionFactory implemen */ public Instruction createCast( final Type src_type, final Type dest_type ) { if ((src_type instanceof BasicType) && (dest_type instanceof BasicType)) { - byte dest = dest_type.getType(); + final byte dest = dest_type.getType(); byte src = src_type.getType(); if (dest == Const.T_LONG && (src == Const.T_CHAR || src == Const.T_BYTE || src == Const.T_SHORT)) { src = Const.T_INT; } - String name = "org.apache.bcel.generic." + short_names[src - Const.T_CHAR] + "2" + final String name = "org.apache.bcel.generic." + short_names[src - Const.T_CHAR] + "2" + short_names[dest - Const.T_CHAR]; Instruction i = null; try { i = (Instruction) java.lang.Class.forName(name).newInstance(); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException("Could not find instruction: " + name, e); } return i; Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionHandle.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionHandle.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionHandle.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionHandle.java Tue Jun 21 20:50:19 2016 @@ -103,7 +103,7 @@ public class InstructionHandle { // See BCEL-273 // TODO remove this method in any redesign of BCEL public Instruction swapInstruction( final Instruction i ) { - Instruction oldInstruction = instruction; + final Instruction oldInstruction = instruction; instruction = i; return oldInstruction; } @@ -122,7 +122,7 @@ public class InstructionHandle { if (ih_list == null) { return new InstructionHandle(i); } - InstructionHandle ih = ih_list; + final InstructionHandle ih = ih_list; ih_list = ih.next; ih.setInstruction(i); return ih; @@ -227,7 +227,7 @@ public class InstructionHandle { if (!hasTargeters()) { return new InstructionTargeter[0]; } - InstructionTargeter[] t = new InstructionTargeter[targeters.size()]; + final InstructionTargeter[] t = new InstructionTargeter[targeters.size()]; targeters.toArray(t); return t; } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionList.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionList.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionList.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InstructionList.java Tue Jun 21 20:50:19 2016 @@ -113,8 +113,8 @@ public class InstructionList implements * Do a binary search since the pos array is orderd. */ do { - int i = (l + r) / 2; - int j = pos[i]; + final int i = (l + r) / 2; + final int j = pos[i]; if (j == target) { return ihs[i]; } else if (target < j) { @@ -135,7 +135,7 @@ public class InstructionList implements * @return target position's instruction handle if available */ public InstructionHandle findHandle(final int pos) { - int[] positions = byte_positions; + final int[] positions = byte_positions; InstructionHandle ih = start; for (int i = 0; i < length; i++) { if (positions[i] == pos) { @@ -164,12 +164,12 @@ public class InstructionList implements */ while (bytes.available() > 0) { // Remember byte offset and associate it with the instruction - int off = bytes.getIndex(); + final int off = bytes.getIndex(); pos[count] = off; /* * Read one instruction from the byte stream, the byte position is set accordingly. */ - Instruction i = Instruction.readInstruction(bytes); + final Instruction i = Instruction.readInstruction(bytes); InstructionHandle ih; if (i instanceof BranchInstruction) { ih = append((BranchInstruction) i); @@ -180,7 +180,7 @@ public class InstructionList implements ihs[count] = ih; count++; } - } catch (IOException e) { + } catch (final IOException e) { throw new ClassGenException(e.toString(), e); } byte_positions = new int[count]; // Trim to proper size @@ -190,7 +190,7 @@ public class InstructionList implements */ for (int i = 0; i < count; i++) { if (ihs[i] instanceof BranchHandle) { - BranchInstruction bi = (BranchInstruction) ihs[i].getInstruction(); + final BranchInstruction bi = (BranchInstruction) ihs[i].getInstruction(); int target = bi.getPosition() + bi.getIndex(); /* * Byte code position: relative -> absolute. */ @@ -202,8 +202,8 @@ public class InstructionList implements bi.setTarget(ih); // Update target // If it is a Select instruction, update all branch targets if (bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH - Select s = (Select) bi; - int[] indices = s.getIndices(); + final Select s = (Select) bi; + final int[] indices = s.getIndices(); for (int j = 0; j < indices.length; j++) { target = bi.getPosition() + indices[j]; ih = findHandle(ihs, pos, count, target); @@ -233,8 +233,8 @@ public class InstructionList implements if (il.isEmpty()) { return ih; } - InstructionHandle next = ih.getNext(); - InstructionHandle ret = il.start; + final InstructionHandle next = ih.getNext(); + final InstructionHandle ret = il.start; ih.setNext(il.start); il.start.setPrev(ih); il.end.setNext(next); @@ -316,7 +316,7 @@ public class InstructionList implements * @return instruction handle of the appended instruction */ public InstructionHandle append(final Instruction i) { - InstructionHandle ih = InstructionHandle.getInstructionHandle(i); + final InstructionHandle ih = InstructionHandle.getInstructionHandle(i); append(ih); return ih; } @@ -329,7 +329,7 @@ public class InstructionList implements * @return branch instruction handle of the appended instruction */ public BranchHandle append(final BranchInstruction i) { - BranchHandle ih = BranchHandle.getBranchHandle(i); + final BranchHandle ih = BranchHandle.getBranchHandle(i); append(ih); return ih; } @@ -407,8 +407,8 @@ public class InstructionList implements * @return instruction handle pointing to the <B>first</B> appended instruction */ public BranchHandle append(final InstructionHandle ih, final BranchInstruction i) { - BranchHandle bh = BranchHandle.getBranchHandle(i); - InstructionList il = new InstructionList(); + final BranchHandle bh = BranchHandle.getBranchHandle(i); + final InstructionList il = new InstructionList(); il.append(bh); append(ih, il); return bh; @@ -430,8 +430,8 @@ public class InstructionList implements if (il.isEmpty()) { return ih; } - InstructionHandle prev = ih.getPrev(); - InstructionHandle ret = il.start; + final InstructionHandle prev = ih.getPrev(); + final InstructionHandle ret = il.start; ih.setPrev(il.end); il.end.setNext(ih); il.start.setPrev(prev); @@ -504,7 +504,7 @@ public class InstructionList implements * @return instruction handle of the inserted instruction */ public InstructionHandle insert(final Instruction i) { - InstructionHandle ih = InstructionHandle.getInstructionHandle(i); + final InstructionHandle ih = InstructionHandle.getInstructionHandle(i); insert(ih); return ih; } @@ -517,7 +517,7 @@ public class InstructionList implements * @return branch instruction handle of the appended instruction */ public BranchHandle insert(final BranchInstruction i) { - BranchHandle ih = BranchHandle.getBranchHandle(i); + final BranchHandle ih = BranchHandle.getBranchHandle(i); insert(ih); return ih; } @@ -595,8 +595,8 @@ public class InstructionList implements * @return instruction handle of the first inserted instruction */ public BranchHandle insert(final InstructionHandle ih, final BranchInstruction i) { - BranchHandle bh = BranchHandle.getBranchHandle(i); - InstructionList il = new InstructionList(); + final BranchHandle bh = BranchHandle.getBranchHandle(i); + final InstructionList il = new InstructionList(); il.append(bh); insert(ih, il); return bh; @@ -630,7 +630,7 @@ public class InstructionList implements } } // Step 2: Temporarily remove the given instructions from the list - InstructionHandle prev = start.getPrev(); + final InstructionHandle prev = start.getPrev(); InstructionHandle next = end.getNext(); if (prev != null) { prev.setNext(next); @@ -709,11 +709,11 @@ public class InstructionList implements } first.setPrev(null); // Completely separated from rest of list last.setNext(null); - List<InstructionHandle> target_vec = new ArrayList<>(); + final List<InstructionHandle> target_vec = new ArrayList<>(); for (InstructionHandle ih = first; ih != null; ih = ih.getNext()) { ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets } - StringBuilder buf = new StringBuilder("{ "); + final StringBuilder buf = new StringBuilder("{ "); for (InstructionHandle ih = first; ih != null; ih = next) { next = ih.getNext(); length--; @@ -727,7 +727,7 @@ public class InstructionList implements } buf.append("}"); if (!target_vec.isEmpty()) { - InstructionHandle[] targeted = new InstructionHandle[target_vec.size()]; + final InstructionHandle[] targeted = new InstructionHandle[target_vec.size()]; target_vec.toArray(targeted); throw new TargetLostException(targeted, buf.toString()); } @@ -854,21 +854,21 @@ public class InstructionList implements int additional_bytes = 0; int index = 0; int count = 0; - int[] pos = new int[length]; + final int[] pos = new int[length]; /* * Pass 0: Sanity checks */ if (check) { for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { - Instruction i = ih.getInstruction(); + final Instruction i = ih.getInstruction(); if (i instanceof BranchInstruction) { // target instruction within list? Instruction inst = ((BranchInstruction) i).getTarget().getInstruction(); if (!contains(inst)) { throw new ClassGenException("Branch target of " + Const.getOpcodeName(i.getOpcode()) + ":" + inst + " not in instruction list"); } if (i instanceof Select) { - InstructionHandle[] targets = ((Select) i).getTargets(); - for (InstructionHandle target : targets) { + final InstructionHandle[] targets = ((Select) i).getTargets(); + for (final InstructionHandle target : targets) { inst = target.getInstruction(); if (!contains(inst)) { throw new ClassGenException("Branch target of " + Const.getOpcodeName(i.getOpcode()) + ":" + inst + " not in instruction list"); @@ -886,7 +886,7 @@ public class InstructionList implements * Pass 1: Set position numbers and sum up the maximum number of bytes an instruction may be shifted. */ for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { - Instruction i = ih.getInstruction(); + final Instruction i = ih.getInstruction(); ih.setPosition(index); pos[count++] = index; /* @@ -917,7 +917,7 @@ public class InstructionList implements */ index = count = 0; for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { - Instruction i = ih.getInstruction(); + final Instruction i = ih.getInstruction(); ih.setPosition(index); pos[count++] = index; index += i.getLength(); @@ -934,15 +934,15 @@ public class InstructionList implements public byte[] getByteCode() { // Update position indices of instructions setPositions(); - ByteArrayOutputStream b = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(b); + final ByteArrayOutputStream b = new ByteArrayOutputStream(); + final DataOutputStream out = new DataOutputStream(b); try { for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { - Instruction i = ih.getInstruction(); + final Instruction i = ih.getInstruction(); i.dump(out); // Traverse list } out.flush(); - } catch (IOException e) { + } catch (final IOException e) { System.err.println(e); return new byte[0]; } @@ -953,12 +953,12 @@ public class InstructionList implements * @return an array of instructions without target information for branch instructions. */ public Instruction[] getInstructions() { - List<Instruction> instructions = new ArrayList<>(); + final List<Instruction> instructions = new ArrayList<>(); try (ByteSequence bytes = new ByteSequence(getByteCode())) { while (bytes.available() > 0) { instructions.add(Instruction.readInstruction(bytes)); } - } catch (IOException e) { + } catch (final IOException e) { throw new ClassGenException(e.toString(), e); } return instructions.toArray(new Instruction[instructions.size()]); @@ -975,7 +975,7 @@ public class InstructionList implements * @return String containing all instructions in this list. */ public String toString(final boolean verbose) { - StringBuilder buf = new StringBuilder(); + final StringBuilder buf = new StringBuilder(); for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { buf.append(ih.toString(verbose)).append("\n"); } @@ -996,7 +996,7 @@ public class InstructionList implements if (ih == null) { throw new NoSuchElementException(); } - InstructionHandle i = ih; + final InstructionHandle i = ih; ih = ih.getNext(); return i; } @@ -1017,7 +1017,7 @@ public class InstructionList implements * @return array containing all instructions (handles) */ public InstructionHandle[] getInstructionHandles() { - InstructionHandle[] ihs = new InstructionHandle[length]; + final InstructionHandle[] ihs = new InstructionHandle[length]; InstructionHandle ih = start; for (int i = 0; i < length; i++) { ihs[i] = ih; @@ -1040,14 +1040,14 @@ public class InstructionList implements * @return complete, i.e., deep copy of this list */ public InstructionList copy() { - Map<InstructionHandle, InstructionHandle> map = new HashMap<>(); - InstructionList il = new InstructionList(); + final Map<InstructionHandle, InstructionHandle> map = new HashMap<>(); + final InstructionList il = new InstructionList(); /* * Pass 1: Make copies of all instructions, append them to the new list and associate old instruction references with the new ones, i.e., a 1:1 mapping. */ for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { - Instruction i = ih.getInstruction(); - Instruction c = i.copy(); // Use clone for shallow copy + final Instruction i = ih.getInstruction(); + final Instruction c = i.copy(); // Use clone for shallow copy if (c instanceof BranchInstruction) { map.put(ih, il.append((BranchInstruction) c)); } else { @@ -1060,17 +1060,17 @@ public class InstructionList implements InstructionHandle ih = start; InstructionHandle ch = il.start; while (ih != null) { - Instruction i = ih.getInstruction(); - Instruction c = ch.getInstruction(); + final Instruction i = ih.getInstruction(); + final Instruction c = ch.getInstruction(); if (i instanceof BranchInstruction) { - BranchInstruction bi = (BranchInstruction) i; - BranchInstruction bc = (BranchInstruction) c; - InstructionHandle itarget = bi.getTarget(); // old target + final BranchInstruction bi = (BranchInstruction) i; + final BranchInstruction bc = (BranchInstruction) c; + final InstructionHandle itarget = bi.getTarget(); // old target // New target is in hash map bc.setTarget(map.get(itarget)); if (bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH - InstructionHandle[] itargets = ((Select) bi).getTargets(); - InstructionHandle[] ctargets = ((Select) bc).getTargets(); + final InstructionHandle[] itargets = ((Select) bi).getTargets(); + final InstructionHandle[] ctargets = ((Select) bc).getTargets(); for (int j = 0; j < itargets.length; j++) { // Update all targets ctargets[j] = map.get(itargets[j]); } @@ -1087,10 +1087,10 @@ public class InstructionList implements */ public void replaceConstantPool(final ConstantPoolGen old_cp, final ConstantPoolGen new_cp) { for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { - Instruction i = ih.getInstruction(); + final Instruction i = ih.getInstruction(); if (i instanceof CPInstruction) { - CPInstruction ci = (CPInstruction) i; - Constant c = old_cp.getConstant(ci.getIndex()); + final CPInstruction ci = (CPInstruction) i; + final Constant c = old_cp.getConstant(ci.getIndex()); ci.setIndex(new_cp.addConstant(c, old_cp)); } } @@ -1154,15 +1154,15 @@ public class InstructionList implements */ public void redirectBranches(final InstructionHandle old_target, final InstructionHandle new_target) { for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { - Instruction i = ih.getInstruction(); + final Instruction i = ih.getInstruction(); if (i instanceof BranchInstruction) { - BranchInstruction b = (BranchInstruction) i; - InstructionHandle target = b.getTarget(); + final BranchInstruction b = (BranchInstruction) i; + final InstructionHandle target = b.getTarget(); if (target == old_target) { b.setTarget(new_target); } if (b instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH - InstructionHandle[] targets = ((Select) b).getTargets(); + final InstructionHandle[] targets = ((Select) b).getTargets(); for (int j = 0; j < targets.length; j++) { if (targets[j] == old_target) { ((Select) b).setTarget(j, new_target); @@ -1185,9 +1185,9 @@ public class InstructionList implements * @see MethodGen */ public void redirectLocalVariables(final LocalVariableGen[] lg, final InstructionHandle old_target, final InstructionHandle new_target) { - for (LocalVariableGen element : lg) { - InstructionHandle start = element.getStart(); - InstructionHandle end = element.getEnd(); + for (final LocalVariableGen element : lg) { + final InstructionHandle start = element.getStart(); + final InstructionHandle end = element.getEnd(); if (start == old_target) { element.setStart(new_target); } @@ -1209,7 +1209,7 @@ public class InstructionList implements * @see MethodGen */ public void redirectExceptionHandlers(final CodeExceptionGen[] exceptions, final InstructionHandle old_target, final InstructionHandle new_target) { - for (CodeExceptionGen exception : exceptions) { + for (final CodeExceptionGen exception : exceptions) { if (exception.getStartPC() == old_target) { exception.setStartPC(new_target); } @@ -1249,7 +1249,7 @@ public class InstructionList implements */ public void update() { if (observers != null) { - for (InstructionListObserver observer : observers) { + for (final InstructionListObserver observer : observers) { observer.notify(this); } } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InvokeInstruction.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InvokeInstruction.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InvokeInstruction.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/InvokeInstruction.java Tue Jun 21 20:50:19 2016 @@ -52,8 +52,8 @@ public abstract class InvokeInstruction */ @Override public String toString( final ConstantPool cp ) { - Constant c = cp.getConstant(super.getIndex()); - StringTokenizer tok = new StringTokenizer(cp.constantToString(c)); + final Constant c = cp.getConstant(super.getIndex()); + final StringTokenizer tok = new StringTokenizer(cp.constantToString(c)); return Const.getOpcodeName(super.getOpcode()) + " " + tok.nextToken().replace('.', '/') + tok.nextToken(); } @@ -73,7 +73,7 @@ public abstract class InvokeInstruction sum = 1; // this reference } - String signature = getSignature(cpg); + final String signature = getSignature(cpg); sum += Type.getArgumentTypesSize(signature); return sum; } @@ -86,7 +86,7 @@ public abstract class InvokeInstruction */ @Override public int produceStack( final ConstantPoolGen cpg ) { - String signature = getSignature(cpg); + final String signature = getSignature(cpg); return Type.getReturnTypeSize(signature); } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/JSR.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/JSR.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/JSR.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/JSR.java Tue Jun 21 20:50:19 2016 @@ -59,11 +59,11 @@ public class JSR extends JsrInstruction @Override protected int updatePosition( final int offset, final int max_offset ) { - int i = getTargetOffset(); // Depending on old position value + final int i = getTargetOffset(); // Depending on old position value setPosition(getPosition() + offset); // Position may be shifted by preceding expansions if (Math.abs(i) >= (Short.MAX_VALUE - max_offset)) { // to large for short (estimate) super.setOpcode(org.apache.bcel.Const.JSR_W); - short old_length = (short) super.getLength(); + final short old_length = (short) super.getLength(); super.setLength(5); return super.getLength() - old_length; } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/JsrInstruction.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/JsrInstruction.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/JsrInstruction.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/JsrInstruction.java Tue Jun 21 20:50:19 2016 @@ -67,7 +67,7 @@ public abstract class JsrInstruction ext while (ih.getInstruction() != this) { ih = ih.getNext(); } - InstructionHandle toThis = ih; + final InstructionHandle toThis = ih; while (ih != null) { ih = ih.getNext(); if ((ih != null) && (ih.getInstruction() == this)) { Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LDC.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LDC.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LDC.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LDC.java Tue Jun 21 20:50:19 2016 @@ -97,7 +97,7 @@ public class LDC extends CPInstruction i org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); switch (c.getTag()) { case org.apache.bcel.Const.CONSTANT_String: - int i = ((org.apache.bcel.classfile.ConstantString) c).getStringIndex(); + final int i = ((org.apache.bcel.classfile.ConstantString) c).getStringIndex(); c = cpg.getConstantPool().getConstant(i); return ((org.apache.bcel.classfile.ConstantUtf8) c).getBytes(); case org.apache.bcel.Const.CONSTANT_Float: @@ -105,7 +105,7 @@ public class LDC extends CPInstruction i case org.apache.bcel.Const.CONSTANT_Integer: return Integer.valueOf(((org.apache.bcel.classfile.ConstantInteger) c).getBytes()); case org.apache.bcel.Const.CONSTANT_Class: - int nameIndex = ((org.apache.bcel.classfile.ConstantClass) c).getNameIndex(); + final int nameIndex = ((org.apache.bcel.classfile.ConstantClass) c).getNameIndex(); c = cpg.getConstantPool().getConstant(nameIndex); return new ObjectType(((org.apache.bcel.classfile.ConstantUtf8) c).getBytes()); default: // Never reached Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LDC2_W.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LDC2_W.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LDC2_W.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LDC2_W.java Tue Jun 21 20:50:19 2016 @@ -53,7 +53,7 @@ public class LDC2_W extends CPInstructio public Number getValue( final ConstantPoolGen cpg ) { - org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); + final org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex()); switch (c.getTag()) { case org.apache.bcel.Const.CONSTANT_Long: return Long.valueOf(((org.apache.bcel.classfile.ConstantLong) c).getBytes()); Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LineNumberGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LineNumberGen.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LineNumberGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LineNumberGen.java Tue Jun 21 20:50:19 2016 @@ -90,7 +90,7 @@ public class LineNumberGen implements In public Object clone() { try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch (final CloneNotSupportedException e) { throw new Error("Clone Not Supported"); // never happens } } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LocalVariableGen.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LocalVariableGen.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LocalVariableGen.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/LocalVariableGen.java Tue Jun 21 20:50:19 2016 @@ -86,8 +86,8 @@ public class LocalVariableGen implements length += end.getInstruction().getLength(); } } - int name_index = cp.addUtf8(name); - int signature_index = cp.addUtf8(type.getSignature()); + final int name_index = cp.addUtf8(name); + final int signature_index = cp.addUtf8(type.getSignature()); return new LocalVariable(start_pc, length, name_index, signature_index, index, cp .getConstantPool()); } @@ -204,7 +204,7 @@ public class LocalVariableGen implements if (!(o instanceof LocalVariableGen)) { return false; } - LocalVariableGen l = (LocalVariableGen) o; + final LocalVariableGen l = (LocalVariableGen) o; return (l.index == index) && (l.start == start) && (l.end == end); } @@ -219,7 +219,7 @@ public class LocalVariableGen implements public Object clone() { try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch (final CloneNotSupportedException e) { throw new Error("Clone Not Supported"); // never happens } }