-
Bug
-
Resolution: Fixed
-
P4
-
17
-
b19
SonarCloud reports:
Cast one of the operands of this subtraction operation to a "long".
Here:
Spliterator<SplittableGenerator> makeSplitsSpliterator(long index, long fence, SplittableGenerator source) {
...
long multiplier = (1 << SALT_SHIFT) - 1; // <---- here
The shift is integer, and the cast to long is too late. SALT_SHIFT is currently 4, so this is not the problem. But it would become a problem if SALT_SHIFT ever becomes 32 or larger. The shift operand should be 1L for safety. Observe:
jshell> Long.toHexString((1 << 31) - 1)
$2 ==> "7fffffff"
jshell> Long.toHexString((1 << 32) - 1)
$3 ==> "0"
jshell> Long.toHexString((1L << 32) - 1)
$4 ==> "ffffffff"
Cast one of the operands of this subtraction operation to a "long".
Here:
Spliterator<SplittableGenerator> makeSplitsSpliterator(long index, long fence, SplittableGenerator source) {
...
long multiplier = (1 << SALT_SHIFT) - 1; // <---- here
The shift is integer, and the cast to long is too late. SALT_SHIFT is currently 4, so this is not the problem. But it would become a problem if SALT_SHIFT ever becomes 32 or larger. The shift operand should be 1L for safety. Observe:
jshell> Long.toHexString((1 << 31) - 1)
$2 ==> "7fffffff"
jshell> Long.toHexString((1 << 32) - 1)
$3 ==> "0"
jshell> Long.toHexString((1L << 32) - 1)
$4 ==> "ffffffff"
- relates to
-
JDK-8248862 Implement Enhanced Pseudo-Random Number Generators
-
- Resolved
-