Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6806261
Votes 0
Synopsis BigDecimal.longValueExact() method throws NullPointerException
Category java:classes_math
Reported Against
Release Fixed 6u14(b03)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 6622432
Submit Date 17-FEB-2009
Description
BigDecimal.longValueExact() method throws NullpointerException with 6u14-b01 build.
Following testcase could be used to reproduce the issue.

<Code>

import java.math.BigDecimal;
class BigDecimalTest
{
 public static void main(String... args){
        try {
			  String longValue = "9223372036854775807.0";
              BigDecimal bd = new BigDecimal(longValue);
              long longvalue= bd.longValue();
              long longValueExact = bd.longValueExact();
              System.out.println("Test passed ");
        } catch(ArithmeticException e) {             
			 System.out.println("Test failed ");
             e.printStackTrace();
        }

    }
}

</Code>

<Output>
Exception in thread "main" java.lang.NullPointerException
        at java.math.BigDecimal$LongOverflow.check(BigDecimal.java:2974)
        at java.math.BigDecimal.longValueExact(BigDecimal.java:2962)
        at BigDecimalTest.main(BigDecimalTest.java:9)

</Output>

java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b01)
Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode)


This test passes with the 6u12-b04 promoted build. Fix for the bug 6622432 may have caused this regression.
Posted Date : 2009-02-17 10:26:25.0
Work Around
N/A
Evaluation
The root cause of the NullPointerException in the test case is that we try to refer intVal before actually calling inflate(). The fix is to add inflate() call.
Posted Date : 2009-02-17 20:19:35.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang