-
Bug
-
Resolution: Fixed
-
P4
-
9
-
b55
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8084007 | emb-9 | Brian Burkhalter | P4 | Resolved | Fixed | team |
JDK-8327123 | 8u421 | Abhishek N | P4 | Resolved | Fixed | b01 |
This is what I found:
1. Seed is constant hence redundant to print on failure
./BigInteger/ModPow.java
./BigInteger/PrimitiveConversionTests.java
2. Seed is printed on failure
./BigDecimal/StringConstructor.java
3. Seed is not printed on failure
3.1 Uses parameterless Random()
./BigInteger/BigIntegerTest.java
./BigInteger/ModPow65537.java
./BigInteger/SymmetricRangeTests.java
Fixing these tests to print the seed is not a problem as a construct such as
private static int seed = new Random().nextInt();
private static Random rnd = new Random(seed);
which is used in the StringConstructor test could be applied. The Random instance actually used is ‘rnd’ and while its seed itself is random it is known and may be printed.
A slight change might actually be better:
private static Random rnd;
private static long seed;
static {
rnd = new Random();
seed = rnd.nextLong();
rnd.setSeed(seed);
}
3.2 Uses parameterless SplittableRandom()
./BigInteger/PrimeTest.java
Something similar to what is currently done in StringConstructor could be done here as well to fix the problem. SplittableRandom does not have a setSeed() method so the other approach is infeasible.
Note that there is no way to retrieve from an instance of either class the seed that was used by the parameterless constructor.
1. Seed is constant hence redundant to print on failure
./BigInteger/ModPow.java
./BigInteger/PrimitiveConversionTests.java
2. Seed is printed on failure
./BigDecimal/StringConstructor.java
3. Seed is not printed on failure
3.1 Uses parameterless Random()
./BigInteger/BigIntegerTest.java
./BigInteger/ModPow65537.java
./BigInteger/SymmetricRangeTests.java
Fixing these tests to print the seed is not a problem as a construct such as
private static int seed = new Random().nextInt();
private static Random rnd = new Random(seed);
which is used in the StringConstructor test could be applied. The Random instance actually used is ‘rnd’ and while its seed itself is random it is known and may be printed.
A slight change might actually be better:
private static Random rnd;
private static long seed;
static {
rnd = new Random();
seed = rnd.nextLong();
rnd.setSeed(seed);
}
3.2 Uses parameterless SplittableRandom()
./BigInteger/PrimeTest.java
Something similar to what is currently done in StringConstructor could be done here as well to fix the problem. SplittableRandom does not have a setSeed() method so the other approach is infeasible.
Note that there is no way to retrieve from an instance of either class the seed that was used by the parameterless constructor.
- backported by
-
JDK-8084007 Always print seeds used in [Splittable]Random instances in java.math tests
- Resolved
-
JDK-8327123 Always print seeds used in [Splittable]Random instances in java.math tests
- Resolved
- duplicates
-
JDK-8051861 [TESTBUG] test "java/math/BigInteger/BigIntegerTest.java" does not hold Random value to have a possibility to reproduce it
- Closed
- relates to
-
JDK-8078672 Print and allow setting by Java property seeds used to initialize Random instances in java.lang numerics tests
- Closed
-
JDK-8078334 Mark regression tests using randomness
- Resolved