RFR: 8305186: Reference.waitForReferenceProcessing should be more accessible to tests [v3]
Stuart Marks
smarks at openjdk.org
Fri Apr 11 02:28:35 UTC 2025
On Thu, 10 Apr 2025 22:18:20 GMT, Brent Christian <bchristi at openjdk.org> wrote:
>> test/lib/jdk/test/whitebox/WhiteBox.java line 570:
>>
>>> 568: * This method should usually be called after a call to WhiteBox.fullGC().
>>> 569: */
>>> 570: public static void waitForReferenceProcessing() {
>>
>> Reference::waitForReferenceProcessing throws InterruptedException. Probably this should be similarly
>> declared.
>
> I disagree. IMO, for a test library, it's an unnecessary burden to make callers catch a checked exception.
Hm. In general, if something blocks interruptibly, it should be declared to throw InterruptedException instead of catching and rethrowing something of another exception type. We should look at the use sites to be sure, but it's generally not an inconvenience for tests to deal with checked exceptions; it's perfectly acceptable for them to declare `throws InterruptedException` or even `throws Exception` and let the framework handle the exception if the test itself doesn't want to.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24527#discussion_r2038705048
More information about the core-libs-dev
mailing list