Saturday, February 18, 2012

Null analysis for fields in Eclipse JDT withdrawn for Juno

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 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() {
            return this.o;


  1. But the null analysis for method parmeters and return values will make it?

  2. @Jan, Yes! definitely. But watch out when you pass a field as a method argument or when you return a field from an annotated method. You're on your own in dealing with fields, atleast for Juno. :)