Summary
Removal of mention of memory addresses from the specification of Object.hashCode().
Problem
The specification of Object.hashCode() contains some odd wording about the computation possibly involving the object's memory address. This might have been the case at some point in the distant past, in an early JVM implementation, but it hasn't been true for many years. Unfortunately, this wording has caused misinformation to be repeated continually and has led to recurring confusion.
Solution
Remove the statement about memory addresses entirely. Reword the "distinct" sentence and recharacterize it as @implSpec.
Specification
diff -r 0d89f672c62e -r 6af324164325 src/java.base/share/classes/java/lang/Object.java
--- a/src/java.base/share/classes/java/lang/Object.java Thu Dec 06 14:34:11 2018 -0800
+++ b/src/java.base/share/classes/java/lang/Object.java Fri Dec 07 09:55:42 2018 -0800
@@ -94,12 +94,10 @@
* programmer should be aware that producing distinct integer results
* for unequal objects may improve the performance of hash tables.
* </ul>
- * <p>
- * As much as is reasonably practical, the hashCode method defined
- * by class {@code Object} does return distinct integers for
- * distinct objects. (The hashCode may or may not be implemented
- * as some function of an object's memory address at some point
- * in time.)
+ *
+ * @implSpec
+ * As far as is reasonably practical, the {@code hashCode} method defined
+ * by class {@code Object} returns distinct integers for distinct objects.
*
* @return a hash code value for this object.
* @see java.lang.Object#equals(java.lang.Object)
- csr of
-
JDK-8199394 Object.hashCode should not mention anything about memory addresses
-
- Resolved
-