United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6365176 java.math.BigInteger.ZERO.multiply(null)
JDK-6365176 : java.math.BigInteger.ZERO.multiply(null)

Details
Type:
Bug
Submit Date:
2005-12-19
Status:
Closed
Updated Date:
2011-05-18
Project Name:
JDK
Resolved Date:
2011-05-18
Component:
core-libs
OS:
linux
Sub-Component:
java.math
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports
Backport:
Backport:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Linux em-09.fitc.org.ar 2.6.11-6mdk #1 Tue Mar 22 16:04:32 CET 2005 i686 Intel(R) Pentium(R) 4 CPU 2.26GHz unknown GNU/Linux


A DESCRIPTION OF THE PROBLEM :
The specification says that "all methods in this class [java.math.BigInteger] throw NullPointerException when passed a null object reference for any input parameter", but BigInteger.ZERO.multiply(null) returns 0.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
execute the sample program

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
NullPointerException to be throw
ACTUAL -
return BigInteger.ZERO

ERROR MESSAGES/STACK TRACES THAT OCCUR :
... the problem is there is no error message (but there should be)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class ZeroByNull{
    public static void main (String[] args){
        System.out.println(java.math.BigInteger.ZERO.multiply(null));
    }
}
---------- END SOURCE ----------

                                    

Comments
EVALUATION

Will investigate.
                                     
2005-12-21
SUGGESTED FIX

src/share/classes/java/math>sccs sccsdiff -r1.76 -r1.77 BigInteger.java

------- BigInteger.java -------
1162c1162
<         if (signum == 0 || val.signum==0)
---
>         if (val.signum == 0 || signum == 0)

Also see attached webrev tar-ball.
                                     
2006-10-14



Hardware and Software, Engineered to Work Together