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

JEditorPane throws EmptyStackException against particular html file(s)

XMLWordPrintable

          javax.swing.JEditorPane throws an Exception, for this particular
          version of korean html file.

          - the html syntax of the file is okay
           I confirmed that the html file is okay from syntax point of view,
           thus it can be displayed correctly with other html browsers.

         - happens for one locale only out of 10 locales
           (in this case, ko, by chance)
           Other language versions of files(syntax, format is exactly the same
           with korean file, except the language and encoding) are okay.
           This issue can be reproduced for ko locale only by chance, but it may
           happen for other locales, if we slightly modify it.


         - even in the same locale(ko), slightly different versions of files
           are okay.
           see attached html files and the test result.
           
           title_xx.html.#

           (where xx is locale, and # is file variant number)


           Table-1: whether exception is thrown or not when
                    running sample code(SwingHelp.java)

           number/ 1 2 3 4 5
           locale
           -------------------------------------------------------
           en No No No No No
           ko No Yes No No No
           ja No No No No No
           other 7 No No No No No
           -------------------------------------------------------


           title_xx.html.1 (original file: 4 <li> tags included between
                            2nd <ul></ul> tag pair)
           title_xx.html.2 (remove 2 <li> tags from the original)
           title_xx.html.3 (remove 2 <li> tags but different tags from #2)
           title_xx.html.4 (remove 1 <li> tags from the original)
           title_xx.html.5 (remove <meta> tag from #2)


           This result indicates that it is very context sensitive, and
           it is very rare this happens. We can not predict when this happens
           in which locale, nor what change makes this happen.



         - if we delete <meta> tag for charset, no exception occurs.
           
           e.g. <meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
          
           title_ko.html.2 has problem displaying,
           title_ko.html.5 is exactly the same as #2, except <meta> tag.

           But ofcourse without <meta> tag, localized html files can not be
           displayed correctly. It is interesting result and it indicates
           that this problem is caused by internal behaviour of JEditorPane.


      ------ Result of running the sample code with ko file #2 ------
      java.util.EmptyStackException
              at java.lang.Throwable.fillInStackTrace(Native Method)
              at java.lang.Throwable.fillInStackTrace(Compiled Code)
              at java.lang.Throwable.<init>(Compiled Code)
              at java.lang.Exception.<init>(Compiled Code)
              at java.lang.RuntimeException.<init>(Compiled Code)
              at java.util.EmptyStackException.<init>(Compiled Code)
              at java.util.Stack.peek(Compiled Code)
              at javax.swing.text.DefaultStyledDocument$ElementBuffer.insertElement(Compiled Code)
              at javax.swing.text.DefaultStyledDocument$ElementBuffer.insertUpdate(Compiled Code)
              at javax.swing.text.DefaultStyledDocument$ElementBuffer.insert(DefaultStyledDocument.java:1211)
              at javax.swing.text.DefaultStyledDocument.insert(Compiled Code)
              at javax.swing.text.html.HTMLDocument.insert(HTMLDocument.java:216)
              at javax.swing.text.html.HTMLDocument$HTMLReader.flushBuffer(HTMLDocument.java:2678)
              at javax.swing.text.html.HTMLDocument$HTMLReader.flush(HTMLDocument.java:1631)
              at javax.swing.text.html.HTMLEditorKit.read(HTMLEditorKit.java:244)
              at javax.swing.JEditorPane.read(JEditorPane.java:404)
              at javax.swing.JEditorPane.read(JEditorPane.java:422)
              at javax.swing.JEditorPane$PageLoader.run(JEditorPane.java:450)
      -------

            svioletsunw Scott Violet (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: