Enforcing Component Constraints
Cantor, Scott
cantor.2 at osu.edu
Fri Jan 27 14:17:29 EST 2017
On 1/27/17, 1:45 PM, "dev on behalf of Brent Putman" <dev-bounces at shibboleth.net on behalf of putmanb at georgetown.edu> wrote:
> Note that: The callee method really could only drop the check if the potentially-null arg was only going to be used
> internally within itself, and in such as way that you know that a null would "safely" result in an NPE.
I have a much harder line on that, I guess. If something is annotated nonnull, that to me says the code should be able to operate as though it is a given that that variable is not null. That goes for everything, including subsequent uses of the variable as input to something else. If it's null, there was a bug in the original caller, and when it fails, that code will be fixed. That's just how I think about the concept, it was why I thought the idea was created.
Otherwise the code is just being littered with the same null checks that would already be happening in a world without the annotation, because as you note the common case will be crossing of methods anyway.
I recognize that the AOP trick is a nice middle ground, with my annoyance at seeing the checks dispensed with. So I definitely can see the value of that.
> So it has the obligation to do the check, and incur the cost.
I think it is freed from that obligation by its own annotation.
-- Scott
More information about the dev
mailing list