[concurrency-interest] Does JDK 9 String.hashCode() have a bug?

Jonas Konrad me at yawk.at
Wed Sep 28 07:28:05 EDT 2016


Hey Aleksey,

On 09/28/2016 12:38 PM, Aleksey Shipilev wrote:
> P.S. Your explanation is similar to a more detailed of mine here:
>
> https://shipilev.net/blog/2016/close-encounters-of-jmm-kind/#wishful-benign-is-resilient

Wouldn't, according to that section in your blog, the old hashcode (and 
the suggested fix) also be unsafe? From what I can tell the hashcode in 
Java 8 already assumed (which it can because it's JDK code) that the VM 
inserts a memory barrier in the String constructor because of the final 
value field.

- Jonas


More information about the Concurrency-interest mailing list