RFR: 8284877: Check type compatibility before looking up method from receiver's vtable [v2]

David Holmes dholmes at openjdk.org
Mon Jun 19 00:43:34 UTC 2023


On Thu, 15 Jun 2023 16:05:55 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:

> Is it possible to add this sanity check as part of `-Xcheck:jni`? I agree that this check should not be added by default.

@dcubed-ojdk , @y1yang0 such a check is already part of `-Xcheck:jni`. See `src/hotspot/share/prims/jniCheck.cpp` and the `jniCheck::validate_call` method - it does a receiver typecheck:

if (obj != nullptr) {
    oop recv = jniCheck::validate_object(thr, obj);
    assert(recv != nullptr, "validate_object checks that");
    Klass* rk = recv->klass();

    // Check that the object is a subtype of method holder too.
    if (!rk->is_subtype_of(holder)) {
      ReportJNIFatalError(thr, fatal_wrong_class_or_method);
    }
  }

-------------

PR Comment: https://git.openjdk.org/jdk/pull/8241#issuecomment-1596330233


More information about the hotspot-dev mailing list