title: MATLAB reports "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
body: <p>I wonder about a Java error that is repeatedly occurs in MATLAB. It typically occurs when MATLAB is doing some heavy stuff with Java. This can for example be holding <kbd>Ctrl</kbd> + <kbd>Z</kbd> or <kbd>Ctrl</kbd> + <kbd>Y</kbd>.</p>
  <p>I did by mistake erase the error message before I copied it, but I think that I can pass the core of the problem anyway.</p>
  <pre class="lang-none prettyprint-override"><code>Exception in thread &quot;AWT-EventQueue-0&quot; java.lang.NullPointerException
  ...
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.run(Unknown Source)
  </code></pre>
  <p>Why did this error occur? I have found some information about this from MATLAB r2007, this due to that Java <a href="https://en.wikipedia.org/wiki/Swing_%28Java%29" rel="nofollow noreferrer">Swing</a> is thread unsafe and MATLAB lacked support to ensure <a href="https://en.wikipedia.org/wiki/Thread_safety" rel="nofollow noreferrer">thread safety</a>. However, that is supposed to have been fixed in MATLAB r2008b. So why do I get it now?</p>
  <p>Here is the full stack trace:</p>
  <pre class="lang-none prettyprint-override"><code>Exception in thread &quot;AWT-EventQueue-0&quot; java.lang.NullPointerException
  at org.netbeans.editor.BaseDocument.notifyUnmodify(BaseDocument.java:1465)
  at org.netbeans.editor.BaseDocument.notifyModifyCheckEnd(BaseDocument.java:816)
  at org.netbeans.editor.BaseDocumentEvent.redo(BaseDocumentEvent.java:336)
  at javax.swing.undo.UndoManager.redoTo(Unknown Source)
  at javax.swing.undo.UndoManager.redo(Unknown Source)
  at com.mathworks.mwswing.undo.MUndoManager.redo(MUndoManager.java:255)
  at org.netbeans.editor.ActionFactory$RedoAction.actionPerformed(ActionFactory.java:767)
  at org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:259)
  at javax.swing.SwingUtilities.notifyAction(Unknown Source)
  at javax.swing.JComponent.processKeyBinding(Unknown Source)
  at javax.swing.JComponent.processKeyBindings(Unknown Source)
  at javax.swing.JComponent.processKeyEvent(Unknown Source)
  at com.mathworks.widgets.SyntaxTextPaneBase.processKeyEvent(SyntaxTextPaneBase.java:1187)
  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.KeyboardFocusManager.redispatchEvent(Unknown Source)
  at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
  at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
  at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
  at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
  at java.awt.Component.dispatchEventImpl(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)
  </code></pre>