Yesterday I was working on some code and did a cvs
merge and lost some of my code during a conflict. So I used a Java decompiler
to get the source code for my last build.
It had all of the code that I had lost so I could just copy the correct code back over. What was interesting was the type of optimizations the compiler made. It was either the compiler or the decompiler misreading the bytecode (I figure it's the compiler.)
My original code had a while loop like this:
SummaryObject obj = (SummaryObject) iter.next();
SummaryObject newObj = obj.newInstance();
While the decompiled code was:
for(; iter.hasNext(); newSummaryObjs.add(newObj))
SummaryObject obj = (SummaryObject)iter.next();
newObj = obj.newInstance();
It looked like all while loops were turned into for loops. Interesting to see how the compiler would optimize things.