RFR: 8280422: thread_from_jni_environment can never return NULL [v2]

Kim Barrett kbarrett at openjdk.java.net
Tue Jan 25 00:41:34 UTC 2022


On Mon, 24 Jan 2022 02:21:34 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Analysing the code and its use (see JBS issue for gory details) we can see that `thread_from_jni_environment` can never actually return NULL, so we change it to not appear to do so and thus keep static analysis tools happy.  We also always validate the incoming JNIEnv for debug builds and scrap the unused `VerifyJNIEnvThread` flag.
>> 
>> Testing: tiers 1-5
>> 
>> Thanks,
>> David
>
> David Holmes has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update copyright

Looks good.

src/hotspot/share/runtime/thread.hpp line 1319:

> 1317:   // external JNI entry points where the JNIEnv is passed into the VM.
> 1318:   static JavaThread* thread_from_jni_environment(JNIEnv* env) {
> 1319:     JavaThread* current = (JavaThread*)((intptr_t)env - in_bytes(jni_environment_offset()));

[pre-existing] If I were writing this I would have used `char*` rather than `intptr_t`.

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

Marked as reviewed by kbarrett (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/7193


More information about the hotspot-runtime-dev mailing list