Why does code alternative(1) compile without warnings, and code alternative(2) produce an \"unchecked cast\" warning?
Common for both:
class Foo
I'm able to emulate this strange behaviour on my Windows 7 64b machine with:
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
OpenJDK Runtime Environment (build 1.8.0-ea-lambda-nightly-h1669-20121030-b63-b00)
Which means both the OpenJDK and the Oracle JDK are affected, both JDK7 and JDK8 (yes, you can already download it).
Eclipse, since it uses its own JDT compiler, doesn't have this problem.
So it seems that this is indeed a javac
bug. If you report it, please keep me updated.
I've also located a JDK6 installation on my computer, so I tried that one and actually, it works without a warning in both cases, which is the correct behaviour:
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Although my Windows are 64b, all the said JDKs are only 32b.