I've just gotten my first bite mark from primitive auto-boxing in Java 1.5. The following code is meant to read a file in either special mode or non-special mode, or to auto-detect special-ness if the boolean argument is null. This would (correctly) be a compile error in 1.4.2:
void readFile(String filename, Boolean isSpecial) {
The problem should be that I'm checking "isSpecial" for null without explicitly comparing it to null--- this is a mistake I make when I switch back and forth between Javascript and Java a lot.
But in Java 1.5 this code compiles without complaint because the compiler thinks I meant to auto-dereference the boolean and check its value for falseness. And then at runtime I get a nice shiny NullPointerException when the auto-boxing logic attempts to dereference "isSpecial" and read its value as a boolean. I'm not saying that auto-boxing is terrible, but it is an example of how it can bite you, and it's not 100% gravy. |