JDK-4831095 : BigDecimal constructor doesn't return exception with invalid format in 1.3.1_0X
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.math
  • Affected Version: 1.3.1_07
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2003-03-12
  • Updated: 2003-05-06
  • Resolved: 2003-05-06
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
When user set the invalid formatted value to BigDecimal, exception deosn't retrun in 1.3.1 and former versions.
Besides, the return value depends on each version.

REPRODUCE:
 1) Compile the attached test program.(BigDecimalTest.java)
 2) Launch "java BigDecimalTest"


EXPECTED VS ACTUAL BEHAVIOR:

 The test program specifies new BigDecimal("--6") and the followings are
 the result in each version.

  Expected : NumberFormatException should be thrown like 1.4.X does as follows.
    Exception in thread "main" java.lang.NumberFormatException: Illegal digit
        at java.math.BigInteger.<init>(BigInteger.java:316)
        at java.math.BigInteger.<init>(BigInteger.java:447)
        at java.math.BigDecimal.<init>(BigDecimal.java:216)
        at BigDecimalTest.main(BigDecimalTest.java:4)
  Actual   :
    1.2.2_014 : -6
    1.3.1_07  : -4294967290


=============================================================================


Comments
SUGGESTED FIX From the fix for 4489146, ------- BigInteger.java ------- 315a316,317 > if (mag[mag.length - 1] < 0) > throw new NumberFormatException("Illegal digit"); 322a325,326 > if (groupVal < 0) > throw new NumberFormatException("Illegal digit"); The regression test is in test/java/math/BigInteger/StringConstructor.java. ###@###.### 2003-03-12
12-03-2003

EVALUATION This sounds like a duplicate of 4489146, "BigInteger(String, int) does not fail on multiple minus signs." ###@###.### 2003-03-12
12-03-2003