JDK-4951621 : change parameter type from String to CharSequence in numeric parse methods
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: linux
  • CPU: x86
  • Submitted: 2003-11-10
  • Updated: 2009-10-09
  • Resolved: 2009-10-09
Related Reports
Relates :  
Relates :  
Description
Name: rmT116609			Date: 11/10/2003


A DESCRIPTION OF THE REQUEST :
Now that the CharSequence interface exists, the parameters of numeric parse
methods (e.g., Integer.parseInt(String)) should probably be changed from
type String to type CharSequence.

This applies to:
* The java.lang.<numeric type> classes:
  - Byte.parseByte(...) methods
  - Short.parseShort(...) methods
  - Integer.parseInt(...) methods
  - Long.parseLong(...) methods
  - Float.parseFloat(...) method
  - Double.parseDouble(...) method
* java.util.Format classes:
  - java.util.Format.parseObject(...)
  - subclass parse(...) methods


JUSTIFICATION :
If nothing else, this change seems like something that should have been done
with the introduction of CharSequence in the first place.

Particularly, it would allow calling the numeric parse methods without having
to create a String object containing just the numeric characters (for example
if the caller has a character array, or a bigger String, within which it has
identified the position of numeric characters).
(Incident Review ID: 224683) 
======================================================================
###@###.### 10/28/04 01:10 GMT
In addition to the parse methods, bug 4838318 also requests that the following numeric methods also have CharSequence parameters:

  Integer(String s)
  Integer.valueOf(String s)
  Double(String s)

Clearly this recommendation would need to be applied to all of the wrapper classes, not just Integer and Double.

Comments
EVALUATION The API design of the text -> number conversion methods would no doubt be different if the CharSequence interface existed at the time of the initial design. However, at this point in the platform's evolution, replicating 5+ text -> number methods in each of Integer, Long, etc. to accept CharSequences instead of Strings does not seem worthwhile. Closing as will not fix.
09-10-2009

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
14-06-2004

EVALUATION A reasonble request; will consider for a future release. ###@###.### 2004-01-26
26-01-2004