FontConfig fails when optional system library is missing

Steve Poole spoole at linux.vnet.ibm.com
Mon Jul 18 23:13:22 UTC 2011


On 18/07/11 23:14, Phil Race wrote:
> Ah you said it was AIX, not Linux. Still,  it should have that library 
> installed
> even if the de-ref is fixed.
>
Not on AIX - its completely optional - and as far we can tell (other 
than this particular problem) nothing else bad happens.    Having said 
that I would expect customers to install the package - this fix is 
simply a belt and braces change.
I don't know why the attachment is missing  - here it is inline:
---
diff --git a/src/solaris/classes/sun/font/FontConfigManager.java 
b/src/solaris/classes/sun/font/FontConfigManager.java
--- a/src/solaris/classes/sun/font/FontConfigManager.java
+++ b/src/solaris/classes/sun/font/FontConfigManager.java
@@ -348,6 +348,8 @@

          initFontConfigFonts(false);

+    if(fontConfigFonts==null) return null; // init failed
+
          FcCompFont fcInfo = null;
          for (int i=0; i<fontConfigFonts.length; i++) {
              if (name.equals(fontConfigFonts[i].fcFamily) &&
---

By the way - why is this 2d?  because it's font?    Anyway I've cc'd 
2d-dev as you suggest.  Thanks for the quick response.


> -phil.
>
> On 7/18/2011 3:12 PM, Phil Race wrote:
>> Steve,
>>
>> There's no attachment .. and this should be discussed on 2d-dev, not 
>> core-libs.
>>
>> I do see in the code where the null de-ref can happen. This is some 
>> new JDK 7 code.
>> Although a system where the library is missing is basically DOA for 
>> client use.
>> I'd suspect you are running 32 bit JDK on a 64 bit Linux which hasn't 
>> had
>> the 32 bit libs installed. If so, likely you'll run into other 
>> problems too.
>>
>> -phil.
>>
>>
>> On 7/18/2011 2:37 PM, Steve Poole wrote:
>>>
>>> Hi all, a problem was discovered on JDK7 when using the Nimbus L&F 
>>> on a system where libfontconfig.so 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 libfontconfig.so 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(FontConfigManager.java:352) 
>>>
>>> at sun.awt.X11FontManager.getFontConfigFUIR(X11FontManager.java:817)
>>> at sun.font.FontUtilities.getFontConfigFUIR(FontUtilities.java:472)
>>> at 
>>> javax.swing.plaf.nimbus.NimbusDefaults.<init>(NimbusDefaults.java:138)
>>> at 
>>> javax.swing.plaf.nimbus.NimbusLookAndFeel.<init>(NimbusLookAndFeel.java:100)
>>> at Nimbus.main(Nimbus.java:6)
>>>>>>
>>> The fix is trivial (see attached) and probably just tactical.
>>>
>>>
>>> Cheers,
>>>
>>> Steve
>>>
>>
>




More information about the core-libs-dev mailing list