Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #32948

Re: A hypothetical compiler extension

Path csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: A hypothetical compiler extension
Date Tue, 27 Oct 2015 18:19:44 -0400
Organization A noiseless patient Spider
Lines 47
Message-ID <n0ot61$l85$1@dont-email.me> (permalink)
References <extension-20151027221547@ram.dialup.fu-berlin.de>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Tue, 27 Oct 2015 22:17:37 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="21765"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Lj8h/Wxr/EInu0FFXee+g"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
In-Reply-To <extension-20151027221547@ram.dialup.fu-berlin.de>
Cancel-Lock sha1:z2SepyuRAt79aQhw7uXth+lFGfo=
Xref csiph.com comp.lang.java.programmer:32948

Show key headers only | View raw


On 10/27/2015 5:24 PM, Stefan Ram wrote:
>    The following is hypothetical AFAIK, but wouldn't it be nice?
>
>    One calls
>
> javac -Xlint:null
>
>    and then
>
> void m( final java.lang.Object o )
> { java.lang.System.out.println
>    ( o.toString() ); }
>
>    gives
>
>    ( o.toString() ); }
>      ^
> Warning: o might be null.
>
>    . One rewrites to
>
> void m( final java.lang.Object o )
> { if( o != null )
>    java.lang.System.out.println
>    ( o.toString() ); }
>
>    and the warning disappears.

     It seems to me this would produce one heckuva lot of noise,
noise that might well drown out more urgent warnings:

	public static void main(String[] args) {
	    if (args.length > 0) ...
	        ^
	        Warning: args might be null

It is true that `args' will not be null *if* this particular
main() is invoked as the initial method, but that's not the
only possible way to invoke a class' main() method!

     I think the @NonNull (and @Nullable and so on) annotations
of <http://types.cs.washington.edu/checker-framework/> are a
superior approach.

-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

Re: A hypothetical compiler extension Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-10-27 18:19 -0400

csiph-web