Is SharedSecrets thread-safe?

Florian Weimer fw at deneb.enyo.de
Tue Dec 29 15:00:45 UTC 2020


* some-java-user:

> However, neither the static fields are `volatile` nor are the getter
> methods synchronized. So if my understanding of the Java Memory
> Model is correct, the compiler is free to reorder the two static
> field reads. So it is in theory possible that the first read yields
> a non-`null` value, but the second read yields a `null` value which
> leads to incorrect behavior (for further reading [1]).

> [1] https://shipilev.net/blog/2016/close-encounters-of-jmm-kind/#wishful-benign-is-resilient

Can the JVM be multi-threaded at this point?  If not, program order
results in the desired behavior.


More information about the core-libs-dev mailing list