On Fri, 17 Sep 2021 07:57:46 GMT, Sergey Bylokhov <[email protected]> wrote:

>> Alexander Scherbatiy has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Move createFontManager() code to sun.font.PlatformFontInfo class
>
> src/java.desktop/share/classes/sun/font/FontManagerFactory.java line 55:
> 
>> 53:      */
>> 54:     @SuppressWarnings("removal")
>> 55:     public static synchronized FontManager getInstance() {
> 
> Just an idea, since the method became so small can we use DLC here instead of 
> synchronised static method?

The method `FontManagerFactory.getInstance()` is updated to use DLC.

I used synchronization on FontManagerFactory.class in the first check to be 
consistent with the previous behavior where synchronization was on the 
`FontManagerFactory.getInstance()` method.

What about to use a static nested class singleton? It could look like:

public final class FontManagerFactory {

    public static FontManager getInstance() {
        return FontManagerHolder.instance;
    }

    private static class FontManagerHolder {
        private static final FontManager instance = 
PlatformFontInfo.createFontManager();
    }
}

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

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

Reply via email to