Community
Participate
Working Groups
This code is an infinite loop when the code is compiled with unused locals optimized out. import java.util.ArrayList; public class X { public static void main(String args[]) { ArrayList<Integer> arr = new ArrayList<Integer>(); arr.add(0); arr.add(1); int counter = 0; // tested statement: for (int i : arr){ ++counter; } System.out.println(counter + " elements found in the array list"); } }
Problem comes from unused local optimization. We forgot to still perform iterator.next() invocation, thus looping forever. Released fix.
Change milestone
Regression tests added in ForeachStatementTest.test029, test030 and test031.
Verified in I20050330-0500
*** Bug 91757 has been marked as a duplicate of this bug. ***