Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!feeder2.ecngs.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.saix.net!news.saix.net.POSTED!not-for-mail NNTP-Posting-Date: Wed, 07 Dec 2011 12:41:10 -0600 Newsgroups: comp.lang.java.programmer Subject: Re: Question re testing constructor References: From: ilAn Date: Wed, 07 Dec 2011 20:41:06 +0200 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (darwin) Cancel-Lock: sha1:M0Xe5JPYRHQ9hIub2i66YKgiepk= MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Forwarded: by - (DeleGate/9.9.1) Lines: 35 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-44mxqR+6Oh2uGZbfMfdBEPn/VqOrgxsyl7hZ4kZhZGaRSeP5HFxC/HZrf3C+PGWPZraG828qFq4+o5n!KLbwI2WBMIQApj7c0JYGE84Ikq1TEOyMeiHaZu6wc3+0qnqcfQxPpkg5A3c= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2444 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10596 ram@zedat.fu-berlin.de (Stefan Ram) writes: > Ian Shef writes: >>ram@zedat.fu-berlin.de (Stefan Ram) wrote in news:null-20111206201830 >>@ram.dialup.fu-berlin.de: >>>If the Java compiler is so smart at detecting null values, >>>why does he not also give an error on code like: >>>(( java.io.PrintStream )null ).println() >>>? >>Short answer: Because the JLS says so. (see the third edition, paragraph >>15.16 where it is explained that most casts are handled at run time). > > Something similar: > > It is difficult for me to forecast an »unreachable statement« error. > For example, I would have expected such an error for > > public class Main > { public static void main( final java.lang.String[] args ) > { java.lang.System.out.println( "alpha3" ); > if( true )return; > java.lang.System.out.println( "beta3" ); }} > > , but did *not* get one, however, the compiler knows that the > beta3 statement *is* unreachable, because he does not care to > compile it. > > Omitting the »if( true )« will give an »unreachable statement« > error. I find that quite useful, when I am debugging and want to exclude a bunch of code.. and still compile it. -- ilAn