Here is an interesting article on how the JRockit JVM (maybe Sun's as well?) does optimize the code on the fly:
The JVM first runs JIT compilation, so that the application can get running.  JRockit then monitor's threads and samples what could benefit from being optimized.  I guess my hypothesis is that the initial JIT compilation of the loop in NamespaceIterator.getInScopeNamespaceCodes() runs okay, but then after time the JVM decides to optimize this loop even more and possibly that's when we experience this issue?
Just a thought.

From: Ackley, Paul
Sent: Thursday, March 19, 2009 4:02 PM
To: 'Mailing list for the SAXON XSLT and XQuery processor'
Subject: RE: [saxon] ArrayIndexOutOfBoundsException in Saxon 8.6

The build of Saxon has been installed and the application has been running for 3 days without running into this "ArrayIndexOutOfBoundsException" exception.  I'll let you know if it happens and what the debugging output looks like.  Typically, by now the problem has occurred.  I'm wondering if the JVM does some optimization of the loop which iterates through the hash and if putting this try/catch in this code possibly caused the JVM to not do the optimization - but really this is just a very weak hypothesis on my part.  Just because it hasn't happened yet doesn't mean it wont.  Time will tell.
I'll keep you updated.
Thanks for all your help thus far.
Paul Ackley