Hi Sebb
Thanks for having a look through the PR. I appreciate all the work you
do with JMeter!
I do not fully understand your argument. Do you have an example of
issues to help me understand where explicit (un)boxing would help
prevent a problem?
My main reason for the PR was to reduce the amount of code to improve
readability. In my opinion most explicit (un)boxing is just noise -
happy to be persuaded otherwise.
For example:
What potential problems does the booleanValue() here avoid? I
understand the need for the null check as you are right auto unboxing
could hide a NPE.
if (success != null) {
if (success.booleanValue()) { ...
vs.:
if (success != null) {
if (success) { ...
If the reasoning was to make it even more obvious that it was an
object and needed the null check, then, just as one example, this
hasn't worked in the HtmlTemplateExporter class, the method
EmptyGraphChecker.checkResult has
supportsControllerDiscrimination.booleanValue() but no null check even
though the method which created it could return null.
As another example, in a method which returns a long, I do not
understand why the .longValue() is helpful, e.g.:
public long getTimestamp() {
return getData(long.class, CSVSaveService.TIME_STAMP).longValue();
}
Or why:
Double.valueOf(((double) data.longValue() * 100 / errorCount))
is preferred over:
((double) data * 100 / errorCount)
I acknowledge you need to be mindful of NPE and auto (un)boxing in
loops etc.
(http://brian.pontarelli.com/2004/07/15/jdk-5-auto-boxing-best-practices/)
but I currently do not see how being explicit about (ub)boxing helps?
I would very much appreciate any time you (or anyone else on the list)
could spare to improve my understanding of this issue, via email or
perhaps comment in github on specific changes and I would be happy to
update the PR.
Many thanks
Graham
On Mon, 15 Feb 2016 at 09:32 sebb <[email protected]> wrote:
>
> -1
>
> Auto boxing is generally a bad idea as it can hide poor design (wrong
> choice of long/Long).
>
> It can also hide wrong choice of method (Long.parseLong/Long.decode)
>
> Implicit unboxing can hide potential NPE.
>
> About the only place where autoboxing is useful is in String.format,
> but that should not be used as an excuse to allow it elsewhere.
>