On 24 November 2013 08:52, Maurizio Cucchiara <mcucchi...@apache.org> wrote: > On 23 November 2013 16:05, sebb <seb...@gmail.com> wrote: >>Indeed; auto-unboxing can generate an NPE under some circumstances. >> And I found at least one case where the auto-boxing was hiding a bug >> (sorry, no longer have the details). > > IIRC the vars I have unboxed were only constant values. I can't > imagine how they can generate a NPE.
The constant values were using auto-boxing, which cannot generate an NPE. Only unboxing can generate NPE. However, the problem with allowing auto-boxing for constants is that it makes it hard to catch auto-boxing for variables in the same source file. If the warnings are enabled, then each of the constants will need an @SuppressWarning - which is even noisier than the original. >> Note also that removing explicit [un]boxing does not change the >> generated code, so I would not class it as an optimisation. > > The code is less verbose so I consider it a good optimisation in terms > of readability (calling every variables with just an alphabetic letter > doesn't change the generated code as well). I agree that constants like static final String S = "s"; are useless. But that is because the constant name is useless, as it does not describe what the constant is used for. > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org