RFR: 8284877: Check type compatibility before looking up method from receiver's vtable [v2]
David Holmes
dholmes at openjdk.org
Thu Jun 15 03:12:06 UTC 2023
On Thu, 15 Jun 2023 02:00:39 GMT, Yi Yang <yyang at openjdk.org> wrote:
> It should detect such errors, shouldn't it?
No, not from JNI. If you pass the wrong kind of argument, or null, etc then that is on you, the JNI implementation does not try to verify the programmer's actions:
https://docs.oracle.com/en/java/javase/20/docs/specs/jni/design.html#reporting-programming-errors
> Furthermore, it is natural to check the receiver type, method modifiers, and whether the method is linked before calling a virtual function.
Yes, for bytecode and that is what verification does. Not for JNI or Unsafe.
I understand the tendency/desire to assist programmers in detecting their errors, but that can't be at the expense of all the correctly written programs. Sorry.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/8241#issuecomment-1592276740
More information about the hotspot-dev
mailing list