RFR: 8346107: Generators: testing utility for random value generation

Emanuel Peter epeter at openjdk.org
Tue Jan 7 14:11:39 UTC 2025


On Tue, 7 Jan 2025 14:05:33 GMT, Theo Weidmann <tweidmann at openjdk.org> wrote:

>> test/hotspot/jtreg/compiler/lib/generators/EmptyGeneratorException.java line 29:
>> 
>>> 27:  * An EmptyGeneratorException is thrown if a generator configuration is requested that would result in an empty
>>> 28:  * set of values. For example, bounds such as [1, 0] cause an EmptyGeneratorException. Another example would be
>>> 29:  * restricting a uniform integer generator over the range [0, 1] to [10, 11].
>> 
>> What if I mix distributions, and one of them has no values from that range, but the other does?
>
> Currently the mixed generator does not even support restricting, but I think that's something that I should still add, also with regard to your comment above.
> 
>> What if I mix distributions, and one of them has no values from that range, but the other does?
> 
> I would make the mixed generator call `restricted` on both its generators, which might in turn throw EmptyGeneratorException, if they cannot be restricted to that range.

You could fix it this way: when you restrict mixed generators, you try to recursively restrict all its sub-generators. If one cannot be restricted, you do not throw, but just remove it from the mixed distribution ;)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22941#discussion_r1905508138


More information about the hotspot-compiler-dev mailing list