Request for Review : CR#8004015 : [final (?) pass] Add interface extends and defaults for basic functional interfaces

Stephen Colebourne scolebourne at joda.org
Thu Dec 6 08:23:55 PST 2012


On 6 December 2012 15:56, Mike Duigou <mike.duigou at oracle.com> wrote:
> Something seems entirely out of balance regarding handling of null. If a methods says that it takes a reference type then why ever might it be assumed that null is permitted?
>
> It feels more than a bit like we are adding "no naked people" stickers to every building entrance and "do not insert fingers" to every electrical outlet. The "@throws NPE" are yet another layer of "Violators will be arrested" or "You will be electrocuted" stickers.
>
> It seems entirely wrongheaded to assume that null could be passed in place of a valid reference unless explicitly and categorically forbidden. Accepting null should be considered extraordinary and worthy of mention only when it occurs. Being rare it would also be a lot easier to document.
>
> So really, why mention null at all?

Null pointer exceptions are extremely common and costly. Sadly despite
asking, there seems to be no movement to handle the issue at what I
consider to be the root cause, lack of type-system support to
distinguish nullable from non-null references (annotations are not the
solution here). So, all we have is Javadoc.

If I had enough time, I would hassle every webrev until they
documented nulls properly. Absence of information at the method level
effectively tells me nothing.

The balance you seek is IMO what I do - two words on the end of the
@param. Mine is deliberately short and without @throws to avoid the
clutter you rightly sense could happen.

Stephen


More information about the lambda-dev mailing list