JDK-4311995 : BigDecimal String constructor throws StringIndexOutOfBounds
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2000-02-11
  • Updated: 2003-10-09
  • Resolved: 2000-06-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.3.1_10 10Fixed 1.4.0Fixed
Related Reports
Relates :  
Relates :  
Description

Name: tb29552			Date: 02/11/2000


/*

java version "1.3.0rc1"

BigDecimal Constructor for String throws
StringIndexOutOfBoundsException when the String has length of 0.

This is due to the fact that the constructor for the String
arguement has newly added code to check for signs; its the first
statements executed in the BigDecimal class, String Constructor,
under the comment "Deal with leading plus sign if present".  This
code was added with release 1.3.  Release 1.2 throws a
NumberFormatException.  This may be related to bug 4259453.

----------------

2/5/2000 eval1127@eng -- confirmed with kestrel build "U".

*/

import java.math.*;

public class BigDeal {

    public static void main(String[] args) {
        BigDecimal deal = new BigDecimal("");   // null String
    }
}
/*

% javac BigDeal.java
% java -showversion BigDeal
java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-U)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, interpreted mode)

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java:507)
        at java.math.BigDecimal.<init>(BigDecimal.java:129)
        at BigDeal.main(BigDeal.java:26)

------------

NOTE: with blank string (" "), get number format error

*/

(Review ID: 100836) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.3.1_10 generic FIXED IN: 1.3.1_10 merlin INTEGRATED IN: 1.3.1_10 merlin VERIFIED IN: 1.3.1_10
14-06-2004

WORK AROUND Name: tb29552 Date: 02/11/2000 I temporarily changed my code to catch Exception instead of NumberFormatException. ======================================================================
11-06-2004

PUBLIC COMMENTS .
10-06-2004

EVALUATION This will be addressed in the changes for 4294519. michael.mccloskey@eng 2000-02-11
11-02-2000