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

Fix for JDK-6882559 breaks JEditorPane.setContentType for unknown types

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 9
    • client-libs
    • None

      The spec for JEditorPane.setContentType says:

      If the type is not recognized, the content will be loaded using the <code>EditorKit</code> registered for plain text, <code>text/plain</code>.

      Unfortunately, after the fix for JDK-6882559, this is no longer true.

      Consider this example:
      ---
      public class TestEditorPane {
          public static void main(String[] args) {
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      new javax.swing.JEditorPane("text/x-oql", "");
                  }
              });
          }
      }
      ---

      Compiling and running it on:
      $ ./java -version
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+126)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+126, mixed mode)

      $ uname -a
      Linux lahvacovo 4.2.0-35-generic #40~14.04.1-Ubuntu SMP Fri Mar 18 16:37:35 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

      $ javac TestEditorPane.java
      $ java TestEditorPane
      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
              at javax.swing.JEditorPane.createEditorKitForContentType(java.desktop@9-ea/JEditorPane.java:1188)
              at javax.swing.JEditorPane.getEditorKitForContentType(java.desktop@9-ea/JEditorPane.java:1086)
              at javax.swing.JEditorPane.setContentType(java.desktop@9-ea/JEditorPane.java:979)
              at javax.swing.JEditorPane.<init>(java.desktop@9-ea/JEditorPane.java:291)
              at TestEditorPane$1.run(TestEditorPane.java:6)
              at java.awt.event.InvocationEvent.dispatch(java.desktop@9-ea/InvocationEvent.java:313)
              at java.awt.EventQueue.dispatchEventImpl(java.desktop@9-ea/EventQueue.java:759)
              at java.awt.EventQueue.access$500(java.desktop@9-ea/EventQueue.java:97)
              at java.awt.EventQueue$3.run(java.desktop@9-ea/EventQueue.java:712)
              at java.awt.EventQueue$3.run(java.desktop@9-ea/EventQueue.java:706)
              at java.security.AccessController.doPrivileged(java.base@9-ea/Native Method)
              at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(java.base@9-ea/ProtectionDomain.java:77)
              at java.awt.EventQueue.dispatchEvent(java.desktop@9-ea/EventQueue.java:729)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(java.desktop@9-ea/EventDispatchThread.java:199)
              at java.awt.EventDispatchThread.pumpEventsForFilter(java.desktop@9-ea/EventDispatchThread.java:124)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(java.desktop@9-ea/EventDispatchThread.java:113)
              at java.awt.EventDispatchThread.pumpEvents(java.desktop@9-ea/EventDispatchThread.java:109)
              at java.awt.EventDispatchThread.pumpEvents(java.desktop@9-ea/EventDispatchThread.java:101)
              at java.awt.EventDispatchThread.run(java.desktop@9-ea/EventDispatchThread.java:90)

      Originally reported here:
      https://netbeans.org/bugzilla/show_bug.cgi?id=262619

            mcherkas Mikhail Cherkasov (Inactive)
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: