JDK-8288648 : (jni spec) Description of 3rd parameter to AttachCurrentThread is confusing
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8,20
  • Priority: P4
  • Status: In Progress
  • Resolution: Unresolved
  • Submitted: 2022-06-17
  • Updated: 2022-06-27
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 20
20Unresolved
Related Reports
CSR :  
Description
In Java 7, the spec was:

“In JDK 1.1, the second argument to AttachCurrentThread is always a pointer to JNIEnv. The third argument to AttachCurrentThread was reserved, and should be set to NULL.

In JDK 1.2, you pass NULL as the third argument for 1.1 behavior, or pass a pointer to the following structure to specify additional information:"


In Java 8 it changed to:

"The second argument to AttachCurrentThread is always a pointer to JNIEnv. The third argument to AttachCurrentThread was reserved, and should be set to NULL."


The sentence "The third argument to ..." is not correct as it can be  NULL or a pointer to a JavaVMAttachArgs structure when there is additional information to specify. This sentence should be replaced with something like

"When not NULL, the third argument is a pointer to the following structure to specify additional information:"


Comments
I think we can simply delete this "paragraph" The second argument to AttachCurrentThread is always a pointer to JNIEnv. The third argument to AttachCurrentThread was reserved, and should be set to NULL. --- The first sentence is redundant as we already state just before this: p_env: pointer to the location where the JNI interface pointer of the current thread will be placed, must not be NULL. The second sentence is just a nonsensical bad edit. That then means: You pass a pointer to the following structure to specify additional information: is also redundant. The resulting text would be : PARAMETERS: vm: the VM to which the current thread will be attached, must not be NULL. p_env: pointer to the location where the JNI interface pointer of the current thread will be placed, must not be NULL. thr_args: can be NULL or a pointer to a JavaVMAttachArgs structure to specify additional information: typedef struct JavaVMAttachArgs { jint version; char *name; /* the name of the thread as a modified UTF-8 string, or NULL */ jobject group; /* global ref of a ThreadGroup object, or NULL */ } JavaVMAttachArgs
19-06-2022