No @NotNull annotations shown in latest Preview version

I have one very simple method:

public void testNull(String s) {
      if (s == null) {
         return;
      }

      System.out.println("ok");
   }

I don't see any @NotNull annotation for it in the gutter, and I think it should be shown as written here:
http://blog.jetbrains.com/idea/2014/10/automatic-notnullnullablecontract-inference-in-intellij-idea-14/

Am I doing something wrong or is this a bug?

3 comments
Comment actions Permalink

@NotNull on a parameter means that a method will surely fail if this parameter is null. Your method won't fail, so there's no reason for @NotNull to be there. Besides, only contract annotations are inferred so far from the sources, @NotNull's are only inferred automatically in the library code. You can open, for example, SwingUtilities class and see a lot of them there.

0
Comment actions Permalink

Hi Peter,

you are basically saing that:
- those annotations are not displayed on-the-fly, but only when the resp. code is a dependency of the project (jar).
- for my example, (if the code was in a jar), a @Nullable annotation would be shown.

Have I got you correctly?

Thanks
Ivaylo

0

Please sign in to leave a comment.