[lworld] RFR: 8373202: [lworld] ObjectReference.equals should follow == semantics for value objects [v2]
Alex Menkov
amenkov at openjdk.org
Fri Jan 16 22:23:08 UTC 2026
On Fri, 16 Jan 2026 03:19:45 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
>> Alex Menkov has updated the pull request incrementally with one additional commit since the last revision:
>>
>> ClassTypeImpl.isValueClass, VirtualMachineImpl.canUseIsSameObject
>
> src/jdk.jdi/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java line 177:
>
>> 175: @Override
>> 176: public int hashCode() {
>> 177: if (isValueObject() && vm.canUseIsSameObject()) {
>
> I don't see how this logic can be correct for value objects if vm.canUseIsSameObject() returns false. We still have a value object in that case. Is using Long.hashCode(ref()) the right thing to do? Same thing applies to equals() above. I think if a JVM supports value objects then the debug agent has to support IsSameObject and HashCode. The version check should really only be in regard to whether or not value objects are supported in general by the JVM, because if they are they have to be supported by the debug agent.
We should execute jdwp command only when it's available (vm.canUseIsSameObject returns true) and the object is value object.
Note that isValueObject() may not work for old releases, so we need to check both conditions here or move version check to ClassTypeImpl.isValueClass
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1834#discussion_r2700160016
More information about the valhalla-dev
mailing list