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: 6850606
Votes 0
Synopsis Regression from JDK 1.6.0_12
Category java:classes_math
Reported Against
Release Fixed 7(b64)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs
Submit Date 12-JUN-2009
Description
FULL PRODUCT VERSION :
C:\JAVA\jdk1.6.0_14_32bit\bin>java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Windows XP Pro 64 bit, SP2

A DESCRIPTION OF THE PROBLEM :
The following code runs fine under JDK 1.6.0_12, but fails with a NullPointerException in JDK 1.6.0_14

    public void testCanApproximateLogWithInputTerms() {

        BigDecimal x = BigDecimal.valueOf(8L, 1);
        BigDecimal xPower = BigDecimal.valueOf(-1L);

        for (int i = 0; i < 100; i++) {
            xPower = xPower.multiply(x);
        }
    }


java.lang.NullPointerException
	at java.math.BigDecimal.multiply(BigDecimal.java:1312)
	at com.rtrms.math.EulersSumTest.testCanApproximateLogWithInputTerms(EulersSumTest.java:25)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Excecute the test code listed above

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should run without error
ACTUAL -
java.lang.NullPointerException
	at java.math.BigDecimal.multiply(BigDecimal.java:1312)
	at com.rtrms.math.EulersSumTest.testCanApproximateLogWithInputTerms(EulersSumTest.java:25)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)


ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
	at java.math.BigDecimal.multiply(BigDecimal.java:1312)
	at com.rtrms.math.EulersSumTest.testCanApproximateLogWithInputTerms(EulersSumTest.java:25)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
    public void testCanApproximateLogWithInputTerms() {

        BigDecimal x = BigDecimal.valueOf(8L, 1);
        BigDecimal xPower = BigDecimal.valueOf(-1L);

        for (int i = 0; i < 100; i++) {
            xPower = xPower.multiply(x);
        }
    }


---------- END SOURCE ----------

Release Regression From : 6u12
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.
Posted Date : 2009-06-12 08:03:52.0
Work Around
N/A
Evaluation
The root cause is that when the product is equals to INFLATED, we construct the returned BigDecimal for multiply explicity and set the intVal to null which is wrong. The correct way is to use BigDecimal.valueOf(product, productScale) since valueOf will take care of the INFLATED case.
Posted Date : 2009-06-18 05:06:20.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang