Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7126361

JLabel.paint throws classcast exception if its html text contains a <script> tag

    XMLWordPrintable

Details

    Description

      FULL PRODUCT VERSION :
      java version "1.7.0_02"
      Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
      Java HotSpot(TM) Server VM (build 22.0-b10, mixed mode)

      1.6.0_30 is also concerned


      ADDITIONAL OS VERSION INFORMATION :
      Linux dimi-pc 2.6.38-13-generic #53-Ubuntu SMP Mon Nov 28 19:23:39 UTC 2011 i686 i686 i386 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      WheneverJLabel with html text that contains a <script> tag is painted, a ClassCastException is thrown.
      This bugs relates to bug 5021864 which has State 10-Fix Delivered, bug

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a JLabel , pass it html text that contains a script tag and let it be painted



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Clearly I don't expect the renderer to interpret javascript, but not throwing an exception and simply ignoring the <scrtipt> tags would be nice!
      ACTUAL -
      Exception gets thrown, program flow is interrupted.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JLabel cannot be cast to javax.swing.text.JTextComponent
      at javax.swing.text.html.EditableView.paint(EditableView.java:76)
      at javax.swing.text.BoxView.paintChild(BoxView.java:161)
      at javax.swing.text.BoxView.paint(BoxView.java:433)
      at javax.swing.text.BoxView.paintChild(BoxView.java:161)
      at javax.swing.text.BoxView.paint(BoxView.java:433)
      at javax.swing.text.ParagraphView.paint(ParagraphView.java:587)
      at javax.swing.text.html.ParagraphView.paint(ParagraphView.java:233)
      at javax.swing.text.BoxView.paintChild(BoxView.java:161)
      at javax.swing.text.BoxView.paint(BoxView.java:433)
      at javax.swing.text.html.BlockView.paint(BlockView.java:282)
      at javax.swing.text.BoxView.paintChild(BoxView.java:161)
      at javax.swing.text.BoxView.paint(BoxView.java:433)
      at javax.swing.text.html.BlockView.paint(BlockView.java:282)
      at javax.swing.plaf.basic.BasicHTML$Renderer.paint(BasicHTML.java:481)
      at javax.swing.plaf.basic.BasicLabelUI.paint(BasicLabelUI.java:173)
      at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
      at javax.swing.JComponent.paintComponent(JComponent.java:778)
      at javax.swing.JComponent.paint(JComponent.java:1054)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paint(JComponent.java:1063)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paint(JComponent.java:1063)
      at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paintToOffscreen(JComponent.java:5228)
      at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:295)
      at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
      at javax.swing.JComponent.paint(JComponent.java:1040)
      at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
      at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
      at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
      at java.awt.Container.paint(Container.java:1967)
      at java.awt.Window.paint(Window.java:3867)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:781)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
      at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
      at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
      at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
      at java.awt.EventQueue.access$000(EventQueue.java:101)
      at java.awt.EventQueue$3.run(EventQueue.java:666)
      at java.awt.EventQueue$3.run(EventQueue.java:664)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
      Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JLabel cannot be cast to javax.swing.text.JTextComponent
      at javax.swing.text.html.EditableView.paint(EditableView.java:76)
      at javax.swing.text.BoxView.paintChild(BoxView.java:161)
      at javax.swing.text.BoxView.paint(BoxView.java:433)
      at javax.swing.text.BoxView.paintChild(BoxView.java:161)
      at javax.swing.text.BoxView.paint(BoxView.java:433)
      at javax.swing.text.ParagraphView.paint(ParagraphView.java:587)
      at javax.swing.text.html.ParagraphView.paint(ParagraphView.java:233)
      at javax.swing.text.BoxView.paintChild(BoxView.java:161)
      at javax.swing.text.BoxView.paint(BoxView.java:433)
      at javax.swing.text.html.BlockView.paint(BlockView.java:282)
      at javax.swing.text.BoxView.paintChild(BoxView.java:161)
      at javax.swing.text.BoxView.paint(BoxView.java:433)
      at javax.swing.text.html.BlockView.paint(BlockView.java:282)
      at javax.swing.plaf.basic.BasicHTML$Renderer.paint(BasicHTML.java:481)
      at javax.swing.plaf.basic.BasicLabelUI.paint(BasicLabelUI.java:173)
      at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
      at javax.swing.JComponent.paintComponent(JComponent.java:778)
      at javax.swing.JComponent.paint(JComponent.java:1054)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paint(JComponent.java:1063)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paint(JComponent.java:1063)
      at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paintToOffscreen(JComponent.java:5228)
      at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:295)
      at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
      at javax.swing.JComponent.paint(JComponent.java:1040)
      at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
      at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
      at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
      at java.awt.Container.paint(Container.java:1967)
      at java.awt.Window.paint(Window.java:3867)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:781)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
      at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
      at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
      at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
      at java.awt.EventQueue.access$000(EventQueue.java:101)
      at java.awt.EventQueue$3.run(EventQueue.java:666)
      at java.awt.EventQueue$3.run(EventQueue.java:664)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;
      import javax.swing.*;
      public class TestFrame extends JFrame {
          
          /** Creates a new instance of TestFrame */
          public TestFrame() {
              super();
              JLabel label = new JLabel("<html>this is a <script>");
              getContentPane().add(label);
              pack();
              setVisible(true);
          }
          
          public static void main(String[] args) {
              TestFrame frame = new TestFrame();
          }
      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              alexsch Alexandr Scherbatiy
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: