java.util.Objects.requireNonNull: an opportunity for NullArgumentException?

Martin Desruisseaux martin.desruisseaux at geomatys.fr
Wed Feb 23 14:55:33 UTC 2011


Hello all

I apologize if this question was already debated previously. I just wonder: 
since JDK 7 defines an Object.requireNonNull(…) method for explicit checks of 
argument value, does the Project-Coin expert group has considered the addition 
of an explicit NullArgumentException extends NullPointerException for making 
clear that this exception is the result of an argument check rather than some 
bug hidden in the middle of a code?

Some kind of NullArgumentException seems a common addition in many libraries 
built on top of JDK. To name just a few from a quick Google search:

http://commons.apache.org/lang/api-2.3/org/apache/commons/lang/NullArgumentException.html
http://www.croftsoft.com/library/code/javadoc/core/com/croftsoft/core/lang/NullArgumentException.html
http://api.dpml.net/dpml/1.1.0/net/dpml/transit/NullArgumentException.html
http://www.geotoolkit.org/apidocs/org/geotoolkit/util/NullArgumentException.html

A blog:
http://closingbraces.net/2007/02/26/nullargumentexception/

Regards,

Martin




More information about the core-libs-dev mailing list