Name: gm110360 Date: 02/11/2004
FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Documentation of new 1.5 static methods valueOf() in the java.lang primitive wrapper classes (Integer, Long, etc.) is misleading. For example, the Integer class valueOf() method reads as follows:
Returns a Integer instance representing the specified int value. If a new Integer instance is not required, this method should generally be used in preference to the constructor Integer(int), as this method is likely to to yield significantly better space and time performance by cacheing frequently requested values.
Besides the fact that "Returns a Integer" should read "Returns an Integer", "to to" should simply read "to" and "cacheing" should read "caching", here is the source code for the method:
public static Integer valueOf(int i) {
return new Integer(i);
}
Maybe I am missing something but how is it invoking a method which is wrappering a constructor faster than simply calling the constructor directly?
REPRODUCIBILITY :
This bug can be reproduced always.
(Incident Review ID: 237738)
======================================================================