JDK-5084266 : Add capability to parse char[] to the Number subclasses
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2004-08-09
  • Updated: 2010-01-12
  • Resolved: 2010-01-12
Related Reports
Relates :  
Description
Name: js151677			Date: 08/09/2004


A DESCRIPTION OF THE REQUEST :
The subclasses of java.lang.Number have contructors accepting only a primative type or a String.  The parse*() methods for the Number subclasses  accept only a String.

When processing
The subclasses of java.lang.Number should have construcand constructors to parse a value from a char[] at an offset and length within the array.

When processing XML with the SAX parser one is provided a char() with
an offset and count for the subject content.  If the content is a number it must a String must be instantiated, and then the desired Number subclass instantiated from the string.  Often the value is assigned to a base type variable (int, float, etc). The String and Number objects, being temporary, are immediately available for garbage collection.

In situations were a large volume of numeric data is parsed, the temporary object creation can become an enormous burden on the virtual machine when it is trying to collect the temporary objects.



JUSTIFICATION :
This enhancement will reduce the creation of temporary objects during parsing oprtations by eliminating the need to created temporary String and Number objects.
(Incident Review ID: 296134) 
======================================================================

Comments
EVALUATION Parsing char[] in addition to strings only provides marginal utility, but adds API bloat. Closing as will not fix.
12-01-2010

EVALUATION Unless a subclass of Number is being returned, there is no longer a need to create a temporary object just to parse a string since the parseFoo methods are static and return a primtive type. While it can be useful to operate over char arrays, it could also be said that operating over StringBuffers, StringBuilders, and CharSequences are equally convenient. However, the marginal utility of all the different methods would be small. The memory management systems of current jvm's are able to optimize the handling of many short-lived objects. Will consider for a future release. ###@###.### 2004-08-09
09-08-2004