RFR: 8366154: Validate thread type requirements in debug commands [v2]
Kevin Walls
kevinw at openjdk.org
Tue Sep 9 10:21:51 UTC 2025
On Tue, 9 Sep 2025 09:27:22 GMT, Kerem Kat <krk at openjdk.org> wrote:
>> Have used these occasionally and am surprised to realize psf and others show frames from the VM operation's caller thread.
>>
>>
>> The duplication around the active() checks is odd. If we are adding:
>>
>> bool onThread()
>> If no current thread, print warning and return false. Callers will return immediately.
>>
>> Could we add e.g.:
>>
>> bool hasActiveThread()
>> If no current thread, print warning and return false. Callers will return immediately.
>> If no active thread, print warning and return false. Callers will return immediately.
>> Callers can go on to use JavaThread* p = JavaThread::active(); without checking (as we currently do).
>> (We are presumably in a debugger session, speed is not the priority, repeating some checks or fetching of active() is not tragic, but this file has less duplication.)
>
> Thank you for the description for `hasActiveThread`. Is it much different than the `onJavaThread` in the first revision?
OK, I see now that I'm suggesting more like what you had originally, that you go back to what David disliked. 8-)
I would have gone for having this check in the helper method (even if it means multiple Thread::current calls) over duplication inserted into three command implementations. Seems like a way to fix their assumptions also.
Just want to check with David if he might agree that keeping the individual commands simpler is worth permitting the additional helper method.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27033#discussion_r2332935293
More information about the hotspot-dev
mailing list