[lworld] RFR: 8373202: [lworld] ObjectReference.equals should follow == semantics for value objects [v4]

Chris Plummer cjplummer at openjdk.org
Thu Jan 22 02:37:56 UTC 2026


On Thu, 22 Jan 2026 02:04:09 GMT, Serguei Spitsyn <sspitsyn at openjdk.org> wrote:

>> If Valhalla is not supported on the target VM, there is no way for isValueClass() or isValueObject() to ever return true. If Valhalla is supported, they can return true, and we have to assume that JDWP and the debug agent support Valhalla also. We can't have Valhalla support in the JVM and not also have it in JDWP and the debug agent. The debugger/JDI will break if isValueObject() returns false for a value object.
>
> We had a private discussion with Alex on this before you've added this comment. The `canUseIsSameObject()` or its equivalent is needed to make sure the Hotspot version is >= 27.  The bit `(modifiers & VMModifiers.IDENTITY)` is reused by the Valhalla in jdk 27 preview. In `jdk versions < 27` this bit was used for different purposes.

Ok, so isValueClass() should check the JDK version, but I don't think we need checks for the availability of IsSameObject or ObjectHashCode because they won't end up being used if the JVM does not support value classes because isValueClass() will always return false in that case. This is true even with JDK 27 when not using --enable-preview. We may also want to have the debug agent return an error if IsSameObject or ObjectHashCode are called and the JVM is not being run with --enable-preview.

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

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


More information about the valhalla-dev mailing list