Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4836743

Backward compatibility - jni apps need to dereference bogus returned reference

XMLWordPrintable

    • 09
    • generic, x86
    • generic, windows_xp
    • Verified


        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.

              foliversunw Fred Oliver (Inactive)
              foliversunw Fred Oliver (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: