Automatically update code to Java 5
<p>I have a lot of Java 1.4 code, which I'm in the process of migrating to Java 5. I would like to fix all the compiler warnings about using raw types in parameterized classes, and am wondering if there is a tool that can automatically transform something like:</p>

<pre><code>List myList = new ArrayList();
myList.add("foo");
String foo = (String) myList.get(0);
</code></pre>

<p>to:</p>

<pre><code>List&lt;String&gt; myList = new ArrayList&lt;String&gt;();
myList.add("foo");
String foo = myList.get(0);
</code></pre>

<p>I understand that Generics are quite complex and therefore don't expect that such a tool would be able to choose the most correct parameterized type in all cases. However, as long as it can handle simple cases (such as the above), and won't break my code, I'll be satisfied.</p>

<p>Similarly, I would like to change all the old-skool loops, to the simplified for loop introduced in Java 5.</p>

<p>Does such a tool exist?</p>
