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

JNI_GetPrimitiveArrayCritical() should not accept object array

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 18
    • hotspot
    • None
    • behavioral
    • minimal
    • Very low - anyone actually trying to use the API with an Object array is severely restricted in what they could try to do with the result. See comments for more detail.
    • Other
    • Implementation

      Summary

      Modify JNI_GetPrimitiveArrayCritical() so that it assumes it is passed a primitive array rather than handing back a pointer to an Object array.

      Problem

      JNI_GetPrimitiveArrayCritical() only supports primitive arrays, and returns a "raw" pointer to the primitive array type passed in. For reasons unknown the implementation has always accepted an Object array and returned a raw pointer to it. This should not happen.

      Solution

      Change the implementation to assume it has a primitive array. This will likely lead to a crash if passed an Object array - which is perfectly fine for JNI (see comments). Passing an incorrect array type will be detected by -Xcheck:jni.

      Specification

      There is no specification change. This is a behavioural change to make the implementation match the specification.

            zgu Zhengyu Gu
            zgu Zhengyu Gu
            David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: