When there is a post-condition, that return value of a method must not be null, what can be done?
I could do
assert returnValue != null : "Not acceptable null value";
but assertions could be turned off!
So is it okay to do
if(returnValue==null)
{
throw new NullPointerException("return value is null at method AAA");
}
?
Or is it better to use a user-defined exception (like NullReturnValueException ) for such a condition?