JDK-5089077 : Regression: NPE when relative font sizes used in html
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    linux_redhat_9.0,windows_98,windows_xp linux_redhat_9.0,windows_98,windows_xp
  • CPU: x86
  • Submitted: 2004-08-19
  • Updated: 2004-11-16
  • Resolved: 2004-09-22
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.
Other JDK 6
5.0u1 betaFixed 6Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
--- Test.java ---
import javax.swing.*;

class Test {
    public static void main(String[] args) {
        String testHtml = 
            "<html><head><STYLE type='text/css'> p { font-size: lager } </STYLE></head>" +
            "<body><p>test</p></body></html>";
        JEditorPane editor = new JEditorPane("text/html",testHtml);
        JFrame frame = new JFrame();
        frame.add(editor);
        frame.pack();
        frame.setVisible(true);
    }
} 

------

java -showversion Test
java version "1.5.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode)

Exception in thread "main" java.lang.NullPointerException
        at javax.swing.text.html.CSS$FontSize.getValue(CSS.java:1672)
        at javax.swing.text.html.CSS$FontSize.toStyleConstants(CSS.java:1805)
        at javax.swing.text.html.StyleSheet$ViewAttributeSet.getAttribute(StyleSheet.java:2630)
        at javax.swing.text.StyleConstants.getFontSize(StyleConstants.java:358)
        at javax.swing.text.html.CSS$FontSize.getValue(CSS.java:1678)
        at javax.swing.text.html.CSS$FontSize.toStyleConstants(CSS.java:1805)
        at javax.swing.text.html.StyleSheet$ViewAttributeSet.getAttribute(StyleSheet.java:2630)
        at javax.swing.text.StyleConstants.getFontSize(StyleConstants.java:358)
        at javax.swing.text.html.CSS$FontSize.getValue(CSS.java:1678)
        at javax.swing.text.html.CSS.getFontSize(CSS.java:614)
        at javax.swing.text.html.CSS.getFont(CSS.java:574)
        at javax.swing.text.html.StyleSheet.getFont(StyleSheet.java:867)
        at javax.swing.text.DefaultStyledDocument.getFont(DefaultStyledDocument.java:777)
        at javax.swing.text.LabelView.setPropertiesFromAttributes(LabelView.java:128)
        at javax.swing.text.html.InlineView.setPropertiesFromAttributes(InlineView.java:229)
        at javax.swing.text.LabelView.sync(LabelView.java:39)
        at javax.swing.text.LabelView.getFont(LabelView.java:189)
        at javax.swing.text.GlyphPainter1.sync(GlyphPainter1.java:194)
        at javax.swing.text.GlyphPainter1.getSpan(GlyphPainter1.java:42)
        at javax.swing.text.GlyphView.getPreferredSpan(GlyphView.java:536)
        at javax.swing.text.FlowView$LogicalView.getPreferredSpan(FlowView.java:692)
        at javax.swing.text.FlowView.calculateMinorAxisRequirements(FlowView.java:216)
        at javax.swing.text.html.ParagraphView.calculateMinorAxisRequirements(ParagraphView.java:128)
        at javax.swing.text.BoxView.checkRequests(BoxView.java:911)
        at javax.swing.text.BoxView.getMinimumSpan(BoxView.java:542)
        at javax.swing.text.html.ParagraphView.getMinimumSpan(ParagraphView.java:257)
        at javax.swing.text.BoxView.calculateMinorAxisRequirements(BoxView.java:879)
        at javax.swing.text.html.BlockView.calculateMinorAxisRequirements(BlockView.java:129)
        at javax.swing.text.BoxView.checkRequests(BoxView.java:911)
        at javax.swing.text.BoxView.getMinimumSpan(BoxView.java:542)
        at javax.swing.text.html.BlockView.getMinimumSpan(BlockView.java:362)
        at javax.swing.text.BoxView.calculateMinorAxisRequirements(BoxView.java:879)
        at javax.swing.text.html.BlockView.calculateMinorAxisRequirements(BlockView.java:129)
        at javax.swing.text.BoxView.checkRequests(BoxView.java:911)
        at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:325)
        at javax.swing.text.BoxView.layout(BoxView.java:682)
        at javax.swing.text.BoxView.setSize(BoxView.java:379)
        at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1631)
        at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:830)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1582)
        at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1227)
        at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:690)
        at java.awt.Container.preferredSize(Container.java:1558)
        at java.awt.Container.getPreferredSize(Container.java:1543)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1584)
        at javax.swing.JRootPane$RootLayout.preferredLayoutSize(JRootPane.java:824)
        at java.awt.Container.preferredSize(Container.java:1558)
        at java.awt.Container.getPreferredSize(Container.java:1543)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1584)
        at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:690)
        at java.awt.Container.preferredSize(Container.java:1558)
        at java.awt.Container.getPreferredSize(Container.java:1543)
        at java.awt.Window.pack(Window.java:478)
        at Test.main(Test.java:11)

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.5.0_01 mustang FIXED IN: 1.5.0_01 mustang INTEGRATED IN: 1.5.0_01 mustang
28-09-2004

EVALUATION this bug is a regression after the fix for 5042095 [GTK+ theming needs to happen for JEditorPane] It happens only if relative font sizes are used in html. CSS.java:1677 if (resolveParent != null) { int pValue = StyleConstants.getFontSize(resolveParent); Simple fix could be : *** /tmp/geta18882 Wed Aug 18 21:36:45 2004 --- CSS.java Wed Aug 18 21:36:23 2004 *************** *** 662,668 **** */ float getLength(AttributeSet a, CSS.Attribute key, StyleSheet ss) { LengthValue lv = (LengthValue) a.getAttribute(key); ! float len = (lv != null) ? lv.getValue(ss.isW3CLengthUnits()) : 0; return len; } --- 662,669 ---- */ float getLength(AttributeSet a, CSS.Attribute key, StyleSheet ss) { LengthValue lv = (LengthValue) a.getAttribute(key); ! boolean isW3CLengthUnits = (ss == null) ? false : ss.isW3CLengthUnits(); ! float len = (lv != null) ? lv.getValue(isW3CLengthUnits) : 0; return len; } *************** *** 1669,1675 **** } else { if (lu.type == 0) { ! return lu.getValue(ss.isW3CLengthUnits()); } if (a != null) { AttributeSet resolveParent = a.getResolveParent(); --- 1670,1677 ---- } else { if (lu.type == 0) { ! boolean isW3CLengthUnits = (ss == null) ? false : ss.isW3CLengthUnits(); ! return lu.getValue(isW3CLengthUnits); } if (a != null) { AttributeSet resolveParent = a.getResolveParent(); =========== The problem with this fix is it partialy disables w3cLengthUnits We do need to have StyleSheet every time we get FontSize from CSSValue I do not think this bug is a showstopper for 1.5 It is definitely should be fixed in the first update release. ###@###.### 2004-08-18
18-08-2004