jdk/src/java.base/share/classes/java/lang/String.java
changeset 41219 eab7a5086e95
parent 38786 8e7b0ac05815
child 44369 b5c4e28a7521
--- a/jdk/src/java.base/share/classes/java/lang/String.java	Fri Sep 30 17:05:54 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/String.java	Fri Sep 30 17:34:08 2016 +0200
@@ -1516,11 +1516,12 @@
      * @return  a hash code value for this object.
      */
     public int hashCode() {
-        if (hash == 0 && value.length > 0) {
-            hash = isLatin1() ? StringLatin1.hashCode(value)
-                              : StringUTF16.hashCode(value);
+        int h = hash;
+        if (h == 0 && value.length > 0) {
+            hash = h = isLatin1() ? StringLatin1.hashCode(value)
+                                  : StringUTF16.hashCode(value);
         }
-        return hash;
+        return h;
     }
 
     /**