commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1554576 [2/2] - in /commons/proper/bcel/trunk/src: 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/bcel/verifier/statics/ main...
Date Tue, 31 Dec 2013 22:05:02 GMT
Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java?rev=1554576&r1=1554575&r2=1554576&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
Tue Dec 31 22:05:01 2013
@@ -261,14 +261,14 @@ public final class Pass3aVerifier extend
 		/* We cannot use code.getLocalVariableTable() because there could be more
 		   than only one. This is a bug in BCEL. */
 		Attribute[] atts = code.getAttributes();
-		for (int a=0; a<atts.length; a++){
-			if (atts[a] instanceof LocalVariableTable){
-				LocalVariableTable lvt = (LocalVariableTable) atts[a];
+		for (Attribute att : atts) {
+			if (att instanceof LocalVariableTable){
+				LocalVariableTable lvt = (LocalVariableTable) att;
 				if (lvt != null){
 					LocalVariable[] localVariables = lvt.getLocalVariableTable();
-					for (int i=0; i<localVariables.length; i++){
-						int startpc = localVariables[i].getStartPC();
-						int length  = localVariables[i].getLength();
+					for (LocalVariable localVariable : localVariables) {
+						int startpc = localVariable.getStartPC();
+						int length  = localVariable.getLength();
 				
 						if (!contains(instructionPositions, startpc)){
 							throw new ClassConstraintException("Code attribute '"+code+"' has a LocalVariableTable
attribute '"+code.getLocalVariableTable()+"' referring to a code offset ('"+startpc+"') that
does not exist.");
@@ -288,21 +288,21 @@ public final class Pass3aVerifier extend
 		// inclusive/exclusive as in the Java Virtual Machine Specification.
 		// WARNING: This is not true for BCEL's "generic" API.
 		CodeException[] exceptionTable = code.getExceptionTable();
-		for (int i=0; i<exceptionTable.length; i++){
-			int startpc = exceptionTable[i].getStartPC();
-			int endpc = exceptionTable[i].getEndPC();
-			int handlerpc = exceptionTable[i].getHandlerPC();
+		for (CodeException element : exceptionTable) {
+			int startpc = element.getStartPC();
+			int endpc = element.getEndPC();
+			int handlerpc = element.getHandlerPC();
 			if (startpc >= endpc){
-				throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table
entry '"+exceptionTable[i]+"' that has its start_pc ('"+startpc+"') not smaller than its end_pc
('"+endpc+"').");
+				throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table
entry '"+element+"' that has its start_pc ('"+startpc+"') not smaller than its end_pc ('"+endpc+"').");
 			}
 			if (!contains(instructionPositions, startpc)){
-				throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table
entry '"+exceptionTable[i]+"' that has a non-existant bytecode offset as its start_pc ('"+startpc+"').");
+				throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table
entry '"+element+"' that has a non-existant bytecode offset as its start_pc ('"+startpc+"').");
 			}
 			if ( (!contains(instructionPositions, endpc)) && (endpc != codeLength)){
-				throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table
entry '"+exceptionTable[i]+"' that has a non-existant bytecode offset as its end_pc ('"+startpc+"')
[that is also not equal to code_length ('"+codeLength+"')].");
+				throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table
entry '"+element+"' that has a non-existant bytecode offset as its end_pc ('"+startpc+"')
[that is also not equal to code_length ('"+codeLength+"')].");
 			}
 			if (!contains(instructionPositions, handlerpc)){
-				throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table
entry '"+exceptionTable[i]+"' that has a non-existant bytecode offset as its handler_pc ('"+handlerpc+"').");
+				throw new ClassConstraintException("Code attribute '"+code+"' has an exception_table
entry '"+element+"' that has a non-existant bytecode offset as its handler_pc ('"+handlerpc+"').");
 			}
 		}
 	}
@@ -423,8 +423,8 @@ public final class Pass3aVerifier extend
 	
 	/** A small utility method returning if a given int i is in the given int[] ints. */
 	private static boolean contains(int[] ints, int i){
-		for (int j=0; j<ints.length; j++){
-			if (ints[j]==i) {
+		for (int k : ints) {
+			if (k==i) {
                 return true;
             }
 		}
@@ -557,15 +557,15 @@ public final class Pass3aVerifier extend
 			JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
 			Field[] fields = jc.getFields();
 			Field f = null;
-			for (int i=0; i<fields.length; i++){
-				if (fields[i].getName().equals(field_name)){
-				  Type f_type = Type.getType(fields[i].getSignature());
+			for (Field field : fields) {
+				if (field.getName().equals(field_name)){
+				  Type f_type = Type.getType(field.getSignature());
 				  Type o_type = o.getType(cpg);
 					/* TODO: Check if assignment compatibility is sufficient.
 				   * What does Sun do?
 				   */
 				  if (f_type.equals(o_type)){
-						f = fields[i];
+						f = field;
 						break;
 					}
 				}
@@ -674,8 +674,8 @@ public final class Pass3aVerifier extend
 			}
 			
 			Type[] ts = o.getArgumentTypes(cpg);
-			for (int i=0; i<ts.length; i++){
-				t = ts[i];
+			for (Type element : ts) {
+				t = element;
 				if (t instanceof ArrayType){
 					t = ((ArrayType) t).getBasicType();
 				}
@@ -998,9 +998,9 @@ public final class Pass3aVerifier extend
 			JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
 			Field[] fields = jc.getFields();
 			Field f = null;
-			for (int i=0; i<fields.length; i++){
-				if (fields[i].getName().equals(field_name)){
-					f = fields[i];
+			for (Field field : fields) {
+				if (field.getName().equals(field_name)){
+					f = field;
 					break;
 				}
 			}
@@ -1038,9 +1038,9 @@ public final class Pass3aVerifier extend
 			JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
 			Field[] fields = jc.getFields();
 			Field f = null;
-			for (int i=0; i<fields.length; i++){
-				if (fields[i].getName().equals(field_name)){
-					f = fields[i];
+			for (Field field : fields) {
+				if (field.getName().equals(field_name)){
+					f = field;
 					break;
 				}
 			}
@@ -1079,11 +1079,11 @@ public final class Pass3aVerifier extend
 			JavaClass jc = Repository.lookupClass(classname);
 			Method[] ms = jc.getMethods();
 			Method m = null;
-			for (int i=0; i<ms.length; i++){
-				if ( (ms[i].getName().equals(o.getMethodName(cpg))) &&
-				     (Type.getReturnType(ms[i].getSignature()).equals(o.getReturnType(cpg))) &&
-				     (objarrayequals(Type.getArgumentTypes(ms[i].getSignature()), o.getArgumentTypes(cpg)))
){
-					m = ms[i];
+			for (Method element : ms) {
+				if ( (element.getName().equals(o.getMethodName(cpg))) &&
+				     (Type.getReturnType(element.getSignature()).equals(o.getReturnType(cpg))) &&
+				     (objarrayequals(Type.getArgumentTypes(element.getSignature()), o.getArgumentTypes(cpg)))
){
+					m = element;
 					break;
 				}
 			}
@@ -1111,11 +1111,11 @@ public final class Pass3aVerifier extend
 			JavaClass jc = Repository.lookupClass(classname);
 			Method[] ms = jc.getMethods();
 			Method m = null;
-			for (int i=0; i<ms.length; i++){
-				if ( (ms[i].getName().equals(o.getMethodName(cpg))) &&
-				     (Type.getReturnType(ms[i].getSignature()).equals(o.getReturnType(cpg))) &&
-				     (objarrayequals(Type.getArgumentTypes(ms[i].getSignature()), o.getArgumentTypes(cpg)))
){
-					m = ms[i];
+			for (Method element : ms) {
+				if ( (element.getName().equals(o.getMethodName(cpg))) &&
+				     (Type.getReturnType(element.getSignature()).equals(o.getReturnType(cpg))) &&
+				     (objarrayequals(Type.getArgumentTypes(element.getSignature()), o.getArgumentTypes(cpg)))
){
+					m = element;
 					break;
 				}
 			}
@@ -1139,11 +1139,11 @@ public final class Pass3aVerifier extend
 							current = Repository.lookupClass(current.getSuperclassName());
 							
 							Method[] meths = current.getMethods();
-							for (int i=0; i<meths.length; i++){
-								if	( (meths[i].getName().equals(o.getMethodName(cpg))) &&
-				     				(Type.getReturnType(meths[i].getSignature()).equals(o.getReturnType(cpg))) &&
-				     				(objarrayequals(Type.getArgumentTypes(meths[i].getSignature()), o.getArgumentTypes(cpg)))
){
-									meth = meths[i];
+							for (Method meth2 : meths) {
+								if	( (meth2.getName().equals(o.getMethodName(cpg))) &&
+				     				(Type.getReturnType(meth2.getSignature()).equals(o.getReturnType(cpg))) &&
+				     				(objarrayequals(Type.getArgumentTypes(meth2.getSignature()), o.getArgumentTypes(cpg)))
){
+									meth = meth2;
 									break;
 								}
 							}
@@ -1177,11 +1177,11 @@ public final class Pass3aVerifier extend
 			JavaClass jc = Repository.lookupClass(classname);
 			Method[] ms = jc.getMethods();
 			Method m = null;
-			for (int i=0; i<ms.length; i++){
-				if ( (ms[i].getName().equals(o.getMethodName(cpg))) &&
-				     (Type.getReturnType(ms[i].getSignature()).equals(o.getReturnType(cpg))) &&
-				     (objarrayequals(Type.getArgumentTypes(ms[i].getSignature()), o.getArgumentTypes(cpg)))
){
-					m = ms[i];
+			for (Method element : ms) {
+				if ( (element.getName().equals(o.getMethodName(cpg))) &&
+				     (Type.getReturnType(element.getSignature()).equals(o.getReturnType(cpg))) &&
+				     (objarrayequals(Type.getArgumentTypes(element.getSignature()), o.getArgumentTypes(cpg)))
){
+					m = element;
 					break;
 				}
 			}
@@ -1210,11 +1210,11 @@ public final class Pass3aVerifier extend
 			JavaClass jc = Repository.lookupClass(classname);
 			Method[] ms = jc.getMethods();
 			Method m = null;
-			for (int i=0; i<ms.length; i++){
-				if ( (ms[i].getName().equals(o.getMethodName(cpg))) &&
-				     (Type.getReturnType(ms[i].getSignature()).equals(o.getReturnType(cpg))) &&
-				     (objarrayequals(Type.getArgumentTypes(ms[i].getSignature()), o.getArgumentTypes(cpg)))
){
-					m = ms[i];
+			for (Method element : ms) {
+				if ( (element.getName().equals(o.getMethodName(cpg))) &&
+				     (Type.getReturnType(element.getSignature()).equals(o.getReturnType(cpg))) &&
+				     (objarrayequals(Type.getArgumentTypes(element.getSignature()), o.getArgumentTypes(cpg)))
){
+					m = element;
 					break;
 				}
 			}

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java?rev=1554576&r1=1554575&r2=1554576&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java
Tue Dec 31 22:05:01 2013
@@ -414,8 +414,8 @@ public class ControlFlowGraph{
 		exceptionhandlers = new ExceptionHandlers(method_gen);
 
 		InstructionHandle[] instructionhandles = method_gen.getInstructionList().getInstructionHandles();
-		for (int i=0; i<instructionhandles.length; i++){
-			instructionContexts.put(instructionhandles[i], new InstructionContextImpl(instructionhandles[i]));
+		for (InstructionHandle instructionhandle : instructionhandles) {
+			instructionContexts.put(instructionhandle, new InstructionContextImpl(instructionhandle));
 		}
 		
 		//this.method_gen = method_gen;

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java?rev=1554576&r1=1554575&r2=1554576&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java
Tue Dec 31 22:05:01 2013
@@ -46,9 +46,9 @@ public class ExceptionHandlers{
 	public ExceptionHandlers(MethodGen mg){
 		exceptionhandlers = new HashMap<InstructionHandle, Set<ExceptionHandler>>();
 		CodeExceptionGen[] cegs = mg.getExceptionHandlers();
-		for (int i=0; i<cegs.length; i++){
-			ExceptionHandler eh = new ExceptionHandler(cegs[i].getCatchType(), cegs[i].getHandlerPC());
-			for (InstructionHandle ih=cegs[i].getStartPC(); ih != cegs[i].getEndPC().getNext(); ih=ih.getNext()){
+		for (CodeExceptionGen ceg : cegs) {
+			ExceptionHandler eh = new ExceptionHandler(ceg.getCatchType(), ceg.getHandlerPC());
+			for (InstructionHandle ih=ceg.getStartPC(); ih != ceg.getEndPC().getNext(); ih=ih.getNext()){
 				Set<ExceptionHandler> hs;
 				hs = exceptionhandlers.get(ih);
 				if (hs == null){

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java?rev=1554576&r1=1554575&r2=1554576&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
Tue Dec 31 22:05:01 2013
@@ -1236,15 +1236,15 @@ public class InstConstraintVisitor exten
 		JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
 		Field[] fields = jc.getFields();
 		Field f = null;
-		for (int i=0; i<fields.length; i++){
-			if (fields[i].getName().equals(field_name)){
-				  Type f_type = Type.getType(fields[i].getSignature());
+		for (Field field : fields) {
+			if (field.getName().equals(field_name)){
+				  Type f_type = Type.getType(field.getSignature());
 				  Type o_type = o.getType(cpg);
 					/* TODO: Check if assignment compatibility is sufficient.
 				   * What does Sun do?
 				   */
 				  if (f_type.equals(o_type)){
-						f = fields[i];
+						f = field;
 						break;
 					}
 			}
@@ -2639,15 +2639,15 @@ public class InstConstraintVisitor exten
 		JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
 		Field[] fields = jc.getFields();
 		Field f = null;
-		for (int i=0; i<fields.length; i++){
-			if (fields[i].getName().equals(field_name)){
-				  Type f_type = Type.getType(fields[i].getSignature());
+		for (Field field : fields) {
+			if (field.getName().equals(field_name)){
+				  Type f_type = Type.getType(field.getSignature());
 				  Type o_type = o.getType(cpg);
 					/* TODO: Check if assignment compatibility is sufficient.
 				   * What does Sun do?
 				   */
 				  if (f_type.equals(o_type)){
-						f = fields[i];
+						f = field;
 						break;
 					}
 			}
@@ -2729,15 +2729,15 @@ public class InstConstraintVisitor exten
 		JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
 		Field[] fields = jc.getFields();
 		Field f = null;
-		for (int i=0; i<fields.length; i++){
-			if (fields[i].getName().equals(field_name)){
-					Type f_type = Type.getType(fields[i].getSignature());
+		for (Field field : fields) {
+			if (field.getName().equals(field_name)){
+					Type f_type = Type.getType(field.getSignature());
 				  Type o_type = o.getType(cpg);
 					/* TODO: Check if assignment compatibility is sufficient.
 				   * What does Sun do?
 				   */
 				  if (f_type.equals(o_type)){
-						f = fields[i];
+						f = field;
 						break;
 					}
 			}

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java?rev=1554576&r1=1554575&r2=1554576&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
Tue Dec 31 22:05:01 2013
@@ -206,8 +206,7 @@ public final class Pass3bVerifier extend
 			
 				// Normal successors. Add them to the queue of successors.
 				InstructionContext[] succs = u.getSuccessors();
-				for (int s=0; s<succs.length; s++){
-					InstructionContext v = succs[s];
+				for (InstructionContext v : succs) {
 					if (v.execute(u.getOutFrame(oldchain), newchain, icv, ev)){
 	                    @SuppressWarnings("unchecked") // newchain is already of type ArrayList<InstructionContext>
 	                    ArrayList<InstructionContext> newchainClone = (ArrayList<InstructionContext>)
newchain.clone();
@@ -219,8 +218,8 @@ public final class Pass3bVerifier extend
 			// Exception Handlers. Add them to the queue of successors.
 			// [subroutines are never protected; mandated by JustIce]
 			ExceptionHandler[] exc_hds = u.getExceptionHandlers();
-			for (int s=0; s<exc_hds.length; s++){
-				InstructionContext v = cfg.contextOf(exc_hds[s].getHandlerStart());
+			for (ExceptionHandler exc_hd : exc_hds) {
+				InstructionContext v = cfg.contextOf(exc_hd.getHandlerStart());
 				// TODO: the "oldchain" and "newchain" is used to determine the subroutine
 				// we're in (by searching for the last JSR) by the InstructionContext
 				// implementation. Therefore, we should not use this chain mechanism
@@ -231,7 +230,7 @@ public final class Pass3bVerifier extend
 				// by using an empty chain for the exception handlers.
 				//if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack (u.getOutFrame().getStack().maxStack(),
(exc_hds[s].getExceptionType()==null? Type.THROWABLE : exc_hds[s].getExceptionType())) ),
newchain), icv, ev){
 					//icq.add(v, (ArrayList) newchain.clone());
-				if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack (u.getOutFrame(oldchain).getStack().maxStack(),
(exc_hds[s].getExceptionType()==null? Type.THROWABLE : exc_hds[s].getExceptionType())) ),
new ArrayList<InstructionContext>(), icv, ev)){
+				if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack (u.getOutFrame(oldchain).getStack().maxStack(),
(exc_hd.getExceptionType()==null? Type.THROWABLE : exc_hd.getExceptionType())) ), new ArrayList<InstructionContext>(),
icv, ev)){
 					icq.add(v, new ArrayList<InstructionContext>());
 				}
 			}

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=1554576&r1=1554575&r2=1554576&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 Dec 31 22:05:01 2013
@@ -119,15 +119,15 @@ public class Subroutines{
 			
 			ret += " Accessed local variable slots: '";
 			int[] alv = getAccessedLocalsIndices();
-			for (int i=0; i<alv.length; i++){
-				ret += alv[i]+" ";
+			for (int element : alv) {
+				ret += element+" ";
 			}
 			ret+="'.";
 
 			ret += " Recursively (via subsub...routines) accessed local variable slots: '";
 			alv = getRecursivelyAccessedLocalsIndices();
-			for (int i=0; i<alv.length; i++){
-				ret += alv[i]+" ";
+			for (int element : alv) {
+				ret += element+" ";
 			}
 			ret+="'.";
 
@@ -228,8 +228,8 @@ public class Subroutines{
 		public int[] getRecursivelyAccessedLocalsIndices(){
 			Set<Integer> s = new HashSet<Integer>();
 			int[] lvs = getAccessedLocalsIndices();
-			for (int j=0; j<lvs.length; j++){
-				s.add(Integer.valueOf(lvs[j]));
+			for (int lv : lvs) {
+				s.add(Integer.valueOf(lv));
 			}
 			_getRecursivelyAccessedLocalsIndicesHelper(s, this.subSubs());
 			int[] ret = new int[s.size()];
@@ -246,13 +246,13 @@ public class Subroutines{
 		 * @see #getRecursivelyAccessedLocalsIndices()
 		 */
 		private void _getRecursivelyAccessedLocalsIndicesHelper(Set<Integer> s, Subroutine[]
subs){
-			for (int i=0; i<subs.length; i++){
-				int[] lvs = subs[i].getAccessedLocalsIndices();
-				for (int j=0; j<lvs.length; j++){
-					s.add(Integer.valueOf(lvs[j]));
+			for (Subroutine sub : subs) {
+				int[] lvs = sub.getAccessedLocalsIndices();
+				for (int lv : lvs) {
+					s.add(Integer.valueOf(lv));
 				}
-				if(subs[i].subSubs().length != 0){
-					_getRecursivelyAccessedLocalsIndicesHelper(s, subs[i].subSubs());
+				if(sub.subSubs().length != 0){
+					_getRecursivelyAccessedLocalsIndicesHelper(s, sub.subSubs());
 				}
 			}
 		}
@@ -376,8 +376,8 @@ public class Subroutines{
 
 		// Calculate "real" subroutines.
 		Set<InstructionHandle> sub_leaders = new HashSet<InstructionHandle>(); // Elements:
InstructionHandle
-		for (int i=0; i<all.length; i++){
-			Instruction inst = all[i].getInstruction();
+		for (InstructionHandle element : all) {
+			Instruction inst = element.getInstruction();
 			if (inst instanceof JsrInstruction){
 				sub_leaders.add(((JsrInstruction) inst).getTarget());
 			}
@@ -399,11 +399,11 @@ 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 (int i=0; i<all.length; i++){
-			Instruction inst = all[i].getInstruction();
+		for (InstructionHandle element : all) {
+			Instruction inst = element.getInstruction();
 			if (inst instanceof JsrInstruction){
 				InstructionHandle leader = ((JsrInstruction) inst).getTarget();
-				((SubroutineImpl) getSubroutine(leader)).addEnteringJsrInstruction(all[i]);
+				((SubroutineImpl) getSubroutine(leader)).addEnteringJsrInstruction(element);
 			}
 		}
 		
@@ -417,8 +417,8 @@ public class Subroutines{
 		for (InstructionHandle actual : sub_leaders) {
 			// Do some BFS with "actual" as the root of the graph.
 			// Init colors
-			for (int i=0; i<all.length; i++){
-				colors.put(all[i], WHITE);
+			for (InstructionHandle element : all) {
+				colors.put(element, WHITE);
 			}
 			colors.put(actual, GRAY);
 			// Init Queue
@@ -428,9 +428,9 @@ public class Subroutines{
 			
 			/* BFS ALGORITHM MODIFICATION: Start out with multiple "root" nodes, as exception handlers
are starting points of top-level code, too. [why top-level? TODO: Refer to the special JustIce
notion of subroutines.]*/
 			if (actual == all[0]){
-				for (int j=0; j<handlers.length; j++){
-					colors.put(handlers[j].getHandlerPC(), GRAY);
-					Q.add(handlers[j].getHandlerPC());
+				for (CodeExceptionGen handler : handlers) {
+					colors.put(handler.getHandlerPC(), GRAY);
+					Q.add(handler.getHandlerPC());
 				}
 			}
 			/* CONTINUE NORMAL BFS ALGORITHM */
@@ -439,23 +439,23 @@ public class Subroutines{
 			while (Q.size() != 0){
 				InstructionHandle u = Q.remove(0);
 				InstructionHandle[] successors = getSuccessors(u);
-				for (int i=0; i<successors.length; i++){
-					if (colors.get(successors[i]) == WHITE){
-						colors.put(successors[i], GRAY);
-						Q.add(successors[i]);
+				for (InstructionHandle successor : successors) {
+					if (colors.get(successor) == WHITE){
+						colors.put(successor, GRAY);
+						Q.add(successor);
 					}
 				}
 				colors.put(u, BLACK);
 			}
 			// BFS ended above.
-			for (int i=0; i<all.length; i++){
-				if (colors.get(all[i]) == BLACK){
-					((SubroutineImpl) (actual==all[0]?getTopLevel():getSubroutine(actual))).addInstruction(all[i]);
-					if (instructions_assigned.contains(all[i])){
-						throw new StructuralCodeConstraintException("Instruction '"+all[i]+"' is part of more
than one subroutine (or of the top level and a subroutine).");
+			for (InstructionHandle element : all) {
+				if (colors.get(element) == BLACK){
+					((SubroutineImpl) (actual==all[0]?getTopLevel():getSubroutine(actual))).addInstruction(element);
+					if (instructions_assigned.contains(element)){
+						throw new StructuralCodeConstraintException("Instruction '"+element+"' is part of more
than one subroutine (or of the top level and a subroutine).");
 					}
 					else{
-						instructions_assigned.add(all[i]);
+						instructions_assigned.add(element);
 					}
 				}
 			}
@@ -466,13 +466,13 @@ public class Subroutines{
 		
 		// Now make sure no instruction of a Subroutine is protected by exception handling code
 		// as is mandated by JustIces notion of subroutines.
-		for (int i=0; i<handlers.length; i++){
-			InstructionHandle _protected = handlers[i].getStartPC();
-			while (_protected != handlers[i].getEndPC().getNext()){// Note the inclusive/inclusive
notation of "generic API" exception handlers!
+		for (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()) {
 					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+"'
is protected by an exception handler, '"+handlers[i]+"'. This is forbidden by the JustIce
verifier due to its clear definition of subroutines.");
+							throw new StructuralCodeConstraintException("Subroutine instruction '"+_protected+"'
is protected by an exception handler, '"+handler+"'. This is forbidden by the JustIce verifier
due to its clear definition of subroutines.");
 						}
 					}
 				}
@@ -504,16 +504,16 @@ public class Subroutines{
 	private void noRecursiveCalls(Subroutine sub, Set<Integer> set){
 		Subroutine[] subs = sub.subSubs();
 
-		for (int i=0; i<subs.length; i++){
-			int index = ((RET) (subs[i].getLeavingRET().getInstruction())).getIndex();
+		for (Subroutine sub2 : subs) {
+			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) subs[i];
+				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? JustIce's clean definition of a subroutine
forbids both.");
 			}
 
-			noRecursiveCalls(subs[i], set);
+			noRecursiveCalls(sub2, set);
 			
 			set.remove(Integer.valueOf(index));
 		}

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=1554576&r1=1554575&r2=1554576&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 Dec
31 22:05:01 2013
@@ -55,9 +55,7 @@ public abstract class AbstractTestCase e
 	protected Method getMethod(JavaClass cl, String methodname)
 	{
 		Method[] methods = cl.getMethods();
-		for (int i = 0; i < methods.length; i++)
-		{
-			Method m = methods[i];
+		for (Method m : methods) {
 			if (m.getName().equals(methodname))
 			{
 				return m;
@@ -94,12 +92,11 @@ public abstract class AbstractTestCase e
 	{
 		Attribute[] all = clazz.getAttributes();
 		List<Attribute> chosenAttrsList = new ArrayList<Attribute>();
-		for (int i = 0; i < all.length; i++)
-		{
+		for (Attribute element : all) {
 			if (verbose)
-				System.err.println("Attribute: " + all[i].getName());
-			if (all[i].getName().equals(name))
-				chosenAttrsList.add(all[i]);
+				System.err.println("Attribute: " + element.getName());
+			if (element.getName().equals(name))
+				chosenAttrsList.add(element);
 		}
 		return chosenAttrsList.toArray(new Attribute[] {});
 	}
@@ -107,12 +104,11 @@ public abstract class AbstractTestCase e
 	protected Attribute findAttribute(String name, Attribute[] all)
 	{
 		List<Attribute> chosenAttrsList = new ArrayList<Attribute>();
-		for (int i = 0; i < all.length; i++)
-		{
+		for (Attribute element : all) {
 			if (verbose)
-				System.err.println("Attribute: " + all[i].getName());
-			if (all[i].getName().equals(name))
-				chosenAttrsList.add(all[i]);
+				System.err.println("Attribute: " + element.getName());
+			if (element.getName().equals(name))
+				chosenAttrsList.add(element);
 		}
 		assertTrue("Should be one match: " + chosenAttrsList.size(),
 				chosenAttrsList.size() == 1);

Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationGenTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationGenTestCase.java?rev=1554576&r1=1554575&r2=1554576&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationGenTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/AnnotationGenTestCase.java Tue
Dec 31 22:05:01 2013
@@ -100,9 +100,7 @@ public class AnnotationGenTestCase exten
 		v.add(a);
 		Attribute[] attributes = Utility.getAnnotationAttributes(cp, v);
 		boolean foundRV = false;
-		for (int i = 0; i < attributes.length; i++)
-		{
-			Attribute attribute = attributes[i];
+		for (Attribute attribute : attributes) {
 			if (attribute instanceof RuntimeVisibleAnnotations)
 			{
 				assertTrue(((Annotations) attribute).isRuntimeVisible());
@@ -117,9 +115,7 @@ public class AnnotationGenTestCase exten
 		v2.add(a2);
 		Attribute[] attributes2 = Utility.getAnnotationAttributes(cp, v2);
 		boolean foundRIV = false;
-		for (int i = 0; i < attributes2.length; i++)
-		{
-			Attribute attribute = attributes2[i];
+		for (Attribute attribute : attributes2) {
 			if (attribute instanceof RuntimeInvisibleAnnotations)
 			{
 				assertFalse(((Annotations) attribute).isRuntimeVisible());

Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/FieldAnnotationsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/FieldAnnotationsTestCase.java?rev=1554576&r1=1554575&r2=1554576&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/FieldAnnotationsTestCase.java
(original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/FieldAnnotationsTestCase.java
Tue Dec 31 22:05:01 2013
@@ -111,9 +111,7 @@ public class FieldAnnotationsTestCase ex
 			String AnnotationEntryElementValue)
 	{
 		Field[] fields = clazz.getFields();
-		for (int i = 0; i < fields.length; i++)
-		{
-			Field f = fields[i];
+		for (Field f : fields) {
 			AnnotationEntry[] fieldAnnotationEntrys = f.getAnnotationEntries();
 			if (f.getName().equals(fieldname))
 			{

Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/GeneratingAnnotatedClassesTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/GeneratingAnnotatedClassesTestCase.java?rev=1554576&r1=1554575&r2=1554576&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/GeneratingAnnotatedClassesTestCase.java
(original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/GeneratingAnnotatedClassesTestCase.java
Tue Dec 31 22:05:01 2013
@@ -19,7 +19,6 @@ package org.apache.bcel;
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.bcel.classfile.AnnotationEntry;
@@ -363,9 +362,8 @@ public class GeneratingAnnotatedClassesT
                 annotations.length == 1);
         List<?> l = annotations[0].getValues();
         boolean found = false;
-        for (Iterator<?> iter = l.iterator(); iter.hasNext();)
-        {
-            ElementValuePairGen element = (ElementValuePairGen) iter.next();
+        for (Object name : l) {
+            ElementValuePairGen element = (ElementValuePairGen) name;
             if (element.getNameString().equals("dval"))
             {
                 if (((SimpleElementValueGen) element.getValue())

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=1554576&r1=1554575&r2=1554576&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 Dec 31
22:05:01 2013
@@ -93,9 +93,7 @@ public final class PerformanceTest exten
 				cgenTime.stop();
 
 				Method[] methods = cg.getMethods();
-				for (int j = 0; j < methods.length; j++) {
-					Method m = methods[j];
-
+				for (Method m : methods) {
 					mgenTime.start();
 					MethodGen mg = new MethodGen(m, cg.getClassName(), cg.getConstantPool());
 					InstructionList il = mg.getInstructionList();



Mime
View raw message