JDK-6365176 : java.math.BigInteger.ZERO.multiply(null)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.math
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2005-12-19
  • Updated: 2017-05-16
  • Resolved: 2011-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u14Fixed 7 b03Fixed OpenJDK6Resolved
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
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.
14-10-2006

EVALUATION Will investigate.
21-12-2005