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 [8/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/main/java/org/apache/bcel/verifier/structurals/Subroutines.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java Tue Jun 21 20:50:19 2016
@@ -115,7 +115,7 @@ public class Subroutines{
*/
@Override
public String toString() {
- StringBuilder ret = new StringBuilder();
+ final StringBuilder ret = new StringBuilder();
ret.append("Subroutine: Local variable is '").append(localVariable);
ret.append("', JSRs are '").append(theJSRs);
ret.append("', RET is '").append(theRET);
@@ -123,14 +123,14 @@ public class Subroutines{
ret.append(" Accessed local variable slots: '");
int[] alv = getAccessedLocalsIndices();
- for (int element : alv) {
+ for (final int element : alv) {
ret.append(element);ret.append(" ");
}
ret.append("'.");
ret.append(" Recursively (via subsub...routines) accessed local variable slots: '");
alv = getRecursivelyAccessedLocalsIndices();
- for (int element : alv) {
+ for (final int element : alv) {
ret.append(element);ret.append(" ");
}
ret.append("'.");
@@ -148,7 +148,7 @@ public class Subroutines{
"setLeavingRET() called for top-level 'subroutine' or forgot to set local variable first.");
}
InstructionHandle ret = null;
- for (InstructionHandle actual : instructions) {
+ for (final InstructionHandle actual : instructions) {
if (actual.getInstruction() instanceof RET) {
if (ret != null) {
throw new StructuralCodeConstraintException(
@@ -175,7 +175,7 @@ public class Subroutines{
if (this == getTopLevel()) {
throw new AssertionViolatedException("getLeavingRET() called on top level pseudo-subroutine.");
}
- InstructionHandle[] jsrs = new InstructionHandle[theJSRs.size()];
+ final InstructionHandle[] jsrs = new InstructionHandle[theJSRs.size()];
return theJSRs.toArray(jsrs);
}
@@ -214,7 +214,7 @@ public class Subroutines{
*/
@Override
public InstructionHandle[] getInstructions() {
- InstructionHandle[] ret = new InstructionHandle[instructions.size()];
+ final InstructionHandle[] ret = new InstructionHandle[instructions.size()];
return instructions.toArray(ret);
}
@@ -233,15 +233,15 @@ public class Subroutines{
/* Satisfies Subroutine.getRecursivelyAccessedLocalsIndices(). */
@Override
public int[] getRecursivelyAccessedLocalsIndices() {
- Set<Integer> s = new HashSet<>();
- int[] lvs = getAccessedLocalsIndices();
- for (int lv : lvs) {
+ final Set<Integer> s = new HashSet<>();
+ final int[] lvs = getAccessedLocalsIndices();
+ for (final int lv : lvs) {
s.add(Integer.valueOf(lv));
}
_getRecursivelyAccessedLocalsIndicesHelper(s, this.subSubs());
- int[] ret = new int[s.size()];
+ final int[] ret = new int[s.size()];
int j=-1;
- for (Integer index : s) {
+ for (final Integer index : s) {
j++;
ret[j] = index.intValue();
}
@@ -253,9 +253,9 @@ public class Subroutines{
* @see #getRecursivelyAccessedLocalsIndices()
*/
private void _getRecursivelyAccessedLocalsIndicesHelper(final Set<Integer> s, final Subroutine[] subs) {
- for (Subroutine sub : subs) {
- int[] lvs = sub.getAccessedLocalsIndices();
- for (int lv : lvs) {
+ for (final Subroutine sub : subs) {
+ final int[] lvs = sub.getAccessedLocalsIndices();
+ for (final int lv : lvs) {
s.add(Integer.valueOf(lv));
}
if(sub.subSubs().length != 0) {
@@ -270,29 +270,29 @@ public class Subroutines{
@Override
public int[] getAccessedLocalsIndices() {
//TODO: Implement caching.
- Set<Integer> acc = new HashSet<>();
+ final Set<Integer> acc = new HashSet<>();
if (theRET == null && this != getTopLevel()) {
throw new AssertionViolatedException(
"This subroutine object must be built up completely before calculating accessed locals.");
}
{
- for (InstructionHandle ih : instructions) {
+ for (final InstructionHandle ih : instructions) {
// RET is not a LocalVariableInstruction in the current version of BCEL.
if (ih.getInstruction() instanceof LocalVariableInstruction || ih.getInstruction() instanceof RET) {
- int idx = ((IndexedInstruction) (ih.getInstruction())).getIndex();
+ final int idx = ((IndexedInstruction) (ih.getInstruction())).getIndex();
acc.add(Integer.valueOf(idx));
// LONG? DOUBLE?.
try{
// LocalVariableInstruction instances are typed without the need to look into
// the constant pool.
if (ih.getInstruction() instanceof LocalVariableInstruction) {
- int s = ((LocalVariableInstruction) ih.getInstruction()).getType(null).getSize();
+ final int s = ((LocalVariableInstruction) ih.getInstruction()).getType(null).getSize();
if (s==2) {
acc.add(Integer.valueOf(idx+1));
}
}
}
- catch(RuntimeException re) {
+ catch(final RuntimeException re) {
throw new AssertionViolatedException("Oops. BCEL did not like NULL as a ConstantPoolGen object.", re);
}
}
@@ -300,9 +300,9 @@ public class Subroutines{
}
{
- int[] ret = new int[acc.size()];
+ final int[] ret = new int[acc.size()];
int j=-1;
- for (Integer accessedLocal : acc) {
+ for (final Integer accessedLocal : acc) {
j++;
ret[j] = accessedLocal.intValue();
}
@@ -315,16 +315,16 @@ public class Subroutines{
*/
@Override
public Subroutine[] subSubs() {
- Set<Subroutine> h = new HashSet<>();
+ final Set<Subroutine> h = new HashSet<>();
- for (InstructionHandle ih : instructions) {
- Instruction inst = ih.getInstruction();
+ for (final InstructionHandle ih : instructions) {
+ final Instruction inst = ih.getInstruction();
if (inst instanceof JsrInstruction) {
- InstructionHandle targ = ((JsrInstruction) inst).getTarget();
+ final InstructionHandle targ = ((JsrInstruction) inst).getTarget();
h.add(getSubroutine(targ));
}
}
- Subroutine[] ret = new Subroutine[h.size()];
+ final Subroutine[] ret = new Subroutine[h.size()];
return h.toArray(ret);
}
@@ -391,24 +391,24 @@ public class Subroutines{
* @since 6.0
*/
public Subroutines(final MethodGen mg, final boolean enableJustIceCheck) {
- InstructionHandle[] all = mg.getInstructionList().getInstructionHandles();
- CodeExceptionGen[] handlers = mg.getExceptionHandlers();
+ final InstructionHandle[] all = mg.getInstructionList().getInstructionHandles();
+ final CodeExceptionGen[] handlers = mg.getExceptionHandlers();
// Define our "Toplevel" fake subroutine.
TOPLEVEL = new SubroutineImpl();
// Calculate "real" subroutines.
- Set<InstructionHandle> sub_leaders = new HashSet<>(); // Elements: InstructionHandle
- for (InstructionHandle element : all) {
- Instruction inst = element.getInstruction();
+ final Set<InstructionHandle> sub_leaders = new HashSet<>(); // Elements: InstructionHandle
+ for (final InstructionHandle element : all) {
+ final Instruction inst = element.getInstruction();
if (inst instanceof JsrInstruction) {
sub_leaders.add(((JsrInstruction) inst).getTarget());
}
}
// Build up the database.
- for (InstructionHandle astore : sub_leaders) {
- SubroutineImpl sr = new SubroutineImpl();
+ for (final InstructionHandle astore : sub_leaders) {
+ final SubroutineImpl sr = new SubroutineImpl();
sr.setLocalVariable( ((ASTORE) (astore.getInstruction())).getIndex() );
subroutines.put(astore, sr);
}
@@ -422,10 +422,10 @@ public class Subroutines{
// since "Jsr 0" is disallowed in Pass 3a.
// Instructions shared by a subroutine and the toplevel are
// disallowed and checked below, after the BFS.
- for (InstructionHandle element : all) {
- Instruction inst = element.getInstruction();
+ for (final InstructionHandle element : all) {
+ final Instruction inst = element.getInstruction();
if (inst instanceof JsrInstruction) {
- InstructionHandle leader = ((JsrInstruction) inst).getTarget();
+ final InstructionHandle leader = ((JsrInstruction) inst).getTarget();
((SubroutineImpl) getSubroutine(leader)).addEnteringJsrInstruction(element);
}
}
@@ -433,16 +433,16 @@ public class Subroutines{
// Now do a BFS from every subroutine leader to find all the
// instructions that belong to a subroutine.
// we don't want to assign an instruction to two or more Subroutine objects.
- Set<InstructionHandle> instructions_assigned = new HashSet<>();
+ final Set<InstructionHandle> instructions_assigned = new HashSet<>();
//Graph colouring. Key: InstructionHandle, Value: ColourConstants enum .
- Map<InstructionHandle, ColourConstants> colors = new HashMap<>();
+ final Map<InstructionHandle, ColourConstants> colors = new HashMap<>();
- List<InstructionHandle> Q = new ArrayList<>();
- for (InstructionHandle actual : sub_leaders) {
+ final List<InstructionHandle> Q = new ArrayList<>();
+ for (final InstructionHandle actual : sub_leaders) {
// Do some BFS with "actual" as the root of the graph.
// Init colors
- for (InstructionHandle element : all) {
+ for (final InstructionHandle element : all) {
colors.put(element, ColourConstants.WHITE);
}
colors.put(actual, ColourConstants.GRAY);
@@ -458,7 +458,7 @@ public class Subroutines{
* TODO: Refer to the special JustIce notion of subroutines.]
*/
if (actual == all[0]) {
- for (CodeExceptionGen handler : handlers) {
+ for (final CodeExceptionGen handler : handlers) {
colors.put(handler.getHandlerPC(), ColourConstants.GRAY);
Q.add(handler.getHandlerPC());
}
@@ -467,9 +467,9 @@ public class Subroutines{
// Loop until Queue is empty
while (Q.size() != 0) {
- InstructionHandle u = Q.remove(0);
- InstructionHandle[] successors = getSuccessors(u);
- for (InstructionHandle successor : successors) {
+ final InstructionHandle u = Q.remove(0);
+ final InstructionHandle[] successors = getSuccessors(u);
+ for (final InstructionHandle successor : successors) {
if (colors.get(successor) == ColourConstants.WHITE) {
colors.put(successor, ColourConstants.GRAY);
Q.add(successor);
@@ -478,7 +478,7 @@ public class Subroutines{
colors.put(u, ColourConstants.BLACK);
}
// BFS ended above.
- for (InstructionHandle element : all) {
+ for (final InstructionHandle element : all) {
if (colors.get(element) == ColourConstants.BLACK) {
((SubroutineImpl) (actual==all[0]?getTopLevel():getSubroutine(actual))).addInstruction(element);
if (instructions_assigned.contains(element)) {
@@ -496,11 +496,11 @@ public class Subroutines{
if (enableJustIceCheck) {
// Now make sure no instruction of a Subroutine is protected by exception handling code
// as is mandated by JustIces notion of subroutines.
- for (CodeExceptionGen handler : handlers) {
+ for (final CodeExceptionGen handler : handlers) {
InstructionHandle _protected = handler.getStartPC();
while (_protected != handler.getEndPC().getNext()) {
// Note the inclusive/inclusive notation of "generic API" exception handlers!
- for (Subroutine sub : subroutines.values()) {
+ for (final Subroutine sub : subroutines.values()) {
if (sub != subroutines.get(all[0])) { // We don't want to forbid top-level exception handlers.
if (sub.contains(_protected)) {
throw new StructuralCodeConstraintException("Subroutine instruction '"+_protected+
@@ -536,14 +536,14 @@ public class Subroutines{
* @throws StructuralCodeConstraintException if the above constraint is not satisfied.
*/
private void noRecursiveCalls(final Subroutine sub, final Set<Integer> set) {
- Subroutine[] subs = sub.subSubs();
+ final Subroutine[] subs = sub.subSubs();
- for (Subroutine sub2 : subs) {
- int index = ((RET) (sub2.getLeavingRET().getInstruction())).getIndex();
+ for (final Subroutine sub2 : subs) {
+ final int index = ((RET) (sub2.getLeavingRET().getInstruction())).getIndex();
if (!set.add(Integer.valueOf(index))) {
// Don't use toString() here because of possibly infinite recursive subSubs() calls then.
- SubroutineImpl si = (SubroutineImpl) sub2;
+ final SubroutineImpl si = (SubroutineImpl) sub2;
throw new StructuralCodeConstraintException("Subroutine with local variable '"+si.localVariable+"', JSRs '"+
si.theJSRs+"', RET '"+si.theRET+
"' is called by a subroutine which uses the same local variable index as itself; maybe even a recursive call?"+
@@ -565,7 +565,7 @@ public class Subroutines{
* @see #getTopLevel()
*/
public Subroutine getSubroutine(final InstructionHandle leader) {
- Subroutine ret = subroutines.get(leader);
+ final Subroutine ret = subroutines.get(leader);
if (ret == null) {
throw new AssertionViolatedException(
@@ -591,7 +591,7 @@ public class Subroutines{
* @see #getTopLevel()
*/
public Subroutine subroutineOf(final InstructionHandle any) {
- for (Subroutine s : subroutines.values()) {
+ for (final Subroutine s : subroutines.values()) {
if (s.contains(any)) {
return s;
}
@@ -624,7 +624,7 @@ System.err.println("DEBUG: Please verify
final InstructionHandle[] empty = new InstructionHandle[0];
final InstructionHandle[] single = new InstructionHandle[1];
- Instruction inst = instruction.getInstruction();
+ final Instruction inst = instruction.getInstruction();
if (inst instanceof RET) {
return empty;
@@ -656,8 +656,8 @@ System.err.println("DEBUG: Please verify
if (inst instanceof Select) {
// BCEL's getTargets() returns only the non-default targets,
// thanks to Eli Tilevich for reporting.
- InstructionHandle[] matchTargets = ((Select) inst).getTargets();
- InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1];
+ final InstructionHandle[] matchTargets = ((Select) inst).getTargets();
+ final InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1];
ret[0] = ((Select) inst).getTarget();
System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length);
return ret;
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AbstractTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AbstractTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AbstractTestCase.java Tue Jun 21 20:50:19 2016
@@ -65,8 +65,8 @@ public abstract class AbstractTestCase e
protected Method getMethod(final JavaClass cl, final String methodname)
{
- Method[] methods = cl.getMethods();
- for (Method m : methods) {
+ final Method[] methods = cl.getMethods();
+ for (final Method m : methods) {
if (m.getName().equals(methodname))
{
return m;
@@ -94,9 +94,9 @@ public abstract class AbstractTestCase e
protected boolean wipe(final String dir, final String name)
{
// The parameter is relative to the TESTDATA dir
- boolean b = wipe(dir + File.separator + name);
+ final boolean b = wipe(dir + File.separator + name);
final File testDir = new File(TESTDATA, dir);
- String[] files = testDir.list();
+ final String[] files = testDir.list();
if (files == null || files.length == 0)
{
if (!testDir.delete()) {
@@ -110,16 +110,16 @@ public abstract class AbstractTestCase e
public SyntheticRepository createRepos(final String cpentry)
{
- ClassPath cp = new ClassPath("target" + File.separator + "testdata"
+ final ClassPath cp = new ClassPath("target" + File.separator + "testdata"
+ File.separator + cpentry + File.separator);
return SyntheticRepository.getInstance(cp);
}
protected Attribute[] findAttribute(final String name, final JavaClass clazz)
{
- Attribute[] all = clazz.getAttributes();
- List<Attribute> chosenAttrsList = new ArrayList<>();
- for (Attribute element : all) {
+ final Attribute[] all = clazz.getAttributes();
+ final List<Attribute> chosenAttrsList = new ArrayList<>();
+ for (final Attribute element : all) {
if (verbose) {
System.err.println("Attribute: " + element.getName());
}
@@ -132,8 +132,8 @@ public abstract class AbstractTestCase e
protected Attribute findAttribute(final String name, final Attribute[] all)
{
- List<Attribute> chosenAttrsList = new ArrayList<>();
- for (Attribute element : all) {
+ final List<Attribute> chosenAttrsList = new ArrayList<>();
+ for (final Attribute element : all) {
if (verbose) {
System.err.println("Attribute: " + element.getName());
}
@@ -148,11 +148,11 @@ public abstract class AbstractTestCase e
protected String dumpAttributes(final Attribute[] as)
{
- StringBuilder result = new StringBuilder();
+ final StringBuilder result = new StringBuilder();
result.append("AttributeArray:[");
for (int i = 0; i < as.length; i++)
{
- Attribute attr = as[i];
+ final Attribute attr = as[i];
result.append(attr.toString());
if (i + 1 < as.length) {
result.append(",");
@@ -164,11 +164,11 @@ public abstract class AbstractTestCase e
protected String dumpAnnotationEntries(final AnnotationEntry[] as)
{
- StringBuilder result = new StringBuilder();
+ final StringBuilder result = new StringBuilder();
result.append("[");
for (int i = 0; i < as.length; i++)
{
- AnnotationEntry annotation = as[i];
+ final AnnotationEntry annotation = as[i];
result.append(annotation.toShortString());
if (i + 1 < as.length) {
result.append(",");
@@ -180,11 +180,11 @@ public abstract class AbstractTestCase e
protected String dumpAnnotationEntries(final AnnotationEntryGen[] as)
{
- StringBuilder result = new StringBuilder();
+ final StringBuilder result = new StringBuilder();
result.append("[");
for (int i = 0; i < as.length; i++)
{
- AnnotationEntryGen annotation = as[i];
+ final AnnotationEntryGen annotation = as[i];
result.append(annotation.toShortString());
if (i + 1 < as.length) {
result.append(",");
@@ -197,11 +197,11 @@ public abstract class AbstractTestCase e
public AnnotationEntryGen createFruitAnnotationEntry(final ConstantPoolGen cp,
final String aFruit, final boolean visibility)
{
- 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, visibility, cp);
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationDefaultAttributeTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationDefaultAttributeTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationDefaultAttributeTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationDefaultAttributeTestCase.java Tue Jun 21 20:50:19 2016
@@ -33,11 +33,11 @@ public class AnnotationDefaultAttributeT
*/
public void testMethodAnnotations() throws ClassNotFoundException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.SimpleAnnotation");
- Method m = getMethod(clazz, "fruit");
- AnnotationDefault a = (AnnotationDefault) findAttribute(
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.SimpleAnnotation");
+ final Method m = getMethod(clazz, "fruit");
+ final AnnotationDefault a = (AnnotationDefault) findAttribute(
"AnnotationDefault", m.getAttributes());
- SimpleElementValue val = (SimpleElementValue) a.getDefaultValue();
+ final SimpleElementValue val = (SimpleElementValue) a.getDefaultValue();
assertTrue("Should be STRING but is " + val.getElementValueType(), val
.getElementValueType() == ElementValue.STRING);
assertTrue("Should have default of bananas but default is "
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnonymousClassTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnonymousClassTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnonymousClassTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnonymousClassTestCase.java Tue Jun 21 20:50:19 2016
@@ -24,7 +24,7 @@ public class AnonymousClassTestCase exte
{
public void testRegularClassIsNotAnonymous() throws ClassNotFoundException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest");
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest");
assertFalse("regular outer classes are not anonymous", clazz
.isAnonymous());
assertFalse("regular outer classes are not nested", clazz.isNested());
@@ -33,7 +33,7 @@ public class AnonymousClassTestCase exte
public void testNamedInnerClassIsNotAnonymous()
throws ClassNotFoundException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest$X");
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest$X");
assertFalse("regular inner classes are not anonymous", clazz
.isAnonymous());
assertTrue("regular inner classes are nested", clazz.isNested());
@@ -42,7 +42,7 @@ public class AnonymousClassTestCase exte
public void testStaticInnerClassIsNotAnonymous()
throws ClassNotFoundException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest$Y");
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest$Y");
assertFalse("regular static inner classes are not anonymous", clazz
.isAnonymous());
assertTrue("regular static inner classes are nested", clazz.isNested());
@@ -51,7 +51,7 @@ public class AnonymousClassTestCase exte
public void testAnonymousInnerClassIsAnonymous()
throws ClassNotFoundException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest$1");
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest$1");
assertTrue("anonymous inner classes are anonymous", clazz.isAnonymous());
assertTrue("anonymous inner classes are anonymous", clazz.isNested());
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/ElementValueGenTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/ElementValueGenTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/ElementValueGenTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/ElementValueGenTestCase.java Tue Jun 21 20:50:19 2016
@@ -45,9 +45,9 @@ public class ElementValueGenTestCase ext
*/
public void testCreateIntegerElementValue() throws Exception
{
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 555);
// Creation of an element like that should leave a new entry in the
// cpool
@@ -59,9 +59,9 @@ public class ElementValueGenTestCase ext
public void testCreateFloatElementValue() throws Exception
{
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_FLOAT, cp, 111.222f);
// Creation of an element like that should leave a new entry in the
// cpool
@@ -73,13 +73,13 @@ public class ElementValueGenTestCase ext
public void testCreateDoubleElementValue() throws Exception
{
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_DOUBLE, cp, 333.44);
// Creation of an element like that should leave a new entry in the
// cpool
- int idx = cp.lookupDouble(333.44);
+ final int idx = cp.lookupDouble(333.44);
assertTrue("Should have the same index in the constantpool but "
+ evg.getIndex() + "!=" + idx, evg.getIndex() == idx);
checkSerialize(evg, cp);
@@ -87,13 +87,13 @@ public class ElementValueGenTestCase ext
public void testCreateLongElementValue() throws Exception
{
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_LONG, cp, 3334455L);
// Creation of an element like that should leave a new entry in the
// cpool
- int idx = cp.lookupLong(3334455L);
+ final int idx = cp.lookupLong(3334455L);
assertTrue("Should have the same index in the constantpool but "
+ evg.getIndex() + "!=" + idx, evg.getIndex() == idx);
checkSerialize(evg, cp);
@@ -101,13 +101,13 @@ public class ElementValueGenTestCase ext
public void testCreateCharElementValue() throws Exception
{
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_CHAR, cp, 't');
// Creation of an element like that should leave a new entry in the
// cpool
- int idx = cp.lookupInteger('t');
+ final int idx = cp.lookupInteger('t');
assertTrue("Should have the same index in the constantpool but "
+ evg.getIndex() + "!=" + idx, evg.getIndex() == idx);
checkSerialize(evg, cp);
@@ -115,13 +115,13 @@ public class ElementValueGenTestCase ext
public void testCreateByteElementValue() throws Exception
{
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_CHAR, cp, (byte) 'z');
// Creation of an element like that should leave a new entry in the
// cpool
- int idx = cp.lookupInteger((byte) 'z');
+ final int idx = cp.lookupInteger((byte) 'z');
assertTrue("Should have the same index in the constantpool but "
+ evg.getIndex() + "!=" + idx, evg.getIndex() == idx);
checkSerialize(evg, cp);
@@ -129,13 +129,13 @@ public class ElementValueGenTestCase ext
public void testCreateBooleanElementValue() throws Exception
{
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_BOOLEAN, cp, true);
// Creation of an element like that should leave a new entry in the
// cpool
- int idx = cp.lookupInteger(1); // 1 == true
+ final int idx = cp.lookupInteger(1); // 1 == true
assertTrue("Should have the same index in the constantpool but "
+ evg.getIndex() + "!=" + idx, evg.getIndex() == idx);
checkSerialize(evg, cp);
@@ -143,13 +143,13 @@ public class ElementValueGenTestCase ext
public void testCreateShortElementValue() throws Exception
{
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_SHORT, cp, (short) 42);
// Creation of an element like that should leave a new entry in the
// cpool
- int idx = cp.lookupInteger(42);
+ final int idx = cp.lookupInteger(42);
assertTrue("Should have the same index in the constantpool but "
+ evg.getIndex() + "!=" + idx, evg.getIndex() == idx);
checkSerialize(evg, cp);
@@ -160,9 +160,9 @@ public class ElementValueGenTestCase ext
public void testCreateStringElementValue() throws Exception
{
// Create HelloWorld
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.STRING, cp, "hello");
// Creation of an element like that should leave a new entry in the
// cpool
@@ -176,11 +176,11 @@ public class ElementValueGenTestCase ext
// Create enum element value
public void testCreateEnumElementValue() throws Exception
{
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- ObjectType enumType = new ObjectType("SimpleEnum"); // Supports rainbow
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final ObjectType enumType = new ObjectType("SimpleEnum"); // Supports rainbow
// :)
- EnumElementValueGen evg = new EnumElementValueGen(enumType, "Red", cp);
+ final EnumElementValueGen evg = new EnumElementValueGen(enumType, "Red", cp);
// Creation of an element like that should leave a new entry in the
// cpool
assertTrue(
@@ -200,18 +200,18 @@ public class ElementValueGenTestCase ext
// Create class element value
public void testCreateClassElementValue() throws Exception
{
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
- ObjectType classType = new ObjectType("java.lang.Integer");
- ClassElementValueGen evg = new ClassElementValueGen(classType, cp);
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
+ final ObjectType classType = new ObjectType("java.lang.Integer");
+ final ClassElementValueGen evg = new ClassElementValueGen(classType, cp);
assertTrue("Unexpected value for contained class: '"
+ evg.getClassString() + "'", evg.getClassString().contains("Integer"));
checkSerialize(evg, cp);
}
private void checkSerialize(final ElementValueGen evgBefore, final ConstantPoolGen cpg) throws IOException {
- String beforeValue = evgBefore.stringifyValue();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final String beforeValue = evgBefore.stringifyValue();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (DataOutputStream dos = new DataOutputStream(baos)) {
evgBefore.dump(dos);
dos.flush();
@@ -220,7 +220,7 @@ public class ElementValueGenTestCase ext
try (DataInputStream dis = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
evgAfter = ElementValueGen.readElementValue(dis, cpg);
}
- String afterValue = evgAfter.stringifyValue();
+ final String afterValue = evgAfter.stringifyValue();
if (!beforeValue.equals(afterValue)) {
fail("Deserialization failed: before='" + beforeValue + "' after='" + afterValue + "'");
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/EnclosingMethodAttributeTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/EnclosingMethodAttributeTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/EnclosingMethodAttributeTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/EnclosingMethodAttributeTestCase.java Tue Jun 21 20:50:19 2016
@@ -37,14 +37,14 @@ public class EnclosingMethodAttributeTes
public void testCheckMethodLevelNamedInnerClass()
throws ClassNotFoundException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AttributeTestClassEM01$1S");
- ConstantPool pool = clazz.getConstantPool();
- Attribute[] encMethodAttrs = findAttribute("EnclosingMethod", clazz);
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AttributeTestClassEM01$1S");
+ final ConstantPool pool = clazz.getConstantPool();
+ final Attribute[] encMethodAttrs = findAttribute("EnclosingMethod", clazz);
assertTrue("Expected 1 EnclosingMethod attribute but found "
+ encMethodAttrs.length, encMethodAttrs.length == 1);
- EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
- String enclosingClassName = em.getEnclosingClass().getBytes(pool);
- String enclosingMethodName = em.getEnclosingMethod().getName(pool);
+ final EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
+ final String enclosingClassName = em.getEnclosingClass().getBytes(pool);
+ final String enclosingMethodName = em.getEnclosingMethod().getName(pool);
assertTrue(
"Expected class name to be '"+PACKAGE_BASE_SIG+"/data/AttributeTestClassEM01' but was "
+ enclosingClassName, enclosingClassName
@@ -60,13 +60,13 @@ public class EnclosingMethodAttributeTes
public void testCheckClassLevelNamedInnerClass()
throws ClassNotFoundException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AttributeTestClassEM02$1");
- ConstantPool pool = clazz.getConstantPool();
- Attribute[] encMethodAttrs = findAttribute("EnclosingMethod", clazz);
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AttributeTestClassEM02$1");
+ final ConstantPool pool = clazz.getConstantPool();
+ final Attribute[] encMethodAttrs = findAttribute("EnclosingMethod", clazz);
assertTrue("Expected 1 EnclosingMethod attribute but found "
+ encMethodAttrs.length, encMethodAttrs.length == 1);
- EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
- String enclosingClassName = em.getEnclosingClass().getBytes(pool);
+ final EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
+ final String enclosingClassName = em.getEnclosingClass().getBytes(pool);
assertTrue(
"The class is not within a method, so method_index should be null, but it is "
+ em.getEnclosingMethodIndex(), em
@@ -83,20 +83,20 @@ public class EnclosingMethodAttributeTes
public void testAttributeSerializtion() throws ClassNotFoundException,
IOException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AttributeTestClassEM02$1");
- ConstantPool pool = clazz.getConstantPool();
- Attribute[] encMethodAttrs = findAttribute("EnclosingMethod", clazz);
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AttributeTestClassEM02$1");
+ final ConstantPool pool = clazz.getConstantPool();
+ final Attribute[] encMethodAttrs = findAttribute("EnclosingMethod", clazz);
assertTrue("Expected 1 EnclosingMethod attribute but found "
+ encMethodAttrs.length, encMethodAttrs.length == 1);
// Write it out
- File tfile = createTestdataFile("AttributeTestClassEM02$1.class");
+ final File tfile = createTestdataFile("AttributeTestClassEM02$1.class");
clazz.dump(tfile);
// Read in the new version and check it is OK
- SyntheticRepository repos2 = createRepos(".");
- JavaClass clazz2 = repos2.loadClass("AttributeTestClassEM02$1");
+ final SyntheticRepository repos2 = createRepos(".");
+ final JavaClass clazz2 = repos2.loadClass("AttributeTestClassEM02$1");
Assert.assertNotNull(clazz2); // Use the variable to avoid a warning
- EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
- String enclosingClassName = em.getEnclosingClass().getBytes(pool);
+ final EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
+ final String enclosingClassName = em.getEnclosingClass().getBytes(pool);
assertTrue(
"The class is not within a method, so method_index should be null, but it is "
+ em.getEnclosingMethodIndex(), em
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/InstructionFinderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/InstructionFinderTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/InstructionFinderTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/InstructionFinderTestCase.java Tue Jun 21 20:50:19 2016
@@ -29,10 +29,10 @@ public class InstructionFinderTestCase e
{
public void testSearchAll() throws Exception
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".util.InstructionFinder");
- Method[] methods = clazz.getMethods();
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".util.InstructionFinder");
+ final Method[] methods = clazz.getMethods();
Method searchM = null;
- for (Method m : methods)
+ for (final Method m : methods)
{
if (m.getName().equals("search") && (m.getArgumentTypes().length == 3))
{
@@ -45,14 +45,14 @@ public class InstructionFinderTestCase e
throw new Exception("search method not found");
}
- byte[] bytes = searchM.getCode().getCode();
- InstructionList il = new InstructionList(bytes);
- InstructionFinder finder = new InstructionFinder(il);
- Iterator<?> it = finder.search(".*", il.getStart(), null);
+ final byte[] bytes = searchM.getCode().getCode();
+ final InstructionList il = new InstructionList(bytes);
+ final InstructionFinder finder = new InstructionFinder(il);
+ final Iterator<?> it = finder.search(".*", il.getStart(), null);
- InstructionHandle[] ihs = (InstructionHandle[])it.next();
+ final InstructionHandle[] ihs = (InstructionHandle[])it.next();
int size = 0;
- for (InstructionHandle ih : ihs)
+ for (final InstructionHandle ih : ihs)
{
size += ih.getInstruction().getLength();
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PLSETestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PLSETestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PLSETestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PLSETestCase.java Tue Jun 21 20:50:19 2016
@@ -34,11 +34,11 @@ public class PLSETestCase extends Abstra
*/
public void testB208() throws ClassNotFoundException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.PLSETestClass");
- ClassGen gen = new ClassGen(clazz);
- ConstantPoolGen pool = gen.getConstantPool();
- Method m = gen.getMethodAt(1);
- MethodGen mg = new MethodGen(m, gen.getClassName(), pool);
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.PLSETestClass");
+ final ClassGen gen = new ClassGen(clazz);
+ final ConstantPoolGen pool = gen.getConstantPool();
+ final Method m = gen.getMethodAt(1);
+ final MethodGen mg = new MethodGen(m, gen.getClassName(), pool);
mg.setInstructionList(null);
mg.addLocalVariable("local2", Type.INT, null, null);
// currently, this will cause null pointer exception
@@ -50,15 +50,15 @@ public class PLSETestCase extends Abstra
*/
public void testB79() throws ClassNotFoundException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.PLSETestClass");
- ClassGen gen = new ClassGen(clazz);
- ConstantPoolGen pool = gen.getConstantPool();
- Method m = gen.getMethodAt(2);
- LocalVariableTable lvt = m.getLocalVariableTable();
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.PLSETestClass");
+ final ClassGen gen = new ClassGen(clazz);
+ final ConstantPoolGen pool = gen.getConstantPool();
+ final Method m = gen.getMethodAt(2);
+ final LocalVariableTable lvt = m.getLocalVariableTable();
//System.out.println(lvt);
//System.out.println(lvt.getTableLength());
- MethodGen mg = new MethodGen(m, gen.getClassName(), pool);
- LocalVariableTable new_lvt = mg.getLocalVariableTable(mg.getConstantPool());
+ final MethodGen mg = new MethodGen(m, gen.getClassName(), pool);
+ final LocalVariableTable new_lvt = mg.getLocalVariableTable(mg.getConstantPool());
//System.out.println(new_lvt);
assertEquals("number of locals", lvt.getTableLength(), new_lvt.getTableLength());
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PerformanceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PerformanceTest.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PerformanceTest.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/PerformanceTest.java Tue Jun 21 20:50:19 2016
@@ -48,10 +48,10 @@ public final class PerformanceTest exten
byte[] b = new byte[is.available()];
int len = 0;
while (true) {
- int n = is.read(b, len, b.length - len);
+ final int n = is.read(b, len, b.length - len);
if (n == -1) {
if (len < b.length) {
- byte[] c = new byte[len];
+ final byte[] c = new byte[len];
System.arraycopy(b, 0, c, 0, len);
b = c;
}
@@ -59,7 +59,7 @@ public final class PerformanceTest exten
}
len += n;
if (len == b.length) {
- byte[] c = new byte[b.length + 1000];
+ final byte[] c = new byte[b.length + 1000];
System.arraycopy(b, 0, c, 0, len);
b = c;
}
@@ -67,21 +67,21 @@ public final class PerformanceTest exten
}
private static void test(final File lib) throws IOException {
- NanoTimer total = new NanoTimer();
- NanoTimer parseTime = new NanoTimer();
- NanoTimer cgenTime = new NanoTimer();
- NanoTimer mgenTime = new NanoTimer();
- NanoTimer mserTime = new NanoTimer();
- NanoTimer serTime = new NanoTimer();
+ final NanoTimer total = new NanoTimer();
+ final NanoTimer parseTime = new NanoTimer();
+ final NanoTimer cgenTime = new NanoTimer();
+ final NanoTimer mgenTime = new NanoTimer();
+ final NanoTimer mserTime = new NanoTimer();
+ final NanoTimer serTime = new NanoTimer();
System.out.println("parsing " + lib);
total.start();
try (JarFile jar = new JarFile(lib)) {
- Enumeration<?> en = jar.entries();
+ final Enumeration<?> en = jar.entries();
while (en.hasMoreElements()) {
- JarEntry e = (JarEntry) en.nextElement();
+ final JarEntry e = (JarEntry) en.nextElement();
if (e.getName().endsWith(".class")) {
byte[] bytes;
try (InputStream in = jar.getInputStream(e)) {
@@ -89,18 +89,18 @@ public final class PerformanceTest exten
}
parseTime.start();
- JavaClass clazz = new ClassParser(new ByteArrayInputStream(bytes), e.getName()).parse();
+ final JavaClass clazz = new ClassParser(new ByteArrayInputStream(bytes), e.getName()).parse();
parseTime.stop();
cgenTime.start();
- ClassGen cg = new ClassGen(clazz);
+ final ClassGen cg = new ClassGen(clazz);
cgenTime.stop();
- Method[] methods = cg.getMethods();
- for (Method m : methods) {
+ final Method[] methods = cg.getMethods();
+ for (final Method m : methods) {
mgenTime.start();
- MethodGen mg = new MethodGen(m, cg.getClassName(), cg.getConstantPool());
- InstructionList il = mg.getInstructionList();
+ final MethodGen mg = new MethodGen(m, cg.getClassName(), cg.getConstantPool());
+ final InstructionList il = mg.getInstructionList();
mgenTime.stop();
mserTime.start();
@@ -132,7 +132,7 @@ public final class PerformanceTest exten
}
public void testPerformance() {
- File javaLib = new File(System.getProperty("java.home") + "/lib");
+ final File javaLib = new File(System.getProperty("java.home") + "/lib");
javaLib.listFiles(new FileFilter() {
@Override
@@ -140,7 +140,7 @@ public final class PerformanceTest exten
if(file.getName().endsWith(".jar")) {
try {
test(file);
- } catch (IOException e) {
+ } catch (final IOException e) {
Assert.fail(e.getMessage());
}
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/classfile/JDKClassDumpTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/classfile/JDKClassDumpTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/classfile/JDKClassDumpTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/classfile/JDKClassDumpTestCase.java Tue Jun 21 20:50:19 2016
@@ -39,7 +39,7 @@ public class JDKClassDumpTestCase {
@Test
public void testPerformance() throws Exception {
- File javaLib = new File(System.getProperty("java.home") + "/lib");
+ final File javaLib = new File(System.getProperty("java.home") + "/lib");
javaLib.listFiles(new FileFilter() {
@Override
@@ -47,7 +47,7 @@ public class JDKClassDumpTestCase {
if (file.getName().endsWith(".jar")) {
try {
testJar(file);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail(e.getMessage());
}
}
@@ -60,15 +60,15 @@ public class JDKClassDumpTestCase {
private void testJar(final File file) throws Exception {
System.out.println("parsing " + 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("parsing " + name);
try (InputStream in = jar.getInputStream(e)) {
- ClassParser parser = new ClassParser(in, name);
- JavaClass jc = parser.parse();
+ final ClassParser parser = new ClassParser(in, name);
+ final JavaClass jc = parser.parse();
compare(jc, jar.getInputStream(e), name);
}
}
@@ -83,8 +83,8 @@ public class JDKClassDumpTestCase {
}
try (DataInputStream src = new DataInputStream(inputStream)) {
int i = 0;
- for (int out : baos.toByteArray()) {
- int in = src.read();
+ for (final int out : baos.toByteArray()) {
+ final int in = src.read();
assertEquals(name + ": Mismatch at " + i, in, out & 0xFF);
i++;
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/data/PLSETestClass.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/data/PLSETestClass.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/data/PLSETestClass.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/data/PLSETestClass.java Tue Jun 21 20:50:19 2016
@@ -25,12 +25,14 @@ public class PLSETestClass
public void meth1(final int arg1)
{
@SuppressWarnings("unused")
+ final
int local1 = arg1;
}
public void meth2(final int arg1, final ArrayList<String> arg2, final int arg3)
{
@SuppressWarnings("unused")
+ final
int local1 = arg1;
}
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/AnnotationGenTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/AnnotationGenTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/AnnotationGenTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/AnnotationGenTestCase.java Tue Jun 21 20:50:19 2016
@@ -46,24 +46,24 @@ public class AnnotationGenTestCase exten
public void testConstructMutableAnnotation()
{
// Create the containing class
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
// Create the simple primitive value '4' of type 'int'
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 4);
// Give it a name, call it 'id'
- ElementValuePairGen nvGen = new ElementValuePairGen("id", evg,
+ final ElementValuePairGen nvGen = new ElementValuePairGen("id", evg,
cp);
// Check it looks right
assertTrue(
"Should include string 'id=4' but says: " + nvGen.toString(),
nvGen.toString().contains("id=4"));
- ObjectType t = new ObjectType("SimpleAnnotation");
- List<ElementValuePairGen> elements = new ArrayList<>();
+ final ObjectType t = new ObjectType("SimpleAnnotation");
+ final List<ElementValuePairGen> elements = new ArrayList<>();
elements.add(nvGen);
// Build an annotation of type 'SimpleAnnotation' with 'id=4' as the
// only value :)
- AnnotationEntryGen a = new AnnotationEntryGen(t, elements, true, cp);
+ final AnnotationEntryGen a = new AnnotationEntryGen(t, elements, true, cp);
// Check we can save and load it ok
checkSerialize(a, cp);
}
@@ -71,29 +71,29 @@ public class AnnotationGenTestCase exten
public void testVisibleInvisibleAnnotationGen()
{
// Create the containing class
- ClassGen cg = createClassGen("HelloWorld");
- ConstantPoolGen cp = cg.getConstantPool();
+ final ClassGen cg = createClassGen("HelloWorld");
+ final ConstantPoolGen cp = cg.getConstantPool();
// Create the simple primitive value '4' of type 'int'
- SimpleElementValueGen evg = new SimpleElementValueGen(
+ final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 4);
// Give it a name, call it 'id'
- ElementValuePairGen nvGen = new ElementValuePairGen("id", evg,
+ final ElementValuePairGen nvGen = new ElementValuePairGen("id", evg,
cp);
// Check it looks right
assertTrue(
"Should include string 'id=4' but says: " + nvGen.toString(),
nvGen.toString().contains("id=4"));
- ObjectType t = new ObjectType("SimpleAnnotation");
- List<ElementValuePairGen> elements = new ArrayList<>();
+ final ObjectType t = new ObjectType("SimpleAnnotation");
+ final List<ElementValuePairGen> elements = new ArrayList<>();
elements.add(nvGen);
// Build a RV annotation of type 'SimpleAnnotation' with 'id=4' as the
// only value :)
- AnnotationEntryGen a = new AnnotationEntryGen(t, elements, true, cp);
- List<AnnotationEntryGen> v = new ArrayList<>();
+ final AnnotationEntryGen a = new AnnotationEntryGen(t, elements, true, cp);
+ final List<AnnotationEntryGen> v = new ArrayList<>();
v.add(a);
- Attribute[] attributes = AnnotationEntryGen.getAnnotationAttributes(cp, v.toArray(new AnnotationEntryGen[0]));
+ final Attribute[] attributes = AnnotationEntryGen.getAnnotationAttributes(cp, v.toArray(new AnnotationEntryGen[0]));
boolean foundRV = false;
- for (Attribute attribute : attributes) {
+ for (final Attribute attribute : attributes) {
if (attribute instanceof RuntimeVisibleAnnotations)
{
assertTrue(((Annotations) attribute).isRuntimeVisible());
@@ -103,12 +103,12 @@ public class AnnotationGenTestCase exten
assertTrue("Should have seen a RuntimeVisibleAnnotation", foundRV);
// Build a RIV annotation of type 'SimpleAnnotation' with 'id=4' as the
// only value :)
- AnnotationEntryGen a2 = new AnnotationEntryGen(t, elements, false, cp);
- List<AnnotationEntryGen> v2 = new ArrayList<>();
+ final AnnotationEntryGen a2 = new AnnotationEntryGen(t, elements, false, cp);
+ final List<AnnotationEntryGen> v2 = new ArrayList<>();
v2.add(a2);
- Attribute[] attributes2 = AnnotationEntryGen.getAnnotationAttributes(cp, v2.toArray(new AnnotationEntryGen[0]));
+ final Attribute[] attributes2 = AnnotationEntryGen.getAnnotationAttributes(cp, v2.toArray(new AnnotationEntryGen[0]));
boolean foundRIV = false;
- for (Attribute attribute : attributes2) {
+ for (final Attribute attribute : attributes2) {
if (attribute instanceof RuntimeInvisibleAnnotations)
{
assertFalse(((Annotations) attribute).isRuntimeVisible());
@@ -122,19 +122,19 @@ public class AnnotationGenTestCase exten
{
try
{
- String beforeName = a.getTypeName();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final String beforeName = a.getTypeName();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (DataOutputStream dos = new DataOutputStream(baos)) {
a.dump(dos);
dos.flush();
}
- byte[] bs = baos.toByteArray();
- ByteArrayInputStream bais = new ByteArrayInputStream(bs);
+ final byte[] bs = baos.toByteArray();
+ final ByteArrayInputStream bais = new ByteArrayInputStream(bs);
AnnotationEntryGen annAfter;
try (DataInputStream dis = new DataInputStream(bais)) {
annAfter = AnnotationEntryGen.read(dis, cpg, a.isRuntimeVisible());
}
- String afterName = annAfter.getTypeName();
+ final String afterName = annAfter.getTypeName();
if (!beforeName.equals(afterName))
{
fail("Deserialization failed: before type='" + beforeName
@@ -148,8 +148,8 @@ public class AnnotationGenTestCase exten
}
for (int i = 0; i < a.getValues().size(); i++)
{
- ElementValuePairGen beforeElement = a.getValues().get(i);
- ElementValuePairGen afterElement = annAfter.getValues().get(i);
+ final ElementValuePairGen beforeElement = a.getValues().get(i);
+ final ElementValuePairGen afterElement = annAfter.getValues().get(i);
if (!beforeElement.getNameString().equals(
afterElement.getNameString()))
{
@@ -158,7 +158,7 @@ public class AnnotationGenTestCase exten
}
}
}
- catch (IOException ioe)
+ catch (final IOException ioe)
{
fail("Unexpected exception whilst checking serialization: " + ioe);
}
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/BranchHandleTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/BranchHandleTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/BranchHandleTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/BranchHandleTestCase.java Tue Jun 21 20:50:19 2016
@@ -25,7 +25,7 @@ public class BranchHandleTestCase {
// Test that setInstruction only allows BranchInstructions
@Test(expected=ClassGenException.class)
public void testsetInstructionNull() {
- BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null));// have to start with a valid BI
+ final BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null));// have to start with a valid BI
Assert.assertNotNull(bh);
bh.setInstruction(null);
Assert.assertNotNull(bh);
@@ -33,7 +33,7 @@ public class BranchHandleTestCase {
@Test
public void testsetInstructionBI() {
- BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null));// have to start with a valid BI
+ final BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null));// have to start with a valid BI
Assert.assertNotNull(bh);
bh.setInstruction(new GOTO(null));
Assert.assertNotNull(bh);
@@ -41,7 +41,7 @@ public class BranchHandleTestCase {
@Test(expected=ClassGenException.class)
public void testsetInstructionnotBI() {
- BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null));// have to start with a valid BI
+ final BranchHandle bh = BranchHandle.getBranchHandle(new GOTO(null));// have to start with a valid BI
Assert.assertNotNull(bh);
bh.setInstruction(new NOP());
Assert.assertNotNull(bh);
Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java?rev=1749603&r1=1749602&r2=1749603&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/generic/FieldAnnotationsTestCase.java Tue Jun 21 20:50:19 2016
@@ -35,7 +35,7 @@ public class FieldAnnotationsTestCase ex
*/
public void testFieldAnnotationEntrys() throws ClassNotFoundException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnnotatedFields");
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnnotatedFields");
// TODO L...;?
checkAnnotatedField(clazz, "i", "L"+PACKAGE_BASE_SIG+"/data/SimpleAnnotation;", "id", "1");
checkAnnotatedField(clazz, "s", "L"+PACKAGE_BASE_SIG+"/data/SimpleAnnotation;", "id", "2");
@@ -47,13 +47,13 @@ public class FieldAnnotationsTestCase ex
public void testFieldAnnotationEntrysReadWrite() throws ClassNotFoundException,
IOException
{
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnnotatedFields");
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnnotatedFields");
checkAnnotatedField(clazz, "i", "L"+PACKAGE_BASE_SIG+"/data/SimpleAnnotation;", "id", "1");
checkAnnotatedField(clazz, "s", "L"+PACKAGE_BASE_SIG+"/data/SimpleAnnotation;", "id", "2");
// Write it out
- File tfile = createTestdataFile("AnnotatedFields.class");
+ final File tfile = createTestdataFile("AnnotatedFields.class");
clazz.dump(tfile);
- SyntheticRepository repos2 = createRepos(".");
+ final SyntheticRepository repos2 = createRepos(".");
repos2.loadClass("AnnotatedFields");
checkAnnotatedField(clazz, "i", "L"+PACKAGE_BASE_SIG+"/data/SimpleAnnotation;", "id", "1");
checkAnnotatedField(clazz, "s", "L"+PACKAGE_BASE_SIG+"/data/SimpleAnnotation;", "id", "2");
@@ -67,9 +67,9 @@ public class FieldAnnotationsTestCase ex
public void testFieldAnnotationModification()
throws ClassNotFoundException
{
- boolean dbg = false;
- JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnnotatedFields");
- ClassGen clg = new ClassGen(clazz);
+ final boolean dbg = false;
+ final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnnotatedFields");
+ final ClassGen clg = new ClassGen(clazz);
Field f = clg.getFields()[0];
if (dbg) {
System.err.println("Field in freshly constructed class is: " + f);
@@ -78,9 +78,9 @@ public class FieldAnnotationsTestCase ex
System.err.println("AnnotationEntrys on field are: "
+ dumpAnnotationEntries(f.getAnnotationEntries()));
}
- AnnotationEntryGen fruitBasedAnnotationEntry = createFruitAnnotationEntry(clg
+ final AnnotationEntryGen fruitBasedAnnotationEntry = createFruitAnnotationEntry(clg
.getConstantPool(), "Tomato", false);
- FieldGen fg = new FieldGen(f, clg.getConstantPool());
+ final FieldGen fg = new FieldGen(f, clg.getConstantPool());
if (dbg) {
System.err.println("Adding AnnotationEntry to the field");
}
@@ -117,9 +117,9 @@ public class FieldAnnotationsTestCase ex
final String AnnotationEntryName, final String AnnotationEntryElementName,
final String AnnotationEntryElementValue)
{
- Field[] fields = clazz.getFields();
- for (Field f : fields) {
- AnnotationEntry[] fieldAnnotationEntrys = f.getAnnotationEntries();
+ final Field[] fields = clazz.getFields();
+ for (final Field f : fields) {
+ final AnnotationEntry[] fieldAnnotationEntrys = f.getAnnotationEntries();
if (f.getName().equals(fieldname))
{
checkAnnotationEntry(fieldAnnotationEntrys[0], AnnotationEntryName,
@@ -136,7 +136,7 @@ public class FieldAnnotationsTestCase ex
.equals(name));
assertTrue("Expected AnnotationEntry to have one element but it had "
+ a.getElementValuePairs().length, a.getElementValuePairs().length == 1);
- ElementValuePair envp = a.getElementValuePairs()[0];
+ final ElementValuePair envp = a.getElementValuePairs()[0];
assertTrue("Expected element name " + elementname + " but was "
+ envp.getNameString(), elementname
.equals(envp.getNameString()));
@@ -150,7 +150,7 @@ public class FieldAnnotationsTestCase ex
{
for (int i = 0; i < a.getElementValuePairs().length; i++)
{
- ElementValuePair element = a.getElementValuePairs()[i];
+ final ElementValuePair element = a.getElementValuePairs()[i];
if (element.getNameString().equals(name))
{
if (!element.getValue().stringifyValue().equals(tostring))