diff options
author | Gary D. Gregory <ggregory@apache.org> | 2017-08-25 16:30:13 +0000 |
---|---|---|
committer | Gary D. Gregory <ggregory@apache.org> | 2017-08-25 16:30:13 +0000 |
commit | 05164d24d77b4f05a309cef5375792b08316f1b6 (patch) | |
tree | b3dc8ef8b3b3feb70766e34d2d43f1972745b2ea | |
parent | b73ff92c29ff18c5cbe81ef75e44ba752392b0d1 (diff) | |
download | apache-commons-bcel-05164d24d77b4f05a309cef5375792b08316f1b6.tar.gz |
Add final modifier to local variables.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/bcel/trunk@1806199 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 22 insertions, 22 deletions
diff --git a/src/main/java/org/apache/bcel/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java index f211dd89..d8d439a5 100644 --- a/src/main/java/org/apache/bcel/generic/MethodGen.java +++ b/src/main/java/org/apache/bcel/generic/MethodGen.java @@ -702,11 +702,11 @@ public class MethodGen extends FieldGenOrMethodGen { } private void adjustLocalVariableLength(final LocalVariableTable lvt) { - LocalVariable[] lv = lvt.getLocalVariableTable(); - LocalVariable[] lvg = local_variable_type_table.getLocalVariableTypeTable(); + final LocalVariable[] lv = lvt.getLocalVariableTable(); + final LocalVariable[] lvg = local_variable_type_table.getLocalVariableTypeTable(); - for (LocalVariable element : lvg) { - for (LocalVariable l : lv) { + for (final LocalVariable element : lvg) { + for (final LocalVariable l : lv) { if (element.getName().equals(l.getName()) && element.getIndex() == l.getIndex()) { element.setLength(l.getLength()); break; diff --git a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java index 298b5b70..c55d79bd 100644 --- a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java +++ b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java @@ -49,9 +49,9 @@ public class LocalVariableTypeTableTestCase extends AbstractTestCase { @Test public void testWithGenericArguement() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException { - String targetClass = PACKAGE_BASE_NAME + ".data.SimpleClassHasMethodIncludeGenericArgument"; - TestClassLoader loader = new TestClassLoader(getClass().getClassLoader()); - Class cls = loader.findClass(targetClass, getBytesFromClass(targetClass)); + final String targetClass = PACKAGE_BASE_NAME + ".data.SimpleClassHasMethodIncludeGenericArgument"; + final TestClassLoader loader = new TestClassLoader(getClass().getClassLoader()); + final Class cls = loader.findClass(targetClass, getBytesFromClass(targetClass)); java.lang.reflect.Method method = cls.getDeclaredMethod("a", String.class, List.class); method.invoke(null, "a1", new LinkedList<String>()); @@ -64,13 +64,13 @@ public class LocalVariableTypeTableTestCase extends AbstractTestCase { } private byte[] getBytesFromClass(final String className) throws ClassNotFoundException, IOException { - JavaClass clazz = getTestClass(className); - ConstantPoolGen cp = new ConstantPoolGen(clazz.getConstantPool()); + final JavaClass clazz = getTestClass(className); + final ConstantPoolGen cp = new ConstantPoolGen(clazz.getConstantPool()); - Method[] methods = clazz.getMethods(); + final Method[] methods = clazz.getMethods(); for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; + final Method method = methods[i]; if (!method.isNative() && !method.isAbstract()) { methods[i] = injection(clazz, method, cp, findFirstStringLocalVariableOffset(method)); } @@ -82,9 +82,9 @@ public class LocalVariableTypeTableTestCase extends AbstractTestCase { } public Method injection(final JavaClass clazz, Method method, final ConstantPoolGen cp, final int firstStringOffset) { - MethodGen methodGen = new MethodGen(method, clazz.getClassName(), cp); + final MethodGen methodGen = new MethodGen(method, clazz.getClassName(), cp); - InstructionList instructionList = methodGen.getInstructionList(); + final InstructionList instructionList = methodGen.getInstructionList(); instructionList.insert(instructionList.getStart(), makeWillBeAddedInstructionList(methodGen, firstStringOffset)); methodGen.setMaxStack(); @@ -101,7 +101,7 @@ public class LocalVariableTypeTableTestCase extends AbstractTestCase { return new InstructionList(); } - LocalVariableGen localVariableGen = methodGen.getLocalVariables()[firstStringOffset]; + final LocalVariableGen localVariableGen = methodGen.getLocalVariables()[firstStringOffset]; Instruction instruction; if (localVariableGen != null) { @@ -126,7 +126,7 @@ public class LocalVariableTypeTableTestCase extends AbstractTestCase { } public int findFirstStringLocalVariableOffset(final Method method) { - Type[] argumentTypes = method.getArgumentTypes(); + final Type[] argumentTypes = method.getArgumentTypes(); int offset = -1; for (int i = 0, count = argumentTypes.length; i < count; i++) { diff --git a/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java b/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java index 8bb4f0f2..13e71b11 100644 --- a/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java +++ b/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java @@ -27,14 +27,14 @@ import org.junit.Test; public class ConstantPoolTestCase extends AbstractTestCase { @Test public void testConstantToString() throws ClassNotFoundException { - JavaClass clazz = getTestClass(PACKAGE_BASE_NAME + ".data.SimpleClassWithDefaultConstructor"); - ConstantPoolGen cp = new ConstantPoolGen(clazz.getConstantPool()); + final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME + ".data.SimpleClassWithDefaultConstructor"); + final ConstantPoolGen cp = new ConstantPoolGen(clazz.getConstantPool()); - Method[] methods = clazz.getMethods(); + final Method[] methods = clazz.getMethods(); - for (Method method : methods) { + for (final Method method : methods) { if (method.getName().equals("<init>")) { - for (InstructionHandle instructionHandle : getInstructionHandles(clazz, cp, method)) { + for (final InstructionHandle instructionHandle : getInstructionHandles(clazz, cp, method)) { System.out.println(instructionHandle.getInstruction().toString(cp.getConstantPool())); } } @@ -42,8 +42,8 @@ public class ConstantPoolTestCase extends AbstractTestCase { } private InstructionHandle[] getInstructionHandles(final JavaClass clazz, final ConstantPoolGen cp, final Method method) { - MethodGen methodGen = new MethodGen(method, clazz.getClassName(), cp); - InstructionList instructionList = methodGen.getInstructionList(); + final MethodGen methodGen = new MethodGen(method, clazz.getClassName(), cp); + final InstructionList instructionList = methodGen.getInstructionList(); return instructionList.getInstructionHandles(); } } |