What version of Java are you using? My understanding is that the Java language specifications say that this code is valid. Some versions of Java "correctly" accept this code is valid, and some versions "incorrectly" don't accept this code, as an implementation quirk.