what does JVM checks in object equality (==
)?
Is it the hashCode
of two objects or something else ?
The ==
operator only checks reference equality. It doesn't call any methods on the object... it just checks whether the two references involved are equal, i.e. they refer to the same object.
In simple cases I believe this is just a matter of comparing the references in a bitwise fashion - checking whether or not they consist of the same bytes. For more complex environments (e.g. "compressed oops") there could be slightly more work involved, in order to compare different representations. But the internally reference is effectively a pointer of some kind, and it's just a matter of comparing the two pointers.
See more on this question at Stackoverflow