Calls to the JNI function Get<type>ArrayElements() normally return a
pointer to a copy of the specified array. Callers can use this pointer
to access elements of the array. If the array is empty, there are no
elements to access, and the returned pointer should not be used.
The fix for bug 4804447 handled this special (empty array) case, by
returning a pointer to an invalid page. Previously, a pointer to an
arbitrary block of memory (with zero data elements) was returned.
Unfortunately, there are one or more customer applications which
(indirectly) rely on the initial zero bytes being present. One customer
passes the zero length array to a Microsoft API (DirectDraw) which
accesses the first character in the zero length array. This is clearly
a bug in the Microsoft code. The VM needs to be compatible with this
buggy behavior to avoid breaking the customer's app.
A test case is attached. Just compile and run.