"enable syntactic null analysis for fields" broken with eclise 4.4rc1 jdk1.8 [message #1378592] |
Sat, 24 May 2014 09:50  |
Eclipse User |
|
|
|
With "enable syntactic null analysis for fields" enabled, the "a.toString();" compiles ok in java1.7 compliance, but give a warning/error with java1.8
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
public class Test3 {
@Nullable Integer a;
@NonNull
Integer get() {
return new Integer(1);
}
void test() {
a = get();
a.toString();
}
}
|
|
|
Re: "enable syntactic null analysis for fields" broken with eclise 4.4rc1 jdk1.8 [message #1379024 is a reply to message #1378592] |
Sat, 24 May 2014 14:14   |
Eclipse User |
|
|
|
Works for me - but sometimes the null analysis warnings/errors start to
show up arbitarily :-(
I also think that generally speaking this code is haveing the risk of
NPEs if it is used in a multi-threaded env.
Tom
On 24.05.14 11:50, Nicola Zanaga wrote:
> With "enable syntactic null analysis for fields" enabled, the
> "a.toString();" compiles ok in java1.7 compliance, but give a
> warning/error with java1.8
>
>
> import org.eclipse.jdt.annotation.NonNull;
> import org.eclipse.jdt.annotation.Nullable;
>
> public class Test3 {
> @Nullable Integer a;
>
> @NonNull
> Integer get() {
> return new Integer(1);
> }
> void test() {
> a = get();
> a.toString();
> }
> }
|
|
|
Re: "enable syntactic null analysis for fields" broken with eclise 4.4rc1 jdk1.8 [message #1379149 is a reply to message #1379024] |
Sat, 24 May 2014 15:29   |
Eclipse User |
|
|
|
With eclipse 4.4rc2 the warning still exists, are you sure using "compiler compliance level" 1.8 ? When using java 1.8 but with compliance 1.8, all works fine.
The option "enable syntactic null analysis for fields" is explained at
http://wiki.eclipse.org/JDT_Core/Null_Analysis/Beta
and it's supposed to eliminate this warning
Thomas Schindl wrote on Sat, 24 May 2014 10:14Works for me - but sometimes the null analysis warnings/errors start to
show up arbitarily 
I also think that generally speaking this code is haveing the risk of
NPEs if it is used in a multi-threaded env.
Tom
On 24.05.14 11:50, Nicola Zanaga wrote:
> With "enable syntactic null analysis for fields" enabled, the
> "a.toString();" compiles ok in java1.7 compliance, but give a
> warning/error with java1.8
>
>
> import org.eclipse.jdt.annotation.NonNull;
> import org.eclipse.jdt.annotation.Nullable;
>
> public class Test3 {
> @Nullable Integer a;
>
> @NonNull
> Integer get() {
> return new Integer(1);
> }
> void test() {
> a = get();
> a.toString();
> }
> }
|
|
|
|
Powered by
FUDForum. Page generated in 0.03377 seconds