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

Alexander Scherbatiy alexsch at openjdk.java.net
Fri Sep 17 12:45:48 UTC 2021


On Fri, 17 Sep 2021 07:57:46 GMT, Sergey Bylokhov <serb at openjdk.org> 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



More information about the client-libs-dev mailing list