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

java.lang.NegativeArraySizeException in tenToThe

XMLWordPrintable

    • b77
    • sparc
    • windows_xp
    • Not verified

      OPERATING SYSTEM(S):
      Windows XP

      FULL JDK VERSION(S):
      java version "1.5.0_08"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)

      DESCRIPTION:
      checkScale allows a value of 2147483647 for the scale but when this
      is passed into tenToThe, a new char array is created with a size one
      larger 'new char[n + 1]' which causes the exception.

      import java.math.BigDecimal;

      public class d108737 {
          public static void main(String[] args) {
              BigDecimal.ONE.setScale(Integer.MAX_VALUE);
          }
      }

      - Exact text of any error messages
      Output:
      Exception in thread "main" java.lang.NegativeArraySizeException
              at java.math.BigDecimal.tenToThe(BigDecimal.java:3117)
              at java.math.BigDecimal.setScale(BigDecimal.java:2300)
              at java.math.BigDecimal.setScale(BigDecimal.java:2348)
              at d108737.main(d108737.java:5)

            bpb Brian Burkhalter
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: