On 4/1/19 1:57 PM, Claes Redestad wrote: > when a String has a calculated hash code value of 0, we recalculate and > store a 0 to the String.hash field every time (except for the empty > String, which is special cased). To make String objects more amenable to > storage in shared read-only memory, e.g., CDS archives, we should avoid > this redundant store. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8221723 > Webrev: http://cr.openjdk.java.net/~redestad/8221723/
Looks fine. I recall we were fixing something like this, but I might be confusing it with the other RFE [0]. The comment might emphasize we are doing it for RO memory: // Avoid issuing a store if the calculated value is also zero: // in addition to minor optimization benefit, this also allows storing // Strings with zero hash code in read-only memory. -Aleksey [0] https://bugs.openjdk.java.net/browse/JDK-6921374