I have reminiscence that the general rule is that unless otherwise
stated methods and constructors will throw NPE if passed null
argument.

Unfortunately I have not found more general place in javadoc stating
this except following citing from java.util.logging package
description:

"In general, unless otherwise noted in the javadoc, methods and
contructors will throw NullPointerException if passed a null argument.
The one broad exception to this rule is that the logging convenience
methods in the Logger class (the config, entering, exiting, fine,
finer, finest, log, logp, logrb, severe, throwing, and warning
methods) will accept null values for all arguments except for the
initial Level argument (if any)."

I understand this as that in general methods and constructors do not
check if arguments passed are null or not, otherwise javadoc specifies
the exact behavior. Of course there are exceptions which are not
stated in javadoc, but those exceptions should be checked on case by
case basis.

Also I think that exact checks for null arguments are not necessary
(except those cases when they have special meaning) and moreover could
cause performance impact.

--
Nikolay Kuznetsov,
Intel Middleware Products Division

Reply via email to