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


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

Re: A hypothetical compiler extension

Started byEric Sosman <esosman@comcast-dot-net.invalid>
First post2015-10-27 18:19 -0400
Last post2015-10-27 18:19 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.java.programmer

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#32948 — Re: A hypothetical compiler extension

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2015-10-27 18:19 -0400
SubjectRe: A hypothetical compiler extension
Message-ID<n0ot61$l85$1@dont-email.me>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web