JDK-6272022 : NPE in FontManager with the baseline changes (b36)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,solaris_10,windows_xp
  • CPU: x86,sparc
  • Submitted: 2005-05-17
  • Updated: 2010-04-02
  • Resolved: 2005-06-01
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 6
6 b39Fixed
Related Reports
Duplicate :  
Duplicate :  
Description
There is a post on the mustang forum complaining about an NPE
in b36 while running Netbeans 4.1

java.lang.NullPointerException
	at sun.font.FontManager.getFont2D(Native Method)
	at sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:330)
	at sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:323)
	at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:271)
	at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:232)
	at java.awt.Component.getFontMetrics(Component.java:2695)
	at javax.swing.JComponent.getFontMetrics(JComponent.java:1652)
	at javax.swing.plaf.basic.BasicLabelUI.getBaseline(BasicLabelUI.java:281)
	at javax.swing.JComponent.getBaseline(JComponent.java:2585)
	at javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(BasicComboBoxUI.java:1289)
	at javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize(BasicComboBoxUI.java:873)
	at javax.swing.plaf.basic.BasicComboBoxUI.getPreferredSize(BasicComboBoxUI.java:863)
	at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.getPreferredSize(WindowsComboBoxUI.java:84)
	at javax.swing.JComponent.getPreferredSize(JComponent.java:1687)
	at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:694)
	at java.awt.Container.preferredSize(Container.java:1559)
	at java.awt.Container.getPreferredSize(Container.java:1544)
	at javax.swing.JComponent.getPreferredSize(JComponent.java:1689)
	at java.awt.BorderLayout.layoutContainer(BorderLayout.java:790)
	at java.awt.Container.layout(Container.java:1402)
	at java.awt.Container.doLayout(Container.java:1391)
	at java.awt.Container.validateTree(Container.java:1474)
	at java.awt.Container.validateTree(Container.java:1481)
	at java.awt.Container.validateTree(Container.java:1481)
	at java.awt.Container.validate(Container.java:1449)
	at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:599)
	at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:127)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:589)
[catch] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:247)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:168)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:162)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:154)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:115)

Here is the post :
http://forums.java.net/jive/thread.jspa?threadID=700&tstart=0
###@###.### 2005-05-17 21:44:28 GMT

Comments
EVALUATION This is happening because BasicLabelUI.getBaseline isn't checking for a null font as getPreferredSize does. I'm not sure why the label has a null font here, none-the-less the fix is to return -1 from baseline if there is no font. ###@###.### 2005-05-19 15:29:10 GMT
19-05-2005