If, for example, a method with a @NotNull parameter is invoked with null (despite the contract), I would expect that method to throw NullPointerException rather than an IllegalArgumentException. This would better mimic the customary use of Objects::requireNonNull null invariant assertion and would allow the removal of all these calls with no impact on production and test code.
Thus, it would be advantageous to be able to set the type of exception thrown. Preferably as a Maven configuration property. If a general exception supplier setting is not easy to do, then at least a <useNullPointerException>true</useNullPointerException> could be considered.
If, for example, a method with a
@NotNull
parameter is invoked withnull
(despite the contract), I would expect that method to throwNullPointerException
rather than anIllegalArgumentException
. This would better mimic the customary use ofObjects::requireNonNull
null invariant assertion and would allow the removal of all these calls with no impact on production and test code.Thus, it would be advantageous to be able to set the type of exception thrown. Preferably as a Maven configuration property. If a general exception supplier setting is not easy to do, then at least a
<useNullPointerException>true</useNullPointerException>
could be considered.See
ThrowOnNullMethodVisitor.IAE_CLASS_NAME