Null analysis for fields with Eclipse JDT , introduced in Juno M5, has been withdrawn and will not be available in the Juno release. Only Juno M5 will contain this feature. The reason for withdrawal is the fact that becuase of implementation constraints, it could not support analysis for alien field references i.e. non-static fields of objects other than 'this'. We will rework the implementation and come back with a full fledged support for fields, including annotations to support null analysis for fields. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=247564#c176 for more details.
Apologies to those who were looking forward to a complete null annotations support for fields as well. We are considering making the current implementation of the feature available as a plugin patch. I will keep you posted.
Also, even when using annotations for method return and parameters, be careful in dealing with fields because we don't warn there. Eg:
class A{
Object o = null;
void goo(@NonNull Object param) {}
@NonNull Object foo() {
goo(this.o);
return this.o;
}
}
Apologies to those who were looking forward to a complete null annotations support for fields as well. We are considering making the current implementation of the feature available as a plugin patch. I will keep you posted.
Also, even when using annotations for method return and parameters, be careful in dealing with fields because we don't warn there. Eg:
class A{
Object o = null;
void goo(@NonNull Object param) {}
@NonNull Object foo() {
goo(this.o);
return this.o;
}
}