On Thu, 2 Feb 2023 22:19:07 GMT, Roger Riggs <rri...@openjdk.org> wrote:

>> `test/jdk/java/lang/invoke/defineHiddenClass/UnloadingTest.java` defines 
>> hidden classes and verify cases that a class loader is not unloaded using 
>> `ForceGC::wait`.    ForceGC::wait` defaults the timeout to 1000ms * jtreg 
>> timeout factor, which is designed to work well to expect an object being 
>> reclaimed, i.e. the boolean supplier returns true.   On the other hand, if 
>> the boolean supplier never returns true, the method returns after it 
>> timeouts which may be long depending on the timeout factor. 
>> 
>> This PR adds a variant of `ForceGC::wait` to take a timeout parameter and 
>> tests can specify the timeout to reduce the time it takes testing a strongly 
>> reachable object not being reclaimed.
>
> test/lib/jdk/test/lib/util/ForceGC.java line 73:
> 
>> 71:      *     if did not complete after the specified waiting time.
>> 72:      */
>> 73:     public static boolean wait(BooleanSupplier booleanSupplier, long 
>> timeout) {
> 
> Can the method name be changed to make it clear the timeout is not scaled by 
> the TIMEOUT factor.
> (It would have been better if the original method name mentioned the timeout 
> factor).
> How about,  `waitNoMoreThan`.

what about `waitFor`?

I also considered renaming the original method to something else to indicate 
that the timeout is scaled with jtreg timeout factor.   Now 
`wait(BooleanSupplier)` is equivalent to `wait` with timeout = 1000L * 
TIMEOUT_FACTOR) and the javadoc states the timeout, which seems okay to me.

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

PR: https://git.openjdk.org/jdk/pull/12392

Reply via email to