diff options
author | Gary D. Gregory <ggregory@apache.org> | 2013-12-31 22:06:09 +0000 |
---|---|---|
committer | Gary D. Gregory <ggregory@apache.org> | 2013-12-31 22:06:09 +0000 |
commit | 09499726b740d11acfdd16d1658ba98beb808d71 (patch) | |
tree | 8cbaead226ddd6eab32294645a1e57b4f71aa070 | |
parent | 9082f2bd701d6b0a90b0b319948057d2ec2922e0 (diff) | |
download | apache-commons-bcel-09499726b740d11acfdd16d1658ba98beb808d71.tar.gz |
Convert control statement bodies to block.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/bcel/trunk@1554577 13f79535-47bb-0310-9956-ffa450edef68
32 files changed, 257 insertions, 162 deletions
diff --git a/src/main/java/org/apache/bcel/classfile/AnnotationElementValue.java b/src/main/java/org/apache/bcel/classfile/AnnotationElementValue.java index 00e9dd10..e4cfd97b 100644 --- a/src/main/java/org/apache/bcel/classfile/AnnotationElementValue.java +++ b/src/main/java/org/apache/bcel/classfile/AnnotationElementValue.java @@ -29,9 +29,10 @@ public class AnnotationElementValue extends ElementValue ConstantPool cpool) { super(type, cpool); - if (type != ANNOTATION) - throw new RuntimeException( - "Only element values of type annotation can be built with this ctor - type specified: " + type); + if (type != ANNOTATION) { + throw new RuntimeException( + "Only element values of type annotation can be built with this ctor - type specified: " + type); + } this.annotationEntry = annotationEntry; } diff --git a/src/main/java/org/apache/bcel/classfile/ArrayElementValue.java b/src/main/java/org/apache/bcel/classfile/ArrayElementValue.java index 250d8bf1..7b2d2e2b 100644 --- a/src/main/java/org/apache/bcel/classfile/ArrayElementValue.java +++ b/src/main/java/org/apache/bcel/classfile/ArrayElementValue.java @@ -33,8 +33,9 @@ public class ArrayElementValue extends ElementValue for (int i = 0; i < evalues.length; i++) { sb.append(evalues[i].toString()); - if ((i + 1) < evalues.length) - sb.append(","); + if ((i + 1) < evalues.length) { + sb.append(","); + } } sb.append("}"); return sb.toString(); @@ -43,9 +44,10 @@ public class ArrayElementValue extends ElementValue public ArrayElementValue(int type, ElementValue[] datums, ConstantPool cpool) { super(type, cpool); - if (type != ARRAY) - throw new RuntimeException( + if (type != ARRAY) { + throw new RuntimeException( "Only element values of type array can be built with this ctor - type specified: " + type); + } this.evalues = datums; } @@ -67,8 +69,9 @@ public class ArrayElementValue extends ElementValue for (int i = 0; i < evalues.length; i++) { sb.append(evalues[i].stringifyValue()); - if ((i + 1) < evalues.length) - sb.append(","); + if ((i + 1) < evalues.length) { + sb.append(","); + } } sb.append("]"); return sb.toString(); diff --git a/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java b/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java index 317afca6..728bac61 100644 --- a/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java +++ b/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java @@ -52,7 +52,7 @@ public final class ConstantUtf8 extends Constant { final static boolean BCEL_DONT_CACHE = Boolean.getBoolean("bcel.dontCache"); static { - if (BCEL_STATISTICS) + if (BCEL_STATISTICS) { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { System.err.println("Cache hit " + hits + "/" + considered +", " @@ -60,6 +60,7 @@ public final class ConstantUtf8 extends Constant { System.err.println("Total of " + created + " ConstantUtf8 objects created"); } }); + } } public static synchronized ConstantUtf8 getCachedInstance(String s) { diff --git a/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java b/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java index 93890fc8..983dfcb4 100644 --- a/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java +++ b/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java @@ -81,7 +81,9 @@ public class EnclosingMethod extends Attribute { } public final ConstantNameAndType getEnclosingMethod() { - if (methodIndex == 0) return null; + if (methodIndex == 0) { + return null; + } ConstantNameAndType nat = (ConstantNameAndType)constant_pool.getConstant(methodIndex,Constants.CONSTANT_NameAndType); return nat; diff --git a/src/main/java/org/apache/bcel/classfile/EnumElementValue.java b/src/main/java/org/apache/bcel/classfile/EnumElementValue.java index 8efb7c44..8bfdf3c1 100644 --- a/src/main/java/org/apache/bcel/classfile/EnumElementValue.java +++ b/src/main/java/org/apache/bcel/classfile/EnumElementValue.java @@ -32,9 +32,10 @@ public class EnumElementValue extends ElementValue ConstantPool cpool) { super(type, cpool); - if (type != ENUM_CONSTANT) - throw new RuntimeException( + if (type != ENUM_CONSTANT) { + throw new RuntimeException( "Only element values of type enum can be built with this ctor - type specified: " + type); + } this.typeIdx = typeIdx; this.valueIdx = valueIdx; } diff --git a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java index 9332b000..676a57ed 100644 --- a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java +++ b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java @@ -213,8 +213,9 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No c.constant_pool = constant_pool; c.attributes = new Attribute[attributes_count]; - for(int i=0; i < attributes_count; i++) - c.attributes[i] = attributes[i].copy(constant_pool); + for(int i=0; i < attributes_count; i++) { + c.attributes[i] = attributes[i].copy(constant_pool); + } return c; } diff --git a/src/main/java/org/apache/bcel/classfile/JavaClass.java b/src/main/java/org/apache/bcel/classfile/JavaClass.java index b4b6016b..b377a795 100644 --- a/src/main/java/org/apache/bcel/classfile/JavaClass.java +++ b/src/main/java/org/apache/bcel/classfile/JavaClass.java @@ -345,8 +345,9 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl for (Attribute attribute : attrs) { if (attribute instanceof Annotations) { Annotations runtimeAnnotations = (Annotations)attribute; - for(int j = 0; j < runtimeAnnotations.getAnnotationEntries().length; j++) - accumulatedAnnotations.add(runtimeAnnotations.getAnnotationEntries()[j]); + for(int j = 0; j < runtimeAnnotations.getAnnotationEntries().length; j++) { + accumulatedAnnotations.add(runtimeAnnotations.getAnnotationEntries()[j]); + } } } annotations = accumulatedAnnotations.toArray(new AnnotationEntry[accumulatedAnnotations.size()]); @@ -649,8 +650,9 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl AnnotationEntry[] annotations = getAnnotationEntries(); if (annotations!=null && annotations.length>0) { buf.append("\nAnnotation(s):\n"); - for (AnnotationEntry annotation : annotations) + for (AnnotationEntry annotation : annotations) { buf.append(indent(annotation)); + } } if (fields.length > 0) { buf.append("\n").append(fields.length).append(" fields:\n"); @@ -726,7 +728,9 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl } private final void computeNestedTypeStatus() { - if (computedNestedTypeStatus) return; + if (computedNestedTypeStatus) { + return; + } for (Attribute attribute : this.attributes) { if (attribute instanceof InnerClasses) { InnerClass[] innerClasses = ((InnerClasses) attribute).getInnerClasses(); diff --git a/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java b/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java index 699833b5..73808828 100644 --- a/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java +++ b/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java @@ -70,8 +70,9 @@ private int local_variable_type_table_length; // Table of local local_variable_type_table_length = (dis.readUnsignedShort()); local_variable_type_table = new LocalVariable[local_variable_type_table_length]; - for(int i=0; i < local_variable_type_table_length; i++) - local_variable_type_table[i] = new LocalVariable(dis, cpool); + for(int i=0; i < local_variable_type_table_length; i++) { + local_variable_type_table[i] = new LocalVariable(dis, cpool); + } } @Override @@ -84,8 +85,9 @@ public final void dump(DataOutputStream file) throws IOException { super.dump(file); file.writeShort(local_variable_type_table_length); - for(int i=0; i < local_variable_type_table_length; i++) - local_variable_type_table[i].dump(file); + for(int i=0; i < local_variable_type_table_length; i++) { + local_variable_type_table[i].dump(file); + } } public final LocalVariable[] getLocalVariableTypeTable() { @@ -93,9 +95,11 @@ public final void dump(DataOutputStream file) throws IOException } public final LocalVariable getLocalVariable(int index) { - for(int i=0; i < local_variable_type_table_length; i++) - if(local_variable_type_table[i].getIndex() == index) - return local_variable_type_table[i]; + for(int i=0; i < local_variable_type_table_length; i++) { + if(local_variable_type_table[i].getIndex() == index) { + return local_variable_type_table[i]; + } + } return null; } @@ -117,7 +121,9 @@ public final String toString() { for(int i=0; i < local_variable_type_table_length; i++) { buf.append(local_variable_type_table[i].toString()); - if(i < local_variable_type_table_length - 1) buf.append('\n'); + if(i < local_variable_type_table_length - 1) { + buf.append('\n'); + } } return buf.toString(); @@ -131,8 +137,9 @@ public Attribute copy(ConstantPool constant_pool) { LocalVariableTypeTable c = (LocalVariableTypeTable)clone(); c.local_variable_type_table = new LocalVariable[local_variable_type_table_length]; - for(int i=0; i < local_variable_type_table_length; i++) - c.local_variable_type_table[i] = local_variable_type_table[i].copy(); + for(int i=0; i < local_variable_type_table_length; i++) { + c.local_variable_type_table[i] = local_variable_type_table[i].copy(); + } c.constant_pool = constant_pool; return c; diff --git a/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java b/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java index bcd747bd..d525bb95 100644 --- a/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java +++ b/src/main/java/org/apache/bcel/classfile/SimpleElementValue.java @@ -46,9 +46,10 @@ public class SimpleElementValue extends ElementValue public String getValueString() { - if (type != STRING) - throw new RuntimeException( + if (type != STRING) { + throw new RuntimeException( "Dont call getValueString() on a non STRING ElementValue"); + } ConstantUtf8 c = (ConstantUtf8) cpool.getConstant(getIndex(), Constants.CONSTANT_Utf8); return c.getBytes(); @@ -56,9 +57,10 @@ public class SimpleElementValue extends ElementValue public int getValueInt() { - if (type != PRIMITIVE_INT) - throw new RuntimeException( + if (type != PRIMITIVE_INT) { + throw new RuntimeException( "Dont call getValueString() on a non STRING ElementValue"); + } ConstantInteger c = (ConstantInteger) cpool.getConstant(getIndex(), Constants.CONSTANT_Integer); return c.getBytes(); @@ -66,9 +68,10 @@ public class SimpleElementValue extends ElementValue public byte getValueByte() { - if (type != PRIMITIVE_BYTE) - throw new RuntimeException( + if (type != PRIMITIVE_BYTE) { + throw new RuntimeException( "Dont call getValueByte() on a non BYTE ElementValue"); + } ConstantInteger c = (ConstantInteger) cpool.getConstant(getIndex(), Constants.CONSTANT_Integer); return (byte) c.getBytes(); @@ -76,9 +79,10 @@ public class SimpleElementValue extends ElementValue public char getValueChar() { - if (type != PRIMITIVE_CHAR) - throw new RuntimeException( + if (type != PRIMITIVE_CHAR) { + throw new RuntimeException( "Dont call getValueChar() on a non CHAR ElementValue"); + } ConstantInteger c = (ConstantInteger) cpool.getConstant(getIndex(), Constants.CONSTANT_Integer); return (char) c.getBytes(); @@ -86,45 +90,50 @@ public class SimpleElementValue extends ElementValue public long getValueLong() { - if (type != PRIMITIVE_LONG) - throw new RuntimeException( + if (type != PRIMITIVE_LONG) { + throw new RuntimeException( "Dont call getValueLong() on a non LONG ElementValue"); + } ConstantLong j = (ConstantLong) cpool.getConstant(getIndex()); return j.getBytes(); } public float getValueFloat() { - if (type != PRIMITIVE_FLOAT) - throw new RuntimeException( + if (type != PRIMITIVE_FLOAT) { + throw new RuntimeException( "Dont call getValueFloat() on a non FLOAT ElementValue"); + } ConstantFloat f = (ConstantFloat) cpool.getConstant(getIndex()); return f.getBytes(); } public double getValueDouble() { - if (type != PRIMITIVE_DOUBLE) - throw new RuntimeException( + if (type != PRIMITIVE_DOUBLE) { + throw new RuntimeException( "Dont call getValueDouble() on a non DOUBLE ElementValue"); + } ConstantDouble d = (ConstantDouble) cpool.getConstant(getIndex()); return d.getBytes(); } public boolean getValueBoolean() { - if (type != PRIMITIVE_BOOLEAN) - throw new RuntimeException( + if (type != PRIMITIVE_BOOLEAN) { + throw new RuntimeException( "Dont call getValueBoolean() on a non BOOLEAN ElementValue"); + } ConstantInteger bo = (ConstantInteger) cpool.getConstant(getIndex()); return (bo.getBytes() != 0); } public short getValueShort() { - if (type != PRIMITIVE_SHORT) - throw new RuntimeException( + if (type != PRIMITIVE_SHORT) { + throw new RuntimeException( "Dont call getValueShort() on a non SHORT ElementValue"); + } ConstantInteger s = (ConstantInteger) cpool.getConstant(getIndex()); return (short) s.getBytes(); } @@ -172,10 +181,11 @@ public class SimpleElementValue extends ElementValue case PRIMITIVE_BOOLEAN: ConstantInteger bo = (ConstantInteger) cpool.getConstant( getIndex(), Constants.CONSTANT_Integer); - if (bo.getBytes() == 0) - return "false"; - else - return "true"; + if (bo.getBytes() == 0) { + return "false"; + } else { + return "true"; + } case STRING: ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(getIndex(), Constants.CONSTANT_Utf8); diff --git a/src/main/java/org/apache/bcel/classfile/Utility.java b/src/main/java/org/apache/bcel/classfile/Utility.java index 0fe5121a..79606fe2 100644 --- a/src/main/java/org/apache/bcel/classfile/Utility.java +++ b/src/main/java/org/apache/bcel/classfile/Utility.java @@ -348,8 +348,9 @@ public abstract class Utility { case Constants.INVOKEVIRTUAL: index = bytes.readUnsignedShort(); Constant c = constant_pool.getConstant(index); - if (c.getTag() != Constants.CONSTANT_Methodref && c.getTag() != Constants.CONSTANT_InterfaceMethodref) - throw new ClassFormatException("Expected class `CONSTANT_Methodref' or 'CONSTANT_InterfaceMethodref' at index " + index + " and got " +c); + if (c.getTag() != Constants.CONSTANT_Methodref && c.getTag() != Constants.CONSTANT_InterfaceMethodref) { + throw new ClassFormatException("Expected class `CONSTANT_Methodref' or 'CONSTANT_InterfaceMethodref' at index " + index + " and got " +c); + } buf.append("\t").append( constant_pool.constantToString(c)) .append((verbose ? " (" + index + ")" : "")); @@ -370,8 +371,9 @@ public abstract class Utility { buf.append("\t").append("<dyn>.").append( constant_pool .constantToString(id.getNameAndTypeIndex(), Constants.CONSTANT_NameAndType)); - if (verbose) - buf.append(" (" + index + "/" + id.getNameAndTypeIndex() +")"); + if (verbose) { + buf.append(" (" + index + "/" + id.getNameAndTypeIndex() +")"); + } break; /* Operands are references to items in constant pool */ @@ -1398,7 +1400,9 @@ public abstract class Utility { */ public static Attribute[] getAnnotationAttributes(ConstantPoolGen cp,List<AnnotationEntryGen> vec) { - if (vec.isEmpty()) return new Attribute[0]; + if (vec.isEmpty()) { + return new Attribute[0]; + } try { int countVisible = 0; @@ -1406,10 +1410,11 @@ public abstract class Utility { // put the annotations in the right output stream for (AnnotationEntryGen a : vec) { - if (a.isRuntimeVisible()) - countVisible++; - else - countInvisible++; + if (a.isRuntimeVisible()) { + countVisible++; + } else { + countInvisible++; + } } ByteArrayOutputStream rvaBytes = new ByteArrayOutputStream(); @@ -1422,10 +1427,11 @@ public abstract class Utility { // put the annotations in the right output stream for (AnnotationEntryGen a : vec) { - if (a.isRuntimeVisible()) - a.dump(rvaDos); - else - a.dump(riaDos); + if (a.isRuntimeVisible()) { + a.dump(rvaDos); + } else { + a.dump(riaDos); + } } rvaDos.close(); @@ -1437,8 +1443,12 @@ public abstract class Utility { int rvaIndex = -1; int riaIndex = -1; - if (rvaData.length>2) rvaIndex = cp.addUtf8("RuntimeVisibleAnnotations"); - if (riaData.length>2) riaIndex = cp.addUtf8("RuntimeInvisibleAnnotations"); + if (rvaData.length>2) { + rvaIndex = cp.addUtf8("RuntimeVisibleAnnotations"); + } + if (riaData.length>2) { + riaIndex = cp.addUtf8("RuntimeInvisibleAnnotations"); + } List<Attribute> newAttributes = new ArrayList<Attribute>(); if (rvaData.length>2) { @@ -1496,8 +1506,9 @@ public abstract class Utility { rvaDos.writeShort(visCount[i]); if (visCount[i] > 0) { for (AnnotationEntryGen element : vec[i]) { - if (element.isRuntimeVisible()) - element.dump(rvaDos); + if (element.isRuntimeVisible()) { + element.dump(rvaDos); + } } } } @@ -1510,8 +1521,9 @@ public abstract class Utility { riaDos.writeShort(invisCount[i]); if (invisCount[i] > 0) { for (AnnotationEntryGen element : vec[i]) { - if (!element.isRuntimeVisible()) - element.dump(riaDos); + if (!element.isRuntimeVisible()) { + element.dump(riaDos); + } } } } @@ -1520,10 +1532,12 @@ public abstract class Utility { byte[] riaData = riaBytes.toByteArray(); int rvaIndex = -1; int riaIndex = -1; - if (totalVisCount > 0) - rvaIndex = cp.addUtf8("RuntimeVisibleParameterAnnotations"); - if (totalInvisCount > 0) - riaIndex = cp.addUtf8("RuntimeInvisibleParameterAnnotations"); + if (totalVisCount > 0) { + rvaIndex = cp.addUtf8("RuntimeVisibleParameterAnnotations"); + } + if (totalInvisCount > 0) { + riaIndex = cp.addUtf8("RuntimeInvisibleParameterAnnotations"); + } List<Attribute> newAttributes = new ArrayList<Attribute>(); if (totalVisCount > 0) { newAttributes diff --git a/src/main/java/org/apache/bcel/generic/AnnotationElementValueGen.java b/src/main/java/org/apache/bcel/generic/AnnotationElementValueGen.java index c94b50f5..aeee7351 100644 --- a/src/main/java/org/apache/bcel/generic/AnnotationElementValueGen.java +++ b/src/main/java/org/apache/bcel/generic/AnnotationElementValueGen.java @@ -37,9 +37,10 @@ public class AnnotationElementValueGen extends ElementValueGen ConstantPoolGen cpool) { super(type, cpool); - if (type != ANNOTATION) - throw new RuntimeException( + if (type != ANNOTATION) { + throw new RuntimeException( "Only element values of type annotation can be built with this ctor - type specified: " + type); + } this.a = annotation; } diff --git a/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java b/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java index bce75c84..b2df12a1 100644 --- a/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java +++ b/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java @@ -132,8 +132,9 @@ public class AnnotationEntryGen public void addElementNameValuePair(ElementValuePairGen evp) { - if (evs == null) - evs = new ArrayList<ElementValuePairGen>(); + if (evs == null) { + evs = new ArrayList<ElementValuePairGen>(); + } evs.add(evp); } @@ -172,8 +173,9 @@ public class AnnotationEntryGen for (int i = 0; i < evs.size(); i++) { s.append(evs.get(i)); - if (i + 1 < evs.size()) - s.append(","); + if (i + 1 < evs.size()) { + s.append(","); + } } s.append("}]"); return s.toString(); @@ -186,8 +188,9 @@ public class AnnotationEntryGen for (int i = 0; i < evs.size(); i++) { s.append(evs.get(i)); - if (i + 1 < evs.size()) - s.append(","); + if (i + 1 < evs.size()) { + s.append(","); + } } s.append(")"); return s.toString(); diff --git a/src/main/java/org/apache/bcel/generic/ArrayElementValueGen.java b/src/main/java/org/apache/bcel/generic/ArrayElementValueGen.java index 59bd753d..88467b6d 100644 --- a/src/main/java/org/apache/bcel/generic/ArrayElementValueGen.java +++ b/src/main/java/org/apache/bcel/generic/ArrayElementValueGen.java @@ -41,9 +41,10 @@ public class ArrayElementValueGen extends ElementValueGen ConstantPoolGen cpool) { super(type, cpool); - if (type != ARRAY) - throw new RuntimeException( + if (type != ARRAY) { + throw new RuntimeException( "Only element values of type array can be built with this ctor - type specified: " + type); + } this.evalues = new ArrayList<ElementValueGen>(); for (ElementValue datum : datums) { evalues.add(ElementValueGen.copy(datum, cpool, true)); diff --git a/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java b/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java index 64024631..737c3e43 100644 --- a/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java +++ b/src/main/java/org/apache/bcel/generic/EnumElementValueGen.java @@ -39,9 +39,10 @@ public class EnumElementValueGen extends ElementValueGen ConstantPoolGen cpool) { super(ElementValueGen.ENUM_CONSTANT, cpool); - if (type != ENUM_CONSTANT) - throw new RuntimeException( + if (type != ENUM_CONSTANT) { + throw new RuntimeException( "Only element values of type enum can be built with this ctor - type specified: " + type); + } this.typeIdx = typeIdx; this.valueIdx = valueIdx; } diff --git a/src/main/java/org/apache/bcel/generic/GETFIELD.java b/src/main/java/org/apache/bcel/generic/GETFIELD.java index 0e37d658..0227e852 100644 --- a/src/main/java/org/apache/bcel/generic/GETFIELD.java +++ b/src/main/java/org/apache/bcel/generic/GETFIELD.java @@ -80,8 +80,9 @@ public class GETFIELD extends FieldInstruction implements ExceptionThrower, Stac v.visitTypedInstruction(this); v.visitLoadClass(this); v.visitCPInstruction(this); - if (v instanceof VisitorSupportsInvokeDynamic) + if (v instanceof VisitorSupportsInvokeDynamic) { ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this); + } v.visitFieldOrMethod(this); v.visitFieldInstruction(this); v.visitGETFIELD(this); diff --git a/src/main/java/org/apache/bcel/generic/GETSTATIC.java b/src/main/java/org/apache/bcel/generic/GETSTATIC.java index 7ef252a3..bef1d972 100644 --- a/src/main/java/org/apache/bcel/generic/GETSTATIC.java +++ b/src/main/java/org/apache/bcel/generic/GETSTATIC.java @@ -78,8 +78,9 @@ public class GETSTATIC extends FieldInstruction implements PushInstruction, Exce v.visitTypedInstruction(this); v.visitLoadClass(this); v.visitCPInstruction(this); - if (v instanceof VisitorSupportsInvokeDynamic) + if (v instanceof VisitorSupportsInvokeDynamic) { ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this); + } v.visitFieldOrMethod(this); v.visitFieldInstruction(this); v.visitGETSTATIC(this); diff --git a/src/main/java/org/apache/bcel/generic/INVOKEINTERFACE.java b/src/main/java/org/apache/bcel/generic/INVOKEINTERFACE.java index 8212fe55..a398daae 100644 --- a/src/main/java/org/apache/bcel/generic/INVOKEINTERFACE.java +++ b/src/main/java/org/apache/bcel/generic/INVOKEINTERFACE.java @@ -133,8 +133,9 @@ public final class INVOKEINTERFACE extends InvokeInstruction { v.visitStackProducer(this); v.visitLoadClass(this); v.visitCPInstruction(this); - if (v instanceof VisitorSupportsInvokeDynamic) + if (v instanceof VisitorSupportsInvokeDynamic) { ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this); + } v.visitFieldOrMethod(this); v.visitInvokeInstruction(this); v.visitINVOKEINTERFACE(this); diff --git a/src/main/java/org/apache/bcel/generic/INVOKESPECIAL.java b/src/main/java/org/apache/bcel/generic/INVOKESPECIAL.java index 2253bf36..56ebbcd7 100644 --- a/src/main/java/org/apache/bcel/generic/INVOKESPECIAL.java +++ b/src/main/java/org/apache/bcel/generic/INVOKESPECIAL.java @@ -75,8 +75,9 @@ public class INVOKESPECIAL extends InvokeInstruction { v.visitStackProducer(this); v.visitLoadClass(this); v.visitCPInstruction(this); - if (v instanceof VisitorSupportsInvokeDynamic) + if (v instanceof VisitorSupportsInvokeDynamic) { ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this); + } v.visitFieldOrMethod(this); v.visitInvokeInstruction(this); v.visitINVOKESPECIAL(this); diff --git a/src/main/java/org/apache/bcel/generic/INVOKESTATIC.java b/src/main/java/org/apache/bcel/generic/INVOKESTATIC.java index 84e40bbe..d5183db5 100644 --- a/src/main/java/org/apache/bcel/generic/INVOKESTATIC.java +++ b/src/main/java/org/apache/bcel/generic/INVOKESTATIC.java @@ -72,8 +72,9 @@ public class INVOKESTATIC extends InvokeInstruction { v.visitStackProducer(this); v.visitLoadClass(this); v.visitCPInstruction(this); - if (v instanceof VisitorSupportsInvokeDynamic) + if (v instanceof VisitorSupportsInvokeDynamic) { ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this); + } v.visitFieldOrMethod(this); v.visitInvokeInstruction(this); v.visitINVOKESTATIC(this); diff --git a/src/main/java/org/apache/bcel/generic/INVOKEVIRTUAL.java b/src/main/java/org/apache/bcel/generic/INVOKEVIRTUAL.java index 5cb86179..4d5b593e 100644 --- a/src/main/java/org/apache/bcel/generic/INVOKEVIRTUAL.java +++ b/src/main/java/org/apache/bcel/generic/INVOKEVIRTUAL.java @@ -75,8 +75,9 @@ public class INVOKEVIRTUAL extends InvokeInstruction { v.visitLoadClass(this); v.visitCPInstruction(this); v.visitFieldOrMethod(this); - if (v instanceof VisitorSupportsInvokeDynamic) + if (v instanceof VisitorSupportsInvokeDynamic) { ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this); + } v.visitInvokeInstruction(this); v.visitINVOKEVIRTUAL(this); } diff --git a/src/main/java/org/apache/bcel/generic/InstructionList.java b/src/main/java/org/apache/bcel/generic/InstructionList.java index cd31e0b2..feead68a 100644 --- a/src/main/java/org/apache/bcel/generic/InstructionList.java +++ b/src/main/java/org/apache/bcel/generic/InstructionList.java @@ -1005,8 +1005,9 @@ public class InstructionList implements Serializable { public InstructionHandle next() throws NoSuchElementException { - if (ih == null) - throw new NoSuchElementException(); + if (ih == null) { + throw new NoSuchElementException(); + } InstructionHandle i = ih; ih = ih.next; return i; diff --git a/src/main/java/org/apache/bcel/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java index 4f2863db..690de4e8 100644 --- a/src/main/java/org/apache/bcel/generic/MethodGen.java +++ b/src/main/java/org/apache/bcel/generic/MethodGen.java @@ -612,7 +612,9 @@ public class MethodGen extends FieldGenOrMethodGen { } public void addParameterAnnotationsAsAttribute(ConstantPoolGen cp) { - if (!hasParameterAnnotations) return; + if (!hasParameterAnnotations) { + return; + } Attribute[] attrs = Utility.getParameterAnnotationAttributes(cp,param_annotations); if (attrs!=null) { for (Attribute attr : attrs) { @@ -1086,7 +1088,9 @@ public class MethodGen extends FieldGenOrMethodGen { */ public List<AnnotationEntryGen> getAnnotationsOnParameter(int i) { ensureExistingParameterAnnotationsUnpacked(); - if (!hasParameterAnnotations || i>arg_types.length) return null; + if (!hasParameterAnnotations || i>arg_types.length) { + return null; + } return param_annotations[i]; } @@ -1100,8 +1104,9 @@ public class MethodGen extends FieldGenOrMethodGen { */ private void ensureExistingParameterAnnotationsUnpacked() { - if (haveUnpackedParameterAnnotations) - return; + if (haveUnpackedParameterAnnotations) { + return; + } // Find attributes that contain parameter annotation data Attribute[] attrs = getAttributes(); ParameterAnnotations paramAnnVisAttr = null; @@ -1113,15 +1118,17 @@ public class MethodGen extends FieldGenOrMethodGen { if (!hasParameterAnnotations) { param_annotations = new List[arg_types.length]; - for (int j = 0; j < arg_types.length; j++) - param_annotations[j] = new ArrayList<AnnotationEntryGen>(); + for (int j = 0; j < arg_types.length; j++) { + param_annotations[j] = new ArrayList<AnnotationEntryGen>(); + } } hasParameterAnnotations = true; ParameterAnnotations rpa = (ParameterAnnotations) attribute; - if (rpa instanceof RuntimeVisibleParameterAnnotations) - paramAnnVisAttr = rpa; - else - paramAnnInvisAttr = rpa; + if (rpa instanceof RuntimeVisibleParameterAnnotations) { + paramAnnVisAttr = rpa; + } else { + paramAnnInvisAttr = rpa; + } for (int j = 0; j < arg_types.length; j++) { // This returns Annotation[] ... @@ -1134,10 +1141,12 @@ public class MethodGen extends FieldGenOrMethodGen { } } } - if (paramAnnVisAttr != null) - removeAttribute(paramAnnVisAttr); - if (paramAnnInvisAttr != null) - removeAttribute(paramAnnInvisAttr); + if (paramAnnVisAttr != null) { + removeAttribute(paramAnnVisAttr); + } + if (paramAnnInvisAttr != null) { + removeAttribute(paramAnnInvisAttr); + } haveUnpackedParameterAnnotations = true; } diff --git a/src/main/java/org/apache/bcel/generic/ObjectType.java b/src/main/java/org/apache/bcel/generic/ObjectType.java index 7a4e2d76..bd0534b9 100644 --- a/src/main/java/org/apache/bcel/generic/ObjectType.java +++ b/src/main/java/org/apache/bcel/generic/ObjectType.java @@ -40,7 +40,7 @@ public class ObjectType extends ReferenceType { private static HashMap<String, ObjectType> cache; public synchronized static ObjectType getInstance(String class_name) { - if (cache == null) + if (cache == null) { cache = new LinkedHashMap<String, ObjectType>(INITIAL_CACHE_CAPACITY, 0.75f, true) { @@ -49,8 +49,11 @@ public class ObjectType extends ReferenceType { } }; + } ObjectType result = cache.get(class_name); - if (result != null) return result; + if (result != null) { + return result; + } result = new ObjectType(class_name); cache.put(class_name, result); return result; diff --git a/src/main/java/org/apache/bcel/generic/PUTFIELD.java b/src/main/java/org/apache/bcel/generic/PUTFIELD.java index eb421925..018bc707 100644 --- a/src/main/java/org/apache/bcel/generic/PUTFIELD.java +++ b/src/main/java/org/apache/bcel/generic/PUTFIELD.java @@ -79,8 +79,9 @@ public class PUTFIELD extends FieldInstruction implements PopInstruction, Except v.visitTypedInstruction(this); v.visitLoadClass(this); v.visitCPInstruction(this); - if (v instanceof VisitorSupportsInvokeDynamic) + if (v instanceof VisitorSupportsInvokeDynamic) { ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this); + } v.visitFieldOrMethod(this); v.visitFieldInstruction(this); v.visitPUTFIELD(this); diff --git a/src/main/java/org/apache/bcel/generic/PUTSTATIC.java b/src/main/java/org/apache/bcel/generic/PUTSTATIC.java index a7a08290..3e9461b3 100644 --- a/src/main/java/org/apache/bcel/generic/PUTSTATIC.java +++ b/src/main/java/org/apache/bcel/generic/PUTSTATIC.java @@ -78,8 +78,9 @@ public class PUTSTATIC extends FieldInstruction implements ExceptionThrower, Pop v.visitTypedInstruction(this); v.visitLoadClass(this); v.visitCPInstruction(this); - if (v instanceof VisitorSupportsInvokeDynamic) + if (v instanceof VisitorSupportsInvokeDynamic) { ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this); + } v.visitFieldOrMethod(this); v.visitFieldInstruction(this); v.visitPUTSTATIC(this); diff --git a/src/main/java/org/apache/bcel/generic/SimpleElementValueGen.java b/src/main/java/org/apache/bcel/generic/SimpleElementValueGen.java index 8fd1ecef..3abb3d0a 100644 --- a/src/main/java/org/apache/bcel/generic/SimpleElementValueGen.java +++ b/src/main/java/org/apache/bcel/generic/SimpleElementValueGen.java @@ -91,10 +91,11 @@ public class SimpleElementValueGen extends ElementValueGen public SimpleElementValueGen(int type, ConstantPoolGen cpGen, boolean value) { super(type, cpGen); - if (value) - idx = cpGen.addInteger(1); - else - idx = cpGen.addInteger(0); + if (value) { + idx = cpGen.addInteger(1); + } else { + idx = cpGen.addInteger(0); + } } public SimpleElementValueGen(int type, ConstantPoolGen cpGen, String value) @@ -180,18 +181,20 @@ public class SimpleElementValueGen extends ElementValueGen public String getValueString() { - if (type != STRING) - throw new RuntimeException( + if (type != STRING) { + throw new RuntimeException( "Dont call getValueString() on a non STRING ElementValue"); + } ConstantUtf8 c = (ConstantUtf8) cpGen.getConstant(idx); return c.getBytes(); } public int getValueInt() { - if (type != PRIMITIVE_INT) - throw new RuntimeException( + if (type != PRIMITIVE_INT) { + throw new RuntimeException( "Dont call getValueString() on a non STRING ElementValue"); + } ConstantInteger c = (ConstantInteger) cpGen.getConstant(idx); return c.getBytes(); } @@ -225,10 +228,11 @@ public class SimpleElementValueGen extends ElementValueGen return Integer.toString(ch.getBytes()); case PRIMITIVE_BOOLEAN: ConstantInteger bo = (ConstantInteger) cpGen.getConstant(idx); - if (bo.getBytes() == 0) - return "false"; - else - return "true"; + if (bo.getBytes() == 0) { + return "false"; + } else { + return "true"; + } case STRING: ConstantUtf8 cu8 = (ConstantUtf8) cpGen.getConstant(idx); return cu8.getBytes(); diff --git a/src/main/java/org/apache/bcel/util/ClassPath.java b/src/main/java/org/apache/bcel/util/ClassPath.java index 6a85d140..8097eea2 100644 --- a/src/main/java/org/apache/bcel/util/ClassPath.java +++ b/src/main/java/org/apache/bcel/util/ClassPath.java @@ -86,8 +86,9 @@ public class ClassPath implements Serializable { } } } catch (IOException e) { - if (path.endsWith(".zip") || path.endsWith(".jar")) + if (path.endsWith(".zip") || path.endsWith(".jar")) { System.err.println("CLASSPATH component " + file + ": " + e); + } } } } @@ -506,8 +507,9 @@ public class ClassPath implements Serializable { ClassFile getClassFile( String name, String suffix ) throws IOException { final ZipEntry entry = zip.getEntry(name.replace('.', '/') + suffix); - if (entry == null) - return null; + if (entry == null) { + return null; + } return new ClassFile() { diff --git a/src/test/java/org/apache/bcel/AbstractCounterVisitorTestCase.java b/src/test/java/org/apache/bcel/AbstractCounterVisitorTestCase.java index 1ceaa5ef..ca40e45a 100644 --- a/src/test/java/org/apache/bcel/AbstractCounterVisitorTestCase.java +++ b/src/test/java/org/apache/bcel/AbstractCounterVisitorTestCase.java @@ -37,8 +37,9 @@ public abstract class AbstractCounterVisitorTestCase extends AbstractTestCase public CounterVisitor getVisitor() { - if (visitor == null) - visitor = new CounterVisitor(); + if (visitor == null) { + visitor = new CounterVisitor(); + } return visitor; } diff --git a/src/test/java/org/apache/bcel/AbstractTestCase.java b/src/test/java/org/apache/bcel/AbstractTestCase.java index 51696ed0..34d98eed 100644 --- a/src/test/java/org/apache/bcel/AbstractTestCase.java +++ b/src/test/java/org/apache/bcel/AbstractTestCase.java @@ -93,10 +93,12 @@ public abstract class AbstractTestCase extends TestCase Attribute[] all = clazz.getAttributes(); List<Attribute> chosenAttrsList = new ArrayList<Attribute>(); for (Attribute element : all) { - if (verbose) - System.err.println("Attribute: " + element.getName()); - if (element.getName().equals(name)) - chosenAttrsList.add(element); + if (verbose) { + System.err.println("Attribute: " + element.getName()); + } + if (element.getName().equals(name)) { + chosenAttrsList.add(element); + } } return chosenAttrsList.toArray(new Attribute[] {}); } @@ -105,10 +107,12 @@ public abstract class AbstractTestCase extends TestCase { List<Attribute> chosenAttrsList = new ArrayList<Attribute>(); for (Attribute element : all) { - if (verbose) - System.err.println("Attribute: " + element.getName()); - if (element.getName().equals(name)) - chosenAttrsList.add(element); + if (verbose) { + System.err.println("Attribute: " + element.getName()); + } + if (element.getName().equals(name)) { + chosenAttrsList.add(element); + } } assertTrue("Should be one match: " + chosenAttrsList.size(), chosenAttrsList.size() == 1); @@ -123,8 +127,9 @@ public abstract class AbstractTestCase extends TestCase { Attribute attr = as[i]; result.append(attr.toString()); - if (i + 1 < as.length) - result.append(","); + if (i + 1 < as.length) { + result.append(","); + } } result.append("]"); return result.toString(); @@ -138,8 +143,9 @@ public abstract class AbstractTestCase extends TestCase { AnnotationEntry annotation = as[i]; result.append(annotation.toShortString()); - if (i + 1 < as.length) - result.append(","); + if (i + 1 < as.length) { + result.append(","); + } } result.append("]"); return result.toString(); @@ -153,8 +159,9 @@ public abstract class AbstractTestCase extends TestCase { AnnotationEntryGen annotation = as[i]; result.append(annotation.toShortString()); - if (i + 1 < as.length) - result.append(","); + if (i + 1 < as.length) { + result.append(","); + } } result.append("]"); return result.toString(); diff --git a/src/test/java/org/apache/bcel/FieldAnnotationsTestCase.java b/src/test/java/org/apache/bcel/FieldAnnotationsTestCase.java index ef56b22f..9df8bd52 100644 --- a/src/test/java/org/apache/bcel/FieldAnnotationsTestCase.java +++ b/src/test/java/org/apache/bcel/FieldAnnotationsTestCase.java @@ -72,35 +72,43 @@ public class FieldAnnotationsTestCase extends AbstractTestCase JavaClass clazz = getTestClass("org.apache.bcel.data.AnnotatedFields"); ClassGen clg = new ClassGen(clazz); Field f = clg.getFields()[0]; - if (dbg) - System.err.println("Field in freshly constructed class is: " + f); - if (dbg) - System.err.println("AnnotationEntrys on field are: " + if (dbg) { + System.err.println("Field in freshly constructed class is: " + f); + } + if (dbg) { + System.err.println("AnnotationEntrys on field are: " + dumpAnnotationEntries(f.getAnnotationEntries())); + } AnnotationEntryGen fruitBasedAnnotationEntry = createFruitAnnotationEntry(clg .getConstantPool(), "Tomato", false); FieldGen fg = new FieldGen(f, clg.getConstantPool()); - if (dbg) - System.err.println("Adding AnnotationEntry to the field"); + if (dbg) { + System.err.println("Adding AnnotationEntry to the field"); + } fg.addAnnotationEntry(fruitBasedAnnotationEntry); - if (dbg) - System.err.println("FieldGen (mutable field) is " + fg); - if (dbg) - System.err.println("with AnnotationEntrys: " + if (dbg) { + System.err.println("FieldGen (mutable field) is " + fg); + } + if (dbg) { + System.err.println("with AnnotationEntrys: " + dumpAnnotationEntries(fg.getAnnotationEntries())); - if (dbg) - System.err + } + if (dbg) { + System.err .println("Replacing original field with new field that has extra AnnotationEntry"); + } clg.removeField(f); clg.addField(fg.getField()); f = clg.getFields()[1]; // there are two fields in the class, removing // and readding has changed the order // so this time index [1] is the 'int i' field - if (dbg) - System.err.println("Field now looks like this: " + f); - if (dbg) - System.err.println("With AnnotationEntrys: " + if (dbg) { + System.err.println("Field now looks like this: " + f); + } + if (dbg) { + System.err.println("With AnnotationEntrys: " + dumpAnnotationEntries(f.getAnnotationEntries())); + } assertTrue("Should be 2 AnnotationEntrys on this field, but there are " + f.getAnnotationEntries().length, f.getAnnotationEntries().length == 2); } diff --git a/src/test/java/org/apache/bcel/GeneratingAnnotatedClassesTestCase.java b/src/test/java/org/apache/bcel/GeneratingAnnotatedClassesTestCase.java index 0ac43c57..0d3012f4 100644 --- a/src/test/java/org/apache/bcel/GeneratingAnnotatedClassesTestCase.java +++ b/src/test/java/org/apache/bcel/GeneratingAnnotatedClassesTestCase.java @@ -367,8 +367,9 @@ public class GeneratingAnnotatedClassesTestCase extends AbstractTestCase if (element.getNameString().equals("dval")) { if (((SimpleElementValueGen) element.getValue()) - .stringifyValue().equals("33.4")) + .stringifyValue().equals("33.4")) { found = true; + } } } assertTrue("Did not find double annotation value with value 33.4", diff --git a/src/test/java/org/apache/bcel/InstructionFinderTestCase.java b/src/test/java/org/apache/bcel/InstructionFinderTestCase.java index 35eb8427..ad24a78c 100644 --- a/src/test/java/org/apache/bcel/InstructionFinderTestCase.java +++ b/src/test/java/org/apache/bcel/InstructionFinderTestCase.java @@ -42,8 +42,9 @@ public class InstructionFinderTestCase extends AbstractTestCase } } - if (searchM == null) - throw new Exception("search method not found"); + if (searchM == null) { + throw new Exception("search method not found"); + } byte[] bytes = searchM.getCode().getCode(); InstructionList il = new InstructionList(bytes); |