Community
Participate
Working Groups
3.1 I wanted to convert this for loop to an enhanced for loop, but the quick fix did not appear: private synchronized Vector<TestListener> cloneListeners() { return (Vector<TestListener>)fListeners.clone(); } public void endTest(Test test) { for (Enumeration<TestListener> e= cloneListeners().elements(); e.hasMoreElements(); ) { TestListener nextElement = e.nextElement(); nextElement.endTest(test); } }
Tobias, is looks like we missed this. How hard would it be to fix this for 3.1.1?
Its quite the same as the iterator case. I can quickly fix this
Can you please investigate a fix for 3.1.1
Created attachment 25826 [details] patch to handle java.util.Enumeration as well Dirk, Markus, can you approve this patch?
Tobias, a question: ConvertIterableLoopProposal#isApplicable - why is the type binding inspected for the enumeration case final ITypeBinding type= binding.getReturnType(); whereas the for the iterable case it is final ITypeBinding type= qualifier.resolveTypeBinding(); - some of the code between the iterable and enumeration case in isApplicable could be shared (all inside iterable != null). Rest of the patch looks fine for me.
Created attachment 25835 [details] simplified patch Simplified the patch, doing code sharing
Dirk, Markus, can you please cast your vote?
Looks good for me, except of: shouldn't we test for java.util.Enumeration< and java.util.Iterator< to make sure that we don't get tricked by a class java.util.Enumeration2
Created attachment 25978 [details] improved patch
No-go for the improved patch. First and last changes: "if (binding != null ..." comes after "binding.getName();" This causes an NPE when applied to e.g. this for loop: void m(Vector<String> vec) { for (Iterator iter = vec.iterator(); iter.hasNext();) { String string = (String) iter.negst(); } } The rest looks fine.
Created attachment 25986 [details] patch
Attachment 25986 [details] looks good. +1 for 3.1.1. Tobias: The last two patches had mime-type text/plain, which is wrong for zip files and makes handling more tedious. Please select auto-detect as content type.
Fixed in 3.1.1 maintenance stream > 20050811
Tobias, you released the test to HEAD, not R3_1_Maintenance.
Released test to 3.1.1 maintenance stream
Fixed in HEAD > 20050815
Start verification...
Verified that converting enumeration for loops works and the iterator and array still works. Opened bug 108672 to track an exception with converting the enumeration case.