-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
8u31
-
x86
-
windows_8
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
The "sum()" method in the classes IntStream/LongStream (of the package java.util.stream) must throw an ArithmeticException if overflow occurs.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An ArithmeticException is thrown.
ACTUAL -
Overflow occurs and a negative result is printed.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.stream.IntStream;
class IntStreamSum {
public static void main(String[] args) {
System.out.println(IntStream.range(1, 65537).sum());
}
}
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
The "sum()" method in the classes IntStream/LongStream (of the package java.util.stream) must throw an ArithmeticException if overflow occurs.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An ArithmeticException is thrown.
ACTUAL -
Overflow occurs and a negative result is printed.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.stream.IntStream;
class IntStreamSum {
public static void main(String[] args) {
System.out.println(IntStream.range(1, 65537).sum());
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8073940 IntStream/LongStream/DoubleStream: sum() specifications must be expanded
- Open