not annotated method overrides method annotated with @notnull

I've posted this question on stack overflow, so you can see it's entirety here: http://stackoverflow.com/questions/24495448/not-annotated-method-overrides-method-annotated-with-notnull
However, I still haven't gotten an answer to this. The behavior and all the different things I've tried to get rid of this problem makes me think it's a bug, but I thought I would ask here.

Basically I get the error message stated in the title on a method where I return the value of the List field's .toArray() method. I've tried things like

return null != list ? list.toArray() : new Object[0];

and adding the @NotNull annotation to the method, (com.sun.istack.internal.NotNull)

but this has no effect and the warning won't go away.

2 comments
Comment actions Permalink

I was trying to eradicate the warning without having to change the settings (plus, I do want to be able to see that warning in other places... that's assuming it isn't broken), because the rest of my company has switched over to IDEA and would see the same warnings. Moreover, I'm just puzzled at why this warning would be shown, I've looked at the implemented interfaces (both, since this class implements both Set and List), neither of them has a @NotNull annotation

1
Comment actions Permalink

You are implementing an interface for which IDEA has inferred "@org.jetbrains.annotations.NotNull" annotation.
I think this is a problem (don't want to say it is bug, it might be intentional) of the inspection called "@NotNull/@Nullable problems".

You can simply disable the rule "Report non-annotated parameters or methods overriding @NotNull" in Settings / Inspections / @NotNull/@Nullable problems

-1

Please sign in to leave a comment.