[OpenJDK 2D-Dev] Thread safety of SunFontManager.platformFontMap
Andrey Turbanov
turbanoff at gmail.com
Mon Feb 22 12:40:34 UTC 2021
Hello.
I recently found suspicious field (with SpotBugs help) in class
SunFontManager:
static HashMap<String, FamilyDescription> platformFontMap;
This HashMap is accessed (read and write) in a method
sun.font.SunFontManager#findFontFromPlatformMap. As I see there is no
synchronization when this HashMap is accessed.
This method can be called from client code with this simple stack trace:
at
sun.font.SunFontManager.findFontFromPlatformMap(SunFontManager.java:1508)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2069)
at java.awt.Font.getFont2D(Font.java:500)
at java.awt.Font.getPSName(Font.java:1416)
I wonder if this unsynchronized access is expected. Looks like it can
break things when accessed from multiple threads simultaneously.
Do I miss something? Is it done this way, because Font objects are
supposed to be accessed from a single thread only?
Andrey Turbanov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/2d-dev/attachments/20210222/b67f60aa/attachment.htm>
More information about the 2d-dev
mailing list