On Fri, 23 Jan 2026 20:16:12 GMT, Serguei Spitsyn <[email protected]> wrote:

>> src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java line 838:
>> 
>>> 836:     }
>>> 837: 
>>> 838:     public boolean supportsValueClasses() {
>> 
>> What happens if not running in preview mode? Value classes are not supported 
>> in that case, but as implemented this API will say they are supported, 
>> leading to isValueClass() looking at modifiers in a way that is not 
>> compatible when value classes are not supported.
>> 
>> JDI didn't really run into this type of problem with virtual thread support. 
>> It did modify a couple of new public APIs with:
>> 
>>     @PreviewFeature(feature = PreviewFeature.Feature.VIRTUAL_THREADS)
>> 
>> However, I don't see how that helps us here. It seems we need to query the 
>> debug agent to find out if value classes are supported. There's no good way 
>> to do that. Is there any way for JDI to somewhat detect that value class 
>> support is supported (preview mode is enabled).
>
>> What happens if not running in preview mode? Value classes are not supported 
>> in that case, but as implemented this API will say they are supported, 
>> leading to isValueClass() looking at modifiers in a way that is not 
>> compatible when value classes are not supported.
> 
> It should work correctly. The IDENTITY modifier bit is not used for other 
> purposes in JDK 27 (Alex, please, fix me if it is wrong). So, the check for 
> version >= 27 is needed. If preview is not enabled in target VM, so it does 
> not support value classes then the IDENTITY modifier bit will be always set 
> which results in `isValueClass()` to always return `false`.

So in JDK 27, with or without enable preview, the IDENTITY modifier bit is 
accurate and can be looked at, but in previous JDK versions it might be used 
for something else?

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1834#discussion_r2722726810

Reply via email to