FontConfig fails when optional system library is missing

Steve Poole spoole at
Mon Jul 18 21:37:19 UTC 2011

Hi all, a problem was discovered on JDK7 when using the Nimbus L&F on a 
system where was not installed (On AIX actually but in 
theory on any unix system)

Under the covers Nimbus uses the sun.font.FontConfigManager to retrieve 
fonts. sun.font.FontConfigManager in turn is intended to use (for a unix 
system) the system library if present.

The code is intended to cope with the library being missing but it 
unfortunately doesn't. A array is referenced without checking if it is 
null. On systems where the system library is present this array is never 
null but in this specific case the array is null and the reference fails 
as follows.

Exception in thread "main" java.lang.NullPointerException
at sun.font.FontConfigManager.getFontConfigFont(
at sun.awt.X11FontManager.getFontConfigFUIR(
at sun.font.FontUtilities.getFontConfigFUIR(
at javax.swing.plaf.nimbus.NimbusDefaults.<init>(
at Nimbus.main(

The fix is trivial (see attached) and probably just tactical.



More information about the core-libs-dev mailing list