As it turns out, it is not legal to compare a primitive with an expression of compile-time type 'Object'. JLS 15.21 expressly forbids it:
The equality operators may be used to compare two operands that are
convertible (§5.1.8) to numeric type, or two operands of type boolean
or Boolean, or two operands that are each of either reference type or
the null type. All other cases result in a compile-time error.
The Eclipse compiler flags the error regardless of Java version. For Java 7, both Oracle JDK and OpenJDK erroneously allow the code to compile. This bug in Oracle and Open JDKs is corrected in version 8.
In summary, this wonky comparison is illegal according to the spec and will only compile on some subset of compilers for a particular subset of language version targets. Won't ever work on Java 4- or 8+. The casting conversions referred to in other answers apply only to the '=' operator, not to '=='. 15.21.3 applies only to two reference operands.