From 05164d24d77b4f05a309cef5375792b08316f1b6 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Fri, 25 Aug 2017 16:30:13 +0000 Subject: 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 --- .../bcel/LocalVariableTypeTableTestCase.java | 22 +++++++++++----------- .../bcel/classfile/ConstantPoolTestCase.java | 14 +++++++------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/test') 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()); @@ -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("")) { - 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(); } } -- cgit v1.2.3