RFR: 8273581: Change the mechanism by which JDK loads the platform-specific FontManager class [v5]

Alexander Scherbatiy alexsch at openjdk.java.net
Mon Sep 20 11:26:19 UTC 2021


On Sat, 18 Sep 2021 22:51:34 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> Alexander Scherbatiy has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Change Solaris default implementation to Mac OS in FontManagerFactory comment
>
> src/java.desktop/share/classes/sun/font/FontManagerFactory.java line 37:
> 
>> 35: 
>> 36:     /** Our singleton instance. */
>> 37:     private static volatile FontManager instance = null;
> 
> It is not necessary to initialize it to null here, there is ongoing effort to delete such initializations:
> https://github.com/openjdk/jdk/pull/5197

The initialization to null is removed.

> src/java.desktop/share/classes/sun/font/FontManagerFactory.java line 46:
> 
>> 44:     public static FontManager getInstance() {
>> 45: 
>> 46:         if (instance == null) {
> 
> You can improve it a little bit further and read the volatile field only once in the common path. Read to local->check-> init local and field -> return local.

The `getInstance()` method is updated to store the volatile field to local variable.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5517



More information about the client-libs-dev mailing list