RFR: 8248862: Implement Enhanced Pseudo-Random Number Generators [v17]
Andrey Turbanov
github.com+741251+turbanoff at openjdk.java.net
Sat Feb 13 21:34:42 UTC 2021
On Thu, 11 Feb 2021 16:02:03 GMT, Jim Laskey <jlaskey at openjdk.org> wrote:
>> This PR is to introduce a new random number API for the JDK. The primary API is found in RandomGenerator and RandomGeneratorFactory. Further description can be found in the JEP https://openjdk.java.net/jeps/356 .
>>
>> javadoc can be found at http://cr.openjdk.java.net/~jlaskey/prng/doc/api/java.base/java/util/random/package-summary.html
>>
>> old PR: https://github.com/openjdk/jdk/pull/1273
>
> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>
> Added table of available algorithms.
src/java.base/share/classes/jdk/internal/util/random/RandomSupport.java line 149:
> 147: */
> 148: public static void checkJumpDistance(double distance) {
> 149: if (!(distance > 0.0 && distance < Float.POSITIVE_INFINITY
I wounder if this usage of `Float.POSITIVE_INFINITY` intentional here? Looks a bit suspicious for comparison with `double` argument
src/java.base/share/classes/jdk/internal/util/random/RandomSupport.java line 1548:
> 1546: * @return a stream of (pseudo)randomly chosen {@code int} values
> 1547: */
> 1548:
Is `@Override` intentionally omitted?
src/java.base/share/classes/jdk/internal/util/random/RandomSupport.java line 1943:
> 1941:
> 1942: // IllegalArgumentException messages
> 1943: static final String BadLogDistance = "logDistance must be non-negative";
seems unused
test/jdk/java/util/Random/RandomTestBsi1999.java line 227:
> 225: static int checkRunStats(int[] stats) {
> 226: int runFailure = 0;
> 227: runFailure |= ((2267 <= stats[1]) || (stats[1] <= 2733)) ? 0 : 1;
1. confusing formatting.
2. This condition is always `true`. Looks like `&&` should be used instead of `||`
-------------
PR: https://git.openjdk.java.net/jdk/pull/1292
More information about the security-dev
mailing list