RFR: 8269697: JNI_GetPrimitiveArrayCritical() should not accept object array
Kim Barrett
kbarrett at openjdk.java.net
Thu Jul 1 21:39:01 UTC 2021
On Thu, 1 Jul 2021 13:41:15 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:
> Open this PR to carry on the discussion started in jdk17 [https://github.com/openjdk/jdk17/pull/185](url)
Following upo on the discussion from https://github.com/openjdk/jdk17/pull/185
GetPrimitiveArrayCritical returns a void* which the caller is then expected
to cast to the appropriate pointer to jXXX for read or write.
If it's an objarray, it's not clear what type should be used for that cast;
it's not jobject. JNI doesn't provide an appropriate type.
In fact, you need to know whether UseCompressedOops is enabled or not to
even begin to access values. Let's say you have side-channel knowledge of
the value of UseCompressedOops. Then what?
Writing has a good chance of leading to crashes with most (maybe all?) of our
collectors. Even if you could somehow obtain a well-formed value, many
collectors have some barrier protocol that's needed for writes.
Reading and doing anything non-trivial with a value also has a good chance
of leading to crashes with at least some GCs.
I don't think changing it to return a copy helps much with any of that.
There are a few corner cases that might be different, but not interestingly
so. And JNI_COMMIT mode might have very bad results for some at least some
collectors.
So I'm going to claim there's no significant compatibility issue with code
that was violating the spec, because I don't think such code could have been
doing anything interesting or useful anyway. About all you can get from the
contents is some raw bits that you can't do much with.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4653
More information about the hotspot-dev
mailing list