-
Enhancement
-
Resolution: Fixed
-
P4
-
5.0
-
None
-
beta
-
generic
-
generic
In src/share/classes/java/io/ObjectStreamClass.java there are currently several places in which new instances of java.lang.Long are constructed:
ObjectStreamClass.java:187: return new Long(computeDefaultSUID(cl));
ObjectStreamClass.java:388: suid = new Long(0);
ObjectStreamClass.java:425: suid = new Long(0);
ObjectStreamClass.java:472: suid = new Long(0);
ObjectStreamClass.java:504: suid = new Long(model.getSerialVersionUID());
ObjectStreamClass.java:586: suid = new Long(in.readLong());
ObjectStreamClass.java:1571: return new Long(f.getLong(null));
Rather than unconditionally creating new Long instances, this code should instead use the method Long.valueOf(long) (introduced in 5.0), which will share instances in some cases, like for values of zero and other low numbers, potentially reducing memory footprint slightly.
ObjectStreamClass.java:187: return new Long(computeDefaultSUID(cl));
ObjectStreamClass.java:388: suid = new Long(0);
ObjectStreamClass.java:425: suid = new Long(0);
ObjectStreamClass.java:472: suid = new Long(0);
ObjectStreamClass.java:504: suid = new Long(model.getSerialVersionUID());
ObjectStreamClass.java:586: suid = new Long(in.readLong());
ObjectStreamClass.java:1571: return new Long(f.getLong(null));
Rather than unconditionally creating new Long instances, this code should instead use the method Long.valueOf(long) (introduced in 5.0), which will share instances in some cases, like for values of zero and other low numbers, potentially reducing memory footprint slightly.
- relates to
-
JDK-8248318 Remove superfluous use of boxing in ObjectStreamClass
-
- Resolved
-