On Tue, 22 Sep 2026 21:31:43 GMT, Chris Plummer <[email protected]> wrote:

>> The test 
>> `serviceability/jvmti/events/FieldModification/fieldmod02/fieldmod02.java` 
>> is crashing with the option:
>> `-XX:-DoJVMTIVirtualThreadTransitions`.
>> The capability `can_support_virtual_threads` must be rejected with the VM 
>> option `-XX:-DoJVMTIVirtualThreadTransitions`. The fix is implementing it. 
>> It impacts just a couple of code lines.
>> 
>> Testing:
>>  - Run the test 
>> `serviceability/jvmti/events/FieldModification/fieldmod02/fieldmod02.java` 
>> with the option `-XX:-DoJVMTIVirtualThreadTransitions`. Now, it is failed 
>> with rejecting the capability instead of crashing:
>> 
>> (AddCapabilities) unexpected error: JVMTI_ERROR_NOT_AVAILABLE (98)
>> Error occurred during initialization of VM
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> src/hotspot/share/prims/jvmtiManageCapabilities.cpp line 106:
> 
>> 104:   jc.can_generate_resource_exhaustion_heap_events = 1;
>> 105:   jc.can_generate_resource_exhaustion_threads_events = 1;
>> 106:   jc.can_support_virtual_threads = DoJVMTIVirtualThreadTransitions;
> 
> This flag may have bit rotted a bit, and that shows here. It has essentially 
> become a flag to enable/disable support for virtualthread events, and when 
> disabling support for virtual thread events, the implementation simply takes 
> advantage of it by not doing the unnecessary transitions.
> 
> DoJVMTIVirtualThreadTransitions was added so profilers could turn it off and 
> not have the overhead of the transitions, which are only executed when JVMTI 
> is enabled. That reasoning in not really captured well in the flag name or 
> its description.  I kind of think that just a plain 
> JVMTISupportVirtualThreadEvents flag would be clearer, with a description 
> saying that it eliminates the JVMTI overhead for virtual thread event 
> support. Possibly something to handle in a future cleanup.

When the `DoJVMTIVirtualThreadTransitions` is disabled then most of the virtual 
thread support can't work as needed, not only virtual thread related events. 
For instance, the functions `SuspendAllVirtualThreads` and 
`ResumeAllVirtualThreads` are not supported. So, this fix correctly disables 
the `can_support_virtual_threads` capability. The flag name 
`JVMTISupportVirtualThreadEvents` would not correctly serve its functionality.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33001#discussion_r4089123749

Reply via email to