RFR: 8308341: JNI_GetCreatedJavaVMs returns a partially initialized JVM

David Holmes dholmes at openjdk.org
Fri May 26 01:09:57 UTC 2023


On Thu, 25 May 2023 09:49:58 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> We now track the in-progress and completed states of VM creation and only return a VM from JNI_GetCreatedJavaVMs when there is a fully initialized VM.
>> 
>> Testing: 
>>  - new regression test
>>  - tiers 1-3 (sanity)
>> 
>> Thanks
>
> src/hotspot/share/prims/jni.cpp line 3475:
> 
>> 3473: 
>> 3474: // Global invocation API vars
>> 3475: enum VM_Creation_State {
> 
> Nit: Would `enum class` be preferred here?

I prefer a basic enum for this (just named integer constants).

> src/hotspot/share/prims/jni.cpp line 3943:
> 
>> 3941:   // initialization, so only bail-out if something seems very wrong.
>> 3942:   // Though how would we get here in that case?
>> 3943:   if (vm_created == NOT_CREATED) {
> 
> Shouldn't we also handle `IN_PROGRESS`?

I guess my comment was not clear enough. :) It is normal to get here while IN_PROGRESS due to calls from the JDK native code during initialization. So we only consider it an error to call then when NOT_CREATED.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14139#discussion_r1206130207
PR Review Comment: https://git.openjdk.org/jdk/pull/14139#discussion_r1206129897


More information about the hotspot-dev mailing list