Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #32948
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: A hypothetical compiler extension |
| Date | 2015-10-27 18:19 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <n0ot61$l85$1@dont-email.me> (permalink) |
| References | <extension-20151027221547@ram.dialup.fu-berlin.de> |
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
Re: A hypothetical compiler extension Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-10-27 18:19 -0400
csiph-web