Community
Participate
Working Groups
Build ID: I20080617-2000 Steps To Reproduce: import java.util.Collections; import java.util.Iterator; public class Test { void foo() { for ( Iterator iter = Collections.emptySet().iterator(); iter.hasNext(); ) { iter.next().toString(); String.valueOf(iter.hasNext() ? "x" : "y"); } } } becomes import java.util.Collections; public class Test { void foo() { for (Object element : Collections.emptySet()) { element.toString(); String.valueOf(iter.hasNext() ? "x" : "y"); } } } More information: The cleanup seems to update code when there is only a single reference to iterator. Things go bad when subsequent refs are in ternary conditions.
*** Bug 307150 has been marked as a duplicate of this bug. ***
Fixed in ConvertIterableLoopOperation. The problem occurred when iter.*() is called inside another method invocation expression.