This post originated from an RSS feed registered with Java Buzz
by Chris Winters.
Original Post: Casting null and failing fast
Feed Title: cwinters.com
Feed URL: http://www.cwinters.com/search/registrar.php?domain=jroller.com®istrar=sedopark
Feed Description: Chris Winters on Java, programming and technology, usually in that order.
I had expected this to die at the two String casts. Nope. Each dies when you try to call a method on it -- this will print out both of the 'Caught NPE' lines from the catch blocks. If you think about null as an instance of Object (which happens to be null) then it makes sense, but doesn't the fail-fast principle tell us we should instead die at the cast?