Java casting: is the compiler wrong, or is the language spec wrong, or am I wrong?
问题 I have been reading the Java Language Spec, 3rd edition, and have found what I think is a discrepancy between the spec and the javac compiler implementation. The same discrepancies exist in the Eclipse compiler. Section 15.16 talks about cast expressions. It says that it should be a compile time error if the argument type cannot be converted to the cast type via casting conversion (section 5.5): It is a compile-time error if the compile-time type of the operand may never be cast to the type