I'm using the NotNull annotations in a lot of my code. I am also using some code generated by XMLBeans, which of course contains no Nullable/NotNull annotations.
I'm having some problems where these two pieces of code meet:
String label = bean.getLabel(); // This is a generated method with no annotations
model.setLabel( label ); // This is my method, declared as setLabel( @NotNull String inLabel );
The problem is that my bean may return a null value for label. When this happens, I get a runtime exception because the @NotNull contract is violated. I see no compiler warning on the call to setLabel(). It's as if Idea is assuming that getLabel() is marked with a @NotNull for the return value.
I don't think Idea is being paranoid enough in this case. I think Idea should automatically assume that any unannotated method (such as the getLabel() above) is @Nullable .Then I would see a compiler warning on the next line.
I understand that this could be really annoying, but if you're going to rely on these annotations, it's better to be overly paranoid than too lax.
Perhaps we could have a project setting like "Assume unannotated mehtods return @Nullable"?