RFR: JDK-8282144 RandomSupport.convertSeedBytesToLongs sign extension overwrites previous bytes
Brian Burkhalter
bpb at openjdk.java.net
Mon Mar 7 22:46:04 UTC 2022
On Sun, 27 Feb 2022 22:30:44 GMT, Jim Laskey <jlaskey at openjdk.org> wrote:
>> test/jdk/java/util/Random/T8282144.java line 39:
>>
>>> 37: public class T8282144 {
>>> 38: public static void main(String[] args) {
>>> 39: RandomGenerator rng = RandomGeneratorFactory.of("L64X128MixRandom").create(42);
>>
>> Does `rng` always produce the same sequence? If so, then perhaps the seed, `42`, should be a random value that is printed.
>
> 42 was chosen because its is known to produce negative byte values, other random values might not.
OK
>> test/jdk/java/util/Random/T8282144.java line 52:
>>
>>> 50: for (int k = 0; k < existing.length; k++) {
>>> 51: if (existing[k] != testing[k]) {
>>> 52: throw new RuntimeException("convertSeedBytesToLongs incorrect");
>>
>> Should `i`, `j`, and `k` be included in the exception message?
>
> Correctness is binary - either it works or it doesn't. The values of i, j, k would not assist in isolating issues. Might add to confusion if displayed.
Understood.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7614
More information about the core-libs-dev
mailing list