While debugging 6300721 I discovered that user code was walking off the end on a Java array being accessed using GetPrimitiveArrayCritical. Our implementation returns a pointer to the interior of the array so walking off the end stomps the java heap. It's permissible to return a copy and I think with -Xcheck:jni that's what we should do. We should return a chunk of memory with a guard region at each end and when ReleasePrimitiveArrayCritical is called the guard regions should be checked to see they are overwritten.
We should also do this for Release/Get*ArrayElements. It would have been useful in diagnosing 6532325 as a JNI problem and not a JVM problem.