RFR: 8273581: Change the mechanism by which JDK loads the platform-specific FontManager class [v6]
Brett Okken
github.com+2996845+bokken at openjdk.java.net
Mon Sep 20 13:28:54 UTC 2021
On Mon, 20 Sep 2021 11:26:13 GMT, Alexander Scherbatiy <alexsch at openjdk.org> wrote:
>> FontManagerFactory class uses reflection to load platform specific FontManager classes from "sun.font.fontmanager" property.
>>
>> Fix proposes creating FontManager platform specific classes directly in the similar way as it has been already done for GraphicsEnvironment and AWT Toolkit ([JDK-8130266](https://bugs.openjdk.java.net/browse/JDK-8130266) and [JDK-8212700](https://bugs.openjdk.java.net/browse/JDK-8212700)).
>>
>> FontManager is internal jdk class. It is placed in `sun.font` package and java modularization encapsulates FontManager from subclassing and using by a user.
>>
>> The fix reuses PlatformGraphicsInfo to create FontManager platform specific classes. May be FontManager creation code needs to be placed in its own info classes.
>
> Alexander Scherbatiy has updated the pull request incrementally with two additional commits since the last revision:
>
> - Use Double-check idiom for lazy initialization of instance fields with local variable
> - Remove unnecessary explicit initialization of volatile variable
src/java.desktop/share/classes/sun/font/FontManagerFactory.java line 37:
> 35:
> 36: /** Our singleton instance. */
> 37: private static volatile FontManager instance;
Consider to instead of DCL to use the holder class pattern:
private static final class DeferredLoader {
public static final FontManager INSTANCE = PlatformFontInfo.createFontManager();
}
public static FontManager getInstance() {
return DeferredLoader.INSTANCE;
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/5517
More information about the client-libs-dev
mailing list