As the title says, I am wondering what the best practice is regarding the throwing of NullPointerExceptions. Specifically, if I have an external library function that can return
Very interesting question.
I think some kind of ProblemCreatingSynthesizerException
should be thrown by that method, instead of returning null.
I'd put the null check and throw a NPE or other custom ProblemWithSynthesizerException
of your own (Sun, for some reason, conceived this Exception as a JVM-ish exception, not meant to be used by the programmer. This is what it says in some certification tutorials and books. However, I don't buy that, and some often I throw my own NPEs in my libraries).