commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <>
Subject Re: svn commit: r1544770 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/
Date Sun, 24 Nov 2013 14:55:32 GMT
On 24 November 2013 08:52, Maurizio Cucchiara <> wrote:
> On 23 November 2013 16:05, sebb <> 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
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:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message