Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Question re testing constructor Date: Wed, 7 Dec 2011 07:14:34 -0800 (PST) Organization: http://groups.google.com Lines: 17 Message-ID: <26281492.354.1323270874867.JavaMail.geo-discussion-forums@pret21> References: Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 173.164.137.214 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1323270875 12533 127.0.0.1 (7 Dec 2011 15:14:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 7 Dec 2011 15:14:35 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.164.137.214; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10594 Ian Shef wrote: > Discussion: The JLS seems to treat casting separately from the operations > (such as calling a method) that would follow a cast. It "feels like" this > doesn't need to be the case. Thus I agree with Stefan that it "feels like" > the compiler or an IDE could catch this at compile time (Eclipse does not) if > the JLS permitted or required it. Perhaps someone can explain why this is > not the case. Short answer: Because despite its best efforts, the compiler cannot cure stupidity. The compiler likely sees this as not different from '((PrintStream)variable).println()', i.e., as a candidate for a 'NullPointerException' rather than a compiler error. -- Lew