On Wed, 19 Aug 2026 19:56:36 GMT, Chris Plummer <[email protected]> wrote:

>> Allow OpaqueFrameException for vthreads when suspended in a loop (not at an 
>> event). This became necessary after 
>> [JDK-8386116](https://bugs.openjdk.org/browse/JDK-8386116). The 
>> ThreadReference.stop() spec allows for this:
>> 
>> `This method may be used to send an asynchronous exception to a virtual 
>> thread when it is suspended at an event. An implementation may support 
>> sending an asynchronous exception to a suspended virtual thread in other 
>> cases.`
>> 
>> and
>> 
>> `OpaqueFrameException - if the thread is a suspended virtual thread and the 
>> implementation was unable to throw an asynchronous exception from the 
>> thread's current frame`
>> 
>> I also field [JDK-8390483](https://bugs.openjdk.org/browse/JDK-8390483) to 
>> investigate if JVMTI should remove all vthread support for StopThread when 
>> not at an event rather than having work just some of the time.
>> 
>> The failure used to happen about 1 out of 50 runs. Tested with both platform 
>> threads and with virtual threads about 200 times each with no issues.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Chris Plummer has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   verify we got OpaqueFrameException when no exception thrown on debuggee side

Thanks, looks good. Just a couple of comments below.

test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002.java line 
234:

> 232:                 thrRef.stop(throwableRef);
> 233:                 log.display("TEST #4 PASSED: stop() call succeeded.");
> 234:                 objRef.setValue(gotOpaqueFrameException, 
> vm.mirrorOf(false));

Isn't the field already initialized to false?

test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002.java line 
248:

> 246:                 log.complain("TEST #4 FAILED: caught unexpected " + ue);
> 247:                 tot_res = Consts.TEST_FAILED;
> 248:                 objRef.setValue(gotOpaqueFrameException, 
> vm.mirrorOf(false));

Also don't understand why this is needed.

test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002t.java line 
151:

> 149:                 } else {
> 150:                     log.complain("TEST #4: Failed to throw expected 
> exception and " +
> 151:                                  "failed to throw debugger side 
> OpaqueFrameException");

We should have a `return Consts.TEST_FAILED;` for this case too. Also, I think 
the output msg is confusing because if the frame is interpreted there is no 
`OpaqueFrameException` that should be expected. I would just remove this `else` 
branch and change the condition in the original `if` to `vthreadMode && 
gotOpaqueFrameException`.

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

PR Review: https://git.openjdk.org/jdk/pull/32403#pullrequestreview-4977639647
PR Review Comment: https://git.openjdk.org/jdk/pull/32403#discussion_r3817484504
PR Review Comment: https://git.openjdk.org/jdk/pull/32403#discussion_r3817487541
PR Review Comment: https://git.openjdk.org/jdk/pull/32403#discussion_r3817491954

Reply via email to