RFR: 8377950: Refactor ClassUnloader to provide explicit waiting API [v2]
Chris Plummer
cjplummer at openjdk.org
Tue Feb 17 17:52:38 UTC 2026
On Tue, 17 Feb 2026 07:29:06 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:
>> Separates GC triggering from class reclamation waiting in vmTestbase ClassUnloader.
>>
>> The original implementation used an implicit wait loop regardless of caller needs. Because the necessity of waiting is caller-specific, this PR introduces an explicit `unloadClassAndWait(timeout)` API. This allows callers to document their specific reasons for waiting (e.g., race conditions with JDWP or background compilation) while keeping `unloadClass()` simple for those who don't need to wait.
>>
>> - Introduced `unloadClassAndWait(timeout)` and simplified `unloadClass()`.
>> - Updated `compmethunload001` and `AbstractDebuggeeTest` to use the explicit waiting API with documented rationale.
>>
>> Test: tier1-5, `vmTestbase/nsk`
>
> Albert Mingkun Yang has updated the pull request incrementally with two additional commits since the last revision:
>
> - copyright
> - review
test/hotspot/jtreg/vmTestbase/nsk/share/jpda/AbstractDebuggeeTest.java line 159:
> 157: if (expectedUnloadingResult) {
> 158: // We expect unloading to succeed. Retry multiple times because
> 159: // JDWP internally creates global references (NewGlobalRef)
Suggestion:
// the debug agent creates global references (NewGlobalRef)
test/hotspot/jtreg/vmTestbase/nsk/share/jpda/AbstractDebuggeeTest.java line 160:
> 158: // We expect unloading to succeed. Retry multiple times because
> 159: // JDWP internally creates global references (NewGlobalRef)
> 160: // when emitting ClassPrepare events. These global references
Suggestion:
// when handling ClassPrepare events. These global references
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29735#discussion_r2818289469
PR Review Comment: https://git.openjdk.org/jdk/pull/29735#discussion_r2818285739
More information about the serviceability-dev
mailing list