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

Alex Menkov amenkov at openjdk.org
Mon Jan 12 21:55:48 UTC 2026


On Thu, 18 Dec 2025 20:35:19 GMT, Alex Menkov <amenkov at openjdk.org> wrote:

>> src/jdk.jdi/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java line 150:
>> 
>>> 148:     public boolean equals(Object obj) {
>>> 149:         if (obj instanceof ObjectReferenceImpl other) {
>>> 150:             if (ref() == other.ref() && super.equals(obj)) {
>> 
>> I'm wondering if the super.equals(obj) call is necessary. The way JDI is implemetned, there is a 1-to-1 relationship between the ObjectID and the ObjectReference. If the ObjectIDs match, then the ObjectRefernces instances should be one in the same. So either one of these checks should be sufficient. I don't think both are needed.
>
> I agree that super.equals call is not necessary, just kept it as it was

Further research shown super.equals checks if the objects belong to the same VM, so it's required

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

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


More information about the valhalla-dev mailing list