From java.lang.Record::equals:
Implementation Requirements:
The implicitly provided implementation returns true if and only if the argument is an instance of the same record class as this record, and each component of this record is equal to the corresponding component of the argument; otherwise, false is returned. Equality of a component c is determined as follows:
* If the component is of a reference type, the component is considered equal if and only if Objects.equals(this.c, r.c) would return true.
* If the component is of a primitive type, using the corresponding primitive wrapper class PW (the corresponding wrapper class for int is java.lang.Integer, and so on), the component is considered equal if and only if PW.compare(this.c, r.c) would return 0.
Apart from the semantics described above, the precise algorithm used in the implicitly provided implementation is unspecified and is subject to change. The implementation may or may not use calls to the particular methods listed, and may or may not perform comparisons in the order of component declaration.
The documentation in these locations would be improved if "representation equivalence" was explicitly mentioned as a concept in addition to whatever coding idioms implementation representation equivalence were referred to.
- relates to
-
JDK-8294539 Augment discussion of equivalence relations on floating-point values
-
- Resolved
-
- links to
-
Review(master) openjdk/jdk/27232