JDK-6870238 : Font2DTest fails on Debian after FontManager refactoring
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: other
  • Submitted: 2009-08-10
  • Updated: 2010-04-02
  • Resolved: 2009-10-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b74Fixed
Related Reports
Relates :  
Description
I did a fresh build of JDK7 on a freshly setup Debian box, tried to run Font2DTest and got the following exception:

Exception in thread "main" java.lang.StackOverflowError
        at java.lang.ThreadLocal$ThreadLocalMap.getEntry(ThreadLocal.java:376)
        at java.lang.ThreadLocal$ThreadLocalMap.access$000(ThreadLocal.java:261)
        at java.lang.ThreadLocal.get(ThreadLocal.java:146)
        at java.lang.StringCoding.deref(StringCoding.java:63)
        at java.lang.StringCoding.encode(StringCoding.java:329)
        at java.lang.String.getBytes(String.java:954)
        at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
        at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:243)
        at java.io.File.exists(File.java:774)
        at sun.font.FcFontConfiguration.readFcInfo(FcFontConfiguration.java:423)
        at sun.font.FcFontConfiguration.init(FcFontConfiguration.java:92)
        at sun.font.FcFontConfiguration.<init>(FcFontConfiguration.java:74)
        at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:766)
        at sun.font.SunFontManager$2.run(SunFontManager.java:423)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.font.SunFontManager.<init>(SunFontManager.java:368)
        at sun.awt.X11FontManager.<init>(X11FontManager.java:32)
        at sun.reflect.GeneratedConstructorAccessor2.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
        at java.lang.Class.newInstance0(Class.java:372)
        at java.lang.Class.newInstance(Class.java:325)
        at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:86)
        at sun.font.SunFontManager.getInstance(SunFontManager.java:242)
        at sun.awt.X11FontManager.getInstance(X11FontManager.java:137)
        at sun.font.FcFontConfiguration.readFcInfo(FcFontConfiguration.java:427)
        at sun.font.FcFontConfiguration.init(FcFontConfiguration.java:92)
        at sun.font.FcFontConfiguration.<init>(FcFontConfiguration.java:74)
        at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:766)
        at sun.font.SunFontManager$2.run(SunFontManager.java:423)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.font.SunFontManager.<init>(SunFontManager.java:368)
        at sun.awt.X11FontManager.<init>(X11FontManager.java:32)
        at sun.reflect.GeneratedConstructorAccessor2.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
        at java.lang.Class.newInstance0(Class.java:372)
        at java.lang.Class.newInstance(Class.java:325)
        at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:86)
        at sun.font.SunFontManager.getInstance(SunFontManager.java:242)
        at sun.awt.X11FontManager.getInstance(X11FontManager.java:137)
        at sun.font.FcFontConfiguration.readFcInfo(FcFontConfiguration.java:427)
        at sun.font.FcFontConfiguration.init(FcFontConfiguration.java:92)
        at sun.font.FcFontConfiguration.<init>(FcFontConfiguration.java:74)
        at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:766)
        at sun.font.SunFontManager$2.run(SunFontManager.java:423)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.font.SunFontManager.<init>(SunFontManager.java:368)
        at sun.awt.X11FontManager.<init>(X11FontManager.java:32)
        at sun.reflect.GeneratedConstructorAccessor2.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
        at java.lang.Class.newInstance0(Class.java:372)
        at java.lang.Class.newInstance(Class.java:325)
        at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:86)
        at sun.font.SunFontManager.getInstance(SunFontManager.java:242)
        at sun.awt.X11FontManager.getInstance(X11FontManager.java:137)
        at sun.font.FcFontConfiguration.readFcInfo(FcFontConfiguration.java:427)
        at sun.font.FcFontConfiguration.init(FcFontConfiguration.java:92)
<ad infinitum>

This is caused by (what I call) initialization loop, where one constructor calls somehow calls another constructor, which somehow manages to call back into the first constructor.

Comments
EVALUATION Fixed by using the fontManager field of FontConfiguration class, rather than querying the FontManagerFactory. This breaks the loop because it is not trying to create yet-another-FontManager over and over again. The fix does not come with a testcase because it can be verified by every GUI app that uses fonts, of which there should be plenty in existing testsuites/JCK.
12-08-2009

EVALUATION We need to use the fontManager field in FontConfiguration instead of asking the factory, this will break the loop.
11-08-2009