RFR: 8290973: In AffineTransform, equals(Object) is inconsistent with hashCode() [v2]

Martin Desruisseaux duke at openjdk.org
Mon Aug 22 17:13:26 UTC 2022


> `AffineTransform.equals(Object)` and `hashCode()` break two contracts:
> 
> * `A.equals(A)` returns `false` if at least one affine transform coefficient is NaN.
> * `A.equals(B)` should imply `A.hashCode() == B.hashCode()`, but it is not the case if a coefficient is zero with an opposite sign in A and B.
> 
> This patch preserves the current behaviour regarding 0 (i.e. -0 is considered equal to +0) for backward compatibility reason. Instead the `hashCode()` method is updated for being consistent with `equals(Object)` behaviour.

Martin Desruisseaux has updated the pull request incrementally with one additional commit since the last revision:

  Fix a trivial typo: "into to" -> "to".

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/9121/files
  - new: https://git.openjdk.org/jdk/pull/9121/files/12abfde7..8ee3f7b8

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=9121&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=9121&range=00-01

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/9121.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9121/head:pull/9121

PR: https://git.openjdk.org/jdk/pull/9121



More information about the client-libs-dev mailing list