8334758: Incorrect note in Javadoc for a few RandomGenerator methods

Reviewed-by: bpb
This commit is contained in:
Raffaello Giulietti 2024-07-23 07:43:57 +00:00
parent 48030a2a86
commit 4c7b3e7fc3

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -809,12 +809,11 @@ public interface RandomGenerator {
* *
* @throws IllegalArgumentException if {@code bound} is not positive * @throws IllegalArgumentException if {@code bound} is not positive
* *
* @implSpec The default implementation checks that {@code bound} is a * @implSpec The default implementation checks that {@code bound} is positive.
* positive {@code int}. Then invokes {@code nextInt()}, limiting the result * It then invokes {@link #nextInt()} one or more times to ensure a uniform
* to be greater than or equal zero and less than {@code bound}. If {@code bound} * distribution in the range 0 (inclusive)
* is a power of two then limiting is a simple masking operation. Otherwise, * to {@code bound} (exclusive).
* the result is re-calculated by invoking {@code nextInt()} until the * It assumes the distribution of {@link #nextInt()} to be uniform.
* result is greater than or equal zero and less than {@code bound}.
*/ */
default int nextInt(int bound) { default int nextInt(int bound) {
RandomSupport.checkBound(bound); RandomSupport.checkBound(bound);
@ -835,13 +834,12 @@ public interface RandomGenerator {
* @throws IllegalArgumentException if {@code origin} is greater than * @throws IllegalArgumentException if {@code origin} is greater than
* or equal to {@code bound} * or equal to {@code bound}
* *
* @implSpec The default implementation checks that {@code origin} and * @implSpec The default implementation checks that {@code origin}
* {@code bound} are positive {@code ints}. Then invokes {@code nextInt()}, * is less than {@code bound}.
* limiting the result to be greater that or equal {@code origin} and less * It then invokes {@link #nextInt()} one or more times to ensure a uniform
* than {@code bound}. If {@code bound} is a power of two then limiting is a * distribution in the range {@code origin} (inclusive)
* simple masking operation. Otherwise, the result is re-calculated by * to {@code bound} (exclusive).
* invoking {@code nextInt()} until the result is greater than or equal * It assumes the distribution of {@link #nextInt()} to be uniform.
* {@code origin} and less than {@code bound}.
*/ */
default int nextInt(int origin, int bound) { default int nextInt(int origin, int bound) {
RandomSupport.checkRange(origin, bound); RandomSupport.checkRange(origin, bound);
@ -868,13 +866,11 @@ public interface RandomGenerator {
* *
* @throws IllegalArgumentException if {@code bound} is not positive * @throws IllegalArgumentException if {@code bound} is not positive
* *
* @implSpec The default implementation checks that {@code bound} is a * @implSpec The default implementation checks that {@code bound} is positive.
* positive {@code long}. Then invokes {@code nextLong()}, limiting the * It then invokes {@link #nextLong()} one or more times to ensure a uniform
* result to be greater than or equal zero and less than {@code bound}. If * distribution in the range 0 (inclusive)
* {@code bound} is a power of two then limiting is a simple masking * to {@code bound} (exclusive).
* operation. Otherwise, the result is re-calculated by invoking * It assumes the distribution of {@link #nextLong()} to be uniform.
* {@code nextLong()} until the result is greater than or equal zero and
* less than {@code bound}.
*/ */
default long nextLong(long bound) { default long nextLong(long bound) {
RandomSupport.checkBound(bound); RandomSupport.checkBound(bound);
@ -895,13 +891,12 @@ public interface RandomGenerator {
* @throws IllegalArgumentException if {@code origin} is greater than * @throws IllegalArgumentException if {@code origin} is greater than
* or equal to {@code bound} * or equal to {@code bound}
* *
* @implSpec The default implementation checks that {@code origin} and * @implSpec The default implementation checks that {@code origin}
* {@code bound} are positive {@code longs}. Then invokes {@code nextLong()}, * is less than {@code bound}.
* limiting the result to be greater than or equal {@code origin} and less * It then invokes {@link #nextLong()} one or more times to ensure a uniform
* than {@code bound}. If {@code bound} is a power of two then limiting is a * distribution in the range {@code origin} (inclusive)
* simple masking operation. Otherwise, the result is re-calculated by * to {@code bound} (exclusive).
* invoking {@code nextLong()} until the result is greater than or equal * It assumes the distribution of {@link #nextLong()} to be uniform.
* {@code origin} and less than {@code bound}.
*/ */
default long nextLong(long origin, long bound) { default long nextLong(long origin, long bound) {
RandomSupport.checkRange(origin, bound); RandomSupport.checkRange(origin, bound);