AffineTransform.equals(Object) is sometime inconsistent with itself and with hashCode()

Martin Desruisseaux martin.desruisseaux at geomatys.com
Fri Jun 10 13:38:56 UTC 2022


Hello

I created a new pull request for two inconsistencies in 
AffineTransform.equals(Object). Current implementation of that method 
breaks two invariant:

  * A.equals(A) returns false if at least one affine transform
    coefficient is NaN (reflexivity broken).
  * 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.

The proposed patch preserves the current equals(Object) behavior when 
possible for backward compatibility. The merge request is at 
https://github.com/openjdk/jdk/pull/9121 and passes the pre-submit 
tests. If accepted, I presume that we would need someone to create an 
issue on https://bugs.openjdk.org/ ?

     Martin




More information about the client-libs-dev mailing list