Bug 403192 - Assignment of NULL to a @NotNull field is not detected
Summary: Assignment of NULL to a @NotNull field is not detected
Status: RESOLVED DUPLICATE of bug 331649
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.2.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.3 M5   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-13 09:55 EDT by Arno Unkrig CLA
Modified: 2013-03-13 12:27 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arno Unkrig CLA 2013-03-13 09:55:41 EDT
Null analysis of fields seems to not work at all. The simplest test case that I could think of

  package pkg;

  import org.eclipse.jdt.annotation.NonNull;

  public class Main {

      @NonNull Object f;

      public void
      meth() {
          this.f = null;
      }
  }

yields no error/warning. I have all options under "Warnings/Null analysis" switched on.

Am I doing something wrong?
Comment 1 Arno Unkrig CLA 2013-03-13 09:57:22 EDT
P.S.: My definition of "NonNull" is


package org.eclipse.jdt.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
@Documented
@Retention(RetentionPolicy.CLASS)
public @interface NonNull {

}
Comment 2 Arno Unkrig CLA 2013-03-13 10:42:41 EDT
Oh, I just saw

https://bugs.eclipse.org/bugs/show_bug.cgi?id=331649

This means that the feature will make it into 4.3 M5, great!
Comment 3 Arno Unkrig CLA 2013-03-13 10:43:33 EDT
Will be implemented in 4.3.
Comment 4 Jay Arthanareeswaran CLA 2013-03-13 12:26:11 EDT
In fact, you can just grab one of the recent I builds and start using this feature. And of course, if you want an official release, you will get it in 4.3.

*** This bug has been marked as a duplicate of bug 331649 ***
Comment 5 Jay Arthanareeswaran CLA 2013-03-13 12:27:08 EDT
Verified for 4.3 M6 with build I20130310-2000.