Long valueOf instead of new Long
Andrej Golovnin
andrej.golovnin at gmail.com
Thu Jun 26 13:29:35 UTC 2014
Hi Paul,
Seems fine to me (pending a full test run).
>
> Just a syntax niggle in the following, too many brackets:
>
> +++
> new/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java
> 2014-06-14 10:16:02.486298421 -0300
> @@ -544,7 +544,7 @@
> }
>
> // convert seconds to milliseconds for time comparison
> - currencyPeriod = ((new Long(expTime)).longValue()) * 1000;
> + currencyPeriod = ((Long.valueOf(expTime)).longValue()) * 1000;
> if (currencyPeriod < 0) {
> /* if currencyTimeLimit is -1 then value is never cached
> */
> returnCachedValue = false;
> @@ -580,7 +580,7 @@
> if (tStamp == null)
> tStamp = "0";
>
> - long lastTime = (new Long(tStamp)).longValue();
> + long lastTime = (Long.valueOf(tStamp)).longValue();
>
>
> Paul.
>
>
Wouldn't it be better to use here Long.parseLong(String)?
Long.valueOf(String) would always create a new object here, as expTime and
tStamp represents the time and they are never in the range [-128;127].
Best regards,
Andrej Golovnin
More information about the core-libs-dev
mailing list