Author: ebourg
Date: Wed Apr 23 12:14:23 2014
New Revision: 1589380

URL: http://svn.apache.org/r1589380
Log:
Foreach loops

Modified:
    
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
    
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java
    
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java
    
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/MethodGen.java
    
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/AttributeHTML.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/CodeHTML.java
    
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/VerifierFactoryListModel.java
    
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
    
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
    
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java

Modified: 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java?rev=1589380&r1=1589379&r2=1589380&view=diff
==============================================================================
--- 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
 (original)
+++ 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
 Wed Apr 23 12:14:23 2014
@@ -126,8 +126,7 @@ public class AnnotationEntry implements 
         dos.writeShort(type_index); // u2 index of type name in cpool
         dos.writeShort(element_value_pairs.size()); // u2 element_value pair
         // count
-        for (int i = 0; i < element_value_pairs.size(); i++) {
-            final ElementValuePair envp = element_value_pairs.get(i);
+        for (final ElementValuePair envp : element_value_pairs) {
             envp.dump(dos);
         }
     }

Modified: 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java
URL: 
http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java?rev=1589380&r1=1589379&r2=1589380&view=diff
==============================================================================
--- 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java
 (original)
+++ 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java
 Wed Apr 23 12:14:23 2014
@@ -67,11 +67,10 @@ public class AnnotationEntryGen
        {
                List<ElementValuePairGen> out = new 
ArrayList<ElementValuePairGen>();
                int l = in.length;
-               for (int i = 0; i < l; i++)
-               {
-                       ElementValuePair nvp = in[i];
-                       out.add(new ElementValuePairGen(nvp, cpool, 
copyPoolEntries));
-               }
+        for (ElementValuePair nvp : in)
+        {
+            out.add(new ElementValuePairGen(nvp, cpool, copyPoolEntries));
+        }
                return out;
        }
 
@@ -123,11 +122,10 @@ public class AnnotationEntryGen
        {
                dos.writeShort(typeIndex); // u2 index of type name in cpool
                dos.writeShort(evs.size()); // u2 element_value pair count
-               for (int i = 0; i < evs.size(); i++)
-               {
-                       ElementValuePairGen envp = evs.get(i);
-                       envp.dump(dos);
-               }
+        for (ElementValuePairGen envp : evs)
+        {
+            envp.dump(dos);
+        }
        }
 
        public void addElementNameValuePair(ElementValuePairGen evp)

Modified: 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java
URL: 
http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java?rev=1589380&r1=1589379&r2=1589380&view=diff
==============================================================================
--- 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java 
(original)
+++ 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/ClassGen.java 
Wed Apr 23 12:14:23 2014
@@ -144,10 +144,10 @@ public class ClassGen extends AccessFlag
         for (String interface1 : interfaces) {
             addInterface(interface1);
         }
-        for (int i = 0; i < attributes.length; i++) {
-               if (!(attributes[i] instanceof Annotations)) {
-                       addAttribute(attributes[i]);
-               }
+        for (Attribute attribute : attributes) {
+            if (!(attribute instanceof Annotations)) {
+                addAttribute(attribute);
+            }
         }
         for (AnnotationEntryGen annotation : annotations) {
             addAnnotationEntry(annotation);

Modified: 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/MethodGen.java
URL: 
http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/MethodGen.java?rev=1589380&r1=1589379&r2=1589380&view=diff
==============================================================================
--- 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/MethodGen.java 
(original)
+++ 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/MethodGen.java 
Wed Apr 23 12:14:23 2014
@@ -142,8 +142,8 @@ public class MethodGen extends FieldGenO
         }
         if (arg_types != null) {
             int size = arg_types.length;
-            for (int i = 0; i < size; i++) {
-                if (Type.VOID == arg_types[i]) {
+            for (Type arg_type : arg_types) {
+                if (Type.VOID == arg_type) {
                     throw new ClassGenException("'void' is an illegal argument 
type for a method");
                 }
             }

Modified: 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/AttributeHTML.java
URL: 
http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/AttributeHTML.java?rev=1589380&r1=1589379&r2=1589380&view=diff
==============================================================================
--- 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/AttributeHTML.java 
(original)
+++ 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/AttributeHTML.java 
Wed Apr 23 12:14:23 2014
@@ -108,8 +108,8 @@ final class AttributeHTML implements org
                 int len = ce.length;
                 if (len > 0) {
                     file.print("<P><B>Exceptions handled</B><UL>");
-                    for (int i = 0; i < len; i++) {
-                        int catch_type = ce[i].getCatchType(); // Index in 
constant pool
+                    for (CodeException cex : ce) {
+                        int catch_type = cex.getCatchType(); // Index in 
constant pool
                         file.print("<LI>");
                         if (catch_type != 0) {
                             
file.print(constant_html.referenceConstant(catch_type)); // Create Link to 
_cp.html
@@ -117,9 +117,9 @@ final class AttributeHTML implements org
                             file.print("Any Exception");
                         }
                         file.print("<BR>(Ranging from lines "
-                                + codeLink(ce[i].getStartPC(), method_number) 
+ " to "
-                                + codeLink(ce[i].getEndPC(), method_number) + 
", handled at line "
-                                + codeLink(ce[i].getHandlerPC(), 
method_number) + ")</LI>");
+                                + codeLink(cex.getStartPC(), method_number) + 
" to "
+                                + codeLink(cex.getEndPC(), method_number) + ", 
handled at line "
+                                + codeLink(cex.getHandlerPC(), method_number) 
+ ")</LI>");
                     }
                     file.print("</UL>");
                 }

Modified: 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/CodeHTML.java
URL: 
http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/CodeHTML.java?rev=1589380&r1=1589379&r2=1589380&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/CodeHTML.java 
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/CodeHTML.java 
Wed Apr 23 12:14:23 2014
@@ -375,10 +375,10 @@ final class CodeHTML implements org.apac
         if (code != null) {
             CodeException[] ce = code.getExceptionTable();
             int len = ce.length;
-            for (int i = 0; i < len; i++) {
-                goto_set.set(ce[i].getStartPC());
-                goto_set.set(ce[i].getEndPC());
-                goto_set.set(ce[i].getHandlerPC());
+            for (CodeException cex : ce) {
+                goto_set.set(cex.getStartPC());
+                goto_set.set(cex.getEndPC());
+                goto_set.set(cex.getHandlerPC());
             }
             // Look for local variables and their range
             Attribute[] attributes = code.getAttributes();

Modified: 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/VerifierFactoryListModel.java
URL: 
http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/VerifierFactoryListModel.java?rev=1589380&r1=1589379&r2=1589380&view=diff
==============================================================================
--- 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/VerifierFactoryListModel.java
 (original)
+++ 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/VerifierFactoryListModel.java
 Wed Apr 23 12:14:23 2014
@@ -50,13 +50,12 @@ public class VerifierFactoryListModel im
         Verifier[] verifiers = VerifierFactory.getVerifiers();
         int num_of_verifiers = verifiers.length;
         cache.clear();
-        for (int i = 0; i < num_of_verifiers; i++) {
-            cache.add(verifiers[i].getClassName());
+        for (Verifier verifier : verifiers) {
+            cache.add(verifier.getClassName());
         }
-        for (int i = 0; i < size; i++) {
-            ListDataEvent e = new ListDataEvent(this, 
ListDataEvent.CONTENTS_CHANGED, 0,
-                    num_of_verifiers - 1);
-            listeners.get(i).contentsChanged(e);
+        for (ListDataListener listener : listeners) {
+            ListDataEvent e = new ListDataEvent(this, 
ListDataEvent.CONTENTS_CHANGED, 0, num_of_verifiers - 1);
+            listener.contentsChanged(e);
         }
     }
 

Modified: 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
URL: 
http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java?rev=1589380&r1=1589379&r2=1589380&view=diff
==============================================================================
--- 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
 (original)
+++ 
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
 Wed Apr 23 12:14:23 2014
@@ -249,30 +249,27 @@ public final class Pass2Verifier extends
                        supidx = jc.getSuperclassNameIndex();
 
                        Method[] methods = jc.getMethods();
-                       for (int i=0; i<methods.length; i++){
-                               String name_and_sig = 
(methods[i].getName()+methods[i].getSignature());
+            for (Method method : methods) {
+                String name_and_sig = (method.getName() + 
method.getSignature());
 
-                               if (hashmap.containsKey(name_and_sig)){
-                                       if ( methods[i].isFinal() ){
-                                         if (!(methods[i].isPrivate())) {
-                                                 throw new 
ClassConstraintException("Method '"+name_and_sig+"' in class 
'"+hashmap.get(name_and_sig)+"' overrides the final (not-overridable) 
definition in class '"+jc.getClassName()+"'.");
-                                         }
-                                         else{
-                                                 addMessage("Method 
'"+name_and_sig+"' in class '"+hashmap.get(name_and_sig)+"' overrides the final 
(not-overridable) definition in class '"+jc.getClassName()+"'. This is okay, as 
the original definition was private; however this constraint leverage was 
introduced by JLS 8.4.6 (not vmspec2) and the behaviour of the Sun verifiers.");
-                                         }
-                                       }
-                                       else{
-                                               if (!methods[i].isStatic()){ // 
static methods don't inherit
-                                                       
hashmap.put(name_and_sig, jc.getClassName());
-                                               }
-                                       }
-                               }
-                               else{
-                                       if (!methods[i].isStatic()){ // static 
methods don't inherit
-                                               hashmap.put(name_and_sig, 
jc.getClassName());
-                                       }
-                               }
-                       }
+                if (hashmap.containsKey(name_and_sig)) {
+                    if (method.isFinal()) {
+                        if (!(method.isPrivate())) {
+                            throw new ClassConstraintException("Method '" + 
name_and_sig + "' in class '" + hashmap.get(name_and_sig) + "' overrides the 
final (not-overridable) definition in class '" + jc.getClassName() + "'.");
+                        } else {
+                            addMessage("Method '" + name_and_sig + "' in class 
'" + hashmap.get(name_and_sig) + "' overrides the final (not-overridable) 
definition in class '" + jc.getClassName() + "'. This is okay, as the original 
definition was private; however this constraint leverage was introduced by JLS 
8.4.6 (not vmspec2) and the behaviour of the Sun verifiers.");
+                        }
+                    } else {
+                        if (!method.isStatic()) { // static methods don't 
inherit
+                            hashmap.put(name_and_sig, jc.getClassName());
+                        }
+                    }
+                } else {
+                    if (!method.isStatic()) { // static methods don't inherit
+                        hashmap.put(name_and_sig, jc.getClassName());
+                    }
+                }
+            }
                
                        jc = Repository.lookupClass(jc.getSuperclassName());    
// Well, for OBJECT this returns OBJECT so it works (could return anything but 
must not throw an Exception).
                }
@@ -381,36 +378,36 @@ public final class Pass2Verifier extends
                        // This is a costly check; existing verifiers don't do 
it!
                        boolean hasInnerClass = new 
InnerClassDetector(jc).innerClassReferenced();
 
-                       for (int i=0; i<atts.length; i++){
-                               if ((! (atts[i] instanceof SourceFile)) &&
-                                   (! (atts[i] instanceof Deprecated))     &&
-                                   (! (atts[i] instanceof InnerClasses)) &&
-                                   (! (atts[i] instanceof Synthetic))){
-                                       addMessage("Attribute 
'"+tostring(atts[i])+"' as an attribute of the ClassFile structure 
'"+tostring(obj)+"' is unknown and will therefore be ignored.");
-                               }
+            for (Attribute att : atts) {
+                if ((!(att instanceof SourceFile)) &&
+                        (!(att instanceof Deprecated)) &&
+                        (!(att instanceof InnerClasses)) &&
+                        (!(att instanceof Synthetic))) {
+                    addMessage("Attribute '" + tostring(att) + "' as an 
attribute of the ClassFile structure '" + tostring(obj) + "' is unknown and 
will therefore be ignored.");
+                }
 
-                               if (atts[i] instanceof SourceFile){
-                                       if (foundSourceFile == false) {
+                if (att instanceof SourceFile) {
+                    if (foundSourceFile == false) {
                         foundSourceFile = true;
                     } else {
-                        throw new ClassConstraintException("A ClassFile 
structure (like '"+tostring(obj)+"') may have no more than one SourceFile 
attribute."); //vmspec2 4.7.7
+                        throw new ClassConstraintException("A ClassFile 
structure (like '" + tostring(obj) + "') may have no more than one SourceFile 
attribute."); //vmspec2 4.7.7
                     }
-                               }
+                }
 
-                               if (atts[i] instanceof InnerClasses){
-                                       if (foundInnerClasses == false) {
+                if (att instanceof InnerClasses) {
+                    if (foundInnerClasses == false) {
                         foundInnerClasses = true;
-                    } else{
-                                               if (hasInnerClass){
-                                                       throw new 
ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must 
have exactly one InnerClasses attribute if at least one Inner Class is 
referenced (which is the case). More than one InnerClasses attribute was 
found.");
-                                               }
-                                       }
-                                       if (!hasInnerClass){
-                                               addMessage("No referenced Inner 
Class found, but InnerClasses attribute '"+tostring(atts[i])+"' found. Strongly 
suggest removal of that attribute.");
-                                       }
-                               }
+                    } else {
+                        if (hasInnerClass) {
+                            throw new ClassConstraintException("A Classfile 
structure (like '" + tostring(obj) + "') must have exactly one InnerClasses 
attribute if at least one Inner Class is referenced (which is the case). More 
than one InnerClasses attribute was found.");
+                        }
+                    }
+                    if (!hasInnerClass) {
+                        addMessage("No referenced Inner Class found, but 
InnerClasses attribute '" + tostring(att) + "' found. Strongly suggest removal 
of that attribute.");
+                    }
+                }
 
-                       }
+            }
                        if (hasInnerClass && !foundInnerClasses){
                                //throw new ClassConstraintException("A 
Classfile structure (like '"+tostring(obj)+"') must have exactly one 
InnerClasses attribute if at least one Inner Class is referenced (which is the 
case). No InnerClasses attribute was found.");
                                //vmspec2, page 125 says it would be a 
constraint: but existing verifiers
@@ -576,16 +573,16 @@ public final class Pass2Verifier extends
                        field_names.add(name);
 
                        Attribute[] atts = obj.getAttributes();
-                       for (int i=0; i<atts.length; i++){
-                               if ((! (atts[i] instanceof ConstantValue)) &&
-                                   (! (atts[i] instanceof Synthetic))     &&
-                                   (! (atts[i] instanceof Deprecated))){
-                                       addMessage("Attribute 
'"+tostring(atts[i])+"' as an attribute of Field '"+tostring(obj)+"' is unknown 
and will therefore be ignored.");
-                               }
-                               if  (! (atts[i] instanceof ConstantValue)){
-                                       addMessage("Attribute 
'"+tostring(atts[i])+"' as an attribute of Field '"+tostring(obj)+"' is not a 
ConstantValue and is therefore only of use for debuggers and such.");
-                               }
-                       }
+            for (Attribute att : atts) {
+                if ((!(att instanceof ConstantValue)) &&
+                        (!(att instanceof Synthetic)) &&
+                        (!(att instanceof Deprecated))) {
+                    addMessage("Attribute '" + tostring(att) + "' as an 
attribute of Field '" + tostring(obj) + "' is unknown and will therefore be 
ignored.");
+                }
+                if (!(att instanceof ConstantValue)) {
+                    addMessage("Attribute '" + tostring(att) + "' as an 
attribute of Field '" + tostring(obj) + "' is not a ConstantValue and is 
therefore only of use for debuggers and such.");
+                }
+            }
                }
                ///////////////////////////
                // METHODS (vmspec2 4.6) //
@@ -738,24 +735,24 @@ public final class Pass2Verifier extends
 
                        Attribute[] atts = obj.getAttributes();
                        int num_code_atts = 0;
-                       for (int i=0; i<atts.length; i++){
-                               if ((! (atts[i] instanceof Code)) &&
-                                   (! (atts[i] instanceof ExceptionTable))     
&&
-                                   (! (atts[i] instanceof Synthetic)) &&
-                                   (! (atts[i] instanceof Deprecated))){
-                                       addMessage("Attribute 
'"+tostring(atts[i])+"' as an attribute of Method '"+tostring(obj)+"' is 
unknown and will therefore be ignored.");
-                               }
-                               if ((! (atts[i] instanceof Code)) &&
-                                               (! (atts[i] instanceof 
ExceptionTable))){
-                                       addMessage("Attribute 
'"+tostring(atts[i])+"' as an attribute of Method '"+tostring(obj)+"' is 
neither Code nor Exceptions and is therefore only of use for debuggers and 
such.");
-                               }
-                               if ((atts[i] instanceof Code) && 
(obj.isNative() || obj.isAbstract())){
-                                       throw new 
ClassConstraintException("Native or abstract methods like '"+tostring(obj)+"' 
must not have a Code attribute like '"+tostring(atts[i])+"'."); //vmspec2 
page120, 4.7.3
-                               }
-                               if (atts[i] instanceof Code) {
+            for (Attribute att : atts) {
+                if ((!(att instanceof Code)) &&
+                        (!(att instanceof ExceptionTable)) &&
+                        (!(att instanceof Synthetic)) &&
+                        (!(att instanceof Deprecated))) {
+                    addMessage("Attribute '" + tostring(att) + "' as an 
attribute of Method '" + tostring(obj) + "' is unknown and will therefore be 
ignored.");
+                }
+                if ((!(att instanceof Code)) &&
+                        (!(att instanceof ExceptionTable))) {
+                    addMessage("Attribute '" + tostring(att) + "' as an 
attribute of Method '" + tostring(obj) + "' is neither Code nor Exceptions and 
is therefore only of use for debuggers and such.");
+                }
+                if ((att instanceof Code) && (obj.isNative() || 
obj.isAbstract())) {
+                    throw new ClassConstraintException("Native or abstract 
methods like '" + tostring(obj) + "' must not have a Code attribute like '" + 
tostring(att) + "'."); //vmspec2 page120, 4.7.3
+                }
+                if (att instanceof Code) {
                     num_code_atts++;
                 }
-                       }
+            }
                        if ( !obj.isNative() && !obj.isAbstract() && 
num_code_atts != 1){
                                throw new ClassConstraintException("Non-native, 
non-abstract methods like '"+tostring(obj)+"' must have exactly one Code 
attribute (found: "+num_code_atts+").");
                        }

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=1589380&r1=1589379&r2=1589380&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
 Wed Apr 23 12:14:23 2014
@@ -237,22 +237,22 @@ public final class Pass3aVerifier extend
                if (lnt != null){
                        LineNumber[] lineNumbers = lnt.getLineNumberTable();
                        IntList offsets = new IntList();
-                       lineNumber_loop: for (int i=0; i < lineNumbers.length; 
i++){ // may appear in any order.
-                               for (int j=0; j < instructionPositions.length; 
j++){
-                                       // TODO: Make this a binary search! The 
instructionPositions array is naturally ordered!
-                                       int offset = 
lineNumbers[i].getStartPC();
-                                       if (instructionPositions[j] == offset){
-                                               if (offsets.contains(offset)){
-                                                       
addMessage("LineNumberTable attribute '"+code.getLineNumberTable()+"' refers to 
the same code offset ('"+offset+"') more than once which is violating the 
semantics [but is sometimes produced by IBM's 'jikes' compiler].");
-                                               }
-                                               else{
-                                                       offsets.add(offset);
-                                               }
-                                               continue lineNumber_loop;
-                                       }
-                               }
-                               throw new ClassConstraintException("Code 
attribute '"+code+"' has a LineNumberTable attribute 
'"+code.getLineNumberTable()+"' referring to a code offset 
('"+lineNumbers[i].getStartPC()+"') that does not exist.");
-                       }
+                       lineNumber_loop:
+            for (LineNumber lineNumber : lineNumbers) { // may appear in any 
order.
+                for (int instructionPosition : instructionPositions) {
+                    // TODO: Make this a binary search! The 
instructionPositions array is naturally ordered!
+                    int offset = lineNumber.getStartPC();
+                    if (instructionPosition == offset) {
+                        if (offsets.contains(offset)) {
+                            addMessage("LineNumberTable attribute '" + 
code.getLineNumberTable() + "' refers to the same code offset ('" + offset + 
"') more than once which is violating the semantics [but is sometimes produced 
by IBM's 'jikes' compiler].");
+                        } else {
+                            offsets.add(offset);
+                        }
+                        continue lineNumber_loop;
+                    }
+                }
+                throw new ClassConstraintException("Code attribute '" + code + 
"' has a LineNumberTable attribute '" + code.getLineNumberTable() + "' 
referring to a code offset ('" + lineNumber.getStartPC() + "') that does not 
exist.");
+            }
                }
 
                ///////////////////////////
@@ -572,23 +572,23 @@ public final class Pass3aVerifier extend
                        }
                        if (f == null){
                                JavaClass[] superclasses = jc.getSuperClasses();
-                               outer: 
-                               for (int j=0; j<superclasses.length; j++){
-                                       fields = superclasses[j].getFields();
-                                       for (int i=0; i<fields.length; i++){
-                                               if 
(fields[i].getName().equals(field_name)){
-                                                       Type f_type = 
Type.getType(fields[i].getSignature());
-                                                       Type o_type = 
o.getType(cpg);
-                                                       if 
(f_type.equals(o_type)){
-                                                               f = fields[i];
-                                                               if 
((f.getAccessFlags() & (Constants.ACC_PUBLIC | Constants.ACC_PROTECTED)) == 0) {
+                               outer:
+                for (JavaClass superclass : superclasses) {
+                    fields = superclass.getFields();
+                    for (Field field : fields) {
+                        if (field.getName().equals(field_name)) {
+                            Type f_type = Type.getType(field.getSignature());
+                            Type o_type = o.getType(cpg);
+                            if (f_type.equals(o_type)) {
+                                f = field;
+                                if ((f.getAccessFlags() & 
(Constants.ACC_PUBLIC | Constants.ACC_PROTECTED)) == 0) {
                                     f = null;
                                 }
-                                                               break outer;
-                                                       }
-                                               }
-                                       }
-                               }
+                                break outer;
+                            }
+                        }
+                    }
+                }
                                if (f == null) {
                     constraintViolated(o, "Referenced field '"+field_name+"' 
does not exist in class '"+jc.getClassName()+"'.");
                 }

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=1589380&r1=1589379&r2=1589380&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
 Wed Apr 23 12:14:23 2014
@@ -1252,23 +1252,23 @@ public class InstConstraintVisitor exten
 
                if (f == null){
                        JavaClass[] superclasses = jc.getSuperClasses();
-                       outer: 
-                       for (int j=0; j<superclasses.length; j++){
-                               fields = superclasses[j].getFields();
-                               for (int i=0; i<fields.length; i++){
-                                       if 
(fields[i].getName().equals(field_name)){
-                                               Type f_type = 
Type.getType(fields[i].getSignature());
-                                               Type o_type = o.getType(cpg);
-                                               if (f_type.equals(o_type)){
-                                                       f = fields[i];
-                                                       if ((f.getAccessFlags() 
& (Constants.ACC_PUBLIC | Constants.ACC_PROTECTED)) == 0) {
+                       outer:
+            for (JavaClass superclass : superclasses) {
+                fields = superclass.getFields();
+                for (Field field : fields) {
+                    if (field.getName().equals(field_name)) {
+                        Type f_type = Type.getType(field.getSignature());
+                        Type o_type = o.getType(cpg);
+                        if (f_type.equals(o_type)) {
+                            f = field;
+                            if ((f.getAccessFlags() & (Constants.ACC_PUBLIC | 
Constants.ACC_PROTECTED)) == 0) {
                                 f = null;
                             }
-                                                       break outer;
-                                               }
-                                       }
-                               }
-                       }
+                            break outer;
+                        }
+                    }
+                }
+            }
                        if (f == null) {
                 throw new AssertionViolatedException("Field '"+field_name+"' 
not found?!?");
             }


Reply via email to