Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4311995

BigDecimal String constructor throws StringIndexOutOfBounds

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      10
    • CPU:
      x86
    • OS:
      windows_nt
    • Verification:
      Verified

      Backports

        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)
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                mmcclosksunw Michael Mccloskey (Inactive)
                Reporter:
                tbell Tim Bell
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: