JDK-8309243 : Re-examine when JNI methods should be allowed during the VM initialization process
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 21
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2023-05-31
  • Updated: 2025-06-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 26
26Unresolved
Related Reports
Relates :  
Relates :  
Description
JDK-8308341 exposed an issue where by JNI_GetCreatedJavaVMs could return a partially initialized VM for which JNI_AttachCurrentThread could crash. That fix initially added checks to the attach/detach functions to make them fail if the VM was not completely initialized. But that was too strong a check as we discovered (JDK-8309171) that a native agent could create native threads that have to attach during VM initialization. It was suggested that the latter problem should still be restricted to the JVMTI "live phase" but it is unclear if that necessarily suffices - a JDK library could also create a native thread that tries to attach to the VM (though we could of course declare that a bug and force it to be delayed).

In any case we should look at whether the JNI-related VM initialization states (NOT_CREATED, IN_PROGRESS, COMPLETED) should be expanded to give more fine grain control that can be used to guard use of other JNI functions like attach/detach.

It was also suggested that we might consider blocking such functions if VM init is in progress rather than returning an error. Though I suspect that could lead to initialization deadlocks.
Comments
Added [~alanb] to the watch list.
31-05-2023