< prev index next >
modules/base/src/main/java/javafx/util/Pair.java
Print this page
rev 9268 : 8140503: JavaFX "Pair" Hash Code Collisions
*** 24,33 ****
--- 24,34 ----
*/
package javafx.util;
import java.io.Serializable;
+ import java.util.Objects;
import javafx.beans.NamedArg;
/**
* <p>A convenience class to represent name-value pairs.</p>
* @since JavaFX 2.0
*** 87,102 ****
*
* @return hash code for this <code>Pair</code>
*/
@Override
public int hashCode() {
! // name's hashCode is multiplied by an arbitrary prime number (13)
! // in order to make sure there is a difference in the hashCode between
! // these two parameters:
! // name: a value: aa
! // name: aa value: a
! return key.hashCode() * 13 + (value == null ? 0 : value.hashCode());
}
/**
* <p>Test this <code>Pair</code> for equality with another
* <code>Object</code>.</p>
--- 88,98 ----
*
* @return hash code for this <code>Pair</code>
*/
@Override
public int hashCode() {
! return Objects.hash(key, value);
}
/**
* <p>Test this <code>Pair</code> for equality with another
* <code>Object</code>.</p>
< prev index next >