Clemens Eisserer a écrit :
Hi cowwoc,
I guess you're right. It is probably as likely that the JIT will optimize
away the null check as it is that it will optimize away the
NullPointerException check. One exception, though, is when production
systems run using -Xverify:none. In such a case, wouldn't my approach run
faster?
I don't think it will optimize the null-check away,
Hotspot removes nullcheck and install a signal handler since its v2
(around 2000/01 If my memory serves me well).
however it is so
cheap that it most likely will not weight at all, compared to all the
other operations happening there. Its maybe 5 instructions compared to
thousands or even more.
-Xverify:none only disables bytecode verification at class-loading
time and has no influence (as far as I know) on the performance of the
generated code.
yes, and there is an option to remove nullcheck that is only available
on debug VM.
...
lg Clemens
Rémi