[OpenJDK 2D-Dev] RFR: 8263138: Initialization of sun.font.SunFontManager.platformFontMap is not thread safe
Sergey Bylokhov
serb at openjdk.java.net
Tue Mar 9 22:31:07 UTC 2021
On Tue, 9 Mar 2021 20:56:15 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> 8263138: Initialization of sun.font.SunFontManager.platformFontMap is not thread safe
>
> Marked as reviewed by aivanov (Reviewer).
> I don't know why making this volatile is doing anything.
> Let's discuss this further.
It will prevent the possibility that one thread will store the non-null value to the SunFontManager.platformFontMap and only after that complete initialization of object stored in that field due to code optimizations. It is similar to the volatile DCL:
see "broken multithreaded version" example:
https://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java
-------------
PR: https://git.openjdk.java.net/jdk/pull/2762
More information about the 2d-dev
mailing list