RFR: 8346107: Generators: testing utility for random value generation [v17]
Theo Weidmann
tweidmann at openjdk.org
Tue Jan 14 16:37:12 UTC 2025
On Tue, 14 Jan 2025 15:51:04 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> Theo Weidmann has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Remove unnecessary type postfixes
>
> test/hotspot/jtreg/compiler/lib/generators/Generators.java line 281:
>
>> 279: * values as powers of two.
>> 280: */
>> 281: public RestrictableGenerator<Integer> specialInts(int range) {
>
> IIUC, this will generate MIN and MAX and values around them but only with `range = 31`. Would it make sense to have a separate method that creates a generator with values including MIN, MAX, zero and values around them? We could also combine them with some power of twos. When calling this new method `specialInts`, we could rename this method to `powerOfTwos` or something like that. This might make it easier to understand the intent.
>
> Same for longs.
Min and max are in the set for range >= 1. But I agree that I would make sense to rename it to `powersOfTwo`. @eme64 What do you think?
> test/hotspot/jtreg/compiler/lib/generators/RandomnessSourceAdapter.java line 32:
>
>> 30: * See RandomnessSource for more information.
>> 31: */
>> 32: public class RandomnessSourceAdapter implements RandomnessSource {
>
> Is this a class a user must be aware of or could it also be package-private?
I don't think we have to make it public but I also don't think there's any reason to hide it. It's the most straightforward implementation of an adapter between RandomGenerator and RandomnessSource so it's kind of trivial and is very unlikely to change (often).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22941#discussion_r1915195863
PR Review Comment: https://git.openjdk.org/jdk/pull/22941#discussion_r1915202676
More information about the hotspot-compiler-dev
mailing list