You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2016/06/21 20:50:21 UTC
svn commit: r1749603 [9/9] - in /commons/proper/bcel/trunk/src:
main/java/org/apache/bcel/ main/java/org/apache/bcel/classfile/
main/java/org/apache/bcel/generic/ main/java/org/apache/bcel/util/
main/java/org/apache/bcel/verifier/ main/java/org/apache/...
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTestCase.java Tue Jun 21 20:50:19 2016
@@ -73,18 +73,18 @@ public class GeneratingAnnotatedClassesT
throws ClassNotFoundException
{
// Create HelloWorld
- ClassGen cg = createClassGen("HelloWorld");
+ final ClassGen cg = createClassGen("HelloWorld");
cg.setMajor(49);
cg.setMinor(0);
- ConstantPoolGen cp = cg.getConstantPool();
- InstructionList il = new InstructionList();
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final InstructionList il = new InstructionList();
cg.addAnnotationEntry(createSimpleVisibleAnnotation(cp));
cg.addAnnotationEntry(createSimpleInvisibleAnnotation(cp));
buildClassContents(cg, cp, il);
//System.out.println(cg.getJavaClass().toString());
dumpClass(cg, "HelloWorld.class");
- JavaClass jc = getClassFrom(".", "HelloWorld");
- AnnotationEntry[] as = jc.getAnnotationEntries();
+ final JavaClass jc = getClassFrom(".", "HelloWorld");
+ final AnnotationEntry[] as = jc.getAnnotationEntries();
assertTrue("Should be two AnnotationEntries but found " + as.length,
as.length == 2);
// TODO L??;
@@ -96,12 +96,12 @@ public class GeneratingAnnotatedClassesT
"Name of annotation 2 should be LSimpleAnnotation; but it is "
+ as[1].getAnnotationType(), as[1].getAnnotationType()
.equals("LSimpleAnnotation;"));
- ElementValuePair[] vals = as[0].getElementValuePairs();
- ElementValuePair nvp = vals[0];
+ final ElementValuePair[] vals = as[0].getElementValuePairs();
+ final ElementValuePair nvp = vals[0];
assertTrue(
"Name of element in SimpleAnnotation should be 'id' but it is "
+ nvp.getNameString(), nvp.getNameString().equals("id"));
- ElementValue ev = nvp.getValue();
+ final ElementValue ev = nvp.getValue();
assertTrue("Type of element value should be int but it is "
+ ev.getElementValueType(),
ev.getElementValueType() == ElementValue.PRIMITIVE_INT);
@@ -118,9 +118,9 @@ public class GeneratingAnnotatedClassesT
throws ClassNotFoundException
{
// Create HelloWorld
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- InstructionList il = new InstructionList();
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final InstructionList il = new InstructionList();
buildClassContentsWithAnnotatedMethods(cg, cp, il);
// Check annotation is OK
int i = cg.getMethods()[0].getAnnotationEntries().length;
@@ -128,18 +128,18 @@ public class GeneratingAnnotatedClassesT
"Prior to dumping, main method should have 1 annotation but has "
+ i, i == 1);
dumpClass(cg, "temp1" + File.separator + "HelloWorld.class");
- JavaClass jc2 = getClassFrom("temp1", "HelloWorld");
+ final JavaClass jc2 = getClassFrom("temp1", "HelloWorld");
// Check annotation is OK
i = jc2.getMethods()[0].getAnnotationEntries().length;
assertTrue("JavaClass should say 1 annotation on main method but says "
+ i, i == 1);
- ClassGen cg2 = new ClassGen(jc2);
+ final ClassGen cg2 = new ClassGen(jc2);
// Check it now it is a ClassGen
- Method[] m = cg2.getMethods();
+ final Method[] m = cg2.getMethods();
i = m[0].getAnnotationEntries().length;
assertTrue("The main 'Method' should have one annotation but has " + i,
i == 1);
- MethodGen mg = new MethodGen(m[0], cg2.getClassName(), cg2
+ final MethodGen mg = new MethodGen(m[0], cg2.getClassName(), cg2
.getConstantPool());
// Check it finally when the Method is changed to a MethodGen
i = mg.getAnnotationEntries().length;
@@ -158,19 +158,19 @@ public class GeneratingAnnotatedClassesT
throws ClassNotFoundException
{
// Create HelloWorld
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- InstructionList il = new InstructionList();
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final InstructionList il = new InstructionList();
buildClassContentsWithAnnotatedMethods(cg, cp, il);
dumpClass(cg, "temp2", "HelloWorld.class");
- JavaClass jc2 = getClassFrom("temp2", "HelloWorld");
- ClassGen cg2 = new ClassGen(jc2);
+ final JavaClass jc2 = getClassFrom("temp2", "HelloWorld");
+ final ClassGen cg2 = new ClassGen(jc2);
// Main method after reading the class back in
- Method mainMethod1 = jc2.getMethods()[0];
+ final Method mainMethod1 = jc2.getMethods()[0];
assertTrue("The 'Method' should have one annotations but has "
+ mainMethod1.getAnnotationEntries().length, mainMethod1
.getAnnotationEntries().length == 1);
- MethodGen mainMethod2 = new MethodGen(mainMethod1, cg2.getClassName(),
+ final MethodGen mainMethod2 = new MethodGen(mainMethod1, cg2.getClassName(),
cg2.getConstantPool());
assertTrue("The 'MethodGen' should have one annotations but has "
+ mainMethod2.getAnnotationEntries().length, mainMethod2
@@ -180,10 +180,10 @@ public class GeneratingAnnotatedClassesT
cg2.removeMethod(mainMethod1);
cg2.addMethod(mainMethod2.getMethod());
dumpClass(cg2, "temp3", "HelloWorld.class");
- JavaClass jc3 = getClassFrom("temp3", "HelloWorld");
- ClassGen cg3 = new ClassGen(jc3);
- Method mainMethod3 = cg3.getMethods()[1];
- int i = mainMethod3.getAnnotationEntries().length;
+ final JavaClass jc3 = getClassFrom("temp3", "HelloWorld");
+ final ClassGen cg3 = new ClassGen(jc3);
+ final Method mainMethod3 = cg3.getMethods()[1];
+ final int i = mainMethod3.getAnnotationEntries().length;
assertTrue("The 'Method' should now have two annotations but has " + i,
i == 2);
assertTrue(wipe("temp2", "HelloWorld.class"));
@@ -197,10 +197,10 @@ public class GeneratingAnnotatedClassesT
public void testTransformClassToClassGen_SimpleTypes()
throws ClassNotFoundException
{
- JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.SimpleAnnotatedClass");
- ClassGen cgen = new ClassGen(jc);
+ final JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.SimpleAnnotatedClass");
+ final ClassGen cgen = new ClassGen(jc);
// Check annotations are correctly preserved
- AnnotationEntryGen[] annotations = cgen.getAnnotationEntries();
+ final AnnotationEntryGen[] annotations = cgen.getAnnotationEntries();
assertTrue("Expected one annotation but found " + annotations.length,
annotations.length == 1);
}
@@ -212,10 +212,10 @@ public class GeneratingAnnotatedClassesT
public void testTransformClassToClassGen_EnumType()
throws ClassNotFoundException
{
- JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.AnnotatedWithEnumClass");
- ClassGen cgen = new ClassGen(jc);
+ final JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.AnnotatedWithEnumClass");
+ final ClassGen cgen = new ClassGen(jc);
// Check annotations are correctly preserved
- AnnotationEntryGen[] annotations = cgen.getAnnotationEntries();
+ final AnnotationEntryGen[] annotations = cgen.getAnnotationEntries();
assertTrue("Expected one annotation but found " + annotations.length,
annotations.length == 1);
}
@@ -227,40 +227,40 @@ public class GeneratingAnnotatedClassesT
public void testTransformClassToClassGen_ArrayAndAnnotationTypes()
throws ClassNotFoundException
{
- JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.AnnotatedWithCombinedAnnotation");
- ClassGen cgen = new ClassGen(jc);
+ final JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.AnnotatedWithCombinedAnnotation");
+ final ClassGen cgen = new ClassGen(jc);
// Check annotations are correctly preserved
- AnnotationEntryGen[] annotations = cgen.getAnnotationEntries();
+ final AnnotationEntryGen[] annotations = cgen.getAnnotationEntries();
assertTrue("Expected one annotation but found " + annotations.length,
annotations.length == 1);
- AnnotationEntryGen a = annotations[0];
+ final AnnotationEntryGen a = annotations[0];
assertTrue("That annotation should only have one value but has "
+ a.getValues().size(), a.getValues().size() == 1);
- ElementValuePairGen nvp = a.getValues().get(0);
- ElementValueGen value = nvp.getValue();
+ final ElementValuePairGen nvp = a.getValues().get(0);
+ final ElementValueGen value = nvp.getValue();
assertTrue("Value should be ArrayElementValueGen but is " + value,
value instanceof ArrayElementValueGen);
- ArrayElementValueGen arrayValue = (ArrayElementValueGen) value;
+ final ArrayElementValueGen arrayValue = (ArrayElementValueGen) value;
assertTrue("Array value should be size one but is "
+ arrayValue.getElementValuesSize(), arrayValue
.getElementValuesSize() == 1);
- ElementValueGen innerValue = arrayValue.getElementValues().get(0);
+ final ElementValueGen innerValue = arrayValue.getElementValues().get(0);
assertTrue(
"Value in the array should be AnnotationElementValueGen but is "
+ innerValue,
innerValue instanceof AnnotationElementValueGen);
- AnnotationElementValueGen innerAnnotationValue = (AnnotationElementValueGen) innerValue;
+ final AnnotationElementValueGen innerAnnotationValue = (AnnotationElementValueGen) innerValue;
assertTrue("Should be called L"+PACKAGE_BASE_SIG+"/data/SimpleAnnotation; but is called: "
+ innerAnnotationValue.getAnnotation().getTypeName(),
innerAnnotationValue.getAnnotation().getTypeSignature().equals(
"L"+PACKAGE_BASE_SIG+"/data/SimpleAnnotation;"));
// check the three methods
- Method[] methods = cgen.getMethods();
+ final Method[] methods = cgen.getMethods();
assertEquals(3, methods.length);
- for (Method method : methods)
+ for (final Method method : methods)
{
- String methodName= method.getName();
+ final String methodName= method.getName();
if(methodName.equals("<init>"))
{
assertMethodAnnotations(method, 0, 1);
@@ -283,8 +283,8 @@ public class GeneratingAnnotatedClassesT
private void assertMethodAnnotations(final Method method, final int expectedNumberAnnotations, final int nExpectedArrayValues)
{
- String methodName= method.getName();
- AnnotationEntry[] annos= method.getAnnotationEntries();
+ final String methodName= method.getName();
+ final AnnotationEntry[] annos= method.getAnnotationEntries();
assertEquals("For "+methodName, expectedNumberAnnotations, annos.length);
if(expectedNumberAnnotations!=0)
{
@@ -294,24 +294,24 @@ public class GeneratingAnnotatedClassesT
private void assertArrayElementValue(final int nExpectedArrayValues, final AnnotationEntry anno)
{
- ElementValuePair elementValuePair = anno.getElementValuePairs()[0];
+ final ElementValuePair elementValuePair = anno.getElementValuePairs()[0];
assertEquals("value", elementValuePair.getNameString());
- ArrayElementValue ev = (ArrayElementValue) elementValuePair.getValue();
- ElementValue[] eva = ev.getElementValuesArray();
+ final ArrayElementValue ev = (ArrayElementValue) elementValuePair.getValue();
+ final ElementValue[] eva = ev.getElementValuesArray();
assertEquals(nExpectedArrayValues, eva.length);
}
private void assertParameterAnnotations(final Method method, final int... expectedNumberOfParmeterAnnotations)
{
- String methodName= "For "+method.getName();
- ParameterAnnotationEntry[] parameterAnnotations= method.getParameterAnnotationEntries();
+ final String methodName= "For "+method.getName();
+ final ParameterAnnotationEntry[] parameterAnnotations= method.getParameterAnnotationEntries();
assertEquals(methodName, expectedNumberOfParmeterAnnotations.length, parameterAnnotations.length);
int i= 0;
- for (ParameterAnnotationEntry parameterAnnotation : parameterAnnotations)
+ for (final ParameterAnnotationEntry parameterAnnotation : parameterAnnotations)
{
- AnnotationEntry[] annos= parameterAnnotation.getAnnotationEntries();
- int expectedLength = expectedNumberOfParmeterAnnotations[i++];
+ final AnnotationEntry[] annos= parameterAnnotation.getAnnotationEntries();
+ final int expectedLength = expectedNumberOfParmeterAnnotations[i++];
assertEquals(methodName+" parameter "+i, expectedLength, annos.length);
if(expectedLength!=0)
{
@@ -322,9 +322,9 @@ public class GeneratingAnnotatedClassesT
private void assertSimpleElementValue(final AnnotationEntry anno)
{
- ElementValuePair elementValuePair = anno.getElementValuePairs()[0];
+ final ElementValuePair elementValuePair = anno.getElementValuePairs()[0];
assertEquals("id", elementValuePair.getNameString());
- SimpleElementValue ev = (SimpleElementValue)elementValuePair.getValue();
+ final SimpleElementValue ev = (SimpleElementValue)elementValuePair.getValue();
assertEquals(42, ev.getValueInt());
}
@@ -334,16 +334,16 @@ public class GeneratingAnnotatedClassesT
public void testTransformComplexClassToClassGen()
throws ClassNotFoundException
{
- JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.ComplexAnnotatedClass");
- ClassGen cgen = new ClassGen(jc);
+ final JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.ComplexAnnotatedClass");
+ final ClassGen cgen = new ClassGen(jc);
// Check annotations are correctly preserved
- AnnotationEntryGen[] annotations = cgen.getAnnotationEntries();
+ final AnnotationEntryGen[] annotations = cgen.getAnnotationEntries();
assertTrue("Expected one annotation but found " + annotations.length,
annotations.length == 1);
- List<?> l = annotations[0].getValues();
+ final List<?> l = annotations[0].getValues();
boolean found = false;
- for (Object name : l) {
- ElementValuePairGen element = (ElementValuePairGen) name;
+ for (final Object name : l) {
+ final ElementValuePairGen element = (ElementValuePairGen) name;
if (element.getNameString().equals("dval"))
{
if (((SimpleElementValueGen) element.getValue())
@@ -362,9 +362,9 @@ public class GeneratingAnnotatedClassesT
*/
public void testModifyingClasses1() throws ClassNotFoundException
{
- JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.SimpleAnnotatedClass");
- ClassGen cgen = new ClassGen(jc);
- ConstantPoolGen cp = cgen.getConstantPool();
+ final JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.SimpleAnnotatedClass");
+ final ClassGen cgen = new ClassGen(jc);
+ final ConstantPoolGen cp = cgen.getConstantPool();
cgen.addAnnotationEntry(createFruitAnnotation(cp, "Pineapple"));
assertTrue("Should now have two annotations but has "
+ cgen.getAnnotationEntries().length, cgen
@@ -379,15 +379,15 @@ public class GeneratingAnnotatedClassesT
*/
public void testModifyingClasses2() throws ClassNotFoundException
{
- JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.SimpleAnnotatedClass");
- ClassGen cgen = new ClassGen(jc);
- ConstantPoolGen cp = cgen.getConstantPool();
+ final JavaClass jc = getTestClass(PACKAGE_BASE_NAME+".data.SimpleAnnotatedClass");
+ final ClassGen cgen = new ClassGen(jc);
+ final ConstantPoolGen cp = cgen.getConstantPool();
cgen.addAnnotationEntry(createCombinedAnnotation(cp));
assertTrue("Should now have two annotations but has "
+ cgen.getAnnotationEntries().length, cgen
.getAnnotationEntries().length == 2);
dumpClass(cgen, "SimpleAnnotatedClass.class");
- JavaClass jc2 = getClassFrom(".", "SimpleAnnotatedClass");
+ final JavaClass jc2 = getClassFrom(".", "SimpleAnnotatedClass");
jc2.getAnnotationEntries();
assertTrue(wipe("SimpleAnnotatedClass.class"));
// System.err.println(jc2.toString());
@@ -397,10 +397,10 @@ public class GeneratingAnnotatedClassesT
{
try
{
- File f = createTestdataFile(fname);
+ final File f = createTestdataFile(fname);
cg.getJavaClass().dump(f);
}
- catch (java.io.IOException e)
+ catch (final java.io.IOException e)
{
System.err.println(e);
}
@@ -415,13 +415,13 @@ public class GeneratingAnnotatedClassesT
final ConstantPoolGen cp, final InstructionList il)
{
// Create method 'public static void main(String[]argv)'
- MethodGen mg = createMethodGen("main", il, cp);
- InstructionFactory factory = new InstructionFactory(cg);
+ final MethodGen mg = createMethodGen("main", il, cp);
+ final InstructionFactory factory = new InstructionFactory(cg);
mg.addAnnotationEntry(createSimpleVisibleAnnotation(mg
.getConstantPool()));
// We now define some often used types:
- ObjectType i_stream = new ObjectType("java.io.InputStream");
- ObjectType p_stream = new ObjectType("java.io.PrintStream");
+ final ObjectType i_stream = new ObjectType("java.io.InputStream");
+ final ObjectType p_stream = new ObjectType("java.io.PrintStream");
// Create variables in and name : We call the constructors, i.e.,
// execute BufferedReader(InputStreamReader(System.in)) . The reference
// to the BufferedReader object stays on top of the stack and is stored
@@ -439,11 +439,11 @@ public class GeneratingAnnotatedClassesT
Const.INVOKESPECIAL));
LocalVariableGen lg = mg.addLocalVariable("in", new ObjectType(
"java.io.BufferedReader"), null, null);
- int in = lg.getIndex();
+ final int in = lg.getIndex();
lg.setStart(il.append(new ASTORE(in))); // "in" valid from here
// Create local variable name and initialize it to null
lg = mg.addLocalVariable("name", Type.STRING, null, null);
- int name = lg.getIndex();
+ final int name = lg.getIndex();
il.append(InstructionConst.ACONST_NULL);
lg.setStart(il.append(new ASTORE(name))); // "name" valid from here
// Create try-catch block: We remember the start of the block, read a
@@ -457,24 +457,24 @@ public class GeneratingAnnotatedClassesT
// il.append(new ALOAD(in));
// il.append(factory.createInvoke("java.io.BufferedReader", "readLine",
// Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
- InstructionHandle try_start = il.append(new PUSH(cp, "Andy"));
+ final InstructionHandle try_start = il.append(new PUSH(cp, "Andy"));
il.append(new ASTORE(name));
// Upon normal execution we jump behind exception handler, the target
// address is not known yet.
- GOTO g = new GOTO(null);
- InstructionHandle try_end = il.append(g);
+ final GOTO g = new GOTO(null);
+ final InstructionHandle try_end = il.append(g);
// We add the exception handler which simply returns from the method.
- LocalVariableGen var_ex = mg.addLocalVariable("ex", Type
+ final LocalVariableGen var_ex = mg.addLocalVariable("ex", Type
.getType("Ljava.io.IOException;"), null, null);
- int var_ex_slot = var_ex.getIndex();
- InstructionHandle handler = il.append(new ASTORE(var_ex_slot));
+ final int var_ex_slot = var_ex.getIndex();
+ final InstructionHandle handler = il.append(new ASTORE(var_ex_slot));
var_ex.setStart(handler);
var_ex.setEnd(il.append(InstructionConst.RETURN));
mg.addExceptionHandler(try_start, try_end, handler, new ObjectType(
"java.io.IOException"));
// "Normal" code continues, now we can set the branch target of the GOTO
// .
- InstructionHandle ih = il.append(factory.createFieldAccess(
+ final InstructionHandle ih = il.append(factory.createFieldAccess(
"java.lang.System", "out", p_stream, Const.GETSTATIC));
g.setTarget(ih);
// Printing "Hello": String concatenation compiles to StringBuffer
@@ -511,11 +511,11 @@ public class GeneratingAnnotatedClassesT
final InstructionList il)
{
// Create method 'public static void main(String[]argv)'
- MethodGen mg = createMethodGen("main", il, cp);
- InstructionFactory factory = new InstructionFactory(cg);
+ final MethodGen mg = createMethodGen("main", il, cp);
+ final InstructionFactory factory = new InstructionFactory(cg);
// We now define some often used types:
- ObjectType i_stream = new ObjectType("java.io.InputStream");
- ObjectType p_stream = new ObjectType("java.io.PrintStream");
+ final ObjectType i_stream = new ObjectType("java.io.InputStream");
+ final ObjectType p_stream = new ObjectType("java.io.PrintStream");
// Create variables in and name : We call the constructors, i.e.,
// execute BufferedReader(InputStreamReader(System.in)) . The reference
// to the BufferedReader object stays on top of the stack and is stored
@@ -533,11 +533,11 @@ public class GeneratingAnnotatedClassesT
Const.INVOKESPECIAL));
LocalVariableGen lg = mg.addLocalVariable("in", new ObjectType(
"java.io.BufferedReader"), null, null);
- int in = lg.getIndex();
+ final int in = lg.getIndex();
lg.setStart(il.append(new ASTORE(in))); // "in" valid from here
// Create local variable name and initialize it to null
lg = mg.addLocalVariable("name", Type.STRING, null, null);
- int name = lg.getIndex();
+ final int name = lg.getIndex();
il.append(InstructionConst.ACONST_NULL);
lg.setStart(il.append(new ASTORE(name))); // "name" valid from here
// Create try-catch block: We remember the start of the block, read a
@@ -551,24 +551,24 @@ public class GeneratingAnnotatedClassesT
// il.append(new ALOAD(in));
// il.append(factory.createInvoke("java.io.BufferedReader", "readLine",
// Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
- InstructionHandle try_start = il.append(new PUSH(cp, "Andy"));
+ final InstructionHandle try_start = il.append(new PUSH(cp, "Andy"));
il.append(new ASTORE(name));
// Upon normal execution we jump behind exception handler, the target
// address is not known yet.
- GOTO g = new GOTO(null);
- InstructionHandle try_end = il.append(g);
+ final GOTO g = new GOTO(null);
+ final InstructionHandle try_end = il.append(g);
// We add the exception handler which simply returns from the method.
- LocalVariableGen var_ex = mg.addLocalVariable("ex", Type
+ final LocalVariableGen var_ex = mg.addLocalVariable("ex", Type
.getType("Ljava.io.IOException;"), null, null);
- int var_ex_slot = var_ex.getIndex();
- InstructionHandle handler = il.append(new ASTORE(var_ex_slot));
+ final int var_ex_slot = var_ex.getIndex();
+ final InstructionHandle handler = il.append(new ASTORE(var_ex_slot));
var_ex.setStart(handler);
var_ex.setEnd(il.append(InstructionConst.RETURN));
mg.addExceptionHandler(try_start, try_end, handler, new ObjectType(
"java.io.IOException"));
// "Normal" code continues, now we can set the branch target of the GOTO
// .
- InstructionHandle ih = il.append(factory.createFieldAccess(
+ final InstructionHandle ih = il.append(factory.createFieldAccess(
"java.lang.System", "out", p_stream, Const.GETSTATIC));
g.setTarget(ih);
// Printing "Hello": String concatenation compiles to StringBuffer
@@ -605,7 +605,7 @@ public class GeneratingAnnotatedClassesT
throws ClassNotFoundException
{
// System.out.println(where);
- SyntheticRepository repos = createRepos(where);
+ final SyntheticRepository repos = createRepos(where);
return repos.loadClass(clazzname);
}
@@ -631,24 +631,24 @@ public class GeneratingAnnotatedClassesT
public AnnotationEntryGen createSimpleVisibleAnnotation(final ConstantPoolGen cp)
{
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 4);
- ElementValuePairGen nvGen = new ElementValuePairGen("id", evg, cp);
- ObjectType t = new ObjectType("SimpleAnnotation");
- List<ElementValuePairGen> elements = new ArrayList<>();
+ final ElementValuePairGen nvGen = new ElementValuePairGen("id", evg, cp);
+ final ObjectType t = new ObjectType("SimpleAnnotation");
+ final List<ElementValuePairGen> elements = new ArrayList<>();
elements.add(nvGen);
- AnnotationEntryGen a = new AnnotationEntryGen(t, elements, true, cp);
+ final AnnotationEntryGen a = new AnnotationEntryGen(t, elements, true, cp);
return a;
}
public AnnotationEntryGen createFruitAnnotation(final ConstantPoolGen cp,
final String aFruit)
{
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.STRING, cp, aFruit);
- ElementValuePairGen nvGen = new ElementValuePairGen("fruit", evg, cp);
- ObjectType t = new ObjectType("SimpleStringAnnotation");
- List<ElementValuePairGen> elements = new ArrayList<>();
+ final ElementValuePairGen nvGen = new ElementValuePairGen("fruit", evg, cp);
+ final ObjectType t = new ObjectType("SimpleStringAnnotation");
+ final List<ElementValuePairGen> elements = new ArrayList<>();
elements.add(nvGen);
return new AnnotationEntryGen(t, elements, true, cp);
}
@@ -656,11 +656,11 @@ public class GeneratingAnnotatedClassesT
public AnnotationEntryGen createCombinedAnnotation(final ConstantPoolGen cp)
{
// Create an annotation instance
- AnnotationEntryGen a = createSimpleVisibleAnnotation(cp);
- ArrayElementValueGen array = new ArrayElementValueGen(cp);
+ final AnnotationEntryGen a = createSimpleVisibleAnnotation(cp);
+ final ArrayElementValueGen array = new ArrayElementValueGen(cp);
array.addElement(new AnnotationElementValueGen(a, cp));
- ElementValuePairGen nvp = new ElementValuePairGen("value", array, cp);
- List<ElementValuePairGen> elements = new ArrayList<>();
+ final ElementValuePairGen nvp = new ElementValuePairGen("value", array, cp);
+ final List<ElementValuePairGen> elements = new ArrayList<>();
elements.add(nvp);
return new AnnotationEntryGen(new ObjectType("CombinedAnnotation"),
elements, true, cp);
@@ -668,13 +668,13 @@ public class GeneratingAnnotatedClassesT
public AnnotationEntryGen createSimpleInvisibleAnnotation(final ConstantPoolGen cp)
{
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 4);
- ElementValuePairGen nvGen = new ElementValuePairGen("id", evg, cp);
- ObjectType t = new ObjectType("SimpleAnnotation");
- List<ElementValuePairGen> elements = new ArrayList<>();
+ final ElementValuePairGen nvGen = new ElementValuePairGen("id", evg, cp);
+ final ObjectType t = new ObjectType("SimpleAnnotation");
+ final List<ElementValuePairGen> elements = new ArrayList<>();
elements.add(nvGen);
- AnnotationEntryGen a = new AnnotationEntryGen(t, elements, false, cp);
+ final AnnotationEntryGen a = new AnnotationEntryGen(t, elements, false, cp);
return a;
}
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/InstructionHandleTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/InstructionHandleTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/InstructionHandleTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/InstructionHandleTestCase.java Tue Jun 21 20:50:19 2016
@@ -26,7 +26,7 @@ public class InstructionHandleTestCase {
@Test(expected=ClassGenException.class)
public void testsetInstructionNull() {
- InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI
+ final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI
Assert.assertNotNull(ih);
ih.setInstruction(null);
Assert.assertNotNull(ih);
@@ -34,7 +34,7 @@ public class InstructionHandleTestCase {
@Test
public void testsetInstructionI() {
- InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI
+ final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI
Assert.assertNotNull(ih);
ih.setInstruction(new NOP());
Assert.assertNotNull(ih);
@@ -42,7 +42,7 @@ public class InstructionHandleTestCase {
@Test(expected=ClassGenException.class)
public void testsetInstructionnotI() {
- InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI
+ final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI
Assert.assertNotNull(ih);
ih.setInstruction(new GOTO(null));
Assert.assertNotNull(ih);
@@ -55,8 +55,8 @@ public class InstructionHandleTestCase {
@Test
public void testBCEL195() {
- InstructionList il = new InstructionList();
- InstructionHandle ih = il.append(InstructionConst.NOP);
+ final InstructionList il = new InstructionList();
+ final InstructionHandle ih = il.append(InstructionConst.NOP);
new TABLESWITCH(new int[0], new InstructionHandle[0], ih);
new TABLESWITCH(new int[0], new InstructionHandle[0], ih);
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/JDKGenericDumpTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/JDKGenericDumpTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/JDKGenericDumpTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/JDKGenericDumpTestCase.java Tue Jun 21 20:50:19 2016
@@ -42,8 +42,8 @@ public class JDKGenericDumpTestCase {
@Test
public void testJDKjars() throws Exception {
- File[] jars = listJDKjars();
- for (File file : jars) {
+ final File[] jars = listJDKjars();
+ for (final File file : jars) {
testJar(file);
}
}
@@ -51,16 +51,16 @@ public class JDKGenericDumpTestCase {
private void testJar(final File file) throws Exception {
System.out.println(file);
try (JarFile jar = new JarFile(file)) {
- Enumeration<JarEntry> en = jar.entries();
+ final Enumeration<JarEntry> en = jar.entries();
while (en.hasMoreElements()) {
- JarEntry e = en.nextElement();
+ final JarEntry e = en.nextElement();
final String name = e.getName();
if (name.endsWith(".class")) {
// System.out.println("- " + name);
try (InputStream in = jar.getInputStream(e)) {
- ClassParser parser = new ClassParser(in, name);
- JavaClass jc = parser.parse();
- for (Method m : jc.getMethods()) {
+ final ClassParser parser = new ClassParser(in, name);
+ final JavaClass jc = parser.parse();
+ for (final Method m : jc.getMethods()) {
compare(name, m);
}
}
@@ -71,20 +71,20 @@ public class JDKGenericDumpTestCase {
private void compare(final String name, final Method m) {
// System.out.println("Method: " + m);
- Code c = m.getCode();
+ final Code c = m.getCode();
if (c==null) {
return; // e.g. abstract method
}
- byte[] src = c.getCode();
- InstructionList il = new InstructionList(src);
- byte[] out = il.getByteCode();
+ final byte[] src = c.getCode();
+ final InstructionList il = new InstructionList(src);
+ final byte[] out = il.getByteCode();
if (src.length == out.length) {
assertArrayEquals(name + ": "+m.toString(), src, out);
} else {
System.out.println(name + ": "+m.toString() +" "+ src.length+" "+out.length);
System.out.println(bytesToHex(src));
System.out.println(bytesToHex(out));
- for (InstructionHandle ih : il) {
+ for (final InstructionHandle ih : il) {
System.out.println(ih.toString(false));
}
fail("Array comparison failure");
@@ -92,7 +92,7 @@ public class JDKGenericDumpTestCase {
}
private File[] listJDKjars() throws Exception {
- File javaLib = new File(System.getProperty("java.home") + "/lib");
+ final File javaLib = new File(System.getProperty("java.home") + "/lib");
return javaLib.listFiles(new FileFilter() {
@Override
public boolean accept(final File file) {
@@ -103,10 +103,10 @@ public class JDKGenericDumpTestCase {
private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
private static String bytesToHex(final byte[] bytes) {
- char[] hexChars = new char[bytes.length * 3];
+ final char[] hexChars = new char[bytes.length * 3];
int i=0;
- for (byte b : bytes) {
- int v = b & 0xFF;
+ for (final byte b : bytes) {
+ final int v = b & 0xFF;
hexChars[i++] = hexArray[v >>> 4];
hexChars[i++] = hexArray[v & 0x0F];
hexChars[i++] = ' ';
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/MethodGenTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/MethodGenTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/MethodGenTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/MethodGenTestCase.java Tue Jun 21 20:50:19 2016
@@ -30,14 +30,15 @@ public class MethodGenTestCase extends T
public static class Foo {
public void bar() {
@SuppressWarnings("unused")
+ final
int a = 1;
}
}
private MethodGen getMethod(final Class<?> cls, final String name) throws ClassNotFoundException {
- JavaClass jc = Repository.lookupClass(cls);
- ConstantPoolGen cp = new ConstantPoolGen(jc.getConstantPool());
- for (Method method : jc.getMethods()) {
+ final JavaClass jc = Repository.lookupClass(cls);
+ final ConstantPoolGen cp = new ConstantPoolGen(jc.getConstantPool());
+ for (final Method method : jc.getMethods()) {
if (method.getName().equals(name)) {
return new MethodGen(method, jc.getClassName(), cp);
}
@@ -48,12 +49,12 @@ public class MethodGenTestCase extends T
}
public void testRemoveLocalVariable() throws Exception {
- MethodGen mg = getMethod(Foo.class, "bar");
+ final MethodGen mg = getMethod(Foo.class, "bar");
- LocalVariableGen lv = mg.getLocalVariables()[1];
+ final LocalVariableGen lv = mg.getLocalVariables()[1];
assertEquals("variable name", "a", lv.getName());
- InstructionHandle start = lv.getStart();
- InstructionHandle end = lv.getEnd();
+ final InstructionHandle start = lv.getStart();
+ final InstructionHandle end = lv.getEnd();
assertNotNull("scope start", start);
assertNotNull("scope end", end);
assertTrue("scope start not targeted by the local variable", Arrays.asList(start.getTargeters()).contains(lv));
@@ -69,12 +70,12 @@ public class MethodGenTestCase extends T
}
public void testRemoveLocalVariables() throws Exception {
- MethodGen mg = getMethod(Foo.class, "bar");
+ final MethodGen mg = getMethod(Foo.class, "bar");
- LocalVariableGen lv = mg.getLocalVariables()[1];
+ final LocalVariableGen lv = mg.getLocalVariables()[1];
assertEquals("variable name", "a", lv.getName());
- InstructionHandle start = lv.getStart();
- InstructionHandle end = lv.getEnd();
+ final InstructionHandle start = lv.getStart();
+ final InstructionHandle end = lv.getEnd();
assertNotNull("scope start", start);
assertNotNull("scope end", end);
assertTrue("scope start not targeted by the local variable", Arrays.asList(start.getTargeters()).contains(lv));
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/TypeTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/TypeTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/TypeTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/TypeTestCase.java Tue Jun 21 20:50:19 2016
@@ -25,8 +25,8 @@ public class TypeTestCase extends TestCa
// The line commented out above is the correct expected value; however,
// the constructor for ObjectType is yet another place where BCEL does
// not understand generics so we need to substitute the modified value below.
- String expectedValue = "Ljava/util/Map<X, java/util/List<Y>>;";
- String actualValue = (Type.getType("Ljava/util/Map<TX;Ljava/util/List<TY;>;>;")).getSignature();
+ final String expectedValue = "Ljava/util/Map<X, java/util/List<Y>>;";
+ final String actualValue = (Type.getType("Ljava/util/Map<TX;Ljava/util/List<TY;>;>;")).getSignature();
assertEquals("Type.getType", expectedValue, actualValue);
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/BCELifierTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/BCELifierTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/BCELifierTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/BCELifierTestCase.java Tue Jun 21 20:50:19 2016
@@ -33,10 +33,10 @@ public class BCELifierTestCase {
@Test
public void test() throws Exception {
- OutputStream os = new ByteArrayOutputStream();
- JavaClass java_class = BCELifier.getJavaClass("Java8Example");
+ final OutputStream os = new ByteArrayOutputStream();
+ final JavaClass java_class = BCELifier.getJavaClass("Java8Example");
assertNotNull(java_class);
- BCELifier bcelifier = new BCELifier(java_class, os);
+ final BCELifier bcelifier = new BCELifier(java_class, os);
bcelifier.start();
}
@@ -55,12 +55,12 @@ public class BCELifierTestCase {
final String initial = exec(null, "javap", "-p", "-c", javaClass);
final File workDir = new File("target");
- File infile = new File(javaClass);
- JavaClass java_class = BCELifier.getJavaClass(infile.getName().replace(".class", ""));
+ final File infile = new File(javaClass);
+ final JavaClass java_class = BCELifier.getJavaClass(infile.getName().replace(".class", ""));
assertNotNull(java_class);
- File outfile = new File(workDir, infile.getName().replace(".class", "Creator.java"));
+ final File outfile = new File(workDir, infile.getName().replace(".class", "Creator.java"));
try (FileOutputStream fos = new FileOutputStream(outfile)) {
- BCELifier bcelifier = new BCELifier(java_class, fos);
+ final BCELifier bcelifier = new BCELifier(java_class, fos);
bcelifier.start();
}
exec(workDir, "javac", "-cp", "classes", outfile.getName());
@@ -79,19 +79,19 @@ public class BCELifierTestCase {
private String exec(final File workDir, final String... args) throws Exception {
// System.err.println(java.util.Arrays.toString(args));
- ProcessBuilder pb = new ProcessBuilder(args);
+ final ProcessBuilder pb = new ProcessBuilder(args);
pb.directory(workDir);
- Process proc = pb.start();
+ final Process proc = pb.start();
try (BufferedInputStream is = new BufferedInputStream(proc.getInputStream());
InputStream es = proc.getErrorStream()) {
proc.waitFor();
- byte[] buff = new byte[2048];
+ final byte[] buff = new byte[2048];
int len;
while ((len = es.read(buff)) != -1) {
System.err.print(new String(buff, 0, len));
}
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
while ((len = is.read(buff)) != -1) {
sb.append(new String(buff, 0, len));
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java Tue Jun 21 20:50:19 2016
@@ -28,14 +28,14 @@ import junit.framework.TestCase;
public class Class2HTMLTestCase extends TestCase {
public void testConvertJavaUtil() throws Exception {
- File outputDir = new File("target/test-output/html");
+ final File outputDir = new File("target/test-output/html");
if (!outputDir.mkdirs()) { // either was not created or already existed
Assert.assertTrue(outputDir.isDirectory()); // fail if missing
}
try (FileInputStream file = new FileInputStream("target/test-classes/Java8Example.class")) {
- ClassParser parser = new ClassParser(file, "Java8Example.class");
+ final ClassParser parser = new ClassParser(file, "Java8Example.class");
new Class2HTML(parser.parse(), outputDir.getAbsolutePath() + "/");
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/InstructionFinderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/InstructionFinderTest.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/InstructionFinderTest.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/InstructionFinderTest.java Tue Jun 21 20:50:19 2016
@@ -30,15 +30,15 @@ import org.apache.bcel.generic.Instructi
public class InstructionFinderTest extends AbstractTestCase {
public void testSearch() {
- InstructionList il = new InstructionList();
+ final InstructionList il = new InstructionList();
il.append(new ILOAD(1));
il.append(new ILOAD(2));
il.append(new IADD());
il.append(new ISTORE(3));
- InstructionFinder finder = new InstructionFinder(il);
+ final InstructionFinder finder = new InstructionFinder(il);
- Iterator<?> it = finder.search("ILOAD IADD", il.getInstructionHandles()[0], null );
- InstructionHandle[] ihs = (InstructionHandle[])it.next();
+ final Iterator<?> it = finder.search("ILOAD IADD", il.getInstructionHandles()[0], null );
+ final InstructionHandle[] ihs = (InstructionHandle[])it.next();
assertEquals(2, ihs.length);
assertEquals(ihs[0].getInstruction(), new ILOAD(2));
assertEquals(ihs[1].getInstruction(), new IADD());
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/AbstractVerifierTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/AbstractVerifierTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/AbstractVerifierTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/AbstractVerifierTestCase.java Tue Jun 21 20:50:19 2016
@@ -60,14 +60,14 @@ public abstract class AbstractVerifierTe
int nbMethods = 0;
try {
- JavaClass jc = Repository.lookupClass(classname);
+ final JavaClass jc = Repository.lookupClass(classname);
nbMethods = jc.getMethods().length;
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
fail(e.getMessage());
return false;
}
- Verifier verifier = VerifierFactory.getVerifier(classname);
+ final Verifier verifier = VerifierFactory.getVerifier(classname);
VerificationResult result = verifier.doPass1();
if (result.getStatus() != VerificationResult.VERIFIED_OK) {
return false;
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java Tue Jun 21 20:50:19 2016
@@ -25,9 +25,9 @@ import junit.framework.TestCase;
public class VerifierTestCase extends TestCase {
public void testDefaultMethodValidation() {
- String classname = Collection.class.getName();
+ final String classname = Collection.class.getName();
- Verifier verifier = VerifierFactory.getVerifier(classname);
+ final Verifier verifier = VerifierFactory.getVerifier(classname);
VerificationResult result = verifier.doPass1();
assertEquals("Pass 1 verification of " + classname + " failed: " + result.getMessage(), VerificationResult.VERIFIED_OK,
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArray01.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArray01.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArray01.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArray01.java Tue Jun 21 20:50:19 2016
@@ -22,7 +22,7 @@ import java.io.Serializable;
public class TestArray01{
public static Object test1() {
- String[] a = new String[4];
+ final String[] a = new String[4];
a[0] = "";
a.equals(null);
test2(a);
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess01.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess01.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess01.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess01.java Tue Jun 21 20:50:19 2016
@@ -21,7 +21,7 @@ package org.apache.bcel.verifier.tests;
public class TestArrayAccess01 extends XTestArray01{
public static void test() {
- XTestArray01[] array = new TestArrayAccess01[1];
+ final XTestArray01[] array = new TestArrayAccess01[1];
array[0] = new XTestArray01();
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess02Creator.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess02Creator.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess02Creator.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess02Creator.java Tue Jun 21 20:50:19 2016
@@ -54,14 +54,14 @@ public void create(final OutputStream ou
}
private void createMethod_0() {
- InstructionList il = new InstructionList();
- MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>",
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>",
TEST_PACKAGE+".TestArrayAccess02", il, _cp);
- InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
+ final InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
Assert.assertNotNull(ih_0); // TODO why is this not used
il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL));
- InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID));
+ final InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID));
Assert.assertNotNull(ih_4); // TODO why is this not used
method.setMaxStack();
method.setMaxLocals();
@@ -70,26 +70,26 @@ public void create(final OutputStream ou
}
private void createMethod_1() {
- InstructionList il = new InstructionList();
- MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.VOID, Type.NO_ARGS, new String[] { },
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.VOID, Type.NO_ARGS, new String[] { },
"test", TEST_PACKAGE+".TestArrayAccess02", il, _cp);
- InstructionHandle ih_0 = il.append(new PUSH(_cp, 1));
+ final InstructionHandle ih_0 = il.append(new PUSH(_cp, 1));
Assert.assertNotNull(ih_0); // TODO why is this not used
il.append(_factory.createNewArray(new ObjectType(TEST_PACKAGE+".TestArrayAccess02"), (short) 1));
il.append(InstructionFactory.createStore(Type.OBJECT, 0));
- InstructionHandle ih_5 = il.append(new PUSH(_cp, 1));
+ final InstructionHandle ih_5 = il.append(new PUSH(_cp, 1));
Assert.assertNotNull(ih_5); // TODO why is this not used
il.append(_factory.createNewArray(Type.STRING, (short) 1));
il.append(InstructionFactory.createStore(Type.OBJECT, 1));
- InstructionHandle ih_10 = il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
+ final InstructionHandle ih_10 = il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
Assert.assertNotNull(ih_10); // TODO why is this not used
il.append(new PUSH(_cp, 0));
il.append(_factory.createNew(TEST_PACKAGE+".TestArrayAccess02"));
il.append(InstructionConst.DUP);
il.append(_factory.createInvoke(TEST_PACKAGE+".TestArrayAccess02", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL));
il.append(InstructionConst.AASTORE);
- InstructionHandle ih_20 = il.append(InstructionFactory.createReturn(Type.VOID));
+ final InstructionHandle ih_20 = il.append(InstructionFactory.createReturn(Type.VOID));
Assert.assertNotNull(ih_20); // TODO why is this not used
method.setMaxStack();
method.setMaxLocals();
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess03Creator.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess03Creator.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess03Creator.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess03Creator.java Tue Jun 21 20:50:19 2016
@@ -54,14 +54,14 @@ public void create(final OutputStream ou
}
private void createMethod_0() {
- InstructionList il = new InstructionList();
- MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>",
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>",
TEST_PACKAGE+".TestArrayAccess03", il, _cp);
- InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
+ final InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
Assert.assertNotNull(ih_0); // TODO why is this not used
il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL));
- InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID));
+ final InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID));
Assert.assertNotNull(ih_4); // TODO why is this not used
method.setMaxStack();
method.setMaxLocals();
@@ -70,22 +70,22 @@ public void create(final OutputStream ou
}
private void createMethod_1() {
- InstructionList il = new InstructionList();
- MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.VOID, new Type[] { Type.OBJECT },
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.VOID, new Type[] { Type.OBJECT },
new String[] { "arg0" }, "test", TEST_PACKAGE+".TestArrayAccess03", il, _cp);
- InstructionHandle ih_0 = il.append(new PUSH(_cp, 1));
+ final InstructionHandle ih_0 = il.append(new PUSH(_cp, 1));
Assert.assertNotNull(ih_0); // TODO why is this not used
il.append(_factory.createNewArray(new ObjectType(TEST_PACKAGE+".TestArrayAccess03"), (short) 1));
il.append(InstructionFactory.createStore(Type.OBJECT, 1));
- InstructionHandle ih_5 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
+ final InstructionHandle ih_5 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
Assert.assertNotNull(ih_5); // TODO why is this not used
il.append(new PUSH(_cp, 0));
il.append(_factory.createNew(TEST_PACKAGE+".TestArrayAccess03"));
il.append(InstructionConst.DUP);
il.append(_factory.createInvoke(TEST_PACKAGE+".TestArrayAccess03", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL));
il.append(InstructionConst.AASTORE);
- InstructionHandle ih_15 = il.append(InstructionFactory.createReturn(Type.VOID));
+ final InstructionHandle ih_15 = il.append(InstructionFactory.createReturn(Type.VOID));
Assert.assertNotNull(ih_15); // TODO why is this not used
method.setMaxStack();
method.setMaxLocals();
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess04Creator.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess04Creator.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess04Creator.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestArrayAccess04Creator.java Tue Jun 21 20:50:19 2016
@@ -54,14 +54,14 @@ public void create(final OutputStream ou
}
private void createMethod_0() {
- InstructionList il = new InstructionList();
- MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>",
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>",
TEST_PACKAGE+".TestArrayAccess04", il, _cp);
- InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
+ final InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
Assert.assertNotNull(ih_0); // TODO why is this not used
il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL));
- InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID));
+ final InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID));
Assert.assertNotNull(ih_4); // TODO why is this not used
method.setMaxStack();
method.setMaxLocals();
@@ -70,23 +70,23 @@ public void create(final OutputStream ou
}
private void createMethod_1() {
- InstructionList il = new InstructionList();
- MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.VOID, new Type[] { Type.OBJECT },
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.VOID, new Type[] { Type.OBJECT },
new String[] { "arg0" }, "test", TEST_PACKAGE+".TestArrayAccess04", il, _cp);
- InstructionHandle ih_0 = il.append(new PUSH(_cp, 1));
+ final InstructionHandle ih_0 = il.append(new PUSH(_cp, 1));
Assert.assertNotNull(ih_0); // TODO why is this not used
il.append(_factory.createNewArray(Type.OBJECT, (short) 1));
il.append(InstructionFactory.createStore(Type.OBJECT, 1));
- InstructionHandle ih_5 = il.append(new PUSH(_cp, 1));
+ final InstructionHandle ih_5 = il.append(new PUSH(_cp, 1));
Assert.assertNotNull(ih_5); // TODO why is this not used
il.append(InstructionFactory.createStore(Type.INT, 2));
- InstructionHandle ih_7 = il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
+ final InstructionHandle ih_7 = il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
Assert.assertNotNull(ih_7); // TODO why is this not used
il.append(new PUSH(_cp, 0));
il.append(InstructionFactory.createLoad(Type.INT, 2));
il.append(InstructionConst.AASTORE);
- InstructionHandle ih_11 = il.append(InstructionFactory.createReturn(Type.VOID));
+ final InstructionHandle ih_11 = il.append(InstructionFactory.createReturn(Type.VOID));
Assert.assertNotNull(ih_11); // TODO why is this not used
method.setMaxStack();
method.setMaxLocals();
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestCreator.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestCreator.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestCreator.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestCreator.java Tue Jun 21 20:50:19 2016
@@ -29,14 +29,14 @@ public abstract class TestCreator {
protected static final String TEST_PACKAGE = TestCreator.class.getPackage().getName();
public void create() throws IOException {
- File classFile = new File(getPackageFolder(), getClassName());
+ final File classFile = new File(getPackageFolder(), getClassName());
try (FileOutputStream out = new FileOutputStream(classFile)) {
create(out);
}
}
private String getClassName() {
- String name = getClass().getName();
+ final String name = getClass().getName();
return name.substring(name.lastIndexOf('.')+1).replace("Creator", ".class");
}
@@ -51,7 +51,7 @@ public abstract class TestCreator {
private File getClassesFolder() throws IOException {
try {
return new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
- } catch (URISyntaxException e) {
+ } catch (final URISyntaxException e) {
throw new IOException(e);
}
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestReturn01Creator.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestReturn01Creator.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestReturn01Creator.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestReturn01Creator.java Tue Jun 21 20:50:19 2016
@@ -52,14 +52,14 @@ public void create(final OutputStream ou
}
private void createMethod_0() {
- InstructionList il = new InstructionList();
- MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { },
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { },
"<init>", TEST_PACKAGE+".TestReturn01", il, _cp);
- InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
+ final InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
Assert.assertNotNull(ih_0); // TODO why is this not used
il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL));
- InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID));
+ final InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID));
Assert.assertNotNull(ih_4); // TODO why is this not used
method.setMaxStack();
method.setMaxLocals();
@@ -68,16 +68,16 @@ public void create(final OutputStream ou
}
private void createMethod_1() {
- InstructionList il = new InstructionList();
- MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.VOID, Type.NO_ARGS,
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.VOID, Type.NO_ARGS,
new String[] { }, "foo", TEST_PACKAGE+".TestReturn01", il, _cp);
- InstructionHandle ih_0 = il.append(_factory.createNew("java.lang.Object"));
+ final InstructionHandle ih_0 = il.append(_factory.createNew("java.lang.Object"));
Assert.assertNotNull(ih_0); // TODO why is this not used
il.append(InstructionConst.DUP);
il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL));
il.append(InstructionConst.NOP);
- InstructionHandle ih_8 = il.append(InstructionFactory.createReturn(Type.OBJECT));
+ final InstructionHandle ih_8 = il.append(InstructionFactory.createReturn(Type.OBJECT));
Assert.assertNotNull(ih_8); // TODO why is this not used
method.setMaxStack();
method.setMaxLocals();
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestReturn03Creator.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestReturn03Creator.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestReturn03Creator.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/verifier/tests/TestReturn03Creator.java Tue Jun 21 20:50:19 2016
@@ -52,14 +52,14 @@ public void create(final OutputStream ou
}
private void createMethod_0() {
- InstructionList il = new InstructionList();
- MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { },
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { },
"<init>", TEST_PACKAGE+".TestReturn03", il, _cp);
- InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
+ final InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
Assert.assertNotNull(ih_0); // TODO why is this not used
il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL));
- InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID));
+ final InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID));
Assert.assertNotNull(ih_4); // TODO why is this not used
method.setMaxStack();
method.setMaxLocals();
@@ -68,11 +68,11 @@ public void create(final OutputStream ou
}
private void createMethod_1() {
- InstructionList il = new InstructionList();
- MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.INT, Type.NO_ARGS,
+ final InstructionList il = new InstructionList();
+ final MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.INT, Type.NO_ARGS,
new String[] { }, "test3", TEST_PACKAGE+".TestReturn03", il, _cp);
- InstructionHandle ih_0 = il.append(InstructionConst.ACONST_NULL);
+ final InstructionHandle ih_0 = il.append(InstructionConst.ACONST_NULL);
Assert.assertNotNull(ih_0); // TODO why is this not used
il.append(InstructionFactory.createReturn(Type.OBJECT));
method.setMaxStack();