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

ClassCastException while entering HINDI characters with CustomDocument

    XMLWordPrintable

Details

    • b110
    • x86
    • windows_xp

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0_21"
      Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
      Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      There is a problems in GlyphPainter2 while rendering a textfield by a Using a Custom Document.

      I have created a custom document by implementing the javax.swing.text.Document interface. I used custom document with my textfield.
      So problem comes when i COPY/PASTE HINDI Characters into my textfield. It throws a ClassCastException in the GlyphPainter2's getNextVisualPositionFrom. Java expects a AbstractDocument instead of Document in GlyphPainter2 which a problem for custom documents.

      Please run the source and type HINDI Character into it.
      COPY/PASTE below text into it.
      (See attachment: hindiChar.txt)
      Click on the text field after copy/paste , you will notice exception in the console(As given with the bug).


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Step1: Run the attached source code, it will display a frame with a textfield into it.
      Step2:- COPY/PASTE below text into it.
      (see attachment: hindiChar.txt )
      Step3:- click on the textfield again.

      Now notice the console , you will see a ClassCastException in GlyphPainter2.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It should behave normally, should not throw an exception.
      ACTUAL -
      Throws a ClassCastException in GlyphPainter2.
      Find the attached exception for more details.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: BugInGlyp
      ainters$LimitedLengthDocument cannot be cast to javax.swing.text.AbstractDocum
      t
              at javax.swing.text.GlyphPainter2.getNextVisualPositionFrom(Unknown So
      ce)
              at javax.swing.text.GlyphView.getNextVisualPositionFrom(Unknown Source
              at javax.swing.text.Utilities.getNextVisualPositionFrom(Unknown Source
              at javax.swing.text.CompositeView.getNextEastWestVisualPositionFrom(Un
      own Source)
              at javax.swing.text.CompositeView.getNextVisualPositionFrom(Unknown So
      ce)
              at javax.swing.text.CompositeView.viewToModel(Unknown Source)
              at javax.swing.text.BoxView.viewToModel(Unknown Source)
              at javax.swing.text.CompositeView.viewToModel(Unknown Source)
              at javax.swing.text.BoxView.viewToModel(Unknown Source)
              at javax.swing.plaf.basic.BasicTextFieldUI$I18nFieldView.viewToModel(U
      nown Source)
              at javax.swing.plaf.basic.BasicTextUI$RootView.viewToModel(Unknown Sou
      e)
              at javax.swing.plaf.basic.BasicTextUI.viewToModel(Unknown Source)
              at javax.swing.text.DefaultCaret.positionCaret(Unknown Source)
              at javax.swing.text.DefaultCaret.adjustCaret(Unknown Source)
              at javax.swing.text.DefaultCaret.adjustCaretAndFocus(Unknown Source)
              at javax.swing.text.DefaultCaret.mousePressed(Unknown Source)
              at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
              at java.awt.Component.processMouseEvent(Unknown Source)
              at javax.swing.JComponent.processMouseEvent(Unknown Source)
              at java.awt.Component.processEvent(Unknown Source)
              at java.awt.Container.processEvent(Unknown Source)
              at java.awt.Component.dispatchEventImpl(Unknown Source)
              at java.awt.Container.dispatchEventImpl(Unknown Source)
              at java.awt.Component.dispatchEvent(Unknown Source)
              at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
              at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
              at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
              at java.awt.Container.dispatchEventImpl(Unknown Source)
              at java.awt.Window.dispatchEventImpl(Unknown Source)
              at java.awt.Component.dispatchEvent(Unknown Source)
              at java.awt.EventQueue.dispatchEvent(Unknown Source)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
              at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
              at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
              at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
              at java.awt.EventDispatchThread.run(Unknown Source)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      (see attachment: BugInGlyphPainters.java)

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No Workaround for this, i am forced to not use my own custom document.

      Attachments

        Activity

          People

            malenkov Sergey Malenkov (Inactive)
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: