diff --git a/jdk/src/java.base/share/classes/java/lang/String.java b/jdk/src/java.base/share/classes/java/lang/String.java index bd39fa60f94..f11292f2cda 100644 --- a/jdk/src/java.base/share/classes/java/lang/String.java +++ b/jdk/src/java.base/share/classes/java/lang/String.java @@ -1473,7 +1473,9 @@ public final class String for (char v : value) { h = 31 * h + v; } - hash = h; + if (h != 0) { + hash = h; + } } return h; }