Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #32946 > unrolled thread
| Started by | Jan Burse <janburse@fastmail.fm> |
|---|---|
| First post | 2015-10-27 23:02 +0100 |
| Last post | 2015-10-27 23:02 +0100 |
| 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.
Re: A hypothetical compiler extension Jan Burse <janburse@fastmail.fm> - 2015-10-27 23:02 +0100
| From | Jan Burse <janburse@fastmail.fm> |
|---|---|
| Date | 2015-10-27 23:02 +0100 |
| Subject | Re: A hypothetical compiler extension |
| Message-ID | <n0osa2$v6d$1@news.albasani.net> |
IntelliJ does this already.
Stefan Ram schrieb:
> 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.
>
> Javac alread has path-value-analysis as it already can
> detect when a path of execution of a method (think of
> nested ifs) accesses a variable that has not been
> defined yet in this path.
>
> We also could have
>
> javac -Xlint:0
>
> void m( final int i )
> { java.lang.System.out.println( 1/i ); }
> ^
> Warning: i might be zero.
>
> void m( final int i )
> { if( i != 0 )
> java.lang.System.out.println( 1/i ); }
>
> That would give you more security, but you could stay within
> the bounds of Java and would not have to be forced to use,
> for example, Scala.
>
Back to top | Article view | comp.lang.java.programmer
csiph-web