ArrayIndexOutOfBoundsException in awt

Peter Mehlitz peter at transvirtual.com
Thu Mar 11 13:48:51 PST 1999


> I didn't understand whats going on, but EventQueue.getNextEvent
> calls native code (X/evt.c) which calls back into FocusEvt.getEvent
> and I'm seeing no test for the index to be valid.  But, as I said, I don't
> understand this level, so here the stack trace
> Chris
> 
> java SwingSet
> !!!WARNING: Swing must be run with a 1.1.2 or higher version VM!!!
> java.lang.ArrayIndexOutOfBoundsException
>         at java.awt.FocusEvt.getEvent(FocusEvt.java:132)
>         at java.awt.EventQueue.getNextEvent(EventQueue.java:112)
>         at java.awt.EventDispatchThread.run(EventDispatchThread.java:75)
>         at java.awt.Dialog.show(Dialog.java:116)
>         at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:641)


That was a ill event solicitation in evt.c, function focusNotify(), which
should read:

-------------------
...
jobject
focusNotify ( JNIEnv* env, Toolkit* X )
{
  int et = X->event.xany.type;
  int sIdx = X->srcIdx;

  while ( XCheckMaskEvent( X->dsp, FocusChangeMask, &X->event) ){
    X->pending--;
    if ( getSourceIdx( X, X->event.xfocus.window) >= 0 ) {
      et = X->event.xany.type;
      sIdx = X->srcIdx;
    }
  }

  X->evtId = (et == FocusIn) ? FOCUS_GAINED : FOCUS_LOST;

  return (*env)->CallStaticObjectMethod( env, FocusEvent, getFocusEvent,
                                            sIdx, X->evtId);
}
...
--------------------

-- Peter


More information about the kaffe mailing list