RFR: 8336468: Reflection and MethodHandles should use more precise initializer checks [v4]
Chen Liang
liach at openjdk.org
Wed Sep 25 13:24:40 UTC 2024
On Wed, 25 Sep 2024 08:37:29 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> This PR should cover the Reflection/MethodHandles part of [JDK-8336103](https://bugs.openjdk.org/browse/JDK-8336103).
>>
>> There are places where we change the behavior: `clinit` would now be recorded as "method", instead of "constructor". Tracing back the uses of `get_flags`: it is used for initializing `java.lang.ClassFrameInfo.flags`. There seem to be no readers for this field in VM. Java side for `j.l.CFI` does not seem to check any method/constructor flags. So I would say this change in behavior is not really visible, and there is no need to try and keep the old (odd) behavior.
>>
>> I also inlined the `select_method` definition, which allows for a bit more straight-forward local code, and obviates the need for wrapping things with `methodHandle`.
>>
>> @mlchung, you probably want to look at this more closely.
>>
>> Additional testing:
>> - [x] Linux x86_64 server fastdebug, `tier1`
>> - [x] Linux x86_64 server fastdebug, `all`
>
> Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
>
> - Merge branch 'master' into JDK-8336468-reflection-init-checks
> - Whitespace and comments
> - Merge branch 'master' into JDK-8336468-reflection-init-checks
> - Merge branch 'master' into JDK-8336468-reflection-init-checks
> - Remove unnecessary handle-izing
> - Fix
> - Fix
src/hotspot/share/prims/jni.cpp line 450:
> 448: reflection_method = Reflection::new_constructor(m, CHECK_NULL);
> 449: } else {
> 450: assert(!m->is_static_initializer(), "Cannot be static initializer");
This looks like a behavioral change; otherwise reflection and method handle changes look good. Per JNI https://docs.oracle.com/en/java/javase/23/docs/specs/jni/functions.html#toreflectedmethod it seems to just return if the method id is valid.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20192#discussion_r1775222862
More information about the hotspot-dev
mailing list