Menu

More on ArrayStoreException

Help
2001-11-30
2001-11-30
  • Piergiuliano Bossi

    > PS: I continue to observe also random ArrayStoreException, unfortunately awtSleep()
    > doesn't help either...

    This is my analysis.

    ArrayStoreException is thrown by java.awt.Window.getOwnedWindows(), called by
    junit.extensions.jfcunit.JFCTestHelper.getShowingDialogs(Window). We are using VAJ, so
    JDK implementation tells that getOwnedWindows is implemented as follows:

    *****************CUT HERE*****************
    /**
      * Return an array containing all the windows this
      * window currently owns.
      * @since JDK1.2
      */
    public Window[] getOwnedWindows() {
      Window realCopy[];

    synchronized(ownedWindowList) {
         // Recall that ownedWindowList is actually a Vector of
         // WeakReferences and calling get() on one of these references
         // may return null. Make two arrays-- one the size of the
         // Vector (fullCopy with size fullSize), and one the size of
         // all non-null get()s (realCopy with size realSize).
         int fullSize = ownedWindowList.size();
         int realSize = 0;
         Window fullCopy[] = new Window[fullSize];

         for (int i = 0; i < fullSize; i++) {
             fullCopy[realSize] = (Window) (((WeakReference)
          (ownedWindowList.elementAt(i))).get());

      if (fullCopy[realSize] != null) {
          realSize++;
      }
         }

         if (fullSize != realSize) {
             realCopy = new Frame[realSize];
      System.arraycopy(fullCopy, 0, realCopy, 0, realSize);
         } else {
             realCopy = fullCopy;
         }
    }

      return realCopy;
    }
    *****************CUT HERE*****************

    The exception is thrown by the call to System.arraycopy - please note, that:
    *) VAJ JDK is still at version 1.2
    *) this implementation IS identical to Sun JDK 1.3.1 implementation
    *) realCopy is declared as a Window array
    *) fullSize == 2, but the second reference contained in fullCopy is null, so realSize ==
    1
    *) due to the fact that fullSize != realSize, realCopy is initialized with a Frame array

    *) fullCopy is a Window array in which element 0 references a JDialog
    ==> according to ArrayStoreException and System.arraycopy descriptions, the problem
    should be caused by the fact that a JDialog (the source in the copy) is not a Frame (the
    destination in the copy) ==> the exception is thrown.

    This should happen only when fullCopy holds some weak references.

    Having said this, I guess that this can be attributed probably to a specific VAJ
    behaviour, that happens even if before calling getShowingDialogs we have invoked
    enterClickAndLeave(itsTestCase, theComponent, aSleepTime) with aSleepTime == 10000.

    Is there anything else that anybody can suggest or comment on this? Any workaround?
    HTH, Giuliano

     
    • Vijay Aravamudhan

      I just ran all my tests inside VAJ and then created a jar export and ran the tests again, and I found this behaviour too: the tests ran fine outside of VAJ while some of them fail randomly while running inside VAJ. SO I guess that this must be due to the JVM inside VAJ. (Ia m using VAJ 3.5.3).
      Vijay

       

Log in to post a comment.